/* NOME DO ARQUIVO: public/css/style.css */

/* --- 1. VARIÁVEIS DE TEMA (LIGHT/DARK) --- */
:root {
    /* Light Mode (Padrão) */
    --bg-body: #f4f6f8;
    --bg-sidebar: #1e272e; /* Sidebar sempre escura para contraste */
    --bg-card: #ffffff;
    --text-main: #2c3e50;
    --text-light: #7f8c8d;
    --border: #e2e8f0;
    
    /* Cores de Ação */
    --accent: #0fbcf9;       /* Azul Ciano (Principal) */
    --accent-hover: #0984e3;
    --success: #27ae60;      /* Verde */
    --danger: #ff5e57;       /* Vermelho */
    --warning: #f1c40f;      /* Amarelo */
    
    /* Sombras */
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.1);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.1);
    
    /* Sidebar */
    --sidebar-width: 260px;
    --header-height: 60px;
}

body.dark-mode {
    /* Dark Mode */
    --bg-body: #0f172a;
    --bg-sidebar: #000000;
    --bg-card: #1e293b;
    --text-main: #f1f5f9;
    --text-light: #94a3b8;
    --border: #334155;
    
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.5);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.5);
}

/* --- 2. RESET E BASE --- */
* { box-sizing: border-box; outline: none; }

body {
    margin: 0;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-body);
    color: var(--text-main);
    height: 100vh;
    overflow: hidden; /* Evita scroll na página inteira, apenas no conteúdo */
    transition: background 0.3s ease, color 0.3s ease;
}

h3 { margin-top: 0; font-size: 18px; font-weight: 700; margin-bottom: 20px; color: var(--text-main); }

/* --- 3. LOGIN SCREEN --- */
#login-screen {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: var(--bg-sidebar); z-index: 9999;
    display: flex; align-items: center; justify-content: center;
    padding: 20px;
}

.login-box {
    background: var(--bg-card);
    padding: 40px; border-radius: 16px;
    width: 100%; max-width: 380px;
    text-align: center;
    box-shadow: 0 20px 50px rgba(0,0,0,0.3);
}

/* --- 4. LAYOUT DASHBOARD --- */
#dashboard-screen {
    display: flex;
    height: 100%;
    width: 100%;
}

/* Sidebar */
#sidebar {
    width: var(--sidebar-width);
    background: var(--bg-sidebar);
    color: white;
    display: flex; flex-direction: column;
    flex-shrink: 0;
    transition: transform 0.3s ease;
    z-index: 1000;
}

.logo-area {
    padding: 20px; text-align: center;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    background: rgba(0,0,0,0.2);
}
.logo-text { font-weight: 800; font-size: 20px; letter-spacing: 1px; }
.logo-img { max-width: 120px; margin: 0 auto; display: block; }

.nav-links { flex: 1; overflow-y: auto; padding: 15px 0; }

.menu-item {
    padding: 12px 25px;
    cursor: pointer;
    color: #aab0c6;
    display: flex; align-items: center; gap: 12px;
    font-size: 14px; font-weight: 500;
    transition: 0.2s;
    border-left: 3px solid transparent;
}
.menu-item:hover { background: rgba(255,255,255,0.05); color: white; }
.menu-item.active { background: rgba(15, 188, 249, 0.1); color: var(--accent); border-left-color: var(--accent); }

/* Conteúdo Principal */
#main-content {
    flex: 1;
    background: var(--bg-body);
    position: relative;
    display: flex; flex-direction: column;
    overflow: hidden;
}

/* Telas (Screens) */
.screen {
    display: none; /* Oculto por padrão */
    padding: 30px;
    height: 100%;
    overflow-y: auto; /* Scroll apenas no conteúdo */
    animation: fadeIn 0.3s ease-out;
}
.screen.active { display: block; }

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

/* --- 5. COMPONENTES UI --- */

/* Cards */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 25px;
    margin-bottom: 25px;
    box-shadow: var(--shadow-sm);
}

/* Formulários */
.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    margin-bottom: 20px;
}

label {
    display: block; margin-bottom: 6px;
    font-size: 12px; font-weight: 600;
    color: var(--text-light); text-transform: uppercase;
}

input, select {
    width: 100%;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--bg-body);
    color: var(--text-main);
    font-size: 14px;
    transition: border-color 0.2s;
}
input:focus, select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(15, 188, 249, 0.1); }

/* Botões */
button {
    padding: 12px 20px;
    border: none; border-radius: 8px;
    font-weight: 600; font-size: 14px;
    cursor: pointer;
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    transition: all 0.2s;
}
button:active { transform: scale(0.98); }

.btn-primary { background: var(--accent); color: white; }
.btn-primary:hover { background: var(--accent-hover); }

