/* SeeVision Design System — Soft & Warm */
@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;500;600;700;800&family=DM+Sans:wght@400;500;600&display=swap');

:root {
  --color-background: #FAF8F5;
  --color-foreground: #2D2520;
  --color-card: #FFFFFF;
  --color-sidebar: #F5F0EB;
  --color-muted: #F0EBE5;
  --color-muted-foreground: #8B8178;
  --color-border: #E8E2DB;
  --color-primary: #E07A5F;
  --color-primary-foreground: #FFFFFF;
  --color-destructive: #C75D5D;
  --color-success: #5B9A8B;
  --color-warning: #D4A046;
  --color-info: #7C6FAB;

  --font-heading: 'Plus Jakarta Sans', sans-serif;
  --font-body: 'DM Sans', sans-serif;

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;
  --radius-card: 20px;
  --radius-pill: 999px;

  --shadow-card: 0 2px 12px rgba(45, 37, 32, 0.06);
  --shadow-card-hover: 0 4px 20px rgba(45, 37, 32, 0.1);
  --shadow-sidebar: 2px 0 12px rgba(45, 37, 32, 0.04);
}

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

html, body {
  height: 100%;
  font-family: var(--font-body);
  color: var(--color-foreground);
  background: var(--color-background);
  -webkit-font-smoothing: antialiased;
}

/* Scrollbar */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--color-border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--color-muted-foreground); }

/* Animations */
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

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

.animate-fade-in-up {
  animation: fadeInUp 200ms ease-out;
}

.animate-spin {
  animation: spin 1s linear infinite;
}

/* Typography */
h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-heading);
  font-weight: 700;
  color: var(--color-foreground);
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  border: none;
  border-radius: var(--radius-md);
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 120ms ease, box-shadow 120ms ease, background-color 150ms ease;
  line-height: 1;
}

.btn:hover { transform: scale(1.02); }
.btn:active { transform: scale(0.98); }
.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.btn-primary {
  background: var(--color-primary);
  color: var(--color-primary-foreground);
}
.btn-primary:hover { box-shadow: 0 4px 16px rgba(224, 122, 95, 0.3); }

.btn-outline {
  background: transparent;
  color: var(--color-foreground);
  border: 1px solid var(--color-border);
}
.btn-outline:hover { background: var(--color-muted); }

.btn-success {
  background: var(--color-success);
  color: #fff;
}

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

/* Cards */
.card {
  background: var(--color-card);
  border-radius: var(--radius-card);
  padding: 20px;
  box-shadow: var(--shadow-card);
  transition: box-shadow 200ms ease;
}

.card:hover {
  box-shadow: var(--shadow-card-hover);
}

/* Inputs */
.input {
  width: 100%;
  padding: 10px 16px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  font-family: var(--font-body);
  font-size: 14px;
  background: var(--color-background);
  color: var(--color-foreground);
  transition: box-shadow 150ms ease, border-color 150ms ease;
  outline: none;
}

.input:focus {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(224, 122, 95, 0.15);
}

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

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 12px;
  border-radius: var(--radius-pill);
  font-size: 12px;
  font-weight: 600;
  line-height: 1.2;
}

.badge-success { background: rgba(91, 154, 139, 0.1); color: var(--color-success); }
.badge-warning { background: rgba(212, 160, 70, 0.1); color: var(--color-warning); }
.badge-info { background: rgba(124, 111, 171, 0.1); color: var(--color-info); }
.badge-primary { background: rgba(224, 122, 95, 0.1); color: var(--color-primary); }

/* Progress bar */
.progress-bar {
  width: 100%;
  height: 6px;
  background: var(--color-muted);
  border-radius: 3px;
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  border-radius: 3px;
  transition: width 400ms ease;
}

/* ========== LOGIN PAGE ========== */
.login-wrapper {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: linear-gradient(135deg, var(--color-background) 0%, var(--color-sidebar) 100%);
}

.login-card {
  width: 100%;
  max-width: 400px;
  padding: 40px;
  border-radius: 24px;
}

.login-card h1 {
  font-size: 24px;
  text-align: center;
  margin-bottom: 8px;
}

.login-card .subtitle {
  text-align: center;
  color: var(--color-muted-foreground);
  font-size: 14px;
  margin-bottom: 32px;
}

.login-logo {
  display: flex;
  justify-content: center;
  margin-bottom: 24px;
}

.login-logo .icon-circle {
  width: 56px;
  height: 56px;
  border-radius: 16px;
  background: rgba(224, 122, 95, 0.1);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--color-primary);
}

.form-group {
  margin-bottom: 16px;
}

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

.login-error {
  color: var(--color-destructive);
  font-size: 13px;
  text-align: center;
  margin-bottom: 12px;
  min-height: 18px;
}

.login-card .btn {
  width: 100%;
  justify-content: center;
  padding: 12px;
}

