/* --- 1. ALAPOK ÉS BETŰTÍPUS --- */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;600;700&display=swap');

/* Egyedi HTML elemek regisztrálása blokkként az elrendezéshez */
analizis-nav, analizis-content, theory-section, practice-section, section-header, 
interactive-stepper, step-display, stepper-controls, step-indicator, 
completion-zone, status-badge, main-container, welcome-header, chapter-grid, 
chapter-card, layout-wrapper, analizis-sidebar, sidebar-header, sidebar-list, 
sidebar-item, sidebar-footer, progress-ring, card-info, main-content,
overall-progress, progress-track, progress-fill {
    display: block;
}

:root {
    /* Dinamikus színek - PHP-ból felülírva a chapter.php-ban */
    --main-color: #3b82f6;
    --main-color-soft: rgba(59, 130, 246, 0.1);
    
    /* Rendszerszínek - Világos mód */
    --bg-body: #f8fafc;
    --bg-card: rgba(255, 255, 255, 0.8);
    --text-main: #1e293b;
    --text-muted: #64748b;
    --border: #e2e8f0;
    --glass-border: rgba(255, 255, 255, 0.5);
    --shadow-sm: 0 2px 4px rgba(0,0,0,0.05);
    --shadow-lg: 0 20px 25px -5px rgba(0,0,0,0.1);
    --radius: 16px;
}

body.dark-mode {
    --bg-body: #0f172a;
    --bg-card: rgba(30, 41, 59, 0.7);
    --text-main: #f1f5f9;
    --text-muted: #94a3b8;
    --border: #334155;
    --glass-border: rgba(255, 255, 255, 0.05);
}

/* --- 2. GLOBÁLIS STÍLUSOK --- */
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-body);
    color: var(--text-main);
    margin: 0;
    line-height: 1.6;
    transition: background 0.4s, color 0.4s;
    overflow-x: hidden;
}

/* Mesh Gradient háttér dekoráció (Látványelem) */
body::before {
    content: "";
    position: fixed;
    top: -100px;
    right: -100px;
    width: 400px;
    height: 400px;
    background: var(--main-color);
    filter: blur(150px);
    opacity: 0.1;
    z-index: -1;
    pointer-events: none;
}

/* Egyedi görgetősáv */
::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-track { background: var(--bg-body); }
::-webkit-scrollbar-thumb { 
    background: var(--border); 
    border-radius: 10px; 
}
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* --- 3. LAYOUT SZERKEZET --- */
layout-wrapper {
    display: flex;
    min-height: 100vh;
}

main-content {
    flex-grow: 1;
    height: 100vh;
    overflow-y: auto;
    scroll-behavior: smooth;
}

/* --- 4. OLDALSÁV (SIDEBAR) --- */
analizis-sidebar {
    width: 320px;
    background: var(--bg-card);
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    border-right: 1px solid var(--glass-border);
    display: flex;
    flex-direction: column;
    height: 100vh;
    position: sticky;
    top: 0;
}

sidebar-header { padding: 2rem; border-bottom: 1px solid var(--glass-border); }
sidebar-header h3 { margin: 0; font-size: 1.2rem; }

sidebar-list {
    flex-grow: 1;
    overflow-y: auto;
    padding: 1rem;
}

sidebar-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    margin-bottom: 8px;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
}

sidebar-item:hover { background: var(--main-color-soft); transform: translateX(5px); }
sidebar-item.active { 
    background: var(--main-color); 
    color: white; 
    box-shadow: 0 10px 15px -3px var(--main-color-soft);
}

.sidebar-check {
    margin-left: auto;
    width: 20px;
    height: 20px;
    background: #10b981;
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    font-weight: bold;
}

sidebar-footer {
    padding: 1.5rem;
    border-top: 1px solid var(--glass-border);
}

.overall-progress { margin-bottom: 1rem; }
.progress-label { font-size: 0.85rem; margin-bottom: 0.5rem; display: block; }
.progress-track { height: 6px; background: var(--border); border-radius: 3px; overflow: hidden; }
.progress-fill { height: 100%; background: var(--main-color); transition: width 0.5s ease; }

/* --- 5. DASHBOARD (INDEX) --- */
chapter-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 24px;
    padding: 40px;
}

chapter-card {
    background: var(--bg-card);
    backdrop-filter: blur(10px);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius);
    padding: 24px;
    display: flex;
    align-items: center;
    gap: 20px;
    transition: all 0.3s ease;
    cursor: pointer;
    position: relative;
    overflow: hidden;
}

chapter-card:hover { transform: translateY(-8px); box-shadow: var(--shadow-lg); }

