/* ==============================================================================
 * Mentifyll: Töltsd fel az elméd! — Komponens stílusok
 * (markdown tartalom, képgaléria, lightbox, válaszlehetőségek, görgetősávok,
 *  űrlap- és sötét téma védőháló, felhasználókártyák)
 * Készítők: Kormos Attila és a Google Gemini valamint Claude Opus
 * ============================================================================== */

/* ---------- Témázott görgetősávok ---------- */
* {
    scrollbar-width: thin;
    scrollbar-color: var(--scrollbar-thumb) transparent;
}

*::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

*::-webkit-scrollbar-track {
    background: transparent;
}

*::-webkit-scrollbar-thumb {
    background: var(--scrollbar-thumb);
    border-radius: 999px;
    border: 2px solid transparent;
    background-clip: content-box;
}

*::-webkit-scrollbar-thumb:hover {
    background: var(--scrollbar-thumb-hover);
    background-clip: content-box;
}

/* Fül- és szűrősávok: vízszintesen görgethetők, de nem mutatnak görgetősávot */
.hide-scrollbar,
.unit-nav-tabs,
.filter-scroll {
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.hide-scrollbar::-webkit-scrollbar,
.unit-nav-tabs::-webkit-scrollbar,
.filter-scroll::-webkit-scrollbar {
    display: none;
}

.unit-nav-tabs {
    scroll-snap-type: x proximity;
    -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 28px), transparent);
    mask-image: linear-gradient(to right, #000 calc(100% - 28px), transparent);
}

.unit-nav-tabs .unit-tab-btn {
    scroll-snap-align: start;
    flex: 0 0 auto;
}

@media (min-width: 900px) {
    .unit-nav-tabs {
        -webkit-mask-image: none;
        mask-image: none;
    }
}

/* ---------- Űrlap-védőháló: minden beviteli mező olvasható mindkét témában ---------- */
:where(input:not([type]), input[type="text"], input[type="number"], input[type="password"], input[type="email"],
       input[type="search"], input[type="date"], input[type="time"], input[type="url"], select, textarea) {
    background-color: var(--input-bg);
    color: var(--input-text);
    border: 1px solid var(--input-border);
    font-family: inherit;
}

.form-input {
    background: var(--input-bg);
    color: var(--input-text);
    border-color: var(--input-border);
}

.form-input::placeholder,
:where(input, textarea)::placeholder {
    color: var(--color-text-muted);
    opacity: 0.8;
}

select.form-input option,
select option {
    background: var(--color-surface);
    color: var(--color-text-main);
}

.field-error {
    color: var(--danger-fg);
    font-size: 0.78rem;
    margin-top: 4px;
    font-weight: 600;
}

.form-input.has-error {
    border-color: var(--danger-border);
    box-shadow: 0 0 0 3px var(--danger-bg);
}

.form-label {
    display: block;
    font-size: 0.82rem;
    font-weight: 700;
    margin-bottom: 4px;
    color: var(--color-heading);
}

/* ---------- Válaszlehetőségek (kvízkérdések) ---------- */
.answer-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin: 12px 0;
}

.answer-option {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    padding: 9px 12px;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    line-height: 1.45;
    background: var(--option-bg);
    border: 1px solid var(--option-border);
    color: var(--option-text);
}

.answer-option .answer-mark {
    flex: 0 0 auto;
    font-weight: 800;
    opacity: 0.8;
}

.answer-option.is-correct {
    background: var(--success-bg);
    border-color: var(--success-border);
    color: var(--success-fg);
    font-weight: 600;
}

.answer-option.is-correct .answer-mark {
    opacity: 1;
}

.prep-empty-row {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    gap: 6px 10px;
    margin-top: 6px;
    padding: 8px 10px;
    background: var(--color-surface-variant);
    border-radius: var(--radius-sm);
    font-size: 0.8rem;
    color: var(--color-text-muted);
}

.prep-empty-row > span {
    flex: 1 1 160px;
    min-width: 0;
}

.grade-filter-btn {
    white-space: nowrap;
    flex: 0 0 auto;
}

.explain-note {
    display: flex;
    gap: 8px;
    font-size: 0.85rem;
    color: var(--color-text-muted);
    background: var(--color-neutral-subtle);
    border: 1px solid var(--color-border);
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    margin: 10px 0;
    line-height: 1.5;
}

