/* ================================================================
   LEARNER LIBRARY — learner-library.css
   Advanced Resource Management System for BrightMe
   Glassmorphism · Dark-first · Fully responsive
   ================================================================ */

/* ── Library Section Header ─────────────────────────────────── */
.lib-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 20px;
}
.lib-subtitle {
    font-size: 0.78rem;
    color: var(--muted);
    margin-top: 4px;
    font-weight: 500;
}
.lib-back-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    background: var(--glass-2);
    border: 1px solid var(--border);
    color: var(--text);
    padding: 8px 16px;
    border-radius: 10px;
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s var(--ease);
    font-family: 'Outfit', sans-serif;
}
.lib-back-btn:hover {
    border-color: var(--accent);
    color: var(--accent);
    background: var(--accent-glow);
}

/* ── Smart Search Bar ───────────────────────────────────────── */
.lib-search-wrapper {
    position: relative;
    margin-bottom: 6px;
    background: var(--glass-2);
    border: 1.5px solid var(--border);
    border-radius: 14px;
    display: flex;
    align-items: center;
    padding: 0 14px;
    transition: border-color 0.25s var(--ease), box-shadow 0.25s var(--ease);
    backdrop-filter: blur(12px);
}
.lib-search-wrapper:focus-within {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
}
.lib-search-icon {
    font-size: 1rem;
    color: var(--muted);
    flex-shrink: 0;
    pointer-events: none;
    margin-right: 10px;
}
.lib-search-input {
    flex: 1;
    background: transparent;
    border: none;
    outline: none;
    color: var(--text);
    font-family: 'Outfit', sans-serif;
    font-size: 0.92rem;
    padding: 13px 0;
    font-weight: 500;
}
.lib-search-input::placeholder { color: var(--muted); font-weight: 400; }
.lib-search-clear {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--muted);
    font-size: 0.9rem;
    padding: 4px 6px;
    border-radius: 6px;
    transition: all 0.2s;
    flex-shrink: 0;
    font-family: 'Outfit', sans-serif;
}
.lib-search-clear:hover { color: var(--danger); background: var(--danger-bg); }

/* ── Live Suggestions Dropdown ──────────────────────────────── */
.lib-suggestions {
    position: relative;
    z-index: 500;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: 0 12px 40px rgba(0,0,0,0.4);
    overflow: hidden;
    margin-bottom: 14px;
    animation: libSugFade 0.18s var(--ease) both;
    backdrop-filter: blur(16px);
}
@keyframes libSugFade {
    from { opacity: 0; transform: translateY(-6px); }
    to   { opacity: 1; transform: translateY(0); }
}
.lib-suggestion-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 16px;
    cursor: pointer;
    border-bottom: 1px solid var(--border);
    transition: background 0.15s;
}
.lib-suggestion-item:last-child { border-bottom: none; }
.lib-suggestion-item:hover { background: var(--glass-2); }
.lib-sug-icon { font-size: 1.2rem; flex-shrink: 0; }
.lib-sug-text { flex: 1; min-width: 0; }
.lib-sug-label { font-size: 0.88rem; font-weight: 600; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lib-sug-sub   { font-size: 0.68rem; color: var(--muted); margin-top: 2px; font-weight: 500; }
.lib-highlight { background: rgba(99,102,241,0.25); color: var(--accent); border-radius: 3px; padding: 0 2px; font-style: normal; }

/* ── Type Filter Chips ──────────────────────────────────────── */
.lib-type-filter-row {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 20px;
}
.lib-type-chip {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 7px 15px;
    border-radius: 20px;
    border: 1.5px solid var(--border);
    background: var(--card-2);
    color: var(--muted);
    font-size: 0.78rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s var(--ease);
    font-family: 'Outfit', sans-serif;
    white-space: nowrap;
}
.lib-type-chip:hover {
    border-color: var(--accent);
    color: var(--accent);
    background: var(--accent-glow);
}
.lib-type-chip.active {
    background: var(--accent);
    color: white;
    border-color: var(--accent);
    box-shadow: 0 4px 14px rgba(99,102,241,0.35);
}

/* ── Recently Viewed ────────────────────────────────────────── */
.lib-section-label {
    font-size: 0.7rem;
    color: var(--muted);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    margin-bottom: 10px;
}
.lib-recently-wrap {
    margin-bottom: 24px;
}

/* ── Subject Cards Grid ─────────────────────────────────────── */
#lib-subject-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 14px;
    margin-bottom: 10px;
}

.lib-subject-card {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 18px 16px;
    background: var(--card);
    border: 1.5px solid var(--border);
    border-radius: 16px;
    cursor: pointer;
    transition: all 0.25s var(--ease);
    position: relative;
    overflow: hidden;
    backdrop-filter: blur(8px);
}
.lib-subject-card::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, var(--accent-glow) 0%, transparent 60%);
    opacity: 0;
    transition: opacity 0.25s var(--ease);
}
.lib-subject-card:hover {
    border-color: var(--accent);
    transform: translateY(-3px);
    box-shadow: 0 8px 28px rgba(99,102,241,0.2);
}
.lib-subject-card:hover::before { opacity: 1; }
.lib-subject-card:active { transform: translateY(-1px); }