/* Kör alakú progress bar az indexen */
progress-ring { position: relative; width: 48px; height: 48px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
progress-ring svg { transform: rotate(-90deg); width: 48px; height: 48px; }
progress-ring circle { fill: none; stroke-width: 4; stroke-linecap: round; }
progress-ring circle.bg { stroke: var(--border); }
progress-ring circle.bar { 
    stroke: var(--chapter-color); 
    stroke-dasharray: 113; 
    transition: stroke-dashoffset 1s cubic-bezier(0.4, 0, 0.2, 1); 
}
.percent-text { position: absolute; font-size: 0.75rem; font-weight: 700; }

/* --- 6. FEJEZET TARTALOM ÉS LÉPTETŐ --- */
analizis-nav {
    background: linear-gradient(135deg, var(--main-color), #4f46e5);
    padding: 1.2rem 5%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: white;
}

theory-section, practice-section {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 40px;
    margin: 30px;
    border: 1px solid var(--glass-border);
}

section-header {
    font-size: 1.8rem;
    font-weight: 700;
    margin-bottom: 1.5rem;
    color: var(--main-color);
}

interactive-stepper {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 30px;
    margin-top: 20px;
}

#step-content {
    font-size: 1.1rem;
    line-height: 1.7;
    margin-bottom: 25px;
    min-height: 100px;
    color: var(--text-main);
}

/* A gombok és a számláló tartója */
stepper-controls {
    display: flex;
    flex-direction: column;
    align-items: center; /* KÖZÉPRE */
    gap: 15px;
    margin: 25px 0;
}

.nav-buttons {
    display: flex;
    justify-content: center; /* KÖZÉPRE */
    gap: 15px;
}

#stepIndicator {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-muted);
    text-align: center;      /* Biztosítjuk, hogy a szöveg is középen legyen */
}

/* A befejezés gomb zónája */
completion-zone {
    border-top: 1px solid var(--border);
    padding-top: 20px;
    width: 100%;
}

.finish-btn {
    width: 100%; /* Teljes szélesség, ahogy a képen */
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.step-progress-bar {
    height: 8px;
    background: var(--border);
    border-radius: 4px;
    margin-bottom: 25px;
    overflow: hidden;
}

.step-progress-fill {
    height: 100%;
    background: var(--main-color);
    transition: width 0.4s ease;
}

/* --- 7. GOMBOK (DINAMIKUS SZÍNŰ) --- */
button {
    padding: 12px 24px;
    border-radius: 10px;
    font-weight: 600;
    cursor: pointer;
    border: none;
    transition: all 0.3s ease;
}

.theme-btn { background: rgba(255,255,255,0.15); border: 1px solid rgba(255,255,255,0.3); color: white; }
.theme-btn:hover { background: rgba(255,255,255,0.25); }

.step-btn, .finish-btn { 
    background: var(--main-color) !important; 
    color: white !important; 
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    box-shadow: 0 4px 15px var(--main-color-soft);
}

.step-btn:hover:not(:disabled), .finish-btn:hover {
    filter: brightness(1.1);
    transform: translateY(-2px);
    box-shadow: 0 8px 20px var(--main-color-soft);
}

.step-btn:disabled { opacity: 0.4; cursor: not-allowed; box-shadow: none; }


.undo-btn { 
    background: transparent; 
    color: #ef4444; 
    text-decoration: underline; 
    width: 100%;
    margin-top: 10px;
}

/* --- 8. RESZPONZIVITÁS --- */
@media (max-width: 1024px) {
    layout-wrapper { flex-direction: column; }
    analizis-sidebar { 
        width: 100%; 
        height: auto; 
        position: relative; 
        border-right: none; 
        border-bottom: 1px solid var(--glass-border); 
    }
    sidebar-list { 
        display: flex; 
        overflow-x: auto; 
        padding: 15px; 
        gap: 12px; 
    }
    sidebar-item { min-width: 220px; margin-bottom: 0; flex-shrink: 0; }
    main-content { height: auto; }
    theory-section, practice-section { margin: 15px; padding: 25px; }
}

/* MathJax (LaTeX) konténer javítása */
theory-body, step-display {
    display: block;
    overflow-x: auto;
    max-width: 100%;
    padding: 10px 0;
}

/* Finomítás a gombok méretén a léptetőben */
.nav-buttons .step-btn {
    padding: 10px 20px; /* Kicsit kisebb, mint a fő gomb */
    font-size: 0.9rem;
    min-width: 120px;
}

/* Ha a gomb ki van kapcsolva (pl. az első lépésnél a Vissza), legyen halványabb */
.step-btn:disabled {
    background: var(--text-muted) !important;
    opacity: 0.2;
    cursor: not-allowed;
    box-shadow: none;
    transform: none !important;
}

/* Egyedi feladat-pipa stílusa */
.task-done-wrapper {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-muted);
    transition: all 0.2s ease;
    padding: 6px 12px;
    border-radius: 10px;
    background: var(--border);
}

.task-done-wrapper:hover {
    background: var(--main-color-soft);
}

.js-task-done-check {
    display: none; /* Elrejtjük az alap checkboxot */
}

.custom-checkbox {
    width: 20px;
    height: 20px;
    border: 2px solid var(--text-muted);
    border-radius: 6px;
    display: inline-block;
    position: relative;
    transition: all 0.2s ease;
}

/* Ha be van pipálva */
.js-task-done-check:checked + .custom-checkbox {
    background: #10b981; /* Zöld */
    border-color: #10b981;
}

