/* ======================================== */
/* --- Base & Layout --- */
/* ======================================== */

/* --- Card List Layout --- */
.controle-card-list {
    display: flex;
    flex-wrap: wrap;
    justify-content: left;
    gap: 20px;
    padding: 15px;
    max-width: 1400px;
    margin-left: auto;
    margin-right: auto;
    box-sizing: border-box;
}

/* --- Individual Card Styling --- */
.controle-card {
    border: 1px solid #ddd;
    border-radius: 8px;
    background-color: #fff;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    width: 300px;
    flex: 1 0 260px;
    max-width: 300px;
}

.controle-card-header {
    padding: 10px 15px;
    background-color: #f8f9fa;
    border-bottom: 1px solid #ddd;
    display: flex;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 10px;
}

.controle-card-header .info-item {
    font-size: 0.9em;
    color: #555;
}

.controle-card-header .info-item strong {
    color: #333;
}

.controle-card-body {
    padding: 15px;
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.card-visible-title {
    order: -1;
    margin-bottom: 10px;
    font-size: 1.1em;
    font-weight: bold;
    color: #737373;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
    max-height: calc(1.4em * 2);
}

/* --- Image Preview --- */
.image-preview-container {
    border: none;
    display: flex;
    justify-content: center;
    align-items: center;
    background-color: #f0f0f0;
    overflow: hidden;
    width: 100%;
    aspect-ratio: 1 / 1.4142; /* A4 Portrait */
}

.image-preview-container img {
    display: block;
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
    object-fit: contain;
}

.image-preview-container a {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    height: 100%;
    line-height: 0;
    box-shadow: 0px 0px 5px #bdbdbd;
}

/* --- Info Text --- */
.controle-card-info {
    margin-top: auto;
}

.controle-card-info .chapitres {
    margin: 10px 0 0 0;
    font-size: 0.95em;
    color: #333;
    line-height: 1.4;
}

.controle-card-info .chapitres strong {
    font-weight: bold;
    display: block;
    margin-bottom: 5px;
}

.controle-card-info .chapitres .pill.pill-chapitres {
    margin-right: 5px;
    margin-bottom: 5px;
}

/* --- Footer --- */
.controle-card-footer {
    padding: 10px 15px;
    background-color: #f8f9fa;
    border-top: 1px solid #ddd;
    font-size: 0.85em;
    color: #666;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
    min-height: 40px;
}

.controle-card-footer .actions {
    display: flex;
    gap: 8px;
    align-items: center;
}

.controle-card-footer .actions a,
.controle-card-footer .actions span {
    text-decoration: none;
    display: inline-flex;
    align-items: center;
}

.controle-card-footer .actions a img,
.controle-card-footer .actions span img {
    margin-right: 3px;
    height: 1em;
    width: 1em;
}

.controle-card-footer .entry-meta {
    text-align: right;
    flex-grow: 1;
}

/* ======================================== */
/* --- Pills --- */
/* ======================================== */
.pill {
    display: inline-block;
    font-weight: bold;
    padding: 5px 10px;
    border-radius: 15px;
    font-size: 0.85em;
    border: 1px solid;
    white-space: nowrap;
    margin-bottom: 3px;
    margin-right: 3px;
}
.pill-niveau { background-color: white; border-color: #f59c27; color: #f59c27; }
.pill-chapitres { background-color: white; border-color: #0e5c4b; color: #0e5c4b; }
.pill-date { background-color: white; border-color: #39b8b0; color: #39b8b0; }
.pill-corrige {
    background-color: #f1a137;
    color: white;
    border-color: #f1a137;
    font-size: 0.8em;
    padding: 3px 8px;
    vertical-align: middle;
}

/* ======================================== */
/* --- Filter Controls --- */
/* ======================================== */
#filter-controls {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    padding: 15px 15px 0 15px;
    margin-bottom: 15px;
    max-width: 1400px;
    margin-left: auto;
    margin-right: auto;
    border-bottom: 1px solid #eee;
    padding-bottom: 15px;
    box-sizing: border-box;
}
.filter-group {
    display: flex;
    flex-direction: column;
    gap: 5px;
}
.filter-group label {
    font-size: 0.9em;
    font-weight: bold;
    color: #555;
}
.filter-group select,
.filter-group input[type="text"] {
    padding: 8px 10px;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-size: 0.95em;
    min-width: 200px;
}
.custom-filter-controls {
    margin-bottom: 20px;
    padding: 15px;
    background-color: #f8f8f8;
    border: 1px solid #ddd;
    border-radius: 5px;
    max-width: 1400px;
    margin-left: auto;
    margin-right: auto;
    box-sizing: border-box;
}
.filter-row {
    margin-bottom: 10px;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
}
.filter-row:last-child {
    margin-bottom: 0;
}
.filter-row strong {
    margin-right: 10px;
    white-space: nowrap;
}
.filter-button {
    padding: 6px 12px;
    border: 1px solid #ccc;
    background-color: #fff;
    color: #0e5c4b;
    cursor: pointer;
    border-radius: 4px;
    transition: background-color 0.2s ease, border-color 0.2s ease;
    font-size: 0.9em;
    white-space: nowrap;
}
.filter-button:hover {
    background-color: #eee;
    border-color: #aaa;
}
.filter-button.active {
    background-color: #0e5c4b;
    color: #fff;
    border-color: #0e5c4b;
    font-weight: bold;
}
.chapter-buttons-container {
    min-height: 30px;
}
#cosmetic-search-button {
    background-color: #0e5c4b;
    font-weight: bolder;
    font-size: inherit;
    color: white;
    border: none;
    padding: 8px 15px;
    border-radius: 4px;
    cursor: pointer;
}
#cosmetic-reset-button {
    display: none;
}

/* ======================================== */
/* --- Moodle Specific Hiding --- */
/* ======================================== */
#data_adv_form, 
#advancedcheckbox, 
#page-mod-data-view .drawer-left:not(#theme_boost-drawers-primary), 
label[for="pref_search"], 
#pref_search, 
#reg_search {
    display: none !important;
}
#page-mod-data-view #page {
    padding-left: 0 !important;
    margin-left: 0 !important;
}

