/* Study Materials — materials.php (aligned with site cream / muted gold) */
.materials-page {
    overflow-x: clip;
    --mp-cream: #f9f7f2;
    --mp-cream-deep: #efe9df;
    --mp-amber: #b8956a;
    --mp-amber-dark: #9a7d55;
    --mp-amber-soft: #e5ddd0;
    --mp-amber-rgb: 184, 149, 106;
    --mp-card: #ffffff;
    --mp-text: #1c1917;
    --mp-muted: #78716c;
    --mp-border: #e7e5e4;
    --mp-shadow: 0 4px 24px rgba(28, 25, 23, 0.06);
    --mp-shadow-lg: 0 12px 40px rgba(28, 25, 23, 0.08);
    flex: 1 0 auto;
    background: var(--mp-cream);
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    color: var(--mp-text);
}

.materials-page__hero {
    position: relative;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: clamp(200px, 26vw, 280px);
    padding: 48px 24px 44px;
    background-color: var(--mp-cream);
    background-image: url('../img/home/materials-hero-bg.png');
    background-repeat: no-repeat;
    background-position: center center;
    background-size: cover;
    border-bottom: 1px solid rgba(var(--mp-amber-rgb), 0.22);
    text-align: center;
}

.materials-page__hero-inner {
    position: relative;
    z-index: 1;
    width: fit-content;
    max-width: min(640px, calc(100% - 32px));
    margin: 0 auto;
    padding: 28px 40px 32px;
    text-align: center;
    background: rgba(249, 247, 242, 0.55);
    backdrop-filter: blur(14px) saturate(1.35);
    -webkit-backdrop-filter: blur(14px) saturate(1.35);
    border: 1px solid rgba(255, 255, 255, 0.65);
    border-radius: 20px;
    box-shadow:
        0 8px 32px rgba(28, 25, 23, 0.08),
        inset 0 1px 0 rgba(255, 255, 255, 0.75);
}

.materials-page__hero-inner::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: inherit;
    background: linear-gradient(
        145deg,
        rgba(255, 255, 255, 0.55) 0%,
        rgba(255, 255, 255, 0.08) 48%,
        rgba(229, 221, 208, 0.18) 100%
    );
    pointer-events: none;
}

.materials-page__hero h1,
.materials-page__hero p {
    position: relative;
    z-index: 1;
}

.materials-page__hero h1 {
    font-family: 'Playfair Display', Georgia, 'Times New Roman', serif;
    font-size: clamp(2rem, 4.5vw, 2.75rem);
    font-weight: 700;
    color: #0c0a09;
    margin: 0 0 10px;
    letter-spacing: -0.02em;
    text-shadow: 0 1px 2px rgba(255, 255, 255, 0.6);
}

.materials-page__hero p {
    margin: 0 auto;
    font-size: 1.05rem;
    color: #44403c;
    max-width: 36rem;
    line-height: 1.5;
}

.materials-page__shell {
    width: min(1200px, 100%);
    max-width: 100%;
    margin: 0 auto;
    padding: 0 20px 64px;
    box-sizing: border-box;
}

.materials-page__toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: stretch;
    gap: 12px;
    margin: -28px auto 28px;
    padding: 14px 16px;
    background: var(--mp-card);
    border-radius: 14px;
    box-shadow: var(--mp-shadow-lg);
    border: 1px solid var(--mp-border);
    position: relative;
    z-index: 2;
    box-sizing: border-box;
    max-width: 100%;
    width: 100%;
}

.materials-page__search {
    flex: 1 1 220px;
    min-width: 0;
    max-width: 100%;
    position: relative;
    display: block;
    box-sizing: border-box;
}

.materials-page__search i {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: #a8a29e;
    pointer-events: none;
    z-index: 1;
    font-size: 0.95rem;
    line-height: 1;
    width: 1em;
    height: 1em;
    display: flex;
    align-items: center;
    justify-content: center;
}

.materials-page__search input {
    display: block;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    box-sizing: border-box;
    padding: 11px 14px 11px 40px;
    border: 1px solid var(--mp-border);
    border-radius: 10px;
    font-size: 0.92rem;
    background: #fafaf9;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.materials-page__search input:focus {
    outline: none;
    border-color: var(--mp-amber);
    box-shadow: 0 0 0 3px rgba(var(--mp-amber-rgb), 0.22);
    background: #fff;
}

.materials-page__filters {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: flex-end;
    flex: 1 1 auto;
    min-width: 0;
    max-width: 100%;
}

.materials-page__filter {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 120px;
    flex: 1 1 120px;
    max-width: 100%;
    box-sizing: border-box;
}

.materials-page__filter label {
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--mp-muted);
}

