.resources-page {
    max-width: 90dvw;
    margin: 0 auto;
    padding: 40px 30px 80px;
}


/* Header */
.page-header {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 24px;
    margin-bottom: 28px;
    flex-wrap: wrap;
}

.header-text h1 {
    text-align: left;
    font-family: var(--font-titles);
    font-size: 36px;
    color: var(--text-dark);
    margin-bottom: 4px;
}

.header-text p {
    font-family: var(--font-text-secondary);
    font-size: 16px;
    color: #777;
}


/* Controls bar */
.controls-bar {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.search-box {
    position: relative;
    flex: 1 1 220px;
    min-width: 180px;
}

.search-box i {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: #aaa;
    font-size: 14px;
    pointer-events: none;
}

.search-box input {
    width: 100%;
    padding: 10px 14px 10px 36px;
    border: 1px solid #dde3e8;
    border-radius: 8px;
    font-family: var(--font-text-secondary);
    font-size: 14px;
    background: white;
    box-shadow: 0 1px 3px rgba(0,0,0,0.04);
    transition: border-color 0.2s, box-shadow 0.2s;
    box-sizing: border-box;
}

.search-box input:focus {
    outline: none;
    border-color: var(--primary-saturated);
    box-shadow: 0 0 0 3px rgba(1, 154, 217, 0.12);
}

.filters {
    display: flex;
    gap: 14px;
    flex-wrap: wrap;
}

.custom-select {
    position: relative;
    min-width: 190px;
}

.custom-select select {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.custom-select-trigger {
    width: 100%;
    min-height: 38px;
    padding: 0 14px;
    border: 1px solid #dde3e8;
    border-radius: 8px;
    background: white;
    box-shadow: 0 1px 3px rgba(0,0,0,0.04);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    font-family: var(--font-text-secondary);
    font-size: 14px;
    font-weight: 500;
    color: #444;
    cursor: pointer;
    transition: border-color 0.2s, box-shadow 0.2s, background-color 0.2s;
}

.custom-select-trigger:hover {
    border-color: #cfdbe3;
    background: #f9fbfd;
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}

.custom-select.open .custom-select-trigger,
.custom-select-trigger:focus-visible {
    outline: none;
    border-color: var(--primary-saturated);
}

.custom-select-icon {
    color: #7f99a8;
    font-size: 11px;
    transition: transform 0.2s ease, color 0.2s ease;
}

.custom-select.open .custom-select-icon {
    transform: rotate(180deg);
    color: var(--primary-saturated);
}

.custom-select-menu {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    right: 0;
    padding: 6px;
    background: #fff;
    border: 1px solid #dde3e8;
    border-radius: 12px;
    box-shadow: 0 6px 18px rgba(0,0,0,0.08);
    max-height: 260px;
    overflow-y: auto;
    opacity: 0;
    visibility: hidden;
    transform: translateY(4px);
    transition: opacity 0.18s ease, transform 0.18s ease, visibility 0.18s ease;
    z-index: 40;
}

.custom-select.open .custom-select-menu {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.custom-select-option {
    width: 100%;
    border: none;
    background: transparent;
    border-radius: 8px;
    padding: 11px 12px;
    text-align: left;
    font-family: var(--font-text-secondary);
    font-size: 14px;
    color: #555;
    cursor: pointer;
    transition: background-color 0.18s ease, color 0.18s ease;
}

.custom-select-option:hover {
    background: #f4f8fb;
    color: var(--text-dark);
}

.custom-select-option.is-selected {
    background: var(--primary-light);
    color: var(--primary-saturated);
    font-weight: 600;
}


/* Grouped layout styles */
.resources-container {
    padding-bottom: 60px;
}

.resource-section {
    margin-bottom: 30px;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
    background: white;
}

.section-header {
    background-color: var(--primary-light);
    padding: 15px 25px;
    display: flex;
    align-items: center;
    cursor: pointer;
    transition: background-color 0.3s;
}

.section-header:hover {
    background-color: rgba(137, 207, 232, 0.3);
}

.section-header h2 {
    font-family: var(--font-titles);
    font-size: 22px;
    margin: 0;
    color: var(--text-dark);
}

.chevron-icon {
    margin-right: 15px;
    color: var(--primary-saturated);
    font-size: 14px;
    transition: transform 0.3s;
}

.section-content {
    padding: 25px;
    background-color: white;
    max-height: 360px; /* Approximately 2 rows of cards */
    overflow-y: auto;
}

.resources-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 30px 20px;
    padding-top: 20px; /* Space for the icons on the top row */
}

.resource-card {
    position: relative;
    display: flex;
    flex-direction: column;
    border: 1px solid #e6e6e6;
    border-radius: 20px;
    height: 120px;
    transition: all 0.3s ease;
    cursor: pointer;
    background-color: #fffffe;
    text-decoration: none;
}

.resource-card:hover {
    box-shadow: 0 6px 15px rgba(0, 0, 0, 0.1);
    transform: translateY(-5px);
}

.resource-icon {
    position: absolute;
    top: -25px;
    left: 50%;
    transform: translateX(-50%);
    width: 50px;
    height: 50px;
    z-index: 1;
}

.resource-icon img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.resource-info {
    margin-top: 25px;
    padding: 10px 15px;
    text-align: center;
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}

.resource-info p {
    font-family: var(--font-text-secondary);
    font-size: 15px;
    font-weight: 600;
    color: var(--text-dark);
    margin: 0;
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.resource-buttons {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: none;
    justify-content: center;
    align-items: center;
    gap: 15px;
    background-color: rgba(252, 217, 204, 0.45);
    border-radius: 20px;
    z-index: 2;
}

.resource-card:hover .resource-buttons {
    display: flex;
}

.resource-buttons .btn-icon {
    width: 48px;
    height: 48px;
    font-size: 2rem;
    background: white;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    background-color: #fde2d8;
    color: var(--accent-light);
    transition: transform 0.2s, background 0.2s;
    box-shadow: 0 2px 6px rgba(0,0,0,0.1);
}

.resource-buttons .btn-icon:hover {
    transform: scale(1.1);
    background: var(--accent);
    color: white;
}


/* Table wrapper update */
.table-wrapper {
    background: white;
    border-radius: 12px;
    box-shadow: 0 2px 12px rgba(0,0,0,0.06);
    overflow-y: auto;
    max-height: 450px;
    position: relative;
}

#resources-table {
    width: 100%;
    border-collapse: collapse;
}

#resources-table thead th {
    position: sticky;
    top: 0;
    z-index: 10;
    background: #f4f8fb;
    box-shadow: 0 2px 2px -1px rgba(0, 0, 0, 0.1);
}

#resources-table thead tr {
    background: #f4f8fb;
    border-bottom: 2px solid #e4edf3;
}

