/* ============================================
   HotwheelHunter — Premium Dark Mode UI
   ============================================ */

/* === CSS Variables / Design Tokens === */
:root {
    /* Colors */
    --bg-primary: #0a0e1a;
    --bg-secondary: #111827;
    --bg-tertiary: #1a2035;
    --bg-card: rgba(17, 24, 39, 0.85);
    --bg-glass: rgba(17, 24, 39, 0.65);
    --bg-hover: rgba(99, 102, 241, 0.1);
    --bg-active: rgba(99, 102, 241, 0.15);
    
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --text-accent: #818cf8;
    
    --accent: #6366f1;
    --accent-light: #818cf8;
    --accent-glow: rgba(99, 102, 241, 0.4);
    --accent-gradient: linear-gradient(135deg, #6366f1, #8b5cf6, #a78bfa);
    
    --success: #22c55e;
    --success-bg: rgba(34, 197, 94, 0.15);
    --warning: #f59e0b;
    --warning-bg: rgba(245, 158, 11, 0.15);
    --danger: #ef4444;
    --danger-bg: rgba(239, 68, 68, 0.15);
    --info: #3b82f6;
    
    /* Category colors */
    --cat-indomaret: #ef4444;
    --cat-alfamart: #3b82f6;
    --cat-alfamidi: #f59e0b;
    --cat-toko-toys: #ec4899;
    --cat-custom: #a855f7;
    
    /* Borders */
    --border-color: rgba(148, 163, 184, 0.1);
    --border-accent: rgba(99, 102, 241, 0.3);
    
    /* Shadows */
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.3);
    --shadow-md: 0 4px 16px rgba(0,0,0,0.4);
    --shadow-lg: 0 8px 32px rgba(0,0,0,0.5);
    --shadow-glow: 0 0 20px var(--accent-glow);
    
    /* Glass effect */
    --glass-bg: rgba(17, 24, 39, 0.75);
    --glass-border: rgba(148, 163, 184, 0.08);
    --glass-blur: 16px;
    
    /* Dimensions */
    --topbar-height: 60px;
    --sidebar-width: 380px;
    --border-radius: 12px;
    --border-radius-sm: 8px;
    --border-radius-xs: 6px;
    
    /* Transitions */
    --transition-fast: 0.15s ease;
    --transition-normal: 0.25s ease;
    --transition-smooth: 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

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

html, body {
    height: 100%;
    overflow: hidden;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    font-size: 14px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 {
    font-weight: 700;
    letter-spacing: -0.02em;
}

a {
    color: var(--accent-light);
    text-decoration: none;
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 6px;
}
::-webkit-scrollbar-track {
    background: transparent;
}
::-webkit-scrollbar-thumb {
    background: rgba(148, 163, 184, 0.2);
    border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
    background: rgba(148, 163, 184, 0.35);
}

/* ============================================
   TOP BAR
   ============================================ */
#topbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--topbar-height);
    background: var(--glass-bg);
    backdrop-filter: blur(var(--glass-blur));
    -webkit-backdrop-filter: blur(var(--glass-blur));
    border-bottom: 1px solid var(--glass-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    z-index: 1000;
    gap: 12px;
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.logo {
    display: flex;
    align-items: center;
    gap: 8px;
}

.logo-icon {
    font-size: 24px;
}

.logo h1 {
    font-size: 18px;
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.topbar-center {
    flex: 1;
    max-width: 400px;
}

.search-box {
    position: relative;
    width: 100%;
}

.search-box i {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    width: 16px;
    height: 16px;
    color: var(--text-muted);
}

.search-box input {
    width: 100%;
    padding: 8px 12px 8px 36px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 999px;
    color: var(--text-primary);
    font-size: 13px;
    font-family: inherit;
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.search-box input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

.search-box input::placeholder {
    color: var(--text-muted);
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.stats-pill {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    background: var(--success-bg);
    border: 1px solid rgba(34, 197, 94, 0.2);
    border-radius: 999px;
    font-size: 13px;
    font-weight: 600;
    color: var(--success);
}

.stats-pill i {
    width: 14px;
    height: 14px;
}

/* Buttons */
.icon-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-sm);
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.icon-btn:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
    border-color: var(--border-accent);
}

.icon-btn.accent {
    background: var(--accent);
    color: white;
    border-color: var(--accent);
}

.icon-btn.accent:hover {
    background: var(--accent-light);
    box-shadow: var(--shadow-glow);
}

.icon-btn i {
    width: 18px;
    height: 18px;
}

.btn-primary {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 20px;
    background: var(--accent-gradient);
    color: white;
    border: none;
    border-radius: var(--border-radius-sm);
    font-size: 13px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.btn-primary:hover {
    box-shadow: var(--shadow-glow);
    transform: translateY(-1px);
}

.btn-primary:active {
    transform: translateY(0);
}

.btn-primary i {
    width: 16px;
    height: 16px;
}

.btn-secondary {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 20px;
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-sm);
    font-size: 13px;
    font-weight: 500;
    font-family: inherit;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.btn-secondary:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
    border-color: var(--border-accent);
}

.btn-secondary i {
    width: 16px;
    height: 16px;
}

.btn-sm {
    padding: 6px 14px;
    font-size: 12px;
}

.btn-danger {
    background: var(--danger);
    color: white;
    border-color: var(--danger);
}
.btn-danger:hover {
    background: #dc2626;
}

.btn-success {
    background: var(--success);
    color: white;
    border: none;
    border-radius: var(--border-radius-sm);
    padding: 8px 16px;
    font-size: 13px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: all var(--transition-fast);
}
.btn-success:hover {
    background: #16a34a;
    box-shadow: 0 0 16px rgba(34,197,94,0.3);
}
.btn-success i {
    width: 16px;
    height: 16px;
}

/* ============================================
   MAIN CONTAINER
   ============================================ */
#main-container {
    display: flex;
    height: calc(100vh - var(--topbar-height));
    margin-top: var(--topbar-height);
}

/* ============================================
   SIDEBAR
   ============================================ */
#sidebar {
    width: var(--sidebar-width);
    min-width: var(--sidebar-width);
    height: 100%;
    background: var(--bg-secondary);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    transition: margin-left var(--transition-smooth), opacity var(--transition-smooth);
    z-index: 100;
    overflow: hidden;
}

#sidebar.closed {
    margin-left: calc(-1 * var(--sidebar-width));
    opacity: 0;
    pointer-events: none;
}

.sidebar-tabs {
    display: flex;
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0;
}

.tab-btn {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: 12px 4px 10px;
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    color: var(--text-muted);
    font-size: 10px;
    font-family: inherit;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.tab-btn i {
    width: 18px;
    height: 18px;
}

.tab-btn:hover {
    color: var(--text-secondary);
    background: var(--bg-hover);
}

.tab-btn.active {
    color: var(--accent-light);
    border-bottom-color: var(--accent);
}

.tab-content {
    display: none;
    flex-direction: column;
    flex: 1;
    overflow: hidden;
}

.tab-content.active {
    display: flex;
}

.tab-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 16px 12px;
    flex-shrink: 0;
}

.tab-header h2 {
    font-size: 16px;
    color: var(--text-primary);
}

.date-badge {
    font-size: 12px;
    color: var(--accent-light);
    background: rgba(99,102,241,0.1);
    padding: 4px 10px;
    border-radius: 999px;
    font-weight: 500;
}

.filter-bar {
    padding: 0 16px 12px;
    flex-shrink: 0;
}

.filter-bar select {
    width: 100%;
}

.scrollable-list {
    flex: 1;
    overflow-y: auto;
    padding: 0 12px 16px;
}

/* ============================================
   STORE CARDS
   ============================================ */
.store-card {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    padding: 14px;
    margin-bottom: 8px;
    cursor: pointer;
    transition: all var(--transition-fast);
    position: relative;
    overflow: hidden;
}

.store-card::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 4px;
    background: var(--card-accent, var(--accent));
    border-radius: 4px 0 0 4px;
}