/* ======================================== */
/* --- Custom Autocomplete Search --- */
/* ======================================== */
#custom-search-container,
#custom-search-container-single {
    max-width: 1400px;
    margin: 0 auto 20px auto;
    padding: 0 15px;
    box-sizing: border-box;
    position: relative;
}
#custom-search-container .autoComplete_wrapper,
#custom-search-container-single .autoComplete_wrapper {
    display: block !important;
    max-width: 700px;
    width: 100%;
    margin-left: auto;
    margin-right: auto;
    position: relative;
}
#custom-search-input,
#custom-search-input-single {
    display: block;
    width: 100%;
    padding: 10px 15px 10px 40px;
    font-size: 1.1em;
    color: #333;
    border: 1px solid #ccc;
    border-radius: 25px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='%23888' class='bi bi-search' viewBox='0 0 16 16'%3E%3Cpath d='M11.742 10.344a6.5 6.5 0 1 0-1.397 1.398h-.001c.03.04.062.078.098.115l3.85 3.85a1 1 0 0 0 1.415-1.414l-3.85-3.85a1.007 1.007 0 0 0-.115-.1zM12 6.5a5.5 5.5 0 1 1-11 0 5.5 5.5 0 0 1 11 0z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: 15px center;
    background-size: 16px 16px;
    -webkit-appearance: none;
    box-sizing: border-box;
}
#custom-search-input:focus,
#custom-search-input-single:focus {
    outline: none;
    border-color: #0e5c4b;
    box-shadow: inset 0 1px 3px rgba(0,0,0,0.1), 0 0 0 2px rgba(14, 92, 75, 0.2);
}
#custom-search-input::placeholder,
#custom-search-input-single::placeholder {
    color: #0e5c4bb2 !important;
    font-weight: bold;
    opacity: 1;
}
/* Autocomplete Results Dropdown */
#custom-search-container .autoComplete_wrapper > ul,
#custom-search-container-single .autoComplete_wrapper > ul {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    z-index: 1000;
    margin-top: 5px;
    list-style: none;
    background-color: #fff;
    border: 1px solid #ccc;
    border-radius: 4px;
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
    max-height: 300px;
    overflow-y: auto;
    padding: 0;
}
#custom-search-container .autoComplete_wrapper > ul > li,
#custom-search-container-single .autoComplete_wrapper > ul > li {
    padding: 8px 12px;
    cursor: pointer;
    border-bottom: 1px solid #eee;
    color: #333;
}
#custom-search-container .autoComplete_wrapper > ul > li:hover,
#custom-search-container-single .autoComplete_wrapper > ul > li.autoComplete_selected {
    background-color: #f0f0f0;
    color: #0e5c4b;
}
#custom-search-container .autoComplete_wrapper > ul > li mark {
    background-color: transparent;
    color: #f59c27;
    font-weight: bold;
}

