/* ==========================================================================
   Tracking Gerobak Mie - Clean White / Light Theme Design System
   Theme: Modern Clean White + Warm Amber & Fresh Emerald Accents
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@300;400;500;600;700;800&family=JetBrains+Mono:wght@400;600&display=swap');

:root {
    --bg-main: #f8fafc;
    --bg-card: #ffffff;
    --bg-card-hover: #ffffff;
    --bg-elevated: #ffffff;
    --border-glass: rgba(0, 0, 0, 0.08);
    --border-glow: rgba(217, 119, 6, 0.25);

    --primary: #d97706;
    --primary-hover: #b45309;
    --primary-glow: rgba(217, 119, 6, 0.2);

    --accent-emerald: #059669;
    --accent-emerald-glow: rgba(5, 150, 105, 0.2);
    --accent-cyan: #0284c7;
    --accent-cyan-glow: rgba(2, 132, 199, 0.2);
    --accent-rose: #e11d48;
    --accent-rose-glow: rgba(225, 29, 72, 0.2);

    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-muted: #94a3b8;

    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-full: 9999px;

    --shadow-glass: 0 4px 20px -2px rgba(15, 23, 42, 0.06), 0 2px 6px -1px rgba(15, 23, 42, 0.04), 0 0 0 1px rgba(0, 0, 0, 0.06);
    --shadow-card: 0 4px 16px rgba(15, 23, 42, 0.06);
    --shadow-glow-emerald: 0 4px 18px rgba(5, 150, 105, 0.35);
    --shadow-glow-amber: 0 4px 18px rgba(217, 119, 6, 0.35);
    --shadow-glow-rose: 0 4px 18px rgba(225, 29, 72, 0.35);

    --transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

/* Reset & Basics */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html, body {
    height: 100%;
    font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background-color: var(--bg-main);
    color: var(--text-primary);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    overflow-x: hidden;
}

/* Subtle Warm Ambient Top Glow */
body::before {
    content: '';
    position: fixed;
    top: -15%;
    left: 25%;
    width: 50vw;
    height: 50vw;
    background: radial-gradient(circle, rgba(245, 158, 11, 0.05) 0%, rgba(16, 185, 129, 0.03) 40%, transparent 70%);
    z-index: -1;
    pointer-events: none;
}

/* Typography */
h1, h2, h3, h4, h5, h6 {
    font-weight: 700;
    letter-spacing: -0.02em;
    color: var(--text-primary);
}

a {
    color: var(--primary);
    text-decoration: none;
    transition: var(--transition);
}
a:hover {
    color: var(--primary-hover);
}

/* Utility Containers */
.app-container {
    max-width: 1440px;
    margin: 0 auto;
    padding: 1.5rem;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* White Card */
.glass-card {
    background: #ffffff;
    border: 1px solid rgba(0, 0, 0, 0.07);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-glass);
    padding: 1.5rem;
    transition: var(--transition);
    position: relative;
    overflow: hidden;
}

.glass-card:hover {
    box-shadow: 0 8px 26px -4px rgba(15, 23, 42, 0.09), 0 0 0 1px rgba(0, 0, 0, 0.09);
}

/* Top Navbar */
.app-navbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.875rem 1.5rem;
    background: #ffffff;
    border: 1px solid rgba(0, 0, 0, 0.08);
    border-radius: var(--radius-lg);
    margin-bottom: 1.5rem;
    box-shadow: 0 2px 12px rgba(15, 23, 42, 0.04);
}

.brand-wrapper {
    display: flex;
    align-items: center;
    gap: 0.875rem;
}

.brand-logo {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    object-fit: cover;
    box-shadow: 0 3px 10px rgba(217, 119, 6, 0.2);
    border: 1.5px solid rgba(217, 119, 6, 0.4);
}

.brand-title {
    font-size: 1.15rem;
    font-weight: 800;
    color: #1e293b;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.brand-subtitle {
    font-size: 0.75rem;
    color: var(--text-secondary);
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

.nav-user {
    display: flex;
    align-items: center;
    gap: 0.875rem;
}

.user-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.35rem 0.85rem;
    border-radius: var(--radius-full);
    background: #f1f5f9;
    border: 1px solid #e2e8f0;
    color: #1e293b;
    font-size: 0.85rem;
    font-weight: 600;
}