.store-card:hover {
    border-color: var(--border-accent);
    transform: translateX(2px);
    box-shadow: var(--shadow-sm);
}

.store-card-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 6px;
}

.store-card-name {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    line-height: 1.3;
}

.store-card-category {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 2px 8px;
    border-radius: 999px;
    white-space: nowrap;
}

.cat-indomaret { background: rgba(239,68,68,0.15); color: #fca5a5; }
.cat-alfamart { background: rgba(59,130,246,0.15); color: #93c5fd; }
.cat-alfamidi { background: rgba(245,158,11,0.15); color: #fcd34d; }
.cat-toko_toys { background: rgba(236,72,153,0.15); color: #f9a8d4; }
.cat-custom { background: rgba(168,85,247,0.15); color: #c4b5fd; }

.store-card-address {
    font-size: 12px;
    color: var(--text-muted);
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 4px;
}

.store-card-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.visit-badge {
    font-size: 11px;
    font-weight: 500;
    padding: 3px 10px;
    border-radius: 999px;
}

.visit-badge.visited {
    background: var(--success-bg);
    color: var(--success);
}

.visit-badge.not-visited {
    background: var(--danger-bg);
    color: #fca5a5;
}

.store-card-actions {
    display: flex;
    gap: 4px;
}

.store-card-actions button {
    width: 30px;
    height: 30px;
    border-radius: var(--border-radius-xs);
    font-size: 12px;
}

.store-card-actions button i {
    width: 14px;
    height: 14px;
}

/* ============================================
   TODAY'S VISITS
   ============================================ */
.today-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    padding: 0 16px 16px;
    flex-shrink: 0;
}

.stat-card {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-sm);
    padding: 12px;
    text-align: center;
}

.stat-number {
    font-size: 24px;
    font-weight: 800;
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.stat-label {
    font-size: 11px;
    color: var(--text-muted);
    font-weight: 500;
    margin-top: 2px;
}

.visit-timeline-item {
    display: flex;
    gap: 12px;
    padding: 12px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    margin-bottom: 8px;
    transition: all var(--transition-fast);
    cursor: pointer;
}

.visit-timeline-item:hover {
    border-color: var(--border-accent);
}

.visit-order {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--accent-gradient);
    color: white;
    font-size: 14px;
    font-weight: 700;
    flex-shrink: 0;
}

.visit-timeline-info {
    flex: 1;
    min-width: 0;
}

.visit-timeline-name {
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 2px;
}

.visit-timeline-time {
    font-size: 11px;
    color: var(--text-muted);
}

.visit-timeline-meta {
    display: flex;
    gap: 6px;
    margin-top: 6px;
    flex-wrap: wrap;
}

.meta-tag {
    font-size: 10px;
    padding: 2px 6px;
    border-radius: 4px;
    background: var(--bg-secondary);
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
}

/* ============================================
   ROUTE PANEL
   ============================================ */
.route-info-panel {
    padding: 0 16px 16px;
    flex-shrink: 0;
}

.route-summary {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
    margin-bottom: 12px;
}

.route-stat {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 12px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-sm);
    font-size: 12px;
    font-weight: 500;
    color: var(--text-secondary);
}

.route-stat i {
    width: 14px;
    height: 14px;
    color: var(--accent-light);
}

.route-step {
    display: flex;
    gap: 12px;
    padding: 12px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    margin-bottom: 8px;
    cursor: pointer;
    transition: all var(--transition-fast);
    position: relative;
}

.route-step:hover {
    border-color: var(--accent);
    transform: translateX(2px);
}

.route-step.visited {
    border-color: rgba(34, 197, 94, 0.3);
    background: rgba(34, 197, 94, 0.04);
}

.route-step.visited:hover {
    border-color: var(--success);
}

.route-step-number {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--accent-gradient);
    color: white;
    font-size: 12px;
    font-weight: 700;
    flex-shrink: 0;
}

.route-step-info {
    flex: 1;
    min-width: 0;
}

.route-step-name {
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 4px;
}

.route-step-details {
    display: flex;
    gap: 12px;
    font-size: 11px;
    color: var(--text-muted);
}

/* ============================================
   HISTORY
   ============================================ */
.history-controls {
    display: flex;
    gap: 8px;
    padding: 0 16px 12px;
    flex-shrink: 0;
}

.history-controls input,
.history-controls select {
    flex: 1;
}

.history-item {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    padding: 14px;
    margin-bottom: 8px;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.history-item:hover {
    border-color: var(--border-accent);
}

.history-item-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 6px;
}

.history-item-store {
    font-weight: 600;
    font-size: 13px;
}

.history-item-date {
    font-size: 11px;
    color: var(--text-muted);
}

.history-item-desc {
    font-size: 12px;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.history-item-tags {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
}

/* ============================================
   MAP
   ============================================ */
#map-container {
    flex: 1;
    position: relative;
    overflow: hidden;
}

#map {
    width: 100%;
    height: 100%;
}

