/* ===========================================
   Simulador de Análise Combinatória
   Theme: Lúdico / Educacional Ciente (Baseado no PDF)
   =========================================== */

:root {
    /* Cores Lúdicas Claras */
    --bg-page: #f4f6f8;
    --bg-panel: #ffffff;
    --border-color: #e2e8f0;
    
    --text-main: #334155;
    --text-muted: #64748b;
    --text-strong: #0f172a;
    
    --brand-dark: #1e293b;
    --brand-teal: #00b4d8;
    --brand-teal-light: #caf0f8;
    --brand-teal-hover: #0096c7;
    
    --bus-floor: #e2e8f0;
    --bus-exterior: #0f172a;
    --seat-bg: #14b8a6; /* Verde-água/teel claro */
    --seat-border: #0d9488;
    --seat-highlight: #fde047; /* Amarelo destaque da cadeira do PDF */
    
    /* Passenger Colors (Bright pop colors) */
    --p1: #ef4444; /* Vermelho */
    --p2: #3b82f6; /* Azul */
    --p3: #eab308; /* Amarelo Escuro */
    --p4: #8b5cf6; /* Roxo */

    --font-heading: 'Fredoka', 'Inter', sans-serif;
    --font-ui: 'Nunito', 'Inter', sans-serif;
    --font-mono: 'JetBrains Mono', 'Fira Code', monospace;
    
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.1), 0 2px 4px -1px rgba(0,0,0,0.06);
    --shadow-pop: 0 10px 15px -3px rgba(0,0,0,0.1);
    
    --radius-round: 50%;
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 20px;
    --radius-xl: 32px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: var(--font-ui);
    background-color: var(--bg-page);
    color: var(--text-main);
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden; /* App-like feel */
}

/* NAVBAR */
.sim-navbar {
    height: 60px;
    background: var(--brand-dark);
    color: #fff;
    flex-shrink: 0;
}

.sim-nav-container {
    height: 100%;
    max-width: 1600px;
    margin: 0 auto;
    padding: 0 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.sim-nav-brand {
    display: flex;
    align-items: center;
    gap: 8px;
    color: #cbd5e1;
    text-decoration: none;
    font-weight: 600;
    font-size: 0.95rem;
    transition: color 0.2s;
}

.sim-nav-brand:hover {
    color: #fff;
}

.sim-nav-title {
    font-family: var(--font-heading);
    color: var(--brand-teal);
    font-weight: 500;
    font-size: 1.1rem;
    letter-spacing: 0.5px;
}

/* APP LAYOUT */
.app-layout {
    display: flex;
    flex: 1;
    overflow: hidden;
    max-width: 1600px;
    margin: 0 auto;
    width: 100%;
    position: relative;
}

/* SIDEBARS */
.sidebar, .results-sidebar {
    width: 320px;
    background: var(--bg-panel);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    flex-shrink: 0;
    z-index: 10;
}

.results-sidebar {
    border-right: none;
    border-left: 1px solid var(--border-color);
    background: #fafafa;
}

/* SIDEBAR HEADER */
.sidebar-header, .results-header {
    padding: 24px;
    border-bottom: 1px solid var(--border-color);
    background: var(--brand-teal-light);
}
.sidebar-header h2 {
    font-family: var(--font-heading);
    font-size: 1.25rem;
    color: var(--text-strong);
    margin-bottom: 4px;
}
.sidebar-header p {
    font-size: 0.85rem;
    color: var(--text-muted);
}
.results-header {
    background: #f1f5f9;
}
.results-header h2 {
    font-family: var(--font-heading);
    font-size: 1.25rem;
    color: var(--text-strong);
}

/* CONTROLS */
.control-group {
    padding: 20px 24px;
    border-bottom: 1px solid var(--border-color);
}
.control-group label {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: 700;
    color: var(--text-strong);
    margin-bottom: 12px;
}
.badge {
    background: var(--brand-dark);
    color: white;
    font-family: var(--font-mono);
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 0.75rem;
}

.stepper {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--bg-page);
    border-radius: var(--radius-md);
    padding: 6px;
    border: 1px solid var(--border-color);
}
.btn-icon {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-sm);
    border: none;
    background: white;
    box-shadow: var(--shadow-sm);
    color: var(--text-main);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
}
.btn-icon:hover {
    background: var(--brand-teal);
    color: white;
}
.btn-icon svg {
    width: 20px;
    height: 20px;
}
.stepper-value {
    font-family: var(--font-heading);
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--brand-teal-hover);
    min-width: 40px;
    text-align: center;
}