.materials-page__filter select {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    box-sizing: border-box;
    padding: 9px 32px 9px 12px;
    border: 1px solid var(--mp-border);
    border-radius: 10px;
    font-size: 0.88rem;
    font-weight: 500;
    background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%2378716c' d='M3 4.5L6 7.5L9 4.5'/%3E%3C/svg%3E") no-repeat right 10px center;
    appearance: none;
    cursor: pointer;
}

.materials-page__layout {
    display: grid;
    grid-template-columns: 1fr 300px;
    gap: 24px;
    align-items: start;
}

.materials-page__main {
    min-width: 0;
}

.materials-page__card {
    background: var(--mp-card);
    border-radius: 14px;
    box-shadow: var(--mp-shadow);
    border: 1px solid var(--mp-border);
    overflow: hidden;
}

.materials-page__alert {
    margin: 1.25rem 1.5rem;
}

.materials-page__empty {
    padding: 3rem 1.5rem;
    text-align: center;
    color: var(--mp-muted);
}

/* Course accordion */
.materials-page__accordion {
    --bs-accordion-border-width: 0;
    --bs-accordion-btn-focus-box-shadow: none;
    --bs-accordion-active-bg: transparent;
    --bs-accordion-btn-padding-x: 0;
    --bs-accordion-btn-padding-y: 0;
    --bs-accordion-body-padding-x: 0;
    --bs-accordion-body-padding-y: 0;
}

.materials-page__accordion .accordion-item {
    border: none;
    border-bottom: 1px solid var(--mp-border);
    background: transparent;
}

.materials-page__accordion .accordion-item:last-child {
    border-bottom: none;
}

.materials-page__course-btn {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    padding: 16px 20px;
    background: var(--mp-amber-soft) !important;
    border: none !important;
    box-shadow: none !important;
    border-radius: 0 !important;
    color: #4a4034 !important;
    font-weight: 700;
    font-size: 1.02rem;
    text-align: left;
}

.materials-page__course-btn:not(.collapsed) {
    background: var(--mp-amber-soft) !important;
}

.materials-page__course-btn::after {
    flex-shrink: 0;
    margin-left: auto;
    background-size: 1rem;
    filter: none;
    opacity: 0.65;
}

.materials-page__course-icon {
    flex-shrink: 0;
    width: 38px;
    height: 38px;
    border-radius: 10px;
    background: var(--mp-amber);
    color: #faf9f7;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.95rem;
}

.materials-page__course-meta {
    margin-left: auto;
    margin-right: 8px;
    font-size: 0.82rem;
    font-weight: 600;
    color: #8f7349;
    white-space: nowrap;
}

.materials-page__course-body {
    padding: 4px 16px 20px;
}

/* Chapter sub-accordion */
.materials-page__chapters {
    --bs-accordion-border-width: 0;
    --bs-accordion-btn-focus-box-shadow: none;
    --bs-accordion-active-bg: transparent;
}

.materials-page__chapters .accordion-item {
    border: none;
    margin-bottom: 8px;
    background: #fafaf9;
    border-radius: 10px;
    overflow: hidden;
    border: 1px solid #f5f5f4;
}

.materials-page__chapter-btn {
    padding: 12px 16px !important;
    background: #fafaf9 !important;
    color: #292524 !important;
    font-weight: 600;
    font-size: 0.95rem;
    box-shadow: none !important;
    border-radius: 0 !important;
}

.materials-page__chapter-btn:not(.collapsed) {
    background: #fff !important;
    border-bottom: 1px solid var(--mp-border);
}

.materials-page__chapter-btn::after {
    margin-left: auto;
    opacity: 0.5;
}

.materials-page__chapter-count {
    margin-left: auto;
    margin-right: 10px;
    font-size: 0.78rem;
    font-weight: 500;
    color: var(--mp-muted);
}

.materials-page__chapter-body {
    padding: 12px 14px 16px;
    background: #fff;
}

/* Material cards */
.materials-page__material {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    gap: 14px;
    padding: 14px 0;
    border-bottom: 1px solid #f5f5f4;
}

.materials-page__material:last-child {
    border-bottom: none;
    padding-bottom: 4px;
}

.materials-page__material.is-hidden {
    display: none !important;
}

.materials-page__mat-icon {
    flex-shrink: 0;
    width: 44px;
    height: 44px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.15rem;
}

.materials-page__mat-icon--pdf {
    background: #fef2f2;
    color: #dc2626;
}

.materials-page__mat-icon--external {
    background: #ecfdf5;
    color: #059669;
}

.materials-page__mat-icon--revision {
    background: var(--mp-amber-soft);
    color: #8f7349;
}

.materials-page__mat-icon--file {
    background: #eff6ff;
    color: #2563eb;
}

.materials-page__mat-body {
    flex: 1 1 200px;
    min-width: 0;
}