/* Map Controls */
.map-control {
    position: absolute;
    z-index: 500;
}

#map-layer-toggle {
    top: 20px;
    right: 20px;
    display: flex;
    gap: 2px;
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
    border-radius: var(--border-radius-sm);
    padding: 3px;
    z-index: 1000;
}

.layer-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border: none;
    border-radius: var(--border-radius-xs);
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.layer-btn:hover {
    color: var(--text-primary);
    background: var(--bg-hover);
}

.layer-btn.active {
    background: var(--accent);
    color: white;
}

.layer-btn i {
    width: 18px;
    height: 18px;
}

/* Custom Leaflet Popup */
.leaflet-popup-content-wrapper {
    background: var(--bg-secondary) !important;
    color: var(--text-primary) !important;
    border: 1px solid var(--border-color) !important;
    border-radius: var(--border-radius) !important;
    box-shadow: var(--shadow-lg) !important;
    padding: 0 !important;
}

.leaflet-popup-content {
    margin: 0 !important;
    font-family: 'Inter', sans-serif !important;
    font-size: 13px !important;
    line-height: 1.5 !important;
    min-width: 220px !important;
}

.leaflet-popup-tip {
    background: var(--bg-secondary) !important;
    border: 1px solid var(--border-color) !important;
    box-shadow: none !important;
}