/* ---------- Markdown tartalom ---------- */
.md-inline strong,
.md-body strong {
    color: var(--color-card-title);
    font-weight: 700;
}

.md-inline code,
.md-body code {
    background: var(--color-neutral-subtle);
    border: 1px solid var(--color-border);
    border-radius: 6px;
    padding: 1px 6px;
    font-size: 0.9em;
    font-family: 'Cascadia Code', Consolas, 'Courier New', monospace;
    color: var(--color-primary-light);
}

.theme-light .md-inline code,
.theme-light .md-body code {
    color: var(--color-primary-dark);
}

.md-body {
    line-height: 1.7;
    color: var(--color-text-main);
    overflow-wrap: anywhere;
}

.md-body > * + * {
    margin-top: 0.7em;
}

.md-body h2,
.md-body h3,
.md-body h4,
.md-body h5 {
    color: var(--color-card-title);
    margin-top: 1.3em;
    margin-bottom: 0.2em;
    line-height: 1.3;
}

.md-body h2 { font-size: 1.3rem; font-weight: 800; }
.md-body h3 { font-size: 1.15rem; font-weight: 800; }
.md-body h4 { font-size: 1.02rem; font-weight: 700; }
.md-body h5 { font-size: 0.95rem; font-weight: 700; }

.md-body p {
    color: var(--color-text-main);
}

.md-body ul,
.md-body ol {
    padding-left: 1.4em;
}

.md-body ul { list-style: disc; }
.md-body ol { list-style: decimal; }
.md-body li { padding: 1px 0; }
.md-body li::marker { color: var(--color-primary); }
.md-body ul ul { list-style: circle; }

.md-body a {
    color: var(--color-primary);
    text-decoration: underline;
}

.md-body hr {
    border: 0;
    border-top: 1px dashed var(--color-border);
    margin: 1.2em 0;
}

.md-body blockquote {
    border-left: 4px solid var(--color-primary);
    background: var(--color-neutral-subtle);
    padding: 8px 14px;
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    color: var(--color-card-text);
}

.md-table-wrap {
    overflow-x: auto;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
}

.md-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

.md-table th,
.md-table td {
    padding: 8px 10px;
    border-bottom: 1px solid var(--color-border);
    text-align: left;
}

.md-table th {
    background: var(--color-surface-variant);
    color: var(--color-heading);
}

.md-figure {
    margin: 16px auto;
    max-width: 640px;
    text-align: center;
    background: var(--color-neutral-subtle);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    padding: 10px;
}

.md-figure img {
    max-width: 100%;
    max-height: 420px;
    border-radius: var(--radius-sm);
    cursor: zoom-in;
    background: #ffffff;
}

.md-figure figcaption {
    margin-top: 8px;
    font-size: 0.82rem;
    color: var(--color-text-muted);
    font-weight: 600;
}

img[data-zoom] {
    cursor: zoom-in;
}

.img-broken {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 14px;
    border: 1px dashed var(--color-border);
    border-radius: var(--radius-sm);
    color: var(--color-text-muted);
    background: var(--color-neutral-subtle);
    font-size: 0.82rem;
}

/* ---------- Képgaléria (forrásoldalak, kivágott ábrák, további tankönyvi ábrák) ---------- */
.media-section {
    margin-top: 14px;
}

.media-section > summary,
.media-section-title {
    cursor: pointer;
    font-size: 0.82rem;
    font-weight: 800;
    letter-spacing: 0.4px;
    text-transform: uppercase;
    color: var(--color-text-muted);
    margin-bottom: 8px;
}

.media-gallery {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 12px;
}

.media-thumb {
    margin: 0;
    border: 1px solid var(--color-border);
    background: var(--color-neutral-subtle);
    border-radius: var(--radius-md);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.media-thumb img {
    width: 100%;
    aspect-ratio: 4 / 3;
    object-fit: contain;
    background: #ffffff;
    cursor: zoom-in;
    display: block;
    min-height: 90px;
}

.media-thumb figcaption {
    padding: 6px 8px;
    font-size: 0.75rem;
    color: var(--color-text-muted);
    line-height: 1.35;
}

.media-file-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 12px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    background: var(--color-surface-variant);
    color: var(--color-text-main);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
}

