/* =====================================================================
   Subjects Section: Filter Pills + Progressive Disclosure
   ---------------------------------------------------------------------
   - Sticky horizontale Filter-Leiste mit Active-State (Standard / Fokus)
   - Fach-Karten mit farbigem Accent-Strich + Status-Ampel-Badge
   - Expandierbare Detail-Region via max-height-Transition
   - Empty-State, Layout-stabil
   ===================================================================== */

.subjects-section {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    transition: opacity 0.3s ease, transform 0.3s ease;
}
.subjects-section[data-ui-mode="smart"] .subjects-filter-wrap { display: block; }
.subjects-section:not([data-ui-mode="smart"]) .subjects-filter-wrap { display: none; }

.subjects-filter-wrap {
    position: relative; /* In der Card kein sticky mehr nötig */
    z-index: 1;
    /* Linksbündig: nur rechts Platz reservieren, falls der Pfeil eingeblendet ist */
    margin: 0 0 0.5rem 0;
    padding: 0; /* Pills starten am linken Rand */
    background: transparent;
}
/* Wenn Overflow: links + rechts Platz für die Pfeile reservieren */
.subjects-filter-wrap.has-overflow {
    padding-left: 36px;
    padding-right: 36px;
}

/* Pfeil-Buttons: links + rechts, dunkel wenn aktiv, hell wenn nicht scrollbar
   (analog zu .sa-pills-arrow in der Analytics-View) */