.popup-content {
    padding: 16px;
}

.popup-title {
    font-size: 15px;
    font-weight: 700;
    margin-bottom: 4px;
}

.popup-category {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 8px;
    display: inline-block;
    padding: 2px 8px;
    border-radius: 999px;
    font-weight: 600;
}

.popup-address {
    font-size: 12px;
    color: var(--text-muted);
    margin-bottom: 10px;
}

.popup-stats {
    display: flex;
    gap: 12px;
    margin-bottom: 12px;
    font-size: 12px;
    color: var(--text-secondary);
}

.popup-actions {
    display: flex;
    gap: 6px;
}

.popup-actions button {
    flex: 1;
    padding: 8px 12px;
    font-size: 12px;
}

/* Custom Marker Icons */
.custom-marker {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 50% 50% 50% 0;
    transform: rotate(-45deg);
    border: 3px solid white;
    box-shadow: 0 2px 8px rgba(0,0,0,0.4);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.custom-marker:hover {
    transform: rotate(-45deg) scale(1.15);
    box-shadow: 0 4px 16px rgba(0,0,0,0.5);
}

.custom-marker-inner {
    transform: rotate(45deg);
    font-size: 14px;
    line-height: 1;
}

.custom-marker.visited {
    border-color: var(--success);
    box-shadow: 0 0 12px rgba(34,197,94,0.4);
}

.custom-marker.pulse {
    animation: markerPulse 2s infinite;
}

@keyframes markerPulse {
    0% { box-shadow: 0 0 0 0 rgba(99,102,241,0.4); }
    70% { box-shadow: 0 0 0 12px rgba(99,102,241,0); }
    100% { box-shadow: 0 0 0 0 rgba(99,102,241,0); }
}

/* User location marker */
.user-location-marker {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--accent);
    border: 3px solid white;
    box-shadow: 0 0 0 4px var(--accent-glow), 0 2px 8px rgba(0,0,0,0.3);
    animation: locationPulse 2s infinite;
}

@keyframes locationPulse {
    0% { box-shadow: 0 0 0 4px rgba(99,102,241,0.3), 0 2px 8px rgba(0,0,0,0.3); }
    50% { box-shadow: 0 0 0 12px rgba(99,102,241,0), 0 2px 8px rgba(0,0,0,0.3); }
    100% { box-shadow: 0 0 0 4px rgba(99,102,241,0.3), 0 2px 8px rgba(0,0,0,0.3); }
}

