/* =============================================
   CONTROLE DE FRETES - Tio Jocá Alimentos
   Mobile-First CSS
   ============================================= */

:root {
    --primary: #1e3a5f;
    --primary-light: #2d5a8e;
    --primary-dark: #0f2440;
    --accent: #e8a830;
    --success: #16a34a;
    --danger: #dc2626;
    --warning: #f59e0b;
    --gray-50: #f8fafc;
    --gray-100: #f1f5f9;
    --gray-200: #e2e8f0;
    --gray-300: #cbd5e1;
    --gray-400: #94a3b8;
    --gray-500: #64748b;
    --gray-600: #475569;
    --gray-700: #334155;
    --gray-800: #1e293b;
    --gray-900: #0f172a;
    --radius: 14px;
    --shadow: 0 2px 8px rgba(0,0,0,0.08);
    --shadow-lg: 0 8px 24px rgba(0,0,0,0.12);
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--gray-100);
    color: var(--gray-800);
    font-size: 16px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    min-height: 100vh;
}

/* ==================== NAVBAR ==================== */
.navbar {
    background: linear-gradient(135deg, var(--primary-dark), var(--primary));
    color: white;
    padding: 14px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 2px 12px rgba(0,0,0,0.2);
}
.navbar .brand { font-size: 18px; font-weight: 800; letter-spacing: -0.5px; }
.navbar .user-info { display: flex; align-items: center; gap: 10px; }
.navbar .user-name { font-size: 13px; opacity: 0.85; }
.navbar .btn-logout {
    color: white; background: rgba(255,255,255,0.15);
    padding: 6px 16px; border-radius: 20px;
    text-decoration: none; font-size: 13px; font-weight: 600;
}

/* ==================== NAV TABS ==================== */
.nav-tabs {
    background: white;
    display: flex;
    border-bottom: 2px solid var(--gray-200);
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    position: sticky;
    top: 52px;
    z-index: 99;
}
.nav-tabs a {
    flex: 1;
    min-width: max-content;
    text-align: center;
    padding: 12px 14px;
    text-decoration: none;
    color: var(--gray-400);
    font-size: 12px;
    font-weight: 700;
    border-bottom: 3px solid transparent;
    white-space: nowrap;
    transition: all 0.2s;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
}
.nav-tabs a .tab-icon { font-size: 18px; }
.nav-tabs a.active, .nav-tabs a:hover {
    color: var(--primary);
    border-bottom-color: var(--accent);
    background: rgba(30,58,95,0.04);
}

/* ==================== CONTAINER ==================== */
.container { max-width: 900px; margin: 0 auto; padding: 16px; padding-bottom: 80px; }

/* ==================== CARDS ==================== */
.card {
    background: white;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 20px;
    margin-bottom: 16px;
}
.card-header {
    font-size: 17px; font-weight: 800;
    color: var(--gray-800);
    margin-bottom: 16px;
    display: flex; align-items: center; justify-content: space-between;
}
.section-header {
    font-size: 17px; font-weight: 800; color: var(--gray-700);
    margin: 20px 0 12px;
    display: flex; align-items: center; justify-content: space-between;
}

/* ==================== STAT CARDS ==================== */
.stats {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-bottom: 16px;
}
.stat-card {
    background: white; border-radius: var(--radius);
    padding: 16px; box-shadow: var(--shadow);
    text-align: center;
}
.stat-card .label {
    font-size: 11px; color: var(--gray-500);
    text-transform: uppercase; letter-spacing: 0.5px; font-weight: 700;
}
.stat-card .value {
    font-size: 20px; font-weight: 900;
    margin-top: 4px; color: var(--gray-800);
}
.stat-card.accent { border-left: 4px solid var(--primary); }
.stat-card.green { border-left: 4px solid var(--success); }
.stat-card.red { border-left: 4px solid var(--danger); }
.stat-card.yellow { border-left: 4px solid var(--warning); }

/* ==================== FRETE CARD ==================== */
.frete-card {
    background: white; border-radius: var(--radius);
    box-shadow: var(--shadow); padding: 16px;
    margin-bottom: 12px; border-left: 4px solid var(--primary-light);
}
.frete-card .frete-top { display: flex; justify-content: space-between; align-items: flex-start; }
.frete-card .frete-date { font-size: 13px; color: var(--gray-400); font-weight: 700; }
.frete-card .frete-valor { font-size: 18px; font-weight: 900; color: var(--primary); }
.frete-card .frete-rota { font-size: 15px; font-weight: 700; color: var(--gray-700); margin-top: 2px; }
.frete-card .frete-rota .arrow { color: var(--accent); margin: 0 6px; font-weight: 400; }
.frete-card .frete-details {
    display: grid; grid-template-columns: 1fr 1fr;
    gap: 4px 16px; font-size: 13px; color: var(--gray-500);
    margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--gray-100);
}
.frete-card .frete-details span { display: flex; justify-content: space-between; }
.frete-card .frete-details .val { font-weight: 700; color: var(--gray-700); }
.frete-card .frete-footer {
    display: flex; justify-content: space-between; align-items: center;
    margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--gray-100);
}
.frete-card .frete-saldo { font-size: 14px; }
.frete-card .frete-actions { display: flex; gap: 6px; }