.materials-page__mat-title {
    font-weight: 600;
    font-size: 0.98rem;
    color: #1c1917;
    line-height: 1.35;
    margin-bottom: 4px;
}

.materials-page__mat-desc {
    font-size: 0.84rem;
    color: var(--mp-muted);
    line-height: 1.45;
    margin-bottom: 8px;
}

.materials-page__mat-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: center;
}

.materials-page__tag {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    border-radius: 6px;
    font-size: 0.72rem;
    font-weight: 600;
    line-height: 1.4;
}

.materials-page__tag--pdf {
    background: #fef2f2;
    color: #b91c1c;
}

.materials-page__tag--external {
    background: #ecfdf5;
    color: #047857;
}

.materials-page__tag--revision {
    background: var(--mp-amber-soft);
    color: #6b5d48;
}

.materials-page__tag--neutral {
    background: #f5f5f4;
    color: #57534e;
}

.materials-page__tag--new {
    background: #dcfce7;
    color: #15803d;
}

.materials-page__mat-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
    margin-left: auto;
}

.materials-page__btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 16px;
    font-size: 0.84rem;
    font-weight: 600;
    border-radius: 9px;
    text-decoration: none;
    border: 1.5px solid transparent;
    white-space: nowrap;
    transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.materials-page__btn--view {
    background: var(--mp-amber);
    color: #faf9f7 !important;
    border-color: var(--mp-amber);
}

.materials-page__btn--view:hover {
    background: var(--mp-amber-dark);
    border-color: var(--mp-amber-dark);
    color: #fff !important;
}

.materials-page__btn--outline {
    background: #fff;
    color: #44403c !important;
    border-color: #d6d3d1;
}

.materials-page__btn--outline:hover {
    background: #fafaf9;
    border-color: #a8a29e;
}

.materials-page__unit-label {
    font-size: 0.75rem;
    color: #a8a29e;
    margin-bottom: 6px;
    font-weight: 500;
}

/* Sidebar */
.materials-page__sidebar {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.materials-page__widget {
    background: var(--mp-card);
    border-radius: 14px;
    border: 1px solid var(--mp-border);
    box-shadow: var(--mp-shadow);
    padding: 16px;
}

.materials-page__widget-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 14px;
}

.materials-page__widget-head h2 {
    margin: 0;
    font-size: 0.95rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 8px;
    color: #292524;
}

.materials-page__widget-head h2 i {
    color: var(--mp-amber);
    font-size: 0.9rem;
}

.materials-page__widget-link {
    font-size: 0.78rem;
    font-weight: 600;
    color: #8f7349;
    text-decoration: none;
}

.materials-page__widget-link:hover {
    text-decoration: underline;
}

.materials-page__continue-card {
    padding: 12px;
    background: #fafaf9;
    border-radius: 10px;
    border: 1px solid #f5f5f4;
    margin-bottom: 12px;
}

.materials-page__continue-title {
    font-size: 0.88rem;
    font-weight: 600;
    line-height: 1.35;
    margin-bottom: 10px;
    color: #292524;
}

.materials-page__progress {
    height: 6px;
    background: #e7e5e4;
    border-radius: 99px;
    overflow: hidden;
    margin-bottom: 6px;
}