.btn-secondary { background: #64748b; color: white; }
.btn-secondary:hover { background: #475569; }

.btn-success { background: var(--success); color: white; }
.btn-danger { background: var(--danger); color: white; }
.btn-icon { padding: 8px 12px; }

/* Tabelas */
.table-responsive { width: 100%; overflow-x: auto; border-radius: 8px; border: 1px solid var(--border); }
table { width: 100%; border-collapse: collapse; min-width: 600px; }
th { background: var(--bg-body); text-align: left; padding: 15px; font-size: 12px; color: var(--text-light); text-transform: uppercase; border-bottom: 1px solid var(--border); }
td { padding: 15px; border-bottom: 1px solid var(--border); font-size: 14px; color: var(--text-main); }
tr:last-child td { border-bottom: none; }

/* Badges de Status */
.badge { padding: 4px 10px; border-radius: 20px; font-size: 11px; font-weight: bold; text-transform: uppercase; }
.st-ativo, .st-entregue { background: rgba(39, 174, 96, 0.1); color: var(--success); }
.st-pendente { background: rgba(127, 140, 141, 0.1); color: var(--text-light); }
.st-em_rota { background: rgba(241, 196, 15, 0.1); color: #f39c12; }
.st-cancelado { background: rgba(231, 76, 60, 0.1); color: var(--danger); }

/* --- 6. MÓDULOS ESPECÍFICOS --- */

/* KPIs (Dashboard & Roteiros) */
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 15px; margin-bottom: 20px; }
.kpi-card { background: var(--bg-card); padding: 15px; border-radius: 8px; border: 1px solid var(--border); text-align: center; }
.kpi-val { font-size: 24px; font-weight: 800; margin-top: 5px; color: var(--text-main); }

/* Roteiro Builder (Drag & Drop) */
.roteiro-builder { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; height: 500px; margin-top: 20px; }
.rb-col { 
    background: var(--bg-body); border: 1px solid var(--border); border-radius: 8px; 
    padding: 15px; display: flex; flex-direction: column; overflow: hidden;
}
.rb-list { flex: 1; overflow-y: auto; padding-right: 5px; }

.rb-item {
    background: var(--bg-card); padding: 12px; margin-bottom: 8px; border-radius: 6px;
    border: 1px solid var(--border); cursor: grab; display: flex; align-items: center; justify-content: space-between;
    box-shadow: 0 1px 2px rgba(0,0,0,0.05); transition: 0.2s;
}
.rb-item:hover { border-color: var(--accent); transform: translateX(2px); }
.rb-item.dragging { opacity: 0.5; border: 2px dashed var(--accent); }
.rb-badge { 
    width: 24px; height: 24px; background: var(--accent); color: white; border-radius: 50%; 
    display: flex; align-items: center; justify-content: center; font-size: 11px; font-weight: bold; margin-right: 10px;
}
.rb-action { cursor: pointer; padding: 5px; opacity: 0.6; font-size: 16px; }
.rb-action:hover { opacity: 1; transform: scale(1.2); }

/* Mapa Full Screen */
#screen-mapa { padding: 0 !important; display: none; }
#screen-mapa.active { display: flex; flex-direction: column; }

/* Marcadores Personalizados do Mapa */
.map-moto-icon { font-size: 24px; filter: drop-shadow(0 2px 2px rgba(0,0,0,0.3)); }
.map-emoji-icon { font-size: 24px; text-align: center; line-height: 30px; }
.map-number-icon div { border: 2px solid white; box-shadow: 0 2px 5px rgba(0,0,0,0.3); }

/* --- 7. MODAL & TOAST --- */
.modal-overlay {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.6); z-index: 2000;
    display: none; align-items: center; justify-content: center;
    backdrop-filter: blur(3px);
}
.modal-box {
    background: var(--bg-card); padding: 30px; border-radius: 16px;
    width: 90%; max-width: 500px; box-shadow: 0 20px 60px rgba(0,0,0,0.4);
    animation: scaleIn 0.2s ease;
}

/* Toast Notification */
.popup-overlay {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.2); z-index: 10000;
    display: flex; align-items: center; justify-content: center;
}
.popup-box-alert {
    background: white; padding: 25px; border-radius: 12px; width: 320px;
    text-align: center; box-shadow: 0 10px 40px rgba(0,0,0,0.2); position: relative;
    animation: scaleIn 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}
.popup-close-btn {
    position: absolute; top: 10px; right: 10px; cursor: pointer;
    width: 30px; height: 30px; line-height: 30px; border-radius: 50%;
    background: #f1f2f6; color: #666; font-weight: bold;
}
.popup-icon { font-size: 40px; margin-bottom: 10px; display: block; }
.popup-msg { font-size: 16px; color: #2c3e50; margin-bottom: 20px; line-height: 1.4; }
.popup-btn { width: 100%; padding: 10px; background: var(--accent); color: white; border:none; border-radius:6px; cursor:pointer; font-weight:600; }

/* Cores do Toast */
.popup-success .popup-icon { color: var(--success); }
.popup-success .popup-btn { background: var(--success); }
.popup-error .popup-icon { color: var(--danger); }
.popup-error .popup-btn { background: var(--danger); }

/* --- 8. RESPONSIVIDADE (MOBILE) --- */
@media (max-width: 768px) {
    #sidebar {
        position: fixed; top: 0; left: 0; height: 100%;
        transform: translateX(-100%); box-shadow: 2px 0 10px rgba(0,0,0,0.5);
    }
    #sidebar.open { transform: translateX(0); }
    
    #sidebar-overlay {
        position: fixed; top: 0; left: 0; width: 100%; height: 100%;
        background: rgba(0,0,0,0.5); z-index: 900; display: none;
    }
    #sidebar-overlay.open { display: block; }
    
    #mobile-header { display: flex !important; }
    
    .roteiro-builder { grid-template-columns: 1fr; height: auto; }
    .rb-col { min-height: 300px; }
    
    .screen { padding: 15px; padding-bottom: 80px; }
    
    /* Mapa ocupa altura restante menos o header */
    #screen-mapa.active { height: calc(100% - 60px); }
}

@keyframes scaleIn { from { transform: scale(0.8); opacity: 0; } to { transform: scale(1); opacity: 1; } }