/* ---------- Lightbox ---------- */
.lightbox {
    position: fixed;
    inset: 0;
    z-index: 5000;
    background: rgba(2, 6, 23, 0.94);
    display: none;
    align-items: center;
    justify-content: center;
    padding: 56px 16px 64px;
}

.lightbox.open {
    display: flex;
}

body.lightbox-open {
    overflow: hidden;
}

.lightbox-img {
    max-width: min(96vw, 1500px);
    max-height: calc(100vh - 130px);
    object-fit: contain;
    border-radius: 8px;
    background: #ffffff;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6);
}

.lightbox-caption {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 16px;
    text-align: center;
    color: #e2e8f0;
    font-size: 0.9rem;
    padding: 0 64px;
}

.lightbox-btn {
    position: absolute;
    border: 0;
    background: rgba(255, 255, 255, 0.14);
    color: #ffffff;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    font-size: 1.6rem;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.lightbox-btn:hover {
    background: rgba(255, 255, 255, 0.28);
}

.lightbox-close { top: 12px; right: 12px; font-size: 1.2rem; }
.lightbox-prev { left: 12px; top: 50%; transform: translateY(-50%); }
.lightbox-next { right: 12px; top: 50%; transform: translateY(-50%); }

/* ---------- Sötét téma védőháló: a hardkódolt világos inline hátterek is olvashatók ---------- */
body.theme-dark [style*="background:#f8fafc"],
body.theme-dark [style*="background: #f8fafc"],
body.theme-dark [style*="background:#f1f5f9"],
body.theme-dark [style*="background: #f1f5f9"],
body.theme-dark [style*="background:#fff;"],
body.theme-dark [style*="background: #fff;"],
body.theme-dark [style*="background:#ffffff"],
body.theme-dark [style*="background-color:#fff"] {
    background: var(--color-surface-variant) !important;
    color: var(--color-text-main) !important;
    border-color: var(--color-border) !important;
}

body.theme-dark [style*="border:1px solid #e2e8f0"],
body.theme-dark [style*="border:1px solid #cbd5e1"] {
    border-color: var(--color-border) !important;
}

body.theme-dark [style*="background:#e2e8f0"] {
    background: var(--color-border) !important;
}

/* ---------- Felhasználókezelés ---------- */
.user-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    padding: 14px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
}

.user-card.is-inactive {
    border-color: var(--danger-border);
    opacity: 0.85;
}

.user-card-main {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 220px;
    flex: 1 1 260px;
}

.user-avatar-badge {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: var(--color-surface-variant);
    border: 1px solid var(--color-border);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
    flex-shrink: 0;
}

.user-card-name {
    font-weight: 700;
    color: var(--color-heading);
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px;
}

.user-card-meta {
    font-size: 0.8rem;
    color: var(--color-text-muted);
    margin-top: 3px;
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
}

.user-card-actions {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
}

.btn-sm {
    width: auto;
    min-height: 36px;
    padding: 0 14px;
    font-size: 0.82rem;
}

.status-pill {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 0.72rem;
    font-weight: 700;
}

.status-pill.is-active { background: var(--success-bg); color: var(--success-fg); }
.status-pill.is-inactive { background: var(--danger-bg); color: var(--danger-fg); }

.role-chip {
    font-weight: 700;
    font-size: 0.78rem;
}

/* ---------- Szemantikus jelvények ---------- */
.badge-success { background: var(--success-bg); color: var(--success-fg); }
.badge-warning { background: var(--warning-bg); color: var(--warning-fg); }
.badge-danger { background: var(--danger-bg); color: var(--danger-fg); }
.badge-info { background: var(--info-bg); color: var(--info-fg); }

/* ---------- Tananyag megjelenítő ---------- */
.material-content-viewer {
    max-height: min(62vh, 560px);
}

.material-content-viewer.is-expanded {
    max-height: none;
}

.modal-backdrop > .card:hover {
    transform: none;
}

/* ---------- Üres állapot ---------- */
.empty-state {
    text-align: center;
    padding: 32px 16px;
    border: 1px dashed var(--color-border);
    border-radius: var(--radius-md);
    background: var(--color-neutral-subtle);
}

.empty-state .empty-icon {
    font-size: 2.4rem;
    margin-bottom: 8px;
}