.subjects-filter-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    z-index: 3;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    border: 1px solid var(--c-border, #e5e7eb);
    background: var(--c-card, #fff);
    color: rgba(0, 0, 0, 0.18); /* heller Default = "kann hier nicht scrollen" */
    display: none; /* erst sichtbar wenn .has-overflow gesetzt */
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 0.85rem;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.06);
    transition:
        color 0.15s ease,
        background 0.15s ease,
        transform 0.15s ease,
        box-shadow 0.15s ease,
        border-color 0.15s ease;
    padding: 0;
}
.subjects-filter-wrap.has-overflow .subjects-filter-nav { display: inline-flex; }
.subjects-filter-nav--prev { left: 0.25rem; }
.subjects-filter-nav--next { right: 0.25rem; }
.subjects-filter-nav.is-active {
    color: rgba(0, 0, 0, 0.6);
    border-color: rgba(0, 0, 0, 0.18);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.10);
}
.subjects-filter-nav:hover.is-active {
    color: var(--c-text-dark, #111);
    border-color: var(--c-text-dark, #111);
    transform: translateY(-50%) scale(1.05);
}
.subjects-filter-nav:disabled { cursor: default; }
.subjects-filter-nav:focus { outline: none; }
.subjects-filter-nav:focus-visible {
    outline: 2px solid var(--c-primary, #7B4BDE);
    outline-offset: 2px;
}

/* Soft fade-edges, damit Pillen nicht "hart" unter die Pfeile laufen */
.subjects-filter-wrap.has-overflow::before,
.subjects-filter-wrap.has-overflow::after {
    content: "";
    position: absolute;
    top: 0;
    bottom: 0;
    width: 24px;
    pointer-events: none;
    z-index: 2;
    opacity: 0.85;
    transition: opacity 0.2s ease;
}
.subjects-filter-wrap.has-overflow::before {
    left: 30px;
    background: linear-gradient(
        to right,
        var(--c-bg-main, #edece7) 0%,
        transparent 100%
    );
}
.subjects-filter-wrap.has-overflow::after {
    right: 30px;
    background: linear-gradient(
        to left,
        var(--c-bg-main, #edece7) 0%,
        transparent 100%
    );
}

/* Dark Mode für Pfeile + Fade-Edges */
[data-theme="dark"] .subjects-filter-nav {
    background: var(--c-card, #1f2937);
    border-color: rgba(255, 255, 255, 0.12);
    color: rgba(255, 255, 255, 0.25);
}
[data-theme="dark"] .subjects-filter-nav.is-active {
    color: rgba(255, 255, 255, 0.7);
    border-color: rgba(255, 255, 255, 0.3);
}
[data-theme="dark"] .subjects-filter-nav:hover.is-active {
    color: #fff;
    border-color: #fff;
}
[data-theme="dark"] .subjects-filter-wrap.has-overflow::before {
    background: linear-gradient(
        to right,
        var(--c-bg-main, #0f172a) 0%,
        transparent 100%
    );
}
[data-theme="dark"] .subjects-filter-wrap.has-overflow::after {
    background: linear-gradient(
        to left,
        var(--c-bg-main, #0f172a) 0%,
        transparent 100%
    );
}

.subjects-filter,
.subjects-pills {
    display: flex;
    flex-direction: row;
    gap: 0.5rem;
    overflow-x: auto;
    overflow-y: hidden;
    scroll-snap-type: x proximity;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding: 0.25rem 0.125rem;
    flex-wrap: nowrap;
    white-space: nowrap;
}
.subjects-filter::-webkit-scrollbar,
.subjects-pills::-webkit-scrollbar { display: none; }

/* Phase A Pills: Container darf nicht sticky sein, soll inline laufen */
.subjects-pills {
    margin: 0.25rem 0 0.75rem 0;
    padding: 0.25rem 0;
}

.subjects-filter-pill,
.subjects-pill {
    flex: 0 0 auto;
    scroll-snap-align: start;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.45rem 0.85rem;
    border-radius: 999px;
    border: 1px solid #E5E7EB;
    background: #FFFFFF;
    color: #374151;
    font-size: 0.8125rem;
    font-weight: 500;
    line-height: 1;
    cursor: pointer;
    user-select: none;
    transition:
        background 0.2s ease,
        color 0.2s ease,
        border-color 0.2s ease,
        box-shadow 0.2s ease,
        transform 0.15s ease;
    white-space: nowrap;
    font-family: var(--font-family);
}
.subjects-filter-pill i,
.subjects-pill i { font-size: 0.8125rem; opacity: 0.8; }
.subjects-filter-pill .subjects-filter-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 1.25rem;
    height: 1.25rem;
    padding: 0 0.4rem;
    border-radius: 999px;
    background: #F3F4F6;
    color: #6B7280;
    font-size: 0.7rem;
    font-weight: 600;
    transition: background 0.2s ease, color 0.2s ease;
}
.subjects-filter-pill:hover,
.subjects-pill:hover {
    border-color: #D1D5DB;
    background: #F9FAFB;
}
.subjects-filter-pill:active,
.subjects-pill:active { transform: scale(0.97); }

/* Pill-Dot (für "Alle"-Pille) */
.subjects-pill .pill-dot {
    display: inline-block;
    width: 0.5rem;
    height: 0.5rem;
    border-radius: 50%;
    background: currentColor;
    opacity: 0.6;
    flex-shrink: 0;
}

/* Active State (Standard – Theme-Farbe) */
.subjects-filter-pill.is-active,
.subjects-pill.is-active {
    background: var(--c-primary, #7B4BDE);
    color: #FFFFFF;
    border-color: var(--c-primary, #7B4BDE);
    box-shadow: 0 4px 12px -2px rgba(123, 75, 222, 0.35);
}
.subjects-filter-pill.is-active i,
.subjects-pill.is-active i { opacity: 1; }
.subjects-filter-pill.is-active .subjects-filter-count {
    background: rgba(255, 255, 255, 0.25);
    color: #FFFFFF;
}
.subjects-pill.is-active .pill-dot {
    background: #FFFFFF;
    opacity: 1;
}

/* Active State (Fokus – visueller Bruch / Kritischer Modus) */
.subjects-filter-pill.is-focus.is-active,
.subjects-pill[data-pill-filter="focus"].is-active {
    background: #111827;
    color: #FFFFFF;
    border-color: #111827;
    box-shadow: 0 4px 14px -2px rgba(17, 24, 39, 0.5);
}
.subjects-filter-pill.is-focus.is-active .subjects-filter-count {
    background: rgba(255, 255, 255, 0.2);
    color: #FFFFFF;
}
.subjects-filter-pill.is-focus.is-active i,
.subjects-pill[data-pill-filter="focus"].is-active i { color: #FCA5A5; }

/* Empty-State der Pill-Filterung (Phase A) */
.subjects-pill-empty {
    margin: 0.5rem 0;
    padding: 1rem;
    text-align: center;
    color: #6B7280;
    font-size: 0.875rem;
    font-style: italic;
    background: #FFFFFF;
    border: 1px dashed #E5E7EB;
    border-radius: var(--border-radius, 8px);
}

/* Subjects-Container: smooth Animation bei Filterwechsel */
#subjects-container {
    display: flex;
    flex-direction: column;
    gap: 0.625rem;
    transition: opacity 0.3s ease;
}

.subjects-filter-empty {
    margin: 0;
    padding: 1.25rem 1rem;
    text-align: center;
    color: #6B7280;
    font-size: 0.875rem;
    font-style: italic;
    background: #FFFFFF;
    border: 1px dashed #E5E7EB;
    border-radius: var(--border-radius);
}

/* Fach-Karte: Accent-Strich (breit, in Fachfarbe) + Hover
   border-left-color wird inline pro Karte gesetzt – das ist die Fachfarbe,
   nicht die Kindfarbe. */
.subject-card-compact {
    border-left-width: 6px;
    border-left-style: solid;
    transition:
        transform 0.2s ease,
        box-shadow 0.2s ease,
        background-color 0.2s ease;
}
.subject-card-compact[hidden] { display: none !important; }
.subject-card-compact.clickable:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px -3px rgba(0, 0, 0, 0.1);
}

/* Trend-Icon im Fach-Namen */
.subject-trend-icon {
    margin-left: 0.4rem;
    font-size: 0.75rem;
    vertical-align: middle;
}
.subject-trend-icon.up { color: #22C55E; }
.subject-trend-icon.down { color: #EF4444; }

/* Status-Ampel-Badge (Note) – überschreibt Fachfarbe */
.subject-grade-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 2.75rem;
    padding: 0.25rem 0.6rem;
    border-radius: 0.5rem;
    font-size: 1.125rem;
    font-weight: 700;
    line-height: 1.2;
    transition: background-color 0.2s ease, color 0.2s ease;
}
.subject-grade-badge.subject-grade-excellent { background: rgba(16, 185, 129, 0.12); color: #047857; }
.subject-grade-badge.subject-grade-good      { background: rgba(132, 204, 22, 0.14); color: #4D7C0F; }
.subject-grade-badge.subject-grade-ok        { background: rgba(245, 158, 11, 0.14); color: #B45309; }
.subject-grade-badge.subject-grade-warn      { background: rgba(249, 115, 22, 0.16); color: #C2410C; }
.subject-grade-badge.subject-grade-critical  { background: rgba(244, 63, 94, 0.16);  color: #BE123C; }
.subject-grade-badge.subject-grade-none      { background: #F3F4F6; color: #9CA3AF; }

/* Expand-Toggle Button */
.subject-expand-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2rem;
    height: 2rem;
    margin-left: 0.5rem;
    padding: 0;
    border-radius: 999px;
    border: none;
    background: transparent;
    color: #6B7280;
    cursor: pointer;
    transition:
        background-color 0.2s ease,
        color 0.2s ease,
        transform 0.3s ease;
}
.subject-expand-toggle:hover {
    background: rgba(0, 0, 0, 0.04);
    color: #111827;
}
.subject-expand-toggle i {
    font-size: 0.875rem;
    transition: transform 0.3s ease;
}
/* Chevron-Rotation: zugeklappt = nach rechts (▶), aufgeklappt = nach unten (▼).
   Da das Icon `fa-chevron-right` standardmäßig nach rechts zeigt, reicht eine
   Drehung um 90° im Uhrzeigersinn, damit die Spitze nach unten zeigt.
   (Die frühere 180°-Regel stammte aus der Zeit, als das Icon `fa-chevron-down`
   war — würde jetzt den Pfeil nach links zeigen lassen.) */
.subject-card-compact.is-expanded .subject-expand-toggle i {
    transform: rotate(90deg);
}

/* Expand-Region (Progressive Disclosure) */
.subject-card-expand {
    overflow: hidden;
    max-height: 0;
    opacity: 0;
    transition:
        max-height 0.3s ease,
        opacity 0.25s ease,
        padding 0.3s ease,
        margin 0.3s ease;
    padding: 0;
    margin-top: 0;
    border-top: 1px solid transparent;
}
.subject-card-compact.is-expanded .subject-card-expand {
    max-height: 40rem;
    opacity: 1;
    padding: 0.75rem 0 0.25rem 0;
    margin-top: 0.75rem;
    border-top-color: rgba(0, 0, 0, 0.08);
}

.subject-expand-stats {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem 1rem;
    font-size: 0.8125rem;
    color: #6B7280;
    margin-bottom: 0.5rem;
}
.subject-expand-stats i {
    margin-right: 0.35rem;
    color: #9CA3AF;
}

.subject-recent-heading {
    margin: 0.5rem 0 0.35rem 0;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: #6B7280;
}
.subject-recent-exam {
    display: grid;
    grid-template-columns: 1fr auto auto;
    gap: 0.5rem;
    align-items: baseline;
    padding: 0.3rem 0;
    border-bottom: 1px dashed rgba(0, 0, 0, 0.06);
    font-size: 0.85rem;
}
.subject-recent-exam:last-child { border-bottom: none; }
.subject-recent-exam-type { color: #374151; font-weight: 500; }
.subject-recent-exam-date { color: #9CA3AF; font-size: 0.75rem; }
.subject-recent-exam-grade { font-weight: 700; }
.subject-recent-empty {
    margin: 0.25rem 0 0.5rem 0;
    color: #9CA3AF;
    font-style: italic;
    font-size: 0.85rem;
}

.subject-expand-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
    margin-top: 0.75rem;
    padding-top: 0.5rem;
    border-top: 1px dashed rgba(0, 0, 0, 0.06);
}
.subject-expand-actions .btn-compact {
    padding: 0.4rem 0.75rem;
    font-size: 0.8125rem;
    border-radius: 0.5rem;
}

/* Spacer schiebt Icon-Buttons nach rechts */
.subject-expand-actions-spacer {
    flex: 1 1 auto;
    min-width: 0;
}

/* Icon-Action-Buttons (Edit, List, Delete) in der Action-Leiste */
.subject-expand-icon-action {
    flex: 0 0 auto;
    width: 2rem;
    height: 2rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 0.5rem;
    border: 1px solid transparent;
    background: rgba(0, 0, 0, 0.04);
    color: #4B5563;
    cursor: pointer;
    transition:
        background-color 0.18s ease,
        color 0.18s ease,
        border-color 0.18s ease,
        transform 0.12s ease;
    padding: 0;
}
.subject-expand-icon-action i {
    font-size: 0.875rem;
}
.subject-expand-icon-action:hover {
    background: rgba(0, 0, 0, 0.08);
    color: #111827;
}
.subject-expand-icon-action:active {
    transform: scale(0.94);
}
/* Delete-Button: bereits im Normalzustand rot eingefärbt */
.subject-expand-icon-action--danger,
.subject-expand-icon-action.delete-subject {
    background: rgba(244, 63, 94, 0.10);
    color: #BE123C;
}
.subject-expand-icon-action--danger:hover,
.subject-expand-icon-action.delete-subject:hover {
    background: rgba(244, 63, 94, 0.18);
    color: #9F1239;
    border-color: rgba(244, 63, 94, 0.3);
}

/* Mobile-friendly: Auf schmalen Screens Icon-Buttons in eigene Zeile umbrechen */
@media (max-width: 380px) {
    .subject-expand-actions-spacer {
        flex-basis: 100%;
        height: 0;
    }
}