#resources-table th {
    padding: 13px 18px;
    font-family: var(--font-titles);
    font-size: 1.3rem;
    color: #778;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    text-align: left;
    white-space: nowrap;
}

#resources-table td {
    padding: 13px 18px;
    font-family: var(--font-text);
    font-size: 1.6rem;
    color: #333;
    border-bottom: 1px solid #f0f4f7;
    vertical-align: middle;
}

#resources-table tbody tr:last-child td {
    border-bottom: none;
}

#resources-table tbody tr:hover {
    background: #f9fbfd;
}

/* column widths */
.col-title { width: 50%; }
.col-type  { width: 25%; }
.col-course{ width: 25%; }
.col-action{ width: 5%; }

.file-icon {
    color: var(--primary-saturated);
    margin-right: 8px;
    font-size: 1.7rem;
    opacity: 0.7;
}


/* Type badges */
.badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 1.6rem;
    font-family: var(--font-text);
    font-weight: 600;
    white-space: nowrap;
    background: #e8f4fb;
    color: var(--primary-saturated);
}
.badge:visited {
    color: var(--primary-saturated);
}

/* give each type a distinct tint */
.badge.type-exam        { background: #fff0eb; color: #d4460a; }
.badge.type-summary     { background: #edfaf0; color: #28a048; }
.badge.type-assignment  { background: #fdf5e0; color: #b07a00; }
.badge.type-pdf         { background: #f0ebff; color: #6b3fcb; }
.badge.type-slides      { background: #e8f4fb; color: var(--primary-saturated); }


/* row buttons */
td.col-action {
    display: flex;
    flex-direction: row;
    justify-content: flex-end;
    gap: 1rem;
}

.col-action {
    width: 120px;
    min-width: 5%;
}
.solve-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 7px;
    color: var(--primary-saturated);
    background: var(--primary-light);
    transition: background 0.2s, color 0.2s;
    text-decoration: none;
}
.solve-btn:visited {
    color: var(--primary-saturated);
}
.solve-btn:hover {
    background: var(--primary-saturated);
    color: white;
}
.download-btn, .resource-view {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 7px;
    color: var(--primary-saturated);
    background: var(--primary-light);
    transition: background 0.2s, color 0.2s;
    text-decoration: none;
}
.download-btn:visited, .resource-view:visited {
    color: var(--primary-saturated);
}
.download-btn:hover, .resource-view:hover {
    background: var(--primary-saturated);
    color: white;
}


/* Empty state */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: #aaa;
}

.empty-state i {
    font-size: 48px;
    margin-bottom: 14px;
    display: block;
}

.empty-state p {
    font-family: var(--font-text);
    font-size: 16px;
}

.table-footer {
    position: sticky;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--primary-saturated);
    color: white;
    padding: 8px 24px;
    font-family: var(--font-text-secondary);
    font-size: 1.4rem;
    text-align: right;
    border-bottom-left-radius: 12px;
    border-bottom-right-radius: 12px;
    z-index: 10;
    display: none;
    box-shadow: 0 -2px 10px rgba(0,0,0,0.1);
}

.table-footer.visible {
    display: block;
}


/* Header right: stats + upload button */
.header-right {
    display: flex;
    align-items: center;
    gap: 14px;
    flex-wrap: wrap;
}

.upload-btn {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 10px 18px;
    background: var(--primary-saturated);
    color: white;
    border: none;
    border-radius: 8px;
    font-family: var(--font-text);
    font-size: 1.5rem;
    cursor: pointer;
    transition: background 0.2s, transform 0.15s;
    white-space: nowrap;
}

.upload-btn:hover {
    background: #0188c0;
    transform: translateY(-1px);
}


/* Upload Modal */
.upload-modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

.upload-modal-overlay.open {
    display: flex;
}

.upload-modal {
    background: white;
    border-radius: 14px;
    width: 90%;
    max-width: 540px;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.18);
    overflow: hidden;
    animation: modal-in 0.2s ease;
}

@keyframes modal-in {
    from { opacity: 0; transform: translateY(-16px); }
    to   { opacity: 1; transform: translateY(0); }
}

.upload-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 18px 24px;
    border-bottom: 1px solid #eee;
    background: #f4f8fb;
}

