:root {
    /* Cores principais baseadas na logo (Azul e Amarelo) */
    --color-primary: #1d3557;   /* Azul Profundo */
    --color-secondary: #f4a261; /* Amarelo/Laranja Vibrante - CNH Style */
    --color-accent: #e9c46a;    /* Amarelo Claro */
    
    --color-success: #2a9d8f;
    --color-danger: #e63946;
    --color-bg: #f1faee;
    --color-bg-card: #ffffff;
    --color-text: #1d3557;
    --color-text-light: #457b9d;
    --color-border: #a8dadc;
    
    --shadow-soft: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-hover: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    
    --radius: 12px;
    --font-main: 'Inter', sans-serif;
}

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

body {
    font-family: var(--font-main);
    background-color: var(--color-bg);
    color: var(--color-text);
    line-height: 1.6;
    min-height: 100vh;
}

/* Utilities */
.hidden { display: none !important; }
.full-width { width: 100%; }
.fade-in { animation: fadeIn 0.4s ease-in-out; }

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

/* Typography */
h1, h2, h3 { color: var(--color-primary); font-weight: 800; margin-bottom: 0.5rem; }
p { color: var(--color-text-light); margin-bottom: 1rem; }

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.75rem 1.5rem;
    font-size: 1rem;
    font-weight: 600;
    border-radius: var(--radius);
    border: none;
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn.primary {
    background-color: var(--color-primary);
    color: #fff;
}
.btn.primary:hover:not(:disabled) { background-color: #152b47; transform: translateY(-2px); box-shadow: var(--shadow-hover); }
.btn.secondary {
    background-color: var(--color-secondary);
    color: #fff;
}
.btn.secondary:hover { background-color: #e08b47; transform: translateY(-2px); box-shadow: var(--shadow-hover); }
.btn.outline {
    background-color: transparent;
    border: 2px solid var(--color-primary);
    color: var(--color-primary);
}
.btn.outline:hover { background-color: var(--color-primary); color: #fff; }
.btn-close {
    background-color: #fff;
    color: var(--color-danger);
    border: 1px solid var(--color-danger);
    padding: 0.4rem 0.8rem;
    font-size: 0.9rem;
}

/* Forms */
.input-group { margin-bottom: 1.2rem; text-align: left; }
.input-group label { display: block; margin-bottom: 0.5rem; font-weight: 600; color: var(--color-primary); }
.input-group input, .input-group select {
    width: 100%;
    padding: 0.8rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    font-size: 1rem;
    background-color: #f8f9fa;
    transition: border-color 0.2s;
}
.input-group input:focus, .input-group select:focus {
    outline: none;
    border-color: var(--color-primary);
    background-color: #fff;
}
.error-msg { color: var(--color-danger); font-size: 0.9rem; margin-bottom: 1rem; display: block; }

/* Loader */
.loader-container {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(29, 53, 87, 0.9);
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    z-index: 9999; color: white;
}
.spinner {
    width: 50px; height: 50px;
    border: 5px solid rgba(255,255,255,0.3); border-top-color: var(--color-accent);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 1rem;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Screens & Containers */
.app-container { min-height: 100vh; display: flex; flex-direction: column; }
.screen { flex: 1; display: none; }
.screen.active { display: flex; flex-direction: column; }

/* Login Screen */
#login-screen { align-items: center; justify-content: center; padding: 1rem; }
.login-card {
    background: var(--color-bg-card); padding: 2.5rem; border-radius: var(--radius);
    box-shadow: var(--shadow-soft); width: 100%; max-width: 450px; text-align: center;
}
.logo-container img { max-width: 100%; margin-bottom: 1.5rem; }

.login-tabs {
    display: flex; gap: 0; margin-bottom: 1.5rem; border-bottom: 2px solid var(--color-border);
}
.login-tabs .tab-btn {
    flex: 1; padding: 0.8rem 0.5rem; border: none; background: none; font-weight: 600; 
    color: var(--color-text-light); cursor: pointer; font-size: 0.95rem;
    border-bottom: 3px solid transparent; margin-bottom: -2px; transition: all 0.2s;
}
.login-tabs .tab-btn:hover { color: var(--color-primary); }
.login-tabs .tab-btn.active { color: var(--color-primary); border-bottom-color: var(--color-primary); }

.login-content { animation: fadeIn 0.3s ease; }

/* Header */
.app-header {
    background: var(--color-bg-card); padding: 1rem 2rem; display: flex;
    justify-content: space-between; align-items: center; box-shadow: var(--shadow-soft);
}
.nav-logo { height: 40px; }
.app-header nav { display: flex; gap: 1rem; align-items: center; }

/* Dashboard */
.dashboard-content { padding: 2rem; max-width: 1200px; margin: 0 auto; width: 100%; }
.cards-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 1.5rem; margin-top: 2rem; }
.action-card {
    background: var(--color-bg-card); padding: 2rem; border-radius: var(--radius);
    box-shadow: var(--shadow-soft); border-top: 4px solid var(--color-secondary);
}

/* Setup Screen */
.setup-container { display: flex; justify-content: center; }
.setup-form {
    background: var(--color-bg-card); padding: 2.5rem; border-radius: var(--radius);
    box-shadow: var(--shadow-soft); width: 100%; max-width: 500px;
}
.setup-info { font-style: italic; color: var(--color-text-light); text-align: center; margin: 1rem 0; font-weight: 600;}

/* Quiz Screen */
.quiz-header {
    background: var(--color-bg-card); padding: 1rem 2rem; box-shadow: var(--shadow-soft);
    position: sticky; top: 0; z-index: 10;
}
.progress-bar { height: 8px; background: #e9ecef; border-radius: 4px; overflow: hidden; margin-bottom: 0.5rem; }
.progress-bar .fill { height: 100%; background: var(--color-secondary); width: 0%; transition: width 0.3s ease; }
.quiz-meta { display: flex; justify-content: space-between; font-weight: 600; color: var(--color-primary); }
.question-container { padding: 2rem; max-width: 800px; margin: 0 auto; width: 100%; flex: 1; }
#question-image { max-height: 200px; max-width: 350px; width: 100%; object-fit: contain; margin: 0 auto 1.5rem auto; display: block; border-radius: var(--radius); box-shadow: var(--shadow-soft); }
.options-list { display: flex; flex-direction: column; gap: 1rem; margin-top: 1rem; }
.option {
    padding: 1rem; background: var(--color-bg-card); border: 2px solid var(--color-border);
    border-radius: var(--radius); font-size: 1rem; text-align: left; cursor: pointer; transition: all 0.2s;
    color: var(--color-text); font-weight: 600;
}
.option:hover:not(:disabled) { background: #eaf4f4; border-color: var(--color-primary); }
.option.correct { background: #d8f3dc; border-color: var(--color-success); color: #1b4332; }
.option.wrong { background: #ffe5d9; border-color: var(--color-danger); color: #780000; }
.option.selected-wrong { background: #ffe5d9; border-color: var(--color-danger); color: #780000; }
.option.selected-prova { background: #e2e8f0; border-color: #94a3b8; color: #334155; }
.commentary-box {
    margin-top: 1.5rem; padding: 1.5rem; background: #fefae0; border-left: 4px solid var(--color-accent);
    border-radius: 0 var(--radius) var(--radius) 0; color: #606c38;
}
.quiz-footer {
    padding: 1rem 2rem; background: var(--color-bg-card); display: flex; justify-content: space-between; align-items: center;
    box-shadow: 0 -4px 6px -1px rgba(0,0,0,0.05); gap: 1rem;
}

.quiz-timer {
    font-size: 1.2rem;
    font-weight: 800;
    color: var(--color-success);
    background: #d8f3dc;
    padding: 0.3rem 1rem;
    border-radius: var(--radius);
    display: inline-flex;
    align-items: center;
}
.quiz-timer.danger {
    color: var(--color-danger);
    background: #ffe5d9;
    animation: pulse 1s infinite alternate;
}
@keyframes pulse {
    from { opacity: 1; }
    to { opacity: 0.6; }
}

/* Menu Mobile e Navigation */
.mobile-menu-btn {
    display: none;
    background: none;
    border: none;
    font-size: 1.8rem;
    color: var(--color-primary);
    cursor: pointer;
}

/* Results Screen */
.results-container { display: flex; justify-content: center; align-items: center; padding: 2rem; flex:1; }
.results-card {
    background: var(--color-bg-card); padding: 3rem; border-radius: var(--radius);
    box-shadow: var(--shadow-soft); text-align: center; max-width: 500px; width: 100%;
}
.score-circle {
    width: 150px; height: 150px; border-radius: 50%; background: var(--color-primary);
    color: white; display: flex; align-items: center; justify-content: center;
    font-size: 3rem; font-weight: 800; margin: 2rem auto; border: 8px solid var(--color-border);
}
.results-actions { margin-top: 2rem; display: flex; justify-content: center; gap: 1rem; }

/* Admin & Tables */
.admin-content { padding: 2rem; max-width: 1200px; margin: 0 auto; width: 100%; }
.admin-tabs { display: flex; gap: 1rem; margin-bottom: 2rem; border-bottom: 2px solid var(--color-border); }
.tab-btn {
    padding: 0.8rem 1.5rem; border: none; background: none; font-weight: 600; color: var(--color-text-light);
    cursor: pointer; border-bottom: 3px solid transparent; margin-bottom: -2px; font-size: 1.1rem;
}
.tab-btn.active { color: var(--color-primary); border-bottom-color: var(--color-primary); }
.view-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1.5rem; }

.data-table { width: 100%; border-collapse: collapse; background: var(--color-bg-card); box-shadow: var(--shadow-soft); border-radius: var(--radius); overflow: hidden; }
.data-table th, .data-table td { padding: 1rem; text-align: left; border-bottom: 1px solid var(--color-border); }
.data-table th { background: var(--color-primary); color: white; font-weight: 600; }
.data-table tr:hover td { background: #f8f9fa; }
.action-btns button { padding: 0.3rem 0.6rem; font-size: 0.8rem; margin-right: 0.5rem; }

.history-list-container { margin-top:3rem; background: var(--color-bg-card); padding: 2rem; border-radius: var(--radius); }

/* Modals */
.modal {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.5); display: flex; align-items: center; justify-content: center;
    z-index: 1000;
}
.modal-content {
    background: var(--color-bg-card); padding: 2rem; border-radius: var(--radius);
    width: 100%; max-width: 450px; box-shadow: var(--shadow-hover);
}
.modal-actions { display: flex; justify-content: flex-end; gap: 1rem; margin-top: 2rem; }

/* Responsive */
@media (max-width: 768px) {
    .app-header { 
        flex-direction: row; 
        justify-content: space-between; 
        align-items: center; 
        flex-wrap: nowrap; 
    }
    .app-nav {
        display: flex !important;
        width: auto;
        flex-direction: column;
        gap: 0.5rem;
        margin-top: 0;
    }
    .app-nav .btn { width: 100%; padding: 0.5rem 1rem; text-align: center; font-size: 0.95rem; }
    
    .input-group label { text-align: left; }
    .results-actions { flex-direction: column; }
    
    /* Tabelas Viram Cards Verticais */
    .data-table { border: 0; box-shadow: none; background: transparent; display: block; overflow: hidden; }
    .data-table thead { display: none; }
    .data-table tbody { display: flex; flex-direction: column; gap: 1.5rem; }
    .data-table tr { 
        display: flex; flex-direction: column; 
        border: 2px solid var(--color-border); 
        border-radius: var(--radius); 
        padding: 1rem; 
        background: var(--color-bg-card);
        box-shadow: var(--shadow-soft);
    }
    .data-table td { 
        display: flex; 
        flex-direction: column; /* Coloca um debaixo do outro de verdade */
        text-align: left; 
        border: none; padding: 0.5rem 0; 
        border-bottom: 1px dashed var(--color-border);
        font-size: 1rem;
    }
    .data-table td:last-child { border-bottom: none; }
}