/* ======================================== */
/* --- SINGLE VIEW SPECIFIC (Original) --- */
/* ======================================== */
.database-backlink,
.fiche-title-area,
.fiche-controle-container,
.mod_data_fastcomments_wrapper,
.custom-search-container-singleview {
    max-width: 1200px;
    margin-left: auto;
    margin-right: auto;
    box-sizing: border-box;
    padding-left: 15px;
    padding-right: 15px;
}

.fiche-title-area {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    padding-bottom: 10px;
}

.fiche-title-wrapper {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-grow: 1;
}

.fiche-title {
    font-size: 1.8em;
    color: #333;
    margin: 0;
}

.fiche-controle-container {
    padding: 15px;
    border: 1px solid #dee2e6;
    border-radius: 5px;
    margin-bottom: 30px;
    background-color: white;
}

.fiche-metadata-pills {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 20px;
}

/* Description & Thumbnail (Floating) */
.fiche-description {
    margin-bottom: 25px;
    padding: 15px;
    background-color: #fdfdfd;
    border: 1px solid #eee;
    border-radius: 4px;
    line-height: 1.6;
    color: #555;
    display: flow-root;
}

.pdf-thumbnail-float {
    float: right;
    width: 27%;
    margin-left: 30px;
    margin-bottom: 10px;
    margin-top: -10px; /* Overlap effect */
    position: relative;
    z-index: 10;
    background-color: #fff;
    border: 1px solid #ccc;
    box-shadow: 0px 3px 8px rgba(0, 0, 0, 0.2);
    border-radius: 5px;
    overflow: hidden;
    line-height: 0;
}

.pdf-thumbnail-float img {
    display: block;
    width: 100%;
    height: auto;
    border-radius: 5px;
}

/* Tabs */
.tabs-and-actions-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0;
    padding-bottom: 10px;
    border-bottom: 1px solid #eee;
    flex-wrap: wrap;
}

.desktop-tabs {
    margin-bottom: -11px;
    margin-right: 15px;
}

.desktop-tabs .tab {
    background-color: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    padding: 10px 15px;
    cursor: pointer;
    font-size: 1em;
    color: #f59c27;
    transition: all 0.2s ease-in-out;
    font-weight: bold;
}

.desktop-tabs .tab:hover {
    background-color: #f8f9fa;
    border-bottom-color: #ccc;
    color: #cf821f;
}

.desktop-tabs .tab.active {
    font-weight: bold;
    color: #0e5c4b;
    border-bottom: 2px solid #0e5c4b;
    background-color: white;
    z-index: 1;
}