.lib-subject-icon {
    font-size: 2rem;
    flex-shrink: 0;
    width: 52px;
    height: 52px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--glass-2);
    border-radius: 12px;
    border: 1px solid var(--border);
    transition: transform 0.25s var(--ease);
}
.lib-subject-card:hover .lib-subject-icon { transform: scale(1.08) rotate(-4deg); }

.lib-subject-info { flex: 1; min-width: 0; }
.lib-subject-name {
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: flex;
    align-items: center;
    gap: 6px;
}
.lib-subject-meta {
    font-size: 0.7rem;
    color: var(--muted);
    margin-top: 4px;
    font-weight: 500;
}
.lib-subject-latest {
    font-size: 0.66rem;
    color: var(--accent);
    background: var(--accent-glow);
    border: 1px solid rgba(99,102,241,0.25);
    padding: 2px 8px;
    border-radius: 20px;
    font-weight: 700;
    display: inline-block;
    margin-top: 5px;
    white-space: nowrap;
}
.lib-subject-arrow {
    font-size: 1.4rem;
    color: var(--muted);
    flex-shrink: 0;
    transition: all 0.2s var(--ease);
    font-weight: 300;
}
.lib-subject-card:hover .lib-subject-arrow {
    color: var(--accent);
    transform: translateX(4px);
}

/* NEW badge on subject card */
.lib-new-badge {
    display: inline-block;
    background: var(--danger);
    color: white;
    font-size: 0.5rem;
    font-weight: 800;
    padding: 1px 6px;
    border-radius: 20px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    vertical-align: middle;
    flex-shrink: 0;
}

/* ── Subject Card Skeletons ─────────────────────────────────── */
.lib-subject-skeletons {
    display: contents;
}
.lib-skel-card {
    height: 90px;
    border-radius: 16px;
    background: var(--sk1);
    background: linear-gradient(90deg, var(--sk1) 25%, var(--sk2) 50%, var(--sk1) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.6s infinite;
}
@keyframes shimmer {
    0%   { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* ── Sort Row (inside subject panel) ───────────────────────── */
.lib-sort-row {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 18px;
    padding: 12px 16px;
    background: var(--glass-2);
    border: 1px solid var(--border);
    border-radius: 12px;
}
.lib-sort-label {
    font-size: 0.68rem;
    color: var(--muted);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    flex-shrink: 0;
}
.lib-sort-btn {
    padding: 5px 13px;
    border-radius: 20px;
    border: 1.5px solid var(--border);
    background: transparent;
    color: var(--muted);
    font-size: 0.72rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s var(--ease);
    font-family: 'Outfit', sans-serif;
    white-space: nowrap;
}
.lib-sort-btn:hover { border-color: var(--accent); color: var(--accent); }
.lib-sort-btn.active {
    background: var(--accent);
    color: white;
    border-color: var(--accent);
    box-shadow: 0 2px 10px rgba(99,102,241,0.3);
}

/* ── Empty States ───────────────────────────────────────────── */
.lib-empty-state {
    grid-column: 1 / -1;
    text-align: center;
    padding: 60px 20px;
    color: var(--muted);
    animation: libFadeIn 0.4s var(--ease) both;
}
.lib-empty-icon { font-size: 3.5rem; opacity: 0.4; margin-bottom: 16px; }
.lib-empty-state p { font-size: 0.92rem; font-weight: 600; color: var(--text-2); }
.lib-empty-state small { font-size: 0.78rem; color: var(--dim); display: block; margin-top: 6px; }

/* ── Results Container ──────────────────────────────────────── */
#lib-results-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 16px;
}
#lib-subject-materials {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 16px;
}

/* ── Count badge on sort row ────────────────────────────────── */
.lib-count-badge {
    margin-left: auto;
    font-size: 0.68rem;
    color: var(--muted);
    background: var(--glass-2);
    padding: 3px 10px;
    border-radius: 20px;
    border: 1px solid var(--border);
    font-weight: 600;
}

/* ── Fade-in animation for panels ──────────────────────────── */
@keyframes libFadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to   { opacity: 1; transform: translateY(0); }
}
#lib-subject-panel { animation: libFadeIn 0.3s var(--ease) both; }
#lib-subject-grid  { animation: libFadeIn 0.3s var(--ease) both; }