.motorista-tag {
    font-size: 11px; background: var(--primary); color: white;
    padding: 2px 10px; border-radius: 10px; font-weight: 700;
    display: inline-block; margin-top: 4px;
}
.placa-tag {
    font-size: 11px; background: var(--accent); color: var(--primary-dark);
    padding: 2px 10px; border-radius: 10px; font-weight: 800;
    display: inline-block; margin-top: 4px; margin-left: 4px;
    letter-spacing: 0.5px;
}

/* ==================== VEÍCULO CARD ==================== */
.veiculo-card {
    background: white; border-radius: var(--radius);
    box-shadow: var(--shadow); padding: 20px;
    margin-bottom: 14px; border-left: 4px solid var(--accent);
}
.veiculo-top { display: flex; justify-content: space-between; align-items: flex-start; }
.veiculo-placa {
    font-size: 20px; font-weight: 900; color: var(--primary);
    letter-spacing: 1px; font-family: 'Courier New', monospace;
}
.veiculo-modelo { font-size: 14px; color: var(--gray-500); margin-top: 2px; }
.veiculo-km { font-size: 16px; font-weight: 800; color: var(--gray-600); }
.veiculo-info-grid {
    display: grid; grid-template-columns: 1fr;
    gap: 8px; margin-top: 14px; padding-top: 14px;
    border-top: 1px solid var(--gray-100);
}
.veiculo-info-item {}
.info-label { font-size: 12px; color: var(--gray-400); font-weight: 700; text-transform: uppercase; letter-spacing: 0.3px; }
.info-value { font-size: 14px; color: var(--gray-700); font-weight: 600; margin-top: 2px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

/* ==================== ALERTA CARD ==================== */
.alerta-card { border-left: 4px solid var(--warning); background: #fffbeb; }
.alerta-item {
    padding: 10px 0; border-bottom: 1px solid rgba(245,158,11,0.15);
}
.alerta-item:last-child { border-bottom: none; }
.alerta-placa { font-weight: 800; color: var(--primary); font-family: 'Courier New', monospace; }
.alerta-msgs { margin-top: 4px; display: flex; gap: 6px; flex-wrap: wrap; }

/* ==================== MOTORISTA CARD ==================== */
.motorista-card { padding: 0; }
.motorista-item {
    display: flex; align-items: center; justify-content: space-between;
    padding: 16px 20px;
}
.motorista-item .info h3 { font-size: 16px; margin-bottom: 2px; }

/* ==================== FORMS ==================== */
.form-group { margin-bottom: 16px; }
.form-group label {
    display: block; font-size: 14px; font-weight: 700;
    color: var(--gray-600); margin-bottom: 6px;
}
.form-control {
    width: 100%; padding: 14px 16px;
    border: 2px solid var(--gray-200); border-radius: 12px;
    font-size: 16px; color: var(--gray-800); background: white;
    transition: border-color 0.2s; -webkit-appearance: none;
}
.form-control:focus {
    outline: none; border-color: var(--primary-light);
    box-shadow: 0 0 0 3px rgba(45,90,142,0.12);
}
.input-money { font-size: 22px !important; font-weight: 800 !important; }
select.form-control {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath d='M6 8L1 3h10z' fill='%2364748b'/%3E%3C/svg%3E");
    background-repeat: no-repeat; background-position: right 16px center; padding-right: 40px;
}
textarea.form-control { min-height: 80px; resize: vertical; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-separator {
    font-size: 14px; font-weight: 800; color: var(--primary);
    padding: 12px 0 8px; margin-top: 8px;
    border-top: 1px dashed var(--gray-200);
}

/* ==================== BUTTONS ==================== */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    padding: 14px 24px; border: none; border-radius: 12px;
    font-size: 16px; font-weight: 700; cursor: pointer;
    text-decoration: none; transition: all 0.15s;
    -webkit-tap-highlight-color: transparent; min-height: 50px;
}
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-success { background: var(--success); color: white; }
.btn-danger { background: var(--danger); color: white; }
.btn-warning { background: var(--warning); color: white; }
.btn-outline { background: transparent; color: var(--primary); border: 2px solid var(--primary); }
.btn-sm { padding: 8px 14px; font-size: 13px; min-height: 38px; border-radius: 10px; }
.btn-block { width: 100%; }
.btn-group-wrap { display: flex; gap: 8px; flex-wrap: wrap; }
.btn-fab {
    position: fixed; bottom: 24px; right: 24px;
    width: 64px; height: 64px; border-radius: 50%;
    background: var(--primary); color: white;
    font-size: 30px; border: none;
    box-shadow: 0 6px 20px rgba(30,58,95,0.4);
    cursor: pointer; z-index: 50;
    display: flex; align-items: center; justify-content: center;
    transition: transform 0.15s;
}
.btn-fab:active { transform: scale(0.9); }

/* ==================== FLASH ==================== */
.flash {
    padding: 14px 20px; border-radius: var(--radius);
    margin-bottom: 16px; font-weight: 700; font-size: 14px;
}
.flash-success { background: #dcfce7; color: #166534; border: 1px solid #bbf7d0; }
.flash-danger { background: #fee2e2; color: #991b1b; border: 1px solid #fecaca; }

/* ==================== LOGIN ==================== */
.login-page {
    min-height: 100vh; display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    background: linear-gradient(135deg, var(--primary-dark), var(--primary), var(--primary-light));
    padding: 20px;
}
.login-box {
    background: white; border-radius: 24px;
    padding: 40px 28px; width: 100%; max-width: 380px;
    box-shadow: 0 25px 60px rgba(0,0,0,0.3);
}
.login-box .logo { text-align: center; margin-bottom: 32px; }
.login-box .logo .logo-icon { font-size: 48px; margin-bottom: 8px; }
.login-box .logo h1 { font-size: 20px; color: var(--primary); font-weight: 800; }
.login-box .logo p { color: var(--gray-400); font-size: 14px; margin-top: 4px; }

/* ==================== MODAL ==================== */
.modal-overlay {
    display: none; position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.5); z-index: 200;
    align-items: flex-end; justify-content: center;
}
.modal-overlay.active { display: flex; }
.modal-content {
    background: white; border-radius: 24px 24px 0 0;
    width: 100%; max-width: 600px; max-height: 92vh;
    overflow-y: auto; padding: 24px;
    animation: slideUp 0.3s ease;
}
@keyframes slideUp {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
}
.modal-header {
    display: flex; justify-content: space-between; align-items: center;
    margin-bottom: 20px; padding-bottom: 16px;
    border-bottom: 1px solid var(--gray-200);
}
.modal-header h2 { font-size: 18px; font-weight: 800; }
.modal-close {
    width: 38px; height: 38px; border-radius: 50%;
    border: none; background: var(--gray-100);
    font-size: 20px; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
}

/* ==================== FILTER BAR ==================== */
.filter-bar {
    display: flex; gap: 8px; margin-bottom: 16px; flex-wrap: wrap;
}
.filter-bar select, .filter-bar input {
    padding: 12px 14px; border: 2px solid var(--gray-200);
    border-radius: 12px; font-size: 15px; font-weight: 600;
    background: white; flex: 1; min-width: 100px;
}

/* ==================== BADGES ==================== */
.badge {
    display: inline-block; padding: 3px 10px;
    border-radius: 20px; font-size: 11px; font-weight: 800;
}
.badge-ok { background: #dcfce7; color: #166534; }
.badge-warning { background: #fef3c7; color: #92400e; }
.badge-danger { background: #fee2e2; color: #991b1b; }

/* ==================== EMPTY STATE ==================== */
.empty-state {
    text-align: center; padding: 40px 20px; color: var(--gray-400);
}
.empty-state .icon { font-size: 48px; margin-bottom: 12px; }
.empty-state p { font-size: 15px; }

/* ==================== UTILITIES ==================== */
.text-right { text-align: right; }
.text-center { text-align: center; }
.text-muted { color: var(--gray-500); }
.text-sm { font-size: 13px; }
.text-green { color: var(--success); }
.text-red { color: var(--danger); }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 16px; }

/* ==================== RESPONSIVE ==================== */
@media (max-width: 480px) {
    .form-row { grid-template-columns: 1fr; }
    .stats { grid-template-columns: 1fr 1fr; }
    .stat-card .value { font-size: 17px; }
    .navbar { padding: 12px 16px; }
    .container { padding: 12px; }
    .btn-group-wrap { flex-direction: column; }
    .btn-group-wrap .btn, .btn-group-wrap form { width: 100%; }
    .btn-group-wrap form .btn { width: 100%; }
}
