/* Serraf Delivery - Global Styles */
:root {
    --primary: #2563EB;
    --primary-dark: #1D4ED8;
    --primary-light: #60A5FA;
    --secondary: #212529;
    --success: #198754;
    --danger: #dc3545;
    --warning: #ffc107;
    --info: #0dcaf0;
    --bg-dark: #1a1d21;
    --bg-card: #ffffff;
    --text-muted: #6c757d;
    --border: #dee2e6;
    --sidebar-w: 260px;
    --header-h: 64px;
}

* { box-sizing: border-box; }

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: #f4f6f9;
    color: var(--secondary);
}

/* ── Sidebar ────────────────────────── */
.sidebar {
    position: fixed;
    top: 0; left: 0;
    width: var(--sidebar-w);
    height: 100vh;
    background: var(--bg-dark);
    color: #fff;
    z-index: 1000;
    overflow-y: auto;
    transition: transform .3s ease;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 20px 20px;
    border-bottom: 1px solid rgba(255,255,255,.1);
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--primary);
    text-decoration: none;
}

.sidebar-brand img { width: 38px; height: 38px; border-radius: 8px; object-fit: cover; }

.nav-section-title {
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 1.2px;
    text-transform: uppercase;
    color: rgba(255,255,255,.4);
    padding: 20px 20px 6px;
}

.sidebar .nav-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 11px 20px;
    color: rgba(255,255,255,.7);
    font-size: .9rem;
    border-radius: 0;
    transition: all .2s;
    text-decoration: none;
    border-left: 3px solid transparent;
}

.sidebar .nav-link:hover,
.sidebar .nav-link.active {
    background: rgba(37,99,235,.15);
    color: #fff;
    border-left-color: var(--primary);
}

.sidebar .nav-link i { width: 18px; text-align: center; }