.materials-page__progress-bar {
    height: 100%;
    background: linear-gradient(90deg, #22c55e, #16a34a);
    border-radius: 99px;
    transition: width 0.3s ease;
}

.materials-page__progress-label {
    font-size: 0.75rem;
    color: var(--mp-muted);
    margin-bottom: 12px;
}

.materials-page__btn--wide {
    width: 100%;
}

.materials-page__list-item {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 8px 0;
    border-bottom: 1px solid #f5f5f4;
    text-decoration: none;
    color: inherit;
}

.materials-page__list-item:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

.materials-page__list-item:hover .materials-page__list-title {
    color: #8f7349;
}

.materials-page__list-icon {
    flex-shrink: 0;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    background: var(--mp-amber-soft);
    color: #8f7349;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
}

.materials-page__list-body {
    min-width: 0;
    flex: 1;
}

.materials-page__list-title {
    font-size: 0.84rem;
    font-weight: 600;
    line-height: 1.3;
    color: #292524;
    transition: color 0.15s ease;
}

.materials-page__list-meta {
    font-size: 0.72rem;
    color: var(--mp-muted);
    margin-top: 2px;
}

.materials-page__popular-num {
    flex-shrink: 0;
    width: 22px;
    height: 22px;
    border-radius: 6px;
    background: var(--mp-amber-soft);
    color: #8f7349;
    font-size: 0.75rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
}

.materials-page__suggest {
    display: flex;
    gap: 12px;
    align-items: flex-start;
}

.materials-page__suggest-thumb {
    flex-shrink: 0;
    width: 56px;
    height: 72px;
    border-radius: 6px;
    background: linear-gradient(145deg, var(--mp-amber-soft), #d4c4a8);
    border: 1px solid #c4b59a;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #8f7349;
    font-size: 1.4rem;
}

.materials-page__suggest-body h3 {
    margin: 0 0 4px;
    font-size: 0.88rem;
    font-weight: 700;
    line-height: 1.3;
}

.materials-page__suggest-pub {
    font-size: 0.75rem;
    color: var(--mp-muted);
    margin-bottom: 10px;
}

.materials-page__support {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    margin-top: 20px;
    padding: 14px 16px;
    background: var(--mp-card);
    border-radius: 12px;
    border: 1px solid var(--mp-border);
    font-size: 0.88rem;
    color: #57534e;
    line-height: 1.45;
}

.materials-page__support i {
    color: var(--mp-amber);
    margin-top: 2px;
}

.materials-page__support a {
    color: #8f7349;
    font-weight: 600;
    text-decoration: none;
}

.materials-page__support a:hover {
    text-decoration: underline;
}

.materials-page__no-results {
    padding: 2rem 1.5rem;
    text-align: center;
    color: var(--mp-muted);
    display: none;
}

.materials-page__no-results.is-visible {
    display: block;
}

@media (max-width: 991px) {
    .materials-page__layout {
        grid-template-columns: 1fr;
    }

    .materials-page__toolbar {
        flex-direction: column;
        align-items: stretch;
        gap: 14px;
    }

    .materials-page__search {
        flex: 0 0 auto;
        width: 100%;
    }

    .materials-page__filters {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 10px;
        width: 100%;
    }

    .materials-page__filter {
        flex: none;
        min-width: 0;
        width: 100%;
    }
}

@media (max-width: 640px) {
    .materials-page {
        padding-bottom: 24px;
    }

    .materials-page__hero {
        min-height: 180px;
        padding: 36px 16px 28px;
        background-position: center center;
        background-size: cover;
    }

    .materials-page__hero-inner {
        padding: 20px 18px 24px;
        border-radius: 16px;
        max-width: calc(100% - 16px);
    }

    .materials-page__hero h1 {
        font-size: clamp(1.65rem, 7vw, 2rem);
    }

    .materials-page__hero p {
        font-size: 0.92rem;
    }

    .materials-page__shell {
        padding: 0 12px 88px;
    }

    .materials-page__toolbar {
        margin-top: -16px;
        margin-bottom: 20px;
        padding: 12px;
        gap: 12px;
    }

    .materials-page__search input {
        min-height: 44px;
        padding: 12px 12px 12px 40px;
        font-size: 16px;
    }

    .materials-page__search i {
        left: 12px;
    }

    .materials-page__filter label {
        font-size: 0.68rem;
    }

    .materials-page__filter select {
        min-height: 44px;
        font-size: 0.9rem;
        padding: 10px 30px 10px 10px;
    }

    .materials-page__card {
        border-radius: 12px;
    }

    .materials-page__course-btn {
        flex-wrap: wrap;
        gap: 8px;
        padding: 14px 14px;
        font-size: 0.95rem;
    }

    .materials-page__course-meta {
        margin-left: 0;
        margin-right: 0;
        width: 100%;
        order: 3;
        padding-left: 50px;
    }

    .materials-page__course-body {
        padding-left: 12px;
        padding-right: 12px;
    }

    .materials-page__chapter-btn {
        flex-wrap: wrap;
        gap: 6px;
        padding: 12px 12px !important;
        font-size: 0.88rem;
    }

    .materials-page__chapter-count {
        margin-left: 0;
        margin-right: 0;
        width: 100%;
        padding-left: 0;
    }

    .materials-page__chapter-body {
        padding: 10px 10px 14px;
    }

    .materials-page__material {
        flex-direction: column;
        gap: 10px;
        padding: 12px 0;
    }

    .materials-page__mat-body {
        flex: 1 1 auto;
        width: 100%;
    }

    .materials-page__mat-actions {
        width: 100%;
        margin-left: 0;
        margin-top: 4px;
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 8px;
    }

    .materials-page__btn {
        width: 100%;
        min-height: 44px;
        flex: none;
        font-size: 0.82rem;
        padding: 10px 12px;
    }

    .materials-page__sidebar {
        gap: 12px;
    }

    .materials-page__widget {
        padding: 14px;
    }

    .materials-page__suggest {
        flex-direction: column;
        align-items: center;
        text-align: center;
    }

    .materials-page__suggest-body {
        display: flex;
        flex-direction: column;
        align-items: center;
    }

    .materials-page__support {
        margin-top: 16px;
        padding: 12px;
    }
}

@media (max-width: 380px) {
    .materials-page__filters {
        grid-template-columns: 1fr;
    }

    .materials-page__mat-actions {
        grid-template-columns: 1fr;
    }
}