/* ========== MAIN LAYOUT ========== */
.app-layout {
  display: flex;
  flex-direction: column;
  height: 100vh;
}

.top-bar {
  display: flex;
  align-items: center;
  height: 56px;
  padding: 0 24px;
  background: var(--color-card);
  border-bottom: 1px solid var(--color-border);
  box-shadow: 0 1px 4px rgba(45, 37, 32, 0.04);
  z-index: 20;
  flex-shrink: 0;
}

.top-bar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--color-primary);
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 18px;
}

.top-bar-logo svg {
  flex-shrink: 0;
}

.top-bar-spacer { flex: 1; }

.top-bar-info {
  display: flex;
  align-items: center;
  gap: 16px;
  font-size: 14px;
  color: var(--color-muted-foreground);
}

.top-bar-user {
  display: flex;
  align-items: center;
  gap: 8px;
}

.top-bar-user .avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: rgba(224, 122, 95, 0.1);
  color: var(--color-primary);
  display: flex;
  align-items: center;
  justify-content: center;
}

.btn-logout {
  background: none;
  border: none;
  color: var(--color-muted-foreground);
  cursor: pointer;
  padding: 4px;
  display: flex;
  border-radius: var(--radius-sm);
  transition: color 150ms ease, background 150ms ease;
}

.btn-logout:hover {
  color: var(--color-destructive);
  background: rgba(199, 93, 93, 0.08);
}

.main-content {
  display: flex;
  flex: 1;
  overflow: hidden;
}

/* Panels */
.panel {
  width: 340px;
  flex-shrink: 0;
  background: var(--color-sidebar);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: var(--shadow-sidebar);
}

.panel-left {
  border-right: 1px solid var(--color-border);
}

.panel-right {
  border-left: 1px solid var(--color-border);
}

.panel-header {
  padding: 16px 20px 12px;
  flex-shrink: 0;
}

.panel-header h2 {
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 12px;
}

.panel-body {
  flex: 1;
  overflow-y: auto;
  padding: 0 20px 20px;
}

.panel-footer {
  padding: 12px 20px;
  border-top: 1px solid var(--color-border);
  flex-shrink: 0;
}

/* Date picker row */
.date-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}

.date-row .input {
  flex: 1;
}

/* Order card */
.order-card {
  background: var(--color-card);
  border-radius: var(--radius-lg);
  padding: 14px 16px;
  margin-bottom: 10px;
  box-shadow: var(--shadow-card);
  transition: box-shadow 200ms ease, transform 150ms ease;
  cursor: default;
}

.order-card:hover {
  box-shadow: var(--shadow-card-hover);
  transform: translateY(-1px);
}

.order-card-name {
  font-family: var(--font-heading);
  font-weight: 600;
  font-size: 14px;
  margin-bottom: 4px;
}

.order-card-address {
  font-size: 12px;
  color: var(--color-muted-foreground);
  margin-bottom: 8px;
}

.order-card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

.order-card-meta .badge {
  font-size: 11px;
  padding: 3px 10px;
}

/* Map container */
.map-container {
  flex: 1;
  position: relative;
}

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

.map-overlay-btn {
  position: absolute;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1000;
  padding: 12px 28px;
  font-size: 15px;
  box-shadow: 0 4px 20px rgba(224, 122, 95, 0.35);
  pointer-events: auto;
}

/* Prevent Leaflet from stealing clicks on overlay elements */
.map-container {
  position: relative;
}

/* Hide Leaflet attribution */
.leaflet-control-attribution {
  display: none !important;
}

/* Route card */
.route-card {
  background: var(--color-card);
  border-radius: var(--radius-lg);
  padding: 16px;
  margin-bottom: 12px;
  box-shadow: var(--shadow-card);
}

.route-card-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}

.route-color-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  flex-shrink: 0;
}

.route-card-title {
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 14px;
  flex: 1;
}

.route-card-driver {
  font-size: 12px;
  color: var(--color-muted-foreground);
}

.route-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 12px;
}

.route-stat {
  font-size: 12px;
  color: var(--color-muted-foreground);
}

.route-stat strong {
  color: var(--color-foreground);
  font-weight: 600;
}

.route-load {
  margin-bottom: 12px;
}

.route-load-label {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: var(--color-muted-foreground);
  margin-bottom: 4px;
}

/* Route stops list */
.route-stops {
  list-style: none;
}

.route-stop {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 6px 0;
  font-size: 13px;
  border-bottom: 1px solid var(--color-border);
}

.route-stop:last-child { border-bottom: none; }

.route-stop-num {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
}

.route-stop-name {
  font-weight: 500;
}

.route-stop-address {
  color: var(--color-muted-foreground);
  font-size: 12px;
  margin-top: 1px;
}

.route-stop-weight {
  color: var(--color-muted-foreground);
  font-size: 12px;
}