/* Active Download Button */
.active-download-button-area {
    display: flex;
    align-items: center;
    gap: 10px;
}

#active-pdf-download-button.whitebutton {
    display: inline-block;
    padding: 6px 12px;
    background-color: #f59c27;
    color: white;
    text-decoration: none;
    border-radius: 4px;
    font-weight: bold;
    font-size: 0.9em;
    border: 1px solid #f59c27;
}

#active-pdf-download-button.whitebutton:hover {
    background-color: #ec971f;
    border-color: #e08e0b;
}

#active-pdf-error {
    color: #dc3545;
    font-size: 0.9em;
}

/* Tab Content */
.fiche-controle-contenu {
    margin-top: 20px;
}

.fiche-controle-colonne.onglet {
    flex-direction: column;
    padding: 15px;
    border: 1px solid #eee;
    border-radius: 4px;
    background-color: #fff;
    width: 100%;
    box-sizing: border-box;
}

.adobe-viewer-container {
    width: 100%;
    aspect-ratio: 1 / 1.414;
    border: 1px solid #ccc;
    margin-bottom: 15px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    position: relative;
}

.adobe-viewer-message {
    color: #666;
    font-style: italic;
    padding: 20px;
    text-align: center;
}

.fiche-controle-footer {
    margin-top: 25px;
    padding-top: 15px;
    border-top: 1px solid #eee;
    font-size: 0.8em;
    color: #6c757d;
    text-align: center;
}

/* ======================================== */
/* --- Responsive Adjustments --- */
/* ======================================== */
@media(max-width:768px) {
    .desktop-tabs { display: none; }
    .fiche-controle-colonne.onglet { display: flex !important; width: 100%; flex-direction: column; margin-bottom: 15px; }
    .tabs-and-actions-header { flex-direction: column; align-items: flex-start; border-bottom: none; margin-bottom: 15px; }
    .active-download-button-area { margin-top: 10px; }
    .pdf-thumbnail-float { float: none; width: auto; max-width: 60%; display: block; margin: 15px auto; position: static; }
    #page-mod-data-view #page { padding-left: 0 !important; margin-left: 0 !important; }
}

@media (max-width: 680px) {
    .controle-card { width: calc(100% - 10px); }
    .controle-card-list { justify-content: center; padding-left: 5px; padding-right: 5px; }
    .pdf-thumbnail-float { max-width: 70%; }
}

@media (max-width: 480px) {
    .fiche-title { font-size: 1.5em; }
    .fiche-title-area { flex-direction: column; align-items: flex-start; }
    .pdf-thumbnail-float { max-width: 85%; }
}

/* ================================================================= */
/* --- NEW SPLIT VIEW & CORRECTION LOGIC (Add to bottom of CSS) --- */
/* ================================================================= */

/* --- 1. The Split Grid (Desktop) --- */
.split-view-container {
    display: grid;
    grid-template-columns: 1fr 1fr; /* 50% - 50% */
    gap: 25px;
    min-height: 650px;
    margin-top: 20px;
}

/* --- 2. The Columns (White, Rounded, Fun) --- */
.view-column {
    background: #ffffff;
    border-radius: 20px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.08);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border: 1px solid #f0f0f0;
    transition: transform 0.3s ease;
}