.js-task-done-check:checked + .custom-checkbox::after {
    content: '✓';
    position: absolute;
    color: white;
    font-size: 14px;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

.js-task-done-check:checked ~ .done-text {
    color: #10b981;
}

/* A feladat konténer vizuális visszajelzése, ha kész */
.task-container.is-completed {
    opacity: 0.8;
    border-left: 4px solid #10b981;
    padding-left: 15px;
    transition: all 0.3s ease;
}

.step-item {
    margin-bottom: 25px;
    padding: 20px;
    border-left: 4px solid var(--main-color);
    background: rgba(128, 128, 128, 0.05);
    border-radius: 0 12px 12px 0;
    box-shadow: 2px 2px 10px rgba(0,0,0,0.05);
}

.step-badge {
    font-size: 0.75rem;
    letter-spacing: 1px;
    color: var(--main-color);
    font-weight: 800;
    margin-bottom: 8px;
    text-transform: uppercase;
}

.animate-fade-in {
    animation: fadeInStep 0.5s ease-out forwards;
}

@keyframes fadeInStep {
    from { opacity: 0; transform: translateX(-10px); }
    to { opacity: 1; transform: translateX(0); }
}

/* Alapértelmezett elrendezés (Asztali nézet) */
.task-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 15px;
    padding: 10px;
}

.task-title {
    flex: 1; /* A szöveg kitölti a maradék helyet */
}

.task-buttons {
    display: flex;
    gap: 8px;
    white-space: nowrap; /* Megakadályozza a gombok széttörését */
}

@media (max-width: 768px) {
    .task-header {
        flex-direction: column; /* Egymás alá rakja a szöveget és a gombokat */
        align-items: flex-start; /* Balra igazítja őket */
    }

    .task-buttons {
        width: 100%; /* A gombok sora kitölti a szélességet */
        justify-content: flex-end; /* Jobbra tolja a gombokat a szöveg alatt */
        margin-top: 10px;
        border-top: 1px solid #eee; /* Opcionális: egy vékony választóvonal */
        padding-top: 10px;
    }
}

/* --- ALAPÉRTELMEZETT (Asztali) --- */
.menu-toggle-btn {
    display: none; /* Asztalin nem kell gomb */
}

.theory-sidebar {
    /* Itt a meglévő oldalsáv stílusod marad */
    width: 250px;
    padding: 20px;
}

/* --- MOBIL NAVIGÁCIÓ JAVÍTÁSA --- */

/* 1. Alaphelyzetben a gomb rejtett asztalin */
/* --- 1. LAYOUT SZERKEZET --- */
layout-wrapper {
    display: flex; /* Asztalon egymás mellett a sáv és a tartalom */
    min-height: 100vh;
}

main-content {
    flex-grow: 1;
    height: 100vh;
    overflow-y: auto;
    padding: 40px;
    background-color: var(--bg-body);
}

/* --- 2. OLDALSÁV (SIDEBAR) - ASZTALI ALAPÉRTELMEZÉS --- */
analizis-sidebar {
    width: 320px;
    background: var(--bg-card);
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    border-right: 1px solid var(--glass-border);
    display: flex;
    flex-direction: column;
    height: 100vh;
    position: sticky;
    top: 0;
    z-index: 100;
}

#theory-menu {
    display: none;
}

/* Asztalon a mobil gomb rejtve van */
.menu-toggle-btn { 
    display: none !important; 
}

/* --- 3. MOBIL SPECIFIKUS MÓDOSÍTÁSOK (1024px alatt) --- */
@media (max-width: 1024px) {
    /* A tartalom kitölti a képernyőt */
    layout-wrapper { display: block; }
    
    /* Megjelenik a gomb a jobb felső sarokban */
    .menu-toggle-btn {
        display: flex !important;
        align-items: center;
        gap: 8px;
        position: fixed;
        top: 15px;
        right: 15px;
        z-index: 2000;
        background: var(--main-color);
        color: white;
        padding: 10px 18px;
        border-radius: 12px;
        font-weight: 700;
        box-shadow: 0 4px 15px rgba(0,0,0,0.2);
    }

    /* A sidebar mobilon "lebegő" menüvé válik a jobb oldalon */
    analizis-sidebar {
        display: none !important; /* Alapból rejtve */
        position: fixed;
        top: 70px;
        right: 15px;
        left: auto; /* Ne ragadjon balra */
        width: 280px;
        height: auto;
        max-height: 80vh;
        border-radius: 20px;
        border: 1px solid var(--border);
        box-shadow: var(--shadow-lg);
        z-index: 1900;
    }

    /* Csak gombnyomásra jelenik meg */
    analizis-sidebar.active {
        display: flex !important;
        animation: menuFade 0.3s ease-out;
    }
    
    /* Mobilon egymás alatt legyenek a tételek a kis menüben */
    sidebar-list {
        display: block !important;
        overflow-y: auto;
    }
    
    sidebar-item {
        margin-bottom: 5px;
    }
}

@keyframes menuFade {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}