/* Unassigned banner */
.unassigned-banner {
  background: rgba(212, 160, 70, 0.08);
  border: 1px solid rgba(212, 160, 70, 0.2);
  border-radius: var(--radius-md);
  padding: 12px 16px;
  margin-bottom: 12px;
  font-size: 13px;
  color: var(--color-warning);
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Loading state */
.loading-text {
  color: var(--color-muted-foreground);
  font-size: 14px;
  text-align: center;
  padding: 32px 0;
}

.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--color-muted-foreground);
  font-size: 14px;
}

.empty-state svg {
  margin: 0 auto 12px;
  opacity: 0.4;
}

/* Modal overlay */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(4px);
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.modal-content {
  background: var(--color-card);
  border-radius: 24px;
  box-shadow: 0 8px 40px rgba(45, 37, 32, 0.15);
  max-width: 480px;
  width: 100%;
  padding: 32px;
  animation: fadeInUp 200ms ease-out;
}

.modal-content h2 {
  font-size: 20px;
  margin-bottom: 20px;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 24px;
}

/* File input styled */
.file-upload {
  position: relative;
  overflow: hidden;
}

.file-upload input[type="file"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

/* Leaflet overrides */
.leaflet-control-zoom a {
  border-radius: var(--radius-sm) !important;
  color: var(--color-foreground) !important;
  border-color: var(--color-border) !important;
}

.leaflet-popup-content-wrapper {
  border-radius: var(--radius-md) !important;
  box-shadow: var(--shadow-card) !important;
  font-family: var(--font-body) !important;
}

.leaflet-popup-content {
  margin: 12px 16px !important;
  font-size: 13px !important;
  line-height: 1.5 !important;
}

/* Custom map markers */
.depot-marker {
  background: var(--color-primary);
  color: #fff;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 8px rgba(224, 122, 95, 0.4);
  border: 3px solid #fff;
}

.order-marker {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  color: #fff;
  box-shadow: 0 2px 6px rgba(45, 37, 32, 0.2);
  border: 2px solid #fff;
  background: var(--color-info);
}

/* Notification toast */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  padding: 12px 20px;
  border-radius: var(--radius-md);
  color: #fff;
  font-size: 14px;
  font-weight: 500;
  z-index: 100;
  animation: fadeInUp 200ms ease-out;
  box-shadow: 0 4px 20px rgba(45, 37, 32, 0.15);
}

.toast-success { background: var(--color-success); }
.toast-error { background: var(--color-destructive); }
.toast-info { background: var(--color-info); }

/* ===== Mobile Tab Bar ===== */
.mobile-tabs {
  display: none;
}

/* ===== Mobile Responsive ===== */
@media (max-width: 768px) {
  .top-bar {
    padding: 8px 12px;
  }
  .top-bar-logo span {
    font-size: 14px;
  }
  .top-bar-info {
    font-size: 12px;
    gap: 8px;
  }
  #top-date {
    display: none;
  }

  .main-content {
    flex-direction: column;
    position: relative;
  }

  .panel {
    width: 100%;
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 10;
    display: none;
  }

  .panel.mobile-active {
    display: flex;
  }

  .map-container {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: none;
  }

  .map-container.mobile-active {
    display: block;
  }

  /* Show map by default on first load */
  .panel-left.mobile-active,
  .panel-right.mobile-active,
  .map-container.mobile-active {
    display: flex;
  }
  .map-container.mobile-active {
    display: block;
  }

  .map-overlay-btn {
    bottom: 74px;
    left: auto;
    right: 16px;
    transform: none;
    width: 48px;
    height: 48px;
    padding: 0;
    font-size: 0;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 16px rgba(224, 122, 95, 0.4);
  }

  .map-overlay-btn svg {
    width: 22px;
    height: 22px;
  }

  /* Mobile Tab Bar */
  .mobile-tabs {
    display: flex;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--color-card);
    border-top: 1px solid var(--color-border);
    z-index: 1000;
    padding: 4px 0;
    padding-bottom: env(safe-area-inset-bottom, 4px);
  }

  .mobile-tab {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: 8px 4px;
    background: none;
    border: none;
    color: var(--color-muted-foreground);
    font-family: var(--font-body);
    font-size: 11px;
    font-weight: 500;
    cursor: pointer;
    transition: color 150ms;
  }

  .mobile-tab.active {
    color: var(--color-primary);
  }

  .mobile-tab svg {
    width: 22px;
    height: 22px;
  }

  /* Adjust app layout for bottom tabs */
  .app-layout {
    padding-bottom: 64px;
  }

  .panel-footer {
    padding-bottom: 8px;
  }

  /* Order cards tighter on mobile */
  .order-card {
    padding: 12px 14px;
  }

  .panel-header {
    padding: 12px 16px 8px;
  }

  .panel-body {
    padding: 0 16px 16px;
  }

  .panel-footer {
    padding: 10px 16px;
  }

  .toast {
    bottom: 80px;
    left: 16px;
    right: 16px;
  }
}