/* ── Layout ─────────────────────────── */
.main-wrapper {
    margin-left: var(--sidebar-w);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.topbar {
    height: var(--header-h);
    background: #fff;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    padding: 0 24px;
    position: sticky;
    top: 0;
    z-index: 100;
    gap: 12px;
}

.topbar .topbar-title { font-weight: 600; font-size: 1.05rem; flex: 1; }
.topbar .btn-sidebar-toggle { display: none; }

.page-content { padding: 28px 24px; flex: 1; }

/* ── Cards KPI ──────────────────────── */
.kpi-card {
    background: #fff;
    border-radius: 14px;
    padding: 22px 24px;
    border: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 18px;
    transition: box-shadow .2s;
}

.kpi-card:hover { box-shadow: 0 4px 20px rgba(0,0,0,.08); }

.kpi-icon {
    width: 54px; height: 54px;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
    flex-shrink: 0;
}

.kpi-icon.orange   { background: rgba(37,99,235,.12); color: var(--primary); }
.kpi-icon.green    { background: rgba(25,135,84,.12);  color: var(--success); }
.kpi-icon.blue     { background: rgba(13,110,253,.12); color: #0d6efd; }
.kpi-icon.red      { background: rgba(220,53,69,.12);  color: var(--danger); }
.kpi-icon.purple   { background: rgba(111,66,193,.12); color: #6f42c1; }

.kpi-card > div:not(.kpi-icon) { min-width: 0; flex: 1; }
.kpi-value { font-size: 1.8rem; font-weight: 700; line-height: 1; }
.kpi-label { font-size: .82rem; color: var(--text-muted); margin-top: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ── Cards genéricos ────────────────── */
.card-serraf {
    background: #fff;
    border-radius: 14px;
    border: 1px solid var(--border);
    overflow: hidden;
}

.card-serraf .card-header-serraf {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    font-weight: 600;
    font-size: .95rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.card-serraf .card-body-serraf { padding: 16px 20px; }

/* ── Status badges ──────────────────── */
.badge-status {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: .72rem;
    font-weight: 700;
    letter-spacing: .5px;
    text-transform: uppercase;
}

.badge-AGUARDANDO  { background: #fff3cd; color: #856404; }
.badge-ACEITA      { background: #cff4fc; color: #055160; }
.badge-EM_COLETA   { background: #d1ecf1; color: #0c5460; }
.badge-EM_ENTREGA  { background: #cce5ff; color: #004085; }
.badge-ENTREGUE    { background: #d4edda; color: #155724; }
.badge-CANCELADA   { background: #f8d7da; color: #721c24; }
.badge-EM_ANALISE  { background: #fff3cd; color: #856404; }
.badge-APROVADO    { background: #d4edda; color: #155724; }
.badge-REPROVADO   { background: #f8d7da; color: #721c24; }
.badge-BLOQUEADO   { background: #d3d3d3; color: #333; }
.badge-PENDENTE    { background: #fff3cd; color: #856404; }
.badge-PAGO        { background: #d4edda; color: #155724; }

/* ── Botões ─────────────────────────── */
.btn-primary-serraf {
    background: var(--primary);
    color: #fff;
    border: none;
    padding: 10px 22px;
    border-radius: 10px;
    font-weight: 600;
    font-size: .9rem;
    cursor: pointer;
    transition: background .2s, transform .1s;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.btn-primary-serraf:hover { background: var(--primary-dark); color: #fff; transform: translateY(-1px); }
.btn-primary-serraf:active { transform: translateY(0); }

/* ── Tabelas ────────────────────────── */
.table-serraf { width: 100%; border-collapse: collapse; }
.table-serraf th {
    background: #f8f9fa;
    padding: 12px 16px;
    text-align: left;
    font-size: .82rem;
    font-weight: 700;
    color: var(--text-muted);
    letter-spacing: .5px;
    text-transform: uppercase;
    border-bottom: 2px solid var(--border);
}
.table-serraf td {
    padding: 14px 16px;
    border-bottom: 1px solid var(--border);
    font-size: .9rem;
    vertical-align: middle;
}
.table-serraf tr:last-child td { border-bottom: none; }
.table-serraf tr:hover td { background: #fafbfc; }

/* ── Alerts / Flash ─────────────────── */
.alert-serraf {
    padding: 14px 18px;
    border-radius: 10px;
    margin-bottom: 18px;
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: .9rem;
    font-weight: 500;
}
.alert-success { background: #d4edda; color: #155724; border-left: 4px solid var(--success); }
.alert-error   { background: #f8d7da; color: #721c24; border-left: 4px solid var(--danger); }
.alert-warning { background: #fff3cd; color: #856404; border-left: 4px solid var(--warning); }

/* ── Forms ──────────────────────────── */
.form-control-serraf {
    width: 100%;
    padding: 11px 14px;
    border: 1.5px solid var(--border);
    border-radius: 10px;
    font-size: .9rem;
    background: #fff;
    transition: border-color .2s, box-shadow .2s;
    color: var(--secondary);
}

.form-control-serraf:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37,99,235,.12);
}

.form-label { font-size: .875rem; font-weight: 600; margin-bottom: 6px; display: block; }

/* ── Responsive ─────────────────────── */
@media (max-width: 991px) {
    .sidebar {
        transform: translateX(-100%);
    }
    .sidebar.open {
        transform: translateX(0);
    }
    .main-wrapper {
        margin-left: 0;
    }
    .topbar .btn-sidebar-toggle {
        display: flex;
    }
    .sidebar-overlay {
        display: none;
        position: fixed;
        inset: 0;
        background: rgba(0,0,0,.5);
        z-index: 999;
    }
    .sidebar-overlay.show { display: block; }
}

@media (max-width: 576px) {
    .page-content { padding: 16px 14px; }
    .kpi-card { padding: 12px 10px; gap: 10px; }
    .kpi-icon { width: 40px; height: 40px; font-size: 1rem; border-radius: 10px; flex-shrink: 0; }
    .kpi-value { font-size: 1.3rem; }
    .kpi-label { font-size: .72rem; }
}

/* ── Corrida timeline ───────────────── */
.timeline { position: relative; padding-left: 28px; }
.timeline::before {
    content: '';
    position: absolute;
    left: 10px; top: 0; bottom: 0;
    width: 2px;
    background: var(--border);
}
.timeline-item { position: relative; margin-bottom: 20px; }
.timeline-dot {
    position: absolute;
    left: -24px;
    top: 4px;
    width: 14px; height: 14px;
    border-radius: 50%;
    background: var(--primary);
    border: 2px solid #fff;
    box-shadow: 0 0 0 2px var(--primary);
}
.timeline-time { font-size: .75rem; color: var(--text-muted); }
.timeline-title { font-weight: 600; font-size: .9rem; margin: 2px 0; }

/* ── Loader ─────────────────────────── */
.loading-spinner {
    display: inline-block;
    width: 18px; height: 18px;
    border: 2px solid rgba(255,255,255,.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin .6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── PWA install bar ────────────────── */
.pwa-install-bar {
    display: none;
    position: fixed;
    bottom: 0; left: 0; right: 0;
    background: var(--secondary);
    color: #fff;
    padding: 14px 20px;
    z-index: 9999;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 -4px 20px rgba(0,0,0,.2);
}
.pwa-install-bar.show { display: flex; }

/* ── Notif badge ────────────────────── */
.notif-badge {
    background: var(--danger);
    color: #fff;
    border-radius: 50%;
    width: 18px; height: 18px;
    font-size: 10px;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    position: absolute;
    top: -4px; right: -4px;
}