.role-tag {
    font-size: 0.7rem;
    padding: 0.2rem 0.55rem;
    border-radius: var(--radius-full);
    text-transform: uppercase;
    font-weight: 700;
    letter-spacing: 0.05em;
}

.role-tag.admin { background: #fef3c7; color: #b45309; border: 1px solid #fde68a; }
.role-tag.karyawan { background: #d1fae5; color: #047857; border: 1px solid #a7f3d0; }
.role-tag.pengunjung { background: #e0f2fe; color: #0369a1; border: 1px solid #bae6fd; }

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.7rem 1.3rem;
    font-size: 0.9rem;
    font-weight: 600;
    border-radius: var(--radius-md);
    border: none;
    cursor: pointer;
    transition: var(--transition);
    font-family: inherit;
    text-decoration: none;
    user-select: none;
}

.btn-primary {
    background: linear-gradient(135deg, #f59e0b, #d97706);
    color: #ffffff;
    box-shadow: var(--shadow-glow-amber);
}
.btn-primary:hover {
    background: linear-gradient(135deg, #d97706, #b45309);
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(217, 119, 6, 0.4);
    color: #ffffff;
}

.btn-success {
    background: linear-gradient(135deg, #10b981, #059669);
    color: #ffffff;
    box-shadow: var(--shadow-glow-emerald);
}
.btn-success:hover {
    background: linear-gradient(135deg, #059669, #047857);
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(5, 150, 105, 0.45);
}

.btn-danger {
    background: linear-gradient(135deg, #f43f5e, #e11d48);
    color: #ffffff;
    box-shadow: var(--shadow-glow-rose);
}
.btn-danger:hover {
    background: linear-gradient(135deg, #e11d48, #be123c);
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(225, 29, 72, 0.45);
}

.btn-outline {
    background: #ffffff;
    color: #334155;
    border: 1px solid #cbd5e1;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}
.btn-outline:hover {
    background: #f8fafc;
    border-color: #94a3b8;
    color: #0f172a;
}

.btn-sm {
    padding: 0.4rem 0.8rem;
    font-size: 0.825rem;
    border-radius: var(--radius-sm);
}

.btn-lg {
    padding: 1rem 1.8rem;
    font-size: 1.1rem;
    border-radius: var(--radius-md);
    font-weight: 700;
}

/* Pulsing Action Tracker Button */
.btn-tracking-start {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    color: #ffffff;
    box-shadow: var(--shadow-glow-emerald);
    width: 100%;
    position: relative;
    overflow: hidden;
}
.btn-tracking-start::after {
    content: '';
    position: absolute;
    top: 0; left: -100%;
    width: 60%; height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.35), transparent);
    animation: shimmer 2.5s infinite;
}

.btn-tracking-stop {
    background: linear-gradient(135deg, #f43f5e 0%, #e11d48 100%);
    color: #ffffff;
    box-shadow: var(--shadow-glow-rose);
    width: 100%;
}

@keyframes shimmer {
    0% { left: -100%; }
    100% { left: 200%; }
}

/* Pulse Radar Indicator */
.radar-pulse {
    position: relative;
    width: 16px;
    height: 16px;
    display: inline-block;
}
.radar-pulse-core {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    border-radius: 50%;
    background: #10b981;
}
.radar-pulse-wave {
    position: absolute;
    top: -6px; left: -6px; right: -6px; bottom: -6px;
    border-radius: 50%;
    border: 2px solid #10b981;
    animation: radarRipple 1.8s infinite cubic-bezier(0.2, 0.8, 0.4, 1);
    opacity: 0;
}
@keyframes radarRipple {
    0% { transform: scale(0.6); opacity: 1; }
    100% { transform: scale(2.2); opacity: 0; }
}

/* Metrics Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1.25rem;
    margin-bottom: 1.5rem;
}

.stat-card {
    padding: 1.25rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    background: #ffffff;
}

.stat-icon {
    width: 52px;
    height: 52px;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
}

.stat-icon.amber { background: #fef3c7; color: #d97706; border: 1px solid #fde68a; }
.stat-icon.emerald { background: #d1fae5; color: #059669; border: 1px solid #a7f3d0; }
.stat-icon.cyan { background: #e0f2fe; color: #0284c7; border: 1px solid #bae6fd; }
.stat-icon.rose { background: #ffe4e6; color: #e11d48; border: 1px solid #fecdd3; }

.stat-value {
    font-size: 1.75rem;
    font-weight: 800;
    line-height: 1.2;
    color: #0f172a;
}

.stat-label {
    font-size: 0.8rem;
    color: var(--text-secondary);
    font-weight: 500;
}

/* Map Containers */
.map-wrapper {
    position: relative;
    border-radius: var(--radius-lg);
    overflow: hidden;
    border: 1px solid rgba(0, 0, 0, 0.08);
    box-shadow: var(--shadow-glass);
    height: 550px;
    background: #f1f5f9;
}

#map {
    width: 100%;
    height: 100%;
    z-index: 1;
}

/* Map Overlay Controls */
.map-floating-panel {
    position: absolute;
    top: 1rem;
    right: 1rem;
    z-index: 999;
    background: rgba(255, 255, 255, 0.94);
    backdrop-filter: blur(12px);
    border: 1px solid rgba(0, 0, 0, 0.1);
    border-radius: var(--radius-md);
    padding: 0.65rem 1rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    box-shadow: 0 4px 18px rgba(0, 0, 0, 0.08);
    color: #0f172a;
}

/* Custom Marker Styling */
.custom-cart-marker {
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}
.marker-pin {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: linear-gradient(135deg, #f59e0b, #d97706);
    border: 3px solid #ffffff;
    box-shadow: 0 4px 16px rgba(217, 119, 6, 0.45);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
    cursor: pointer;
    transition: transform 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}
.marker-pin:hover {
    transform: scale(1.15) translateY(-4px);
}
.marker-pin.active {
    background: linear-gradient(135deg, #10b981, #059669);
    box-shadow: 0 4px 18px rgba(5, 150, 105, 0.5);
}
.marker-pin.inactive {
    background: linear-gradient(135deg, #94a3b8, #64748b);
    box-shadow: none;
    opacity: 0.75;
}
.marker-label {
    position: absolute;
    top: -26px;
    background: #ffffff;
    border: 1px solid rgba(0, 0, 0, 0.12);
    color: #0f172a;
    font-size: 0.72rem;
    font-weight: 700;
    padding: 0.15rem 0.5rem;
    border-radius: 6px;
    white-space: nowrap;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
    pointer-events: none;
}

/* Leaflet Clean White Popup Customization */
.leaflet-popup-content-wrapper {
    background: #ffffff !important;
    border: 1px solid rgba(0, 0, 0, 0.1) !important;
    border-radius: 14px !important;
    color: #0f172a !important;
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.12) !important;
    padding: 0.25rem !important;
}
.leaflet-popup-tip {
    background: #ffffff !important;
}
.leaflet-popup-content {
    margin: 12px 14px !important;
    line-height: 1.4 !important;
    color: #0f172a !important;
}

/* Forms & Inputs */
.form-group {
    margin-bottom: 1.25rem;
}
.form-label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: #334155;
}
.form-control {
    width: 100%;
    padding: 0.85rem 1.1rem;
    background: #ffffff;
    border: 1px solid #cbd5e1;
    border-radius: var(--radius-md);
    color: #0f172a;
    font-size: 0.95rem;
    font-family: inherit;
    transition: var(--transition);
}
.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(217, 119, 6, 0.15);
    background: #ffffff;
}
.form-control::placeholder {
    color: #94a3b8;
}

/* Tables */
.table-responsive {
    overflow-x: auto;
}
.custom-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}
.custom-table th {
    text-align: left;
    padding: 0.85rem 1rem;
    color: #475569;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    background: #f8fafc;
    border-bottom: 1px solid #e2e8f0;
}
.custom-table td {
    padding: 1rem;
    border-bottom: 1px solid #f1f5f9;
    vertical-align: middle;
    color: #1e293b;
}
.custom-table tr:hover td {
    background: #f8fafc;
}

/* Modals */
.modal-backdrop {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(15, 23, 42, 0.45);
    backdrop-filter: blur(6px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    opacity: 0;
    visibility: hidden;
    transition: all 0.25s ease;
    padding: 1rem;
}
.modal-backdrop.active {
    opacity: 1;
    visibility: visible;
}
.modal-window {
    background: #ffffff;
    border: 1px solid rgba(0, 0, 0, 0.08);
    border-radius: var(--radius-lg);
    box-shadow: 0 20px 45px -10px rgba(0, 0, 0, 0.15);
    width: 100%;
    max-width: 540px;
    transform: translateY(20px) scale(0.96);
    transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
    overflow: hidden;
}
.modal-backdrop.active .modal-window {
    transform: translateY(0) scale(1);
}
.modal-header {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid #f1f5f9;
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.modal-body {
    padding: 1.5rem;
    max-height: 75vh;
    overflow-y: auto;
}
.modal-footer {
    padding: 1.25rem 1.5rem;
    border-top: 1px solid #f1f5f9;
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
    background: #f8fafc;
}

/* Toast Notifications */
.toast-container {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    z-index: 99999;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    pointer-events: none;
}
.toast-box {
    pointer-events: auto;
    background: #ffffff;
    border: 1px solid rgba(0, 0, 0, 0.08);
    border-radius: var(--radius-md);
    padding: 0.85rem 1.25rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.09);
    font-size: 0.9rem;
    font-weight: 500;
    min-width: 280px;
    max-width: 400px;
    color: #0f172a;
    animation: toastSlideIn 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}
@keyframes toastSlideIn {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}
.toast-box.success { border-left: 4px solid var(--accent-emerald); }
.toast-box.error { border-left: 4px solid var(--accent-rose); }
.toast-box.info { border-left: 4px solid var(--accent-cyan); }
.toast-box.warning { border-left: 4px solid var(--primary); }

/* Telemetry Dashboard (Karyawan) */
.telemetry-card {
    background: #ffffff;
    border: 1px solid rgba(0, 0, 0, 0.08);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
}
.telemetry-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
    margin-top: 1rem;
}
.telemetry-item {
    background: #f8fafc;
    padding: 0.85rem;
    border-radius: var(--radius-md);
    border: 1px solid #e2e8f0;
}
.telemetry-val {
    font-family: 'JetBrains Mono', monospace;
    font-size: 1.25rem;
    font-weight: 700;
    color: #0284c7;
}

/* Offline Sync Queue Banner */
.offline-sync-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.4rem 0.85rem;
    border-radius: var(--radius-full);
    background: #fffbeb;
    border: 1px solid #fde68a;
    color: #b45309;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
}

/* Tabs */
.tabs-nav {
    display: flex;
    gap: 0.5rem;
    border-bottom: 1px solid #e2e8f0;
    margin-bottom: 1.5rem;
}
.tab-btn {
    padding: 0.75rem 1.25rem;
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    color: #64748b;
    font-weight: 600;
    font-size: 0.95rem;
    cursor: pointer;
    transition: var(--transition);
}
.tab-btn:hover {
    color: #0f172a;
}
.tab-btn.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
}

/* Playback bar in Admin */
.playback-bar {
    display: flex;
    align-items: center;
    gap: 1rem;
    background: #f8fafc;
    padding: 0.75rem 1rem;
    border-radius: var(--radius-md);
    border: 1px solid #e2e8f0;
    margin-top: 0.75rem;
}

/* Permission notice box */
.permission-notice-box {
    background: #fffbeb;
    border: 1px solid #fde68a;
    border-radius: var(--radius-md);
    padding: 1rem;
    margin-bottom: 1.25rem;
    display: flex;
    gap: 0.75rem;
    align-items: flex-start;
    color: #92400e;
}

/* Responsive */
@media (max-width: 768px) {
    .app-container {
        padding: 0.75rem;
    }
    .app-navbar {
        padding: 0.75rem 1rem;
        flex-direction: column;
        gap: 0.75rem;
        align-items: stretch;
    }
    .nav-user {
        justify-content: space-between;
    }
    .stats-grid {
        grid-template-columns: 1fr 1fr;
    }
    .map-wrapper {
        height: 420px;
    }
}