/* SPEED CONTROLS */
.speed-control {
    padding: 20px 24px;
    border-bottom: 1px solid var(--border-color);
}
.speed-control label {
    display: block;
    font-weight: 700;
    margin-bottom: 12px;
}
.speed-btns {
    display: flex;
    gap: 8px;
    background: var(--bg-page);
    padding: 4px;
    border-radius: var(--radius-sm);
}
.speed-btn {
    flex: 1;
    padding: 8px 0;
    border: none;
    border-radius: var(--radius-sm);
    background: transparent;
    font-family: var(--font-ui);
    font-weight: 600;
    font-size: 0.85rem;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.2s;
}
.speed-btn:hover {
    color: var(--text-strong);
}
.speed-btn.active {
    background: white;
    color: var(--brand-teal-hover);
    box-shadow: var(--shadow-sm);
}

/* WAITING AREA */
.waiting-area {
    padding: 24px;
    border-bottom: 1px solid var(--border-color);
}
.waiting-area h3 {
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    font-weight: 800;
    margin-bottom: 12px;
}
.passengers-list {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

/* AVATARS */
.passenger {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.passenger.seated {
    transform: scale(0) rotate(-10deg);
    opacity: 0;
}
.avatar {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-round);
    background: #fff;
    box-shadow: var(--shadow-md);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    position: relative;
    border: 2px solid;
}
.avatar-svg {
    width: 80%;
    height: 80%;
}
.p-label {
    font-family: var(--font-mono);
    font-weight: 700;
    font-size: 0.7rem;
    padding: 2px 8px;
    border-radius: 10px;
    color: white;
}

/* Color specific avatars */
.passenger-1 .avatar { border-color: var(--p1); }
.passenger-1 .p-label { background: var(--p1); }
.passenger-1 .avatar-svg .skin { fill: #fca5a5; }
.passenger-1 .avatar-svg .hair { fill: #450a0a; }

.passenger-2 .avatar { border-color: var(--p2); }
.passenger-2 .p-label { background: var(--p2); }
.passenger-2 .avatar-svg .skin { fill: #fed7aa; }
.passenger-2 .avatar-svg .hair { fill: #d97706; }

.passenger-3 .avatar { border-color: var(--p3); }
.passenger-3 .p-label { background: var(--p3); }
.passenger-3 .avatar-svg .skin { fill: #d1d5db; } /* Elderly */
.passenger-3 .avatar-svg .hair { fill: #e5e7eb; }

.passenger-4 .avatar { border-color: var(--p4); }
.passenger-4 .p-label { background: var(--p4); }
.passenger-4 .avatar-svg .skin { fill: #a78bfa; } /* Alien/Fantasy */
.passenger-4 .avatar-svg .hair { fill: #4c1d95; }


/* THEORY ACCORDION */
.theory-accordion {
    margin: 24px;
    background: var(--bg-page);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    overflow: hidden;
}
.theory-accordion summary {
    padding: 16px;
    font-weight: 700;
    color: var(--text-strong);
    display: flex;
    align-items: center;
    cursor: pointer;
    list-style: none; /* Hide default arrow */
    user-select: none;
    background: white;
}
.theory-accordion summary::-webkit-details-marker {
    display: none;
}
.theory-accordion .book-icon {
    width: 20px;
    height: 20px;
    color: var(--brand-teal);
    margin-right: 12px;
}
.theory-accordion .chevron {
    width: 16px;
    height: 16px;
    margin-left: auto;
    transition: transform 0.3s;
    color: var(--text-muted);
}
.theory-accordion[open] .chevron {
    transform: rotate(180deg);
}
.theory-content {
    padding: 16px;
    font-size: 0.85rem;
    line-height: 1.6;
    color: var(--text-main);
    border-top: 1px solid var(--border-color);
}
.theory-content p {
    margin-bottom: 12px;
}
.theory-content p:last-child {
    margin-bottom: 0;
}


/* MAIN WORKSPACE */
.workspace {
    flex: 1;
    display: flex;
    flex-direction: column;
    background-color: var(--bg-page);
    position: relative;
}

/* TOPBAR */
.workspace-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 32px;
    background: transparent;
    pointer-events: none; /* Let clicks pass through except on children */
    z-index: 5;
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
}

.question-card {
    background: white;
    padding: 16px 24px;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    max-width: 500px;
    pointer-events: auto;
    border: 2px solid var(--brand-teal-light);
}
.question-label {
    font-family: var(--font-heading);
    color: var(--brand-teal-hover);
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 1px;
    font-weight: 700;
    display: block;
    margin-bottom: 6px;
}
.question-card p {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-strong);
    line-height: 1.4;
}

/* PLAYBACK CONTROLS (Top Right) */
.playback-controls {
    display: flex;
    gap: 12px;
    background: white;
    padding: 12px;
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-md);
    pointer-events: auto;
}
.btn-play {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-round);
    border: 2px solid var(--border-color);
    background: white;
    color: var(--text-strong);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.btn-play svg {
    width: 20px;
    height: 20px;
}
.btn-play:hover {
    border-color: var(--text-strong);
    background: var(--bg-page);
    transform: translateY(-2px);
}
.btn-play:active {
    transform: translateY(0) scale(0.95);
}
.btn-play-primary {
    background: var(--brand-teal);
    border-color: var(--brand-teal);
    color: white;
    width: 56px;
    height: 56px;
}
.btn-play-primary svg {
    width: 28px;
    height: 28px;
}
.btn-play-primary:hover {
    background: var(--brand-teal-hover);
    border-color: var(--brand-teal-hover);
    color: white;
    box-shadow: 0 8px 15px rgba(0, 180, 216, 0.3);
}

/* BUS CONTAINER (Top-Down View) */
.bus-container {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 120px 40px 40px 40px; /* Space for top header */
}

.bus-exterior {
    background: var(--bus-exterior);
    border-radius: 40px 40px 16px 16px;
    padding: 12px;
    box-shadow: 0 20px 25px -5px rgba(0,0,0,0.2), 0 10px 10px -5px rgba(0,0,0,0.1);
    position: relative;
    max-height: 100%;
}
.bus-exterior::after {
    /* Wheels */
    content: '';
    position: absolute;
    top: 60px;
    bottom: 60px;
    left: -8px;
    right: -8px;
    background: repeating-linear-gradient(
        to bottom,
        #000 0, #000 60px,
        transparent 60px, transparent calc(100% - 60px),
        #000 calc(100% - 60px), #000 100%
    );
    z-index: -1;
    border-radius: 4px;
}

.bus-windshield {
    height: 60px;
    background: linear-gradient(180deg, #38bdf8 0%, #0369a1 100%);
    border-radius: 30px 30px 8px 8px;
    margin-bottom: 8px;
    border: 3px solid #334155;
    display: flex;
    align-items: center;
    justify-content: center;
    color: rgba(255,255,255,0.8);
    font-family: var(--font-heading);
    font-weight: 700;
    letter-spacing: 4px;
    font-size: 0.8rem;
    box-shadow: inset 0 2px 10px rgba(255,255,255,0.3);
}

.bus-interior {
    background: var(--bus-floor);
    border-radius: 12px;
    padding: 16px;
    display: grid;
    grid-template-columns: 1fr 60px 1fr; /* Left seats, aisle, right seats */
    gap: 12px;
    border: 3px solid #334155;
    min-width: 380px;
}

.bus-aisle {
    background: rgba(0,0,0,0.03);
    border-radius: 40px;
    display: flex;
    justify-content: center;
    padding-top: 20px;
    border: 1px dashed rgba(0,0,0,0.1);
}
.aisle-arrow {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: white;
    color: #cbd5e1;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow-sm);
}
.aisle-arrow svg {
    width: 20px;
    height: 20px;
}

.seat-column {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    grid-auto-rows: min-content;
    gap: 8px;
}
/* Align seats left/right properly */
.right-cols {
    direction: rtl; /* Pushes the single seats toward the window */
}
.right-cols > * {
    direction: ltr; /* Reset text direction inside seat */
}


/* SEATS */
.bus-seat {
    aspect-ratio: 1;
    background: var(--seat-bg);
    border-top: 8px solid var(--seat-border); /* Fake 3D backrest */
    border-radius: 12px 12px 8px 8px;
    position: relative;
    box-shadow: 0 4px 0 rgba(0,0,0,0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.bus-seat-num {
    position: absolute;
    bottom: 4px;
    font-family: var(--font-mono);
    font-size: 0.7rem;
    color: white;
    font-weight: 700;
    opacity: 0.7;
    text-shadow: 0 1px 2px rgba(0,0,0,0.3);
}

.bus-seat.empty .seat-avatar {
    opacity: 0;
    transform: scale(0.5);
}

/* Selected Seat Styles */
.bus-seat.highlight {
    background: var(--seat-highlight);
    border-top-color: #ca8a04;
    transform: translateY(-4px) scale(1.05);
    box-shadow: 0 8px 0 rgba(0,0,0,0.1), 0 0 20px rgba(253, 224, 71, 0.6);
    z-index: 2;
}
.bus-seat.highlight .bus-seat-num {
    color: #713f12;
    text-shadow: none;
}

.seat-avatar {
    position: absolute;
    top: -20px;
    width: 56px;
    height: 56px;
    border-radius: var(--radius-round);
    background: white;
    border: 3px solid;
    box-shadow: var(--shadow-pop);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
    z-index: 5;
}
.seat-avatar svg {
    width: 80%;
    height: 80%;
}

/* Match passenger colors to seat avatars via JS classes */
.seat-avatar.p1 { border-color: var(--p1); }
.seat-avatar.p1 .skin { fill: #fca5a5; }
.seat-avatar.p1 .hair { fill: #450a0a; }

.seat-avatar.p2 { border-color: var(--p2); }
.seat-avatar.p2 .skin { fill: #fed7aa; }
.seat-avatar.p2 .hair { fill: #d97706; }

.seat-avatar.p3 { border-color: var(--p3); }
.seat-avatar.p3 .skin { fill: #d1d5db; }
.seat-avatar.p3 .hair { fill: #e5e7eb; }

.seat-avatar.p4 { border-color: var(--p4); }
.seat-avatar.p4 .skin { fill: #a78bfa; }
.seat-avatar.p4 .hair { fill: #4c1d95; }


/* RESULTS SIDEBAR */
.formula-card {
    padding: 24px;
    border-bottom: 1px solid var(--border-color);
    text-align: center;
}
.formula-title {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-muted);
    font-weight: 800;
}
.formula-math {
    font-family: var(--font-heading);
    font-size: 2.4rem;
    font-weight: 700;
    color: var(--brand-teal);
    margin: 8px 0;
    text-shadow: 0 2px 4px rgba(0, 180, 216, 0.2);
}
.formula-desc {
    font-family: var(--font-mono);
    font-size: 0.85rem;
    color: var(--text-strong);
    background: #e2e8f0;
    display: inline-block;
    padding: 4px 12px;
    border-radius: 8px;
    font-weight: 600;
}

.progress-bar {
    height: 8px;
    background: #e2e8f0;
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 8px;
}
.progress-fill {
    height: 100%;
    background: var(--brand-teal);
    width: 0%;
    transition: width 0.3s ease;
}
.progress-text {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    color: var(--text-muted);
    text-align: right;
}

/* PERMUTATION LIST */
.permutations-container {
    padding: 24px;
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.permutations-container h3 {
    font-size: 0.9rem;
    color: var(--text-strong);
    margin-bottom: 16px;
    font-weight: 700;
}
.perm-list {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding-right: 8px;
}
.perm-list::-webkit-scrollbar {
    width: 4px;
}
.perm-list::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 4px;
}

.perm-item {
    background: white;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 12px;
    display: flex;
    align-items: center;
    cursor: pointer;
    transition: all 0.2s;
    opacity: 0;
    animation: slideIn 0.3s forwards;
}
.perm-item:hover {
    border-color: #cbd5e1;
    transform: translateX(4px);
}
.perm-item.active {
    border-color: var(--brand-teal);
    background: var(--brand-teal-light);
    box-shadow: var(--shadow-sm);
}

.perm-num {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    color: var(--text-muted);
    font-weight: 700;
    min-width: 28px;
}
.perm-content {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}
.p-badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    border-radius: 12px;
    font-family: var(--font-mono);
    font-size: 0.75rem;
    font-weight: 700;
    color: white;
}
.p-badge.p1 { background: var(--p1); }
.p-badge.p2 { background: var(--p2); }
.p-badge.p3 { background: var(--p3); }
.p-badge.p4 { background: var(--p4); }

.seat-dest {
    background: white;
    color: var(--text-strong);
    padding: 0 4px;
    border-radius: 4px;
    margin-left: 4px;
}

@keyframes slideIn {
    from { opacity: 0; transform: translateX(10px); }
    to { opacity: 1; transform: translateX(0); }
}

/* RESPONSIVE */
@media (max-width: 1200px) {
    .app-layout {
        flex-direction: column;
        overflow: auto;
    }
    .sidebar, .results-sidebar {
        width: 100%;
        border-right: none;
        border-bottom: 2px solid var(--border-color);
    }
    .workspace {
        min-height: 800px;
    }
    .workspace-header {
        flex-direction: column;
        gap: 16px;
        position: static;
        background: var(--bg-page);
    }
    .bus-container {
        padding: 40px 20px;
    }
}