/* Leaflet cluster overrides */
.marker-cluster-small, 
.marker-cluster-medium, 
.marker-cluster-large {
    background: rgba(99,102,241,0.3) !important;
}

.marker-cluster-small div, 
.marker-cluster-medium div, 
.marker-cluster-large div {
    background: var(--accent) !important;
    color: white !important;
    font-family: 'Inter', sans-serif !important;
    font-weight: 700 !important;
}

/* ============================================
   MODALS
   ============================================ */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    padding: 20px;
    animation: fadeIn 0.2s ease;
}

.modal-overlay.open {
    display: flex;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.modal {
    width: 100%;
    max-width: 480px;
    max-height: 90vh;
    overflow-y: auto;
    animation: slideUp 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.modal-lg {
    max-width: 500px;
}

@keyframes slideUp {
    from { opacity: 0; transform: translateY(20px) scale(0.97); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

.glass-card {
    background: var(--glass-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--glass-border);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-lg);
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 20px 0;
}

.modal-header h3 {
    font-size: 18px;
}

.modal-body {
    padding: 20px;
}

.modal-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px solid var(--border-color);
}

/* ============================================
   FORMS
   ============================================ */
.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.input-field {
    width: 100%;
    padding: 10px 14px;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-sm);
    color: var(--text-primary);
    font-size: 13px;
    font-family: inherit;
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.input-field:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

.input-field::placeholder {
    color: var(--text-muted);
}

select.input-field {
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    padding-right: 32px;
}

textarea.input-field {
    resize: vertical;
    min-height: 60px;
}

.coordinates-display {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-sm);
    padding: 12px;
}

.coordinates-display label {
    margin-bottom: 4px;
}

.coords {
    font-family: 'SF Mono', 'Fira Code', monospace;
    font-size: 13px;
    color: var(--accent-light);
    margin-bottom: 4px;
}

.coordinates-display small {
    color: var(--text-muted);
    font-size: 11px;
}

/* ============================================
   PHOTO UPLOAD
   ============================================ */
.photo-upload-area {
    border: 2px dashed var(--border-color);
    border-radius: var(--border-radius);
    padding: 20px;
    text-align: center;
    cursor: pointer;
    transition: all var(--transition-fast);
    position: relative;
}

.photo-upload-area:hover,
.photo-upload-area.drag-over {
    border-color: var(--accent);
    background: var(--bg-hover);
}

.upload-placeholder {
    color: var(--text-muted);
}

.upload-placeholder i {
    width: 32px;
    height: 32px;
    margin-bottom: 8px;
    color: var(--text-muted);
}

.upload-placeholder p {
    font-size: 13px;
    margin-bottom: 4px;
}

.upload-placeholder small {
    font-size: 11px;
}

.photo-previews {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-top: 12px;
}

.photo-preview {
    position: relative;
    width: 80px;
    height: 80px;
    border-radius: var(--border-radius-sm);
    overflow: hidden;
    border: 2px solid var(--border-color);
}

.photo-preview img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.photo-preview .remove-photo {
    position: absolute;
    top: 2px;
    right: 2px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: rgba(0,0,0,0.7);
    color: white;
    border: none;
    cursor: pointer;
    font-size: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ============================================
   VISIT DETAIL
   ============================================ */
.detail-section {
    margin-bottom: 20px;
}

.detail-section h4 {
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.detail-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.detail-item {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-sm);
    padding: 10px 12px;
}

.detail-item-label {
    font-size: 10px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 4px;
}

.detail-item-value {
    font-size: 14px;
    font-weight: 600;
}

.detail-description {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-sm);
    padding: 12px;
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.6;
}

.detail-photos {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 8px;
}

.detail-photo {
    aspect-ratio: 1;
    border-radius: var(--border-radius-sm);
    overflow: hidden;
    border: 1px solid var(--border-color);
    cursor: pointer;
    transition: transform var(--transition-fast);
}

.detail-photo:hover {
    transform: scale(1.03);
}

.detail-photo img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* ============================================
   TOAST NOTIFICATIONS
   ============================================ */
#toast-container {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 3000;
    display: flex;
    flex-direction: column-reverse;
    gap: 8px;
    pointer-events: none;
}