.upload-modal-header h2 {
    font-family: var(--font-titles);
    font-size: 2rem;
    color: var(--text-dark);
    margin: 0;
}

.upload-modal-header h2 i {
    color: var(--primary-saturated);
    margin-right: 8px;
}

.upload-modal-close {
    background: none;
    border: none;
    font-size: 24px;
    color: #999;
    cursor: pointer;
    line-height: 1;
    padding: 0 4px;
    transition: color 0.2s;
}

.upload-modal-close:hover {
    color: var(--accent);
}

.upload-modal-body {
    padding: 24px;
}

.upload-form-group {
    display: flex;
    flex-direction: column;
    margin-bottom: 16px;
}

.upload-form-group label {
    font-family: var(--font-text-secondary);
    font-size: 1.4rem;
    color: #555;
    margin-bottom: 6px;
}

.required {
    color: var(--accent);
}

.upload-form-group input[type="text"],
.upload-form-group input[type="file"],
.upload-form-group select {
    padding: 9px 12px;
    border: 1px solid #dde3e8;
    border-radius: 8px;
    font-family: var(--font-text-secondary);
    font-size: 1.4rem;
    color: #333;
    background: white;
    transition: border-color 0.2s, box-shadow 0.2s;
    box-sizing: border-box;
}

.upload-form-group input:focus,
.upload-form-group select:focus {
    outline: none;
    border-color: var(--primary-saturated);
    box-shadow: 0 0 0 3px rgba(1, 154, 217, 0.12);
}

.upload-form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
}

.upload-notice {
    font-family: var(--font-text-secondary);
    font-size: 1.3rem;
    color: #888;
    background: #f4f8fb;
    border-radius: 8px;
    padding: 10px 14px;
    margin: 4px 0 18px;
}

.upload-notice i {
    color: var(--primary-saturated);
    margin-right: 6px;
}

.upload-form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
}

.upload-cancel-btn {
    padding: 9px 20px;
    background: #f0f0f0;
    color: #555;
    border: none;
    border-radius: 8px;
    font-family: var(--font-text);
    font-size: 1.5rem;
    cursor: pointer;
    transition: background 0.2s;
}

.upload-cancel-btn:hover {
    background: #e0e0e0;
}

.upload-submit-btn {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 9px 22px;
    background: var(--primary-saturated);
    color: white;
    border: none;
    border-radius: 8px;
    font-family: var(--font-text);
    font-size: 1.5rem;
    cursor: pointer;
    transition: background 0.2s;
}

.upload-submit-btn:hover {
    background: #0188c0;
}

.upload-submit-btn:disabled {
    background: #aaa;
    cursor: not-allowed;
}


/* Upload Toast notification */
.upload-toast {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    padding: 13px 24px;
    border-radius: 10px;
    font-family: var(--font-text-secondary);
    font-size: 1.5rem;
    color: white;
    z-index: 2000;
    opacity: 0;
    transition: opacity 0.3s, transform 0.3s;
    pointer-events: none;
    white-space: nowrap;
}
.upload-toast-success { background: #28a048; }
.upload-toast-error   { background: #d4460a; }
.upload-toast-show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}


/* Responsive */
@media (max-width: 700px) {
    .resources-page {
        padding: 24px 16px 60px;
    }

    .page-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .custom-select {
        width: 100%;
    }

    .col-course {
        display: none;
    }

    .upload-form-row {
        grid-template-columns: 1fr;
    }
}
