/* ============================================================
   AUROTRACKER - styles.css
   ============================================================ */

:root {
    --primary: #0A2E52;
    --accent: #00BCD4;
    --accent2: #7C3AED;
    --warning: #F59E0B;
    --success: #10B981;
    --danger: #EF4444;
    --bg-light: #F0F4F8;
    --surface: #FFFFFF;
    --text-main: #1E293B;
    --text-muted: #64748B;
    --border: #E2E8F0;
}

* { box-sizing: border-box; }

body {
    font-family: 'Plus Jakarta Sans', sans-serif;
    background-color: var(--bg-light);
    color: var(--text-main);
    margin: 0;
}

/* SCROLLBAR */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: #f1f5f9; }
::-webkit-scrollbar-thumb { background: #CBD5E1; border-radius: 10px; }

.font-mono { font-family: 'DM Mono', monospace; }

/* NAV */
.navbar {
    background: rgba(255,255,255,0.9);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border);
    position: sticky; top: 0; z-index: 50;
}

/* BRAND */
.brand-logo {
    background: linear-gradient(135deg, var(--primary) 0%, #1a4a7a 100%);
    border-radius: 12px;
    padding: 8px 10px;
    display: flex; align-items: center; justify-content: center;
}

/* HERO GRADIENT */
.hero-bg {
    background: linear-gradient(135deg, #0A2E52 0%, #0f4a7c 50%, #1a6ba8 100%);
    position: relative;
    overflow: hidden;
}
.hero-bg::before {
    content: '';
    position: absolute; inset: 0;
    pointer-events: none;
    background: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23ffffff' fill-opacity='0.03'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
}

/* SEARCH INPUT */
.search-wrapper {
    background: white;
    border-radius: 18px;
    padding: 6px 6px 6px 20px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.15);
    border: 1px solid rgba(255,255,255,0.2);
    display: flex; align-items: center; gap: 12px;
}
.search-wrapper input {
    flex: 1; min-width: 0; border: none; outline: none;
    font-size: 15px; font-family: 'Plus Jakarta Sans', sans-serif;
    font-weight: 500; color: var(--text-main);
    background: transparent;
}
.search-wrapper input::placeholder { color: #94A3B8; }
.search-wrapper:focus-within {
    outline: 3px solid rgba(6, 182, 212, 0.45);
    outline-offset: 3px;
}
.btn-search {
    background: linear-gradient(135deg, var(--primary), #1a4a7a);
    color: white; border: none; cursor: pointer;
    padding: 14px 28px; border-radius: 12px;
    font-family: 'Plus Jakarta Sans', sans-serif;
    font-weight: 700; font-size: 14px; letter-spacing: 0.3px;
    transition: all 0.2s; box-shadow: 0 4px 15px rgba(10,46,82,0.4);
    white-space: nowrap;
}
.btn-search:hover { transform: translateY(-1px); box-shadow: 0 6px 20px rgba(10,46,82,0.5); }
.btn-search:active { transform: scale(0.97); }

@media (max-width: 420px) {
    .hero-bg { padding-top: 1rem; padding-bottom: 1.25rem; }
    .hero-bg > .max-w-4xl { margin-bottom: 1rem; }
    .hero-bg h2 { font-size: 1.5rem; margin-bottom: 0.5rem; }
    .hero-bg h2 + span { padding: 0.375rem 0.625rem; margin-bottom: 0.5rem; font-size: 0.625rem; }
    .hero-bg h1 { font-size: 1.625rem; line-height: 1.12; margin-bottom: 0.5rem; }
    .hero-bg h1 + p { font-size: 0.875rem; line-height: 1.35; }
    .search-wrapper { gap: 6px; padding-left: 12px; }
    .search-wrapper input { font-size: 14px; }
    .btn-search { padding: 12px 14px; }
}

/* CARDS */
.card {
    background: white;
    border-radius: 20px;
    border: 1px solid var(--border);
    box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}
.card-lg {
    background: white;
    border-radius: 24px;
    border: 1px solid var(--border);
    box-shadow: 0 4px 20px rgba(0,0,0,0.06);
}

/* HIDDEN SECTIONS */
.hidden-section { display: none !important; }

/* TRUCK ANIMATION */
.truck-track {
    height: 5px;
    background: #E2E8F0;
    border-radius: 3px;
    position: relative;
}
.truck-progress {
    height: 100%;
    background: linear-gradient(90deg, var(--accent), var(--accent2));
    border-radius: 3px;
    transition: width 1.5s cubic-bezier(0.4, 0, 0.2, 1);
}
.truck-icon {
    position: absolute;
    top: -14px;
    transition: left 1.5s cubic-bezier(0.4, 0, 0.2, 1);
    font-size: 24px;
    color: var(--primary);
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.15));
}
.step-node { transition: all 0.3s ease; }
.step-active .step-circle {
    background: linear-gradient(135deg, var(--accent), var(--accent2)) !important;
    border-color: transparent !important;
    color: white !important;
    box-shadow: 0 4px 15px rgba(0,188,212,0.4);
}
.step-active .step-label { color: var(--accent) !important; font-weight: 700; }

/* BADGE STATUS */
.badge-transito { background: #DBEAFE; color: #1D4ED8; }
.badge-entregado { background: #D1FAE5; color: #065F46; }
.badge-despacho { background: #FEF3C7; color: #92400E; }
.badge-alerta { background: #FEE2E2; color: #991B1B; }
.badge-porempacar { background: #EDE9FE; color: #6D28D9; }
.badge-empaque { background: #E0E7FF; color: #4338CA; }
.badge-devuelto { background: #FFEDD5; color: #C2410C; }
.badge-cancelado { background: #F1F5F9; color: #475569; }

/* ADMIN SIDEBAR */
.sidebar {
    background: linear-gradient(180deg, #0A2E52 0%, #0d3d6e 100%);
    width: 250px;
    flex-shrink: 0;
}
.sidebar-link {
    display: flex; align-items: center; gap: 10px;
    padding: 10px 14px; border-radius: 12px;
    color: #94A3B8; font-size: 13px; font-weight: 600;
    cursor: pointer; text-decoration: none;
    transition: all 0.2s; border: none; background: transparent;
    width: 100%;
}
.sidebar-link:hover { background: rgba(255,255,255,0.08); color: white; }
.sidebar-link.active { background: rgba(0,188,212,0.2); color: var(--accent); }
.sidebar-link i { width: 18px; text-align: center; }

/* KPI CARDS */
.kpi-card { position: relative; overflow: hidden; }
.kpi-card::after {
    content: '';
    position: absolute; bottom: -20px; right: -20px;
    width: 80px; height: 80px;
    border-radius: 50%;
    opacity: 0.06;
}

/* TOAST NOTIFICATION */
#toast {
    position: fixed; top: 80px; right: 20px; z-index: 9999;
    min-width: 300px; padding: 16px 20px;
    border-radius: 14px; font-size: 14px; font-weight: 600;
    box-shadow: 0 10px 40px rgba(0,0,0,0.15);
    transform: translateX(120%); transition: transform 0.3s ease;
}
#toast.show { transform: translateX(0); }
#toast.success { background: #D1FAE5; color: #065F46; border-left: 4px solid #10B981; }
#toast.error { background: #FEE2E2; color: #991B1B; border-left: 4px solid #EF4444; }
#toast.info { background: #DBEAFE; color: #1E40AF; border-left: 4px solid #3B82F6; }

/* MODAL */
.modal-overlay {
    position: fixed; inset: 0; background: rgba(0,0,0,0.5);
    z-index: 200; display: flex; align-items: center; justify-content: center;
    backdrop-filter: blur(4px);
}
.modal-box {
    background: white; border-radius: 24px; padding: 32px;
    width: 90%; max-width: 560px; max-height: 90vh; overflow-y: auto;
    box-shadow: 0 25px 80px rgba(0,0,0,0.25);
}

/* FORM INPUTS */
.form-input {
    width: 100%; padding: 10px 14px; border-radius: 10px;
    border: 1.5px solid var(--border); font-family: 'Plus Jakarta Sans', sans-serif;
    font-size: 13px; outline: none; transition: border-color 0.2s;
    background: #F8FAFC;
}
.form-input:focus { border-color: var(--accent); background: white; }
.form-label { font-size: 11px; font-weight: 700; text-transform: uppercase; color: #64748B; margin-bottom: 5px; display: block; letter-spacing: 0.5px; }

/* LOADING SPINNER */
.spinner {
    width: 20px; height: 20px; border: 2.5px solid rgba(255,255,255,0.3);
    border-top-color: white; border-radius: 50%;
    animation: spin 0.7s linear infinite; display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* CHATBOT */
#chat-box {
    transform: translateY(16px) scale(0.95);
    opacity: 0;
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    pointer-events: none;
}
#chat-box.open {
    transform: translateY(0) scale(1);
    opacity: 1;
    pointer-events: all;
}
.chat-btn-float {
    width: 56px; height: 56px;
    background: linear-gradient(135deg, var(--primary), #1a4a7a);
    border-radius: 50%; border: none; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    color: white; font-size: 20px;
    box-shadow: 0 8px 25px rgba(10,46,82,0.4);
    transition: transform 0.2s;
}
.chat-btn-float:hover { transform: scale(1.1); }

@media (max-width: 420px) {
    #chat-container { left: 12px; right: 12px; bottom: 12px; }
    #chat-box { width: 100%; max-width: none; height: min(460px, calc(100vh - 96px)) !important; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        scroll-behavior: auto !important;
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* DB STATUS */
#db-status { transition: all 0.3s; }

@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}
.animate-in { animation: fadeInUp 0.4s ease both; }

/* MOBILE NAV */
#mobile-menu { display: none; }
#mobile-menu.open { display: flex; flex-direction: column; }

/* CHART GRANULARITY TOGGLE */
.chart-btn {
    padding: 4px 12px;
    border-radius: 999px;
    border: 1.5px solid var(--border);
    background: white;
    color: #64748B;
    font-size: 11px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s;
}
.chart-btn:hover { border-color: var(--accent); color: var(--accent); }
.chart-btn-active { background: var(--primary); color: white; border-color: var(--primary); }
.chart-btn-active:hover { color: white; }

/* DASHBOARD PERIOD FILTER */
.period-btn {
    padding: 6px 16px;
    border-radius: 999px;
    border: 1.5px solid var(--border);
    background: white;
    color: #475569;
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s;
}
.period-btn:hover { border-color: var(--accent); color: var(--accent); }
.period-btn-active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}
.period-btn-active:hover { color: white; }

/* MOBILE ADMIN TABS */
.mobile-tab {
    white-space: nowrap;
    padding: 8px 14px;
    border-radius: 999px;
    border: 1.5px solid var(--border);
    background: white;
    color: #475569;
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
    flex-shrink: 0;
    transition: all 0.2s;
}
.mobile-tab-active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

/* PAGINATION */
.page-btn { padding: 6px 12px; border-radius: 8px; border: 1.5px solid var(--border); font-size: 12px; font-weight: 600; cursor: pointer; background: white; transition: all 0.2s; }
.page-btn:hover { background: var(--primary); color: white; border-color: var(--primary); }
.page-btn.active { background: var(--primary); color: white; border-color: var(--primary); }

/* ACTION BUTTONS in tables */
.action-btn {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    border: none;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    transition: background 0.2s, color 0.2s, transform 0.1s;
}
.action-btn:active { transform: scale(0.93); }
.action-btn-eye  { background: #ecfeff; color: #0891b2; }
.action-btn-eye:hover  { background: #0891b2; color: white; }
.action-btn-edit  { background: #f1f5f9; color: #475569; }
.action-btn-edit:hover  { background: #0891b2; color: white; }
.action-btn-bell  { background: #fff7ed; color: #ea580c; }
.action-btn-bell:hover  { background: #ea580c; color: white; }
.action-btn-trash { background: #f1f5f9; color: #475569; }
.action-btn-trash:hover { background: #ef4444; color: white; }

.logout-button {
    background: rgba(239, 68, 68, 0.15);
    color: #FC8181;
}
.logout-button:hover,
.logout-button:focus-visible {
    background: rgba(239, 68, 68, 0.3);
}

/* RÓTULOS DE EMPAQUE: etiqueta térmica 100 × 50 mm */
#print-area { display: none; }
.rotulo {
    box-sizing: border-box;
    width: 100mm;
    height: 50mm;
    background: #fff;
    color: #000;
    font-family: 'Plus Jakarta Sans', sans-serif;
    display: flex;
    overflow: hidden;
}
.rotulo-sidebar {
    flex-shrink: 0;
    width: 28mm;
    background: #000;
    color: #fff;
    position: relative;
    overflow: hidden;
    line-height: 1;
}
.rotulo-sidebar-bg {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    display: block;
}
.rotulo-sidebar-content {
    box-sizing: border-box;
    position: relative;
    z-index: 1;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2mm;
    padding: 2mm 1.5mm;
}
.rotulo-logo { width: 24mm; height: auto; display: block; }
.rotulo-logo-fallback { font-size: 12pt; font-weight: 800; color: #fff; }
.rotulo-sidebar .cap { font-size: 7pt; font-weight: 700; letter-spacing: .14em; color: #cbd5e1; }
.rotulo-sidebar .big { font-size: 30pt; font-weight: 900; color: #fff; font-variant-numeric: tabular-nums; }
.rotulo-main { flex: 1; min-width: 0; padding: 3mm 4mm; display: flex; flex-direction: column; }
.rotulo-number { font-family: 'DM Mono', monospace; font-size: 17pt; font-weight: 800; color: #000; }
.rotulo-client {
    font-size: 13pt;
    font-weight: 800;
    line-height: 1.06;
    margin-top: 1mm;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
    overflow-wrap: anywhere;
}
.rotulo-city { font-size: 9pt; font-weight: 600; line-height: 1.2; margin-top: .5mm; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rotulo-meta { font-size: 9pt; margin-top: auto; line-height: 1.25; }
.rotulo-meta b { font-weight: 700; }
.rotulo-barcode { margin-top: 1.5mm; text-align: center; }
.rotulo-barcode svg { display: block; width: 100%; height: 11mm; }
.rotulo-code-fallback { font-size: 9pt; }

@media print {
    @page { size: 100mm 50mm; margin: 0; }
    body * { visibility: hidden; }
    #print-area, #print-area * { visibility: visible; }
    #print-area { display: block; position: absolute; inset: 0; }
    .rotulo, .rotulo-sidebar, .rotulo-sidebar-bg, .rotulo-sidebar-content {
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }
    .rotulo { page-break-after: always; break-after: page; }
    .rotulo:last-child { page-break-after: auto; break-after: auto; }
}