.toast {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 20px;
    background: var(--glass-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--glass-border);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-lg);
    font-size: 13px;
    font-weight: 500;
    color: var(--text-primary);
    pointer-events: auto;
    animation: toastSlideUp 0.3s ease;
    white-space: nowrap;
}

.toast.success { border-left: 3px solid var(--success); }
.toast.error { border-left: 3px solid var(--danger); }
.toast.info { border-left: 3px solid var(--info); }
.toast.warning { border-left: 3px solid var(--warning); }

.toast i {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}

.toast.success i { color: var(--success); }
.toast.error i { color: var(--danger); }
.toast.info i { color: var(--info); }
.toast.warning i { color: var(--warning); }

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

.toast.removing {
    animation: toastFadeOut 0.2s ease forwards;
}

@keyframes toastFadeOut {
    to { opacity: 0; transform: translateY(10px); }
}

/* ============================================
   EMPTY STATES
   ============================================ */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
    text-align: center;
    color: var(--text-muted);
}

.empty-state i {
    width: 48px;
    height: 48px;
    margin-bottom: 12px;
    opacity: 0.3;
}

.empty-state p {
    font-size: 13px;
    line-height: 1.6;
    max-width: 260px;
}

/* ============================================
   LOADING
   ============================================ */
.loading-spinner {
    display: inline-flex;
    width: 20px;
    height: 20px;
    border: 2px solid var(--border-color);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ============================================
   RESPONSIVE — MOBILE
   ============================================ */
@media (max-width: 768px) {
    :root {
        --sidebar-width: 100%;
        --topbar-height: 56px;
    }
    
    .logo h1 {
        font-size: 15px;
    }
    @media (max-width: 600px) {
        .logo h1 {
            display: none;
        }
    }
    
    .modal {
        max-width: 95% !important;
        max-height: 85vh;
    }
    .modal-body {
        padding: 12px 16px;
    }
    .modal-header {
        padding: 16px 16px 0;
    }
    .form-group {
        margin-bottom: 12px;
    }
    .modal-actions {
        margin-top: 16px;
        padding-top: 12px;
    }
    
    .topbar-center {
        display: none;
    }
    
    #sidebar {
        position: fixed;
        top: var(--topbar-height);
        left: 0;
        right: 0;
        bottom: 0;
        z-index: 500;
        width: 100%;
        min-width: 100%;
    }
    
    #sidebar.closed {
        margin-left: 0;
        transform: translateY(100%);
        opacity: 0;
    }
    
    #sidebar.open {
        transform: translateY(0);
        opacity: 1;
    }
    
    #sidebar {
        transition: transform var(--transition-smooth), opacity var(--transition-smooth);
        height: 60vh;
        top: auto;
        bottom: 0;
        border-radius: 20px 20px 0 0;
        border-top: 1px solid var(--border-color);
    }
    
    .stats-pill span:not(#visited-count):not(#total-count) {
        display: none;
    }
    
    .form-row {
        grid-template-columns: 1fr;
    }
    
    .today-stats {
        grid-template-columns: repeat(3, 1fr);
    }
    
    .modal {
        max-width: 100%;
        margin: 0;
        max-height: 100vh;
        border-radius: 20px 20px 0 0;
    }
    
    .modal-overlay {
        align-items: flex-end;
        padding: 0;
    }
}

@media (max-width: 420px) {
    .topbar-right {
        gap: 4px;
    }
    
    .icon-btn {
        width: 34px;
        height: 34px;
    }
    
    .stats-pill {
        padding: 4px 10px;
        font-size: 12px;
    }
}

/* ============================================
   ROUTE LINE ANIMATION
   ============================================ */
.leaflet-route-line {
    stroke-dasharray: 12 6;
    animation: routeDash 1s linear infinite;
}

@keyframes routeDash {
    to { stroke-dashoffset: -18; }
}

/* ============================================
   CONTEXT MENU (Right-Click)
   ============================================ */
.context-menu {
    position: fixed;
    z-index: 3000;
    background: var(--glass-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--glass-border);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-lg);
    padding: 6px;
    min-width: 200px;
    animation: ctxMenuIn 0.15s ease;
}

@keyframes ctxMenuIn {
    from { opacity: 0; transform: scale(0.95) translateY(-4px); }
    to { opacity: 1; transform: scale(1) translateY(0); }
}