.column-header {
    background: #fff;
    padding: 15px 25px;
    border-bottom: 3px solid #f59c27; /* Orange Highlight */
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.column-header h3 {
    margin: 0;
    color: #0e5c4b; /* Dark Green */
    font-size: 1.2rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* --- 3. Buttons inside Headers --- */
.btn-download-header {
    text-decoration: none !important;
    background: #f0fdfc;
    color: #39b8b0;
    padding: 8px 15px;
    border-radius: 10px;
    font-size: 0.85rem;
    font-weight: 700;
    border: 1px solid #cbf7f4;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 5px;
}
.btn-download-header:hover {
    background: #39b8b0;
    color: white;
}

/* --- 4. The Correction Blur/Mask --- */
.correction-wrapper {
    position: relative;
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    height: 100%;
}

#correction-overlay {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(8px); /* The Blur Effect */
    -webkit-backdrop-filter: blur(8px);
    padding: 20px;
    z-index: 10;
}

.lock-icon {
    font-size: 50px;
    margin-bottom: 15px;
    animation: bounce 2s infinite;
}

@keyframes bounce {
    0%, 20%, 50%, 80%, 100% {transform: translateY(0);}
    40% {transform: translateY(-10px);}
    60% {transform: translateY(-5px);}
}

.btn-reveal {
    background-color: #39b8b0; /* Teal */
    color: white;
    border: none;
    padding: 12px 30px;
    font-size: 16px;
    font-weight: 800;
    border-radius: 50px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(57, 184, 176, 0.3);
}
.btn-reveal:hover {
    background-color: #0e5c4b;
    transform: scale(1.05);
}

/* --- 5. Mobile Adjustments (Keep it simple) --- */
@media (max-width: 900px) {
    .split-view-container {
        grid-template-columns: 1fr; /* Stack vertically */
        gap: 40px;
    }
    .view-column {
        min-height: 500px; /* Ensure height on mobile */
    }
    .pdf-thumbnail-float {
        display: none !important; /* Hide thumbnail on mobile as requested */
    }
}

/* ================================================================= */
/* --- NEW SPLIT VIEW & CORRECTION LOGIC --- */
/* ================================================================= */

/* --- 1. The Split Grid (Desktop: 95% Width Breakout) --- */
.split-view-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 25px;
    min-height: 800px;
    margin-top: 20px;
}

@media (min-width: 992px) {
    .split-view-container {
        /* Force width to 95% of the Viewport, ignoring parent width */
        width: 90vw; 
        /* Center it relative to the viewport */
        margin-left: calc(50% - 45vw); 
        margin-right: calc(50% - 45vw);
        max-width: none;
    }
}

/* --- 2. The Columns --- */
.view-column {
    background: #ffffff;
    border-radius: 20px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.08);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border: 1px solid #f0f0f0;
    height: 100%;
}

.column-header {
    background: #fff;
    padding: 15px 25px;
    border-bottom: 3px solid #f59c27;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}

.column-header h3 {
    margin: 0;
    color: #0e5c4b;
    font-size: 1.2rem;
    font-weight: 800;
    text-transform: uppercase;
}

/* --- 3. Viewer Area --- */
.adobe-viewer-container {
    flex-grow: 1;
    width: 100%;
    height: 100%;
    min-height: 700px;
    background: #f9f9f9;
}

/* --- 4. Correction Mask --- */
.correction-wrapper {
    position: relative;
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    height: 100%;
}

#correction-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.96);
    z-index: 20;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    padding: 20px;
}

/* --- 5. Buttons --- */
.btn-reveal {
    background-color: #39b8b0;
    color: white;
    border: none;
    padding: 12px 30px;
    font-size: 16px;
    font-weight: 800;
    border-radius: 50px;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(57, 184, 176, 0.3);
    transition: transform 0.2s;
}
.btn-reveal:hover {
    background-color: #0e5c4b;
    transform: scale(1.05);
}

.btn-download-header {
    text-decoration: none !important;
    background: #f0fdfc;
    color: #39b8b0;
    padding: 8px 15px;
    border-radius: 10px;
    font-size: 0.85rem;
    font-weight: 700;
    border: 1px solid #cbf7f4;
}
.btn-download-header:hover {
    background: #39b8b0;
    color: white;
}

/* --- 6. Mobile --- */
@media (max-width: 991px) {
    .split-view-container {
        grid-template-columns: 1fr;
        gap: 40px;
        width: 100%; /* Reset width */
        margin-left: 0; /* Reset margin */
    }
    .pdf-thumbnail-float {
        display: none !important;
    }
}