/* ── Active subject breadcrumb title ───────────────────────── */
.lib-breadcrumb {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.78rem;
    color: var(--muted);
    margin-bottom: 16px;
    flex-wrap: wrap;
}
.lib-breadcrumb span { cursor: pointer; }
.lib-breadcrumb span:hover { color: var(--accent); text-decoration: underline; }
.lib-breadcrumb .sep { color: var(--dim); }
.lib-breadcrumb .current { color: var(--text); font-weight: 700; cursor: default; }
.lib-breadcrumb .current:hover { color: var(--text); text-decoration: none; }

/* ── Resource card enhancements (library-specific) ─────────── */
.lib-card-date {
    font-size: 0.67rem;
    color: var(--dim);
    margin-top: 2px;
}

/* ── Mobile Responsive ──────────────────────────────────────── */
@media (max-width: 640px) {
    #lib-subject-grid {
        grid-template-columns: 1fr;
    }
    #lib-results-grid,
    #lib-subject-materials {
        grid-template-columns: 1fr;
    }
    .lib-type-filter-row {
        gap: 6px;
    }
    .lib-type-chip {
        padding: 6px 11px;
        font-size: 0.72rem;
    }
    .lib-sort-row {
        gap: 6px;
        padding: 10px 12px;
    }
    .lib-sort-btn { padding: 4px 10px; font-size: 0.68rem; }
    .lib-subject-card { padding: 14px 12px; gap: 10px; }
    .lib-subject-icon { width: 44px; height: 44px; font-size: 1.6rem; border-radius: 10px; }
}

@media (min-width: 641px) and (max-width: 1024px) {
    #lib-subject-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* ── Search input keyboard focus ring ───────────────────────── */
.lib-search-input:focus { outline: none; }

/* ── Light theme overrides ──────────────────────────────────── */
[data-theme="light"] .lib-subject-card {
    background: #ffffff;
    box-shadow: 0 2px 12px rgba(0,0,0,0.06);
}
[data-theme="light"] .lib-subject-card:hover {
    box-shadow: 0 8px 28px rgba(79,70,229,0.15);
}
[data-theme="light"] .lib-suggestions {
    background: #ffffff;
    box-shadow: 0 12px 40px rgba(0,0,0,0.12);
}
[data-theme="light"] .lib-search-wrapper {
    background: #ffffff;
}
[data-theme="light"] .lib-highlight {
    background: rgba(79,70,229,0.15);
}


/* ── BRIGHTME v4 GAMIFIED DARK — LIBRARY OVERRIDES ── */
.lib-back-btn { font-family: 'Outfit', sans-serif; font-weight: 700; border-radius: var(--radius-sm); }
.lib-back-btn:hover { background: var(--accent-dim); border-color: var(--border-accent); color: var(--accent); }

.lib-search-wrapper { border-radius: var(--radius-sm); transition: border-color 0.22s, box-shadow 0.22s; }
.lib-search-wrapper:focus-within { border-color: var(--accent) !important; box-shadow: 0 0 0 3px var(--accent-glow) !important; }

.subject-folder-card { border-radius: var(--radius) !important; transition: all 0.25s !important; background: var(--card) !important; }
.subject-folder-card:hover { transform: translateY(-5px) !important; border-color: var(--border-accent) !important; box-shadow: 0 12px 30px rgba(0,0,0,0.3), 0 0 18px rgba(0,200,255,0.1) !important; }

.resource-card { border-radius: var(--radius) !important; transition: all 0.25s !important; background: var(--card) !important; }
.resource-card:hover { transform: translateY(-4px) !important; border-color: var(--border-accent) !important; box-shadow: 0 10px 28px rgba(0,0,0,0.25), 0 0 14px rgba(0,200,255,0.08) !important; }

.lib-filter-chip { font-family: 'Outfit', sans-serif !important; font-weight: 700 !important; border-radius: 20px !important; transition: all 0.2s !important; }
.lib-filter-chip.active, .lib-filter-chip:hover { background: var(--accent) !important; border-color: var(--accent) !important; color: #000 !important; font-weight: 800 !important; box-shadow: 0 4px 14px rgba(0,200,255,0.25) !important; }

.lib-view-btn.active { background: var(--accent) !important; color: #000 !important; border-color: transparent !important; font-weight: 800 !important; }

.type-notes     { background: var(--accent-dim) !important; color: var(--accent) !important; border: 1px solid var(--border-accent) !important; }
.type-video     { background: rgba(239,68,68,0.12) !important;  color: #f87171 !important; border: 1px solid rgba(239,68,68,0.3) !important; }
.type-worksheet { background: rgba(34,197,94,0.12) !important;  color: #22c55e !important; border: 1px solid rgba(34,197,94,0.3) !important; }
.type-link      { background: rgba(245,158,11,0.12) !important; color: #f59e0b !important; border: 1px solid rgba(245,158,11,0.3) !important; }

.lib-sort-select { font-family: 'Outfit', sans-serif !important; border-radius: var(--radius-sm) !important; }
.lib-sort-select:focus { border-color: var(--accent) !important; box-shadow: 0 0 0 3px var(--accent-glow) !important; }