.context-menu-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    border-radius: var(--border-radius-sm);
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-primary);
    transition: background var(--transition-fast);
}

.context-menu-item:hover {
    background: var(--bg-hover);
}

.context-menu-item i {
    width: 16px;
    height: 16px;
    color: var(--accent-light);
}

.ctx-dot {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}

.context-menu-divider {
    height: 1px;
    background: var(--border-color);
    margin: 4px 8px;
}

/* ============================================
   SCAN OVERLAY
   ============================================ */
.scan-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 4000;
    animation: fadeIn 0.2s ease;
}

.scan-card {
    background: var(--glass-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--glass-border);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-lg);
    padding: 40px;
    text-align: center;
    max-width: 320px;
}

.scan-icon {
    width: 48px;
    height: 48px;
    margin: 0 auto 16px;
    color: var(--accent-light);
    animation: scanPulse 1.5s ease infinite;
}

@keyframes scanPulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.5; transform: scale(1.1); }
}

.scan-card h3 {
    font-size: 16px;
    margin-bottom: 8px;
}

.scan-card p {
    font-size: 13px;
    color: var(--text-muted);
}

/* Scan button active state */
#btn-scan-area.scanning {
    animation: scanBtnPulse 1s ease infinite;
    background: var(--accent);
    color: white;
    border-color: var(--accent);
}

@keyframes scanBtnPulse {
    0%, 100% { box-shadow: 0 0 0 0 var(--accent-glow); }
    50% { box-shadow: 0 0 0 8px rgba(99,102,241,0); }
}

/* ============================================
   NAVIGATION MODE (FULLSCREEN MAP)
   ============================================ */
body.nav-mode-active #topbar {
    display: none !important;
}

body.nav-mode-active #sidebar {
    display: none !important;
}

body.nav-mode-active #main-container {
    height: 100vh !important;
    padding-top: 0 !important;
    margin-top: 0 !important;
}

body.nav-mode-active #map-container {
    width: 100vw !important;
    height: 100vh !important;
}

body.nav-mode-active #topbar {
    display: none !important;
}

body.nav-mode-active #btn-exit-nav {
    display: flex !important;
}

body.nav-mode-active #btn-exit-nav:hover {
    background: var(--bg-hover);
    transform: translateY(1px);
}

/* === Custom Routing Styles === */
.sub-tab-btn.active {
    background: var(--accent) !important;
    color: white !important;
}

.sub-tab-btn:hover:not(.active) {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-primary) !important;
}

.saved-route-card {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-sm);
    padding: 12px;
    margin-bottom: 10px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: all var(--transition-fast);
}

.saved-route-card:hover {
    border-color: var(--border-accent);
    transform: translateY(-2px);
    box-shadow: var(--shadow-sm);
}

.saved-route-info {
    flex: 1;
    cursor: pointer;
}

.saved-route-title {
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 4px;
    font-size: 13px;
}

.saved-route-meta {
    font-size: 11px;
    color: var(--text-muted);
    display: flex;
    gap: 8px;
}

.saved-route-actions {
    display: flex;
    gap: 6px;
}

.btn-icon-danger {
    background: var(--danger-bg);
    color: var(--danger);
    border: 1px solid rgba(239, 68, 68, 0.2);
    border-radius: var(--border-radius-xs);
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.btn-icon-danger:hover {
    background: var(--danger);
    color: white;
}

.btn-icon-danger i {
    width: 14px;
    height: 14px;
}

.draft-store-card {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-xs);
    padding: 8px 10px;
    margin-bottom: 6px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.draft-store-details {
    flex: 1;
    overflow: hidden;
}

.draft-store-name {
    font-weight: 500;
    font-size: 12px;
    color: var(--text-primary);
    white-space: nowrap;
    text-overflow: ellipsis;
    overflow: hidden;
}

.draft-store-order {
    background: var(--accent);
    color: white;
    font-size: 10px;
    font-weight: bold;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.draft-store-actions {
    display: flex;
    gap: 4px;
}

.btn-action-sm {
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-xs);
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 10px;
}

.btn-action-sm:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.btn-action-sm i {
    width: 12px;
    height: 12px;
}


