/* === Mizomed Logistics 2026 — Dark Theme === */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

:root {
  --bg-primary: #0f172a;
  --bg-secondary: #1e293b;
  --bg-tertiary: #334155;
  --bg-card: #1e293b;
  --bg-hover: #334155;
  --bg-input: #0f172a;
  --border-color: #334155;
  --border-light: #475569;
  --text-primary: #f1f5f9;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --accent: #0891b2;
  --accent-light: #22d3ee;
  --accent-bg: rgba(8, 145, 178, 0.12);
  --danger: #ef4444;
  --success: #22c55e;
  --warning: #f59e0b;
  --shadow: 0 4px 24px rgba(0, 0, 0, 0.3);
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.2);
  --radius: 12px;
  --radius-sm: 8px;
  --radius-xs: 6px;
  --sidebar-width: 320px;
  --navbar-height: 56px;
  --transition: 0.2s ease;
}

* { box-sizing: border-box; }

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  margin: 0;
  -webkit-font-smoothing: antialiased;
}

/* === Scrollbar === */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--bg-primary); }
::-webkit-scrollbar-thumb { background: var(--bg-tertiary); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--border-light); }

/* === Navbar === */
.navbar {
  background: var(--bg-secondary) !important;
  border-bottom: 1px solid var(--border-color);
  height: var(--navbar-height);
  padding: 0 1.25rem;
  backdrop-filter: blur(12px);
}

.navbar-brand {
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--accent) !important;
  letter-spacing: -0.02em;
  display: flex;
  align-items: center;
  gap: 8px;
}

.navbar-brand .brand-icon {
  width: 28px;
  height: 28px;
  background: var(--accent);
  border-radius: var(--radius-xs);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 14px;
}

.nav-link {
  color: var(--text-secondary) !important;
  font-size: 0.875rem;
  font-weight: 500;
  padding: 0.5rem 0.875rem !important;
  border-radius: var(--radius-xs);
  transition: all var(--transition);
}

.nav-link:hover {
  color: var(--text-primary) !important;
  background: var(--bg-hover);
}

.nav-link.active {
  color: var(--accent-light) !important;
  background: var(--accent-bg);
}

.navbar-toggler { border-color: var(--border-color); }
.navbar-toggler-icon { filter: invert(0.7); }

/* === Layout === */
.app-container {
  padding-top: var(--navbar-height);
  min-height: 100vh;
}

.page-content {
  padding: 1.5rem;
}

/* === Map Layout === */
.map-layout {
  display: flex;
  height: calc(100vh - var(--navbar-height));
  overflow: hidden;
}

.map-sidebar {
  width: var(--sidebar-width);
  min-width: var(--sidebar-width);
  background: var(--bg-secondary);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 10;
  position: relative;
}

.map-sidebar-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-color);
  flex-shrink: 0;
}

.map-sidebar-header h6 {
  margin: 0;
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
}

.map-sidebar-body {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
}

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

.map-canvas {
  flex: 1;
  position: relative;
}

#map {
  width: 100%;
  height: 100%;
  border: none;
  border-radius: 0;
}

/* === Courier Cards in Sidebar === */
.courier-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition);
  margin-bottom: 4px;
}

.courier-card:hover {
  background: var(--bg-hover);
}

.courier-card.active {
  background: var(--accent-bg);
  border: 1px solid rgba(8, 145, 178, 0.3);
}

.courier-dot {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.8rem;
  color: white;
  flex-shrink: 0;
}

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

.courier-name {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.courier-meta {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.courier-badge {
  background: var(--bg-tertiary);
  color: var(--text-secondary);
  font-size: 0.75rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 10px;
  flex-shrink: 0;
}

/* === Stats Bar on Map === */
.map-stats {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 100;
  display: flex;
  gap: 8px;
}

.stat-chip {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 20px;
  padding: 6px 14px;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-secondary);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  gap: 6px;
}

.stat-chip .num {
  color: var(--text-primary);
  font-weight: 700;
}

.stat-chip.accent .num { color: var(--accent-light); }

/* === Filter Panel === */
.filter-section {
  margin-bottom: 16px;
}

.filter-label {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: 8px;
}

/* === Cards === */
.dark-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  overflow: hidden;
  transition: all var(--transition);
}

.dark-card:hover {
  border-color: var(--border-light);
  box-shadow: var(--shadow-sm);
}

.dark-card .card-header {
  background: transparent;
  border-bottom: 1px solid var(--border-color);
  padding: 16px 20px;
  font-weight: 600;
  font-size: 0.9rem;
}

.dark-card .card-body { padding: 20px; }

/* === Dashboard Cards === */
.metric-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  padding: 24px;
  transition: all var(--transition);
}

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

.metric-icon {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  margin-bottom: 16px;
}

.metric-icon.cyan { background: var(--accent-bg); color: var(--accent-light); }
.metric-icon.green { background: rgba(34, 197, 94, 0.12); color: var(--success); }
.metric-icon.amber { background: rgba(245, 158, 11, 0.12); color: var(--warning); }
.metric-icon.red { background: rgba(239, 68, 68, 0.12); color: var(--danger); }

.metric-value {
  font-size: 2rem;
  font-weight: 700;
  line-height: 1;
  margin-bottom: 4px;
}

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

/* === Tables === */
.dark-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
}

.dark-table thead th {
  background: var(--bg-tertiary);
  color: var(--text-muted);
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 10px 16px;
  border: none;
  white-space: nowrap;
}

.dark-table thead th:first-child { border-radius: var(--radius-sm) 0 0 var(--radius-sm); }
.dark-table thead th:last-child { border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }

.dark-table tbody td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-color);
  font-size: 0.875rem;
  color: var(--text-secondary);
  vertical-align: middle;
}

.dark-table tbody tr:hover td {
  background: var(--bg-hover);
}

.dark-table tbody tr:last-child td { border-bottom: none; }

/* === Forms === */
.form-control, .form-select {
  background: var(--bg-input) !important;
  border: 1px solid var(--border-color) !important;
  color: var(--text-primary) !important;
  color-scheme: dark;
  border-radius: var(--radius-xs);
  font-size: 0.875rem;
  padding: 8px 12px;
  transition: border-color var(--transition);
}

input[type="date"] {
  color-scheme: dark;
}

input[type="date"]::-webkit-calendar-picker-indicator {
  filter: invert(0.7);
  cursor: pointer;
}

.form-control:focus, .form-select:focus {
  border-color: var(--accent) !important;
  box-shadow: 0 0 0 3px var(--accent-bg) !important;
}

.form-control::placeholder { color: var(--text-muted) !important; }

.form-check-input {
  background-color: var(--bg-tertiary);
  border-color: var(--border-light);
}

.form-check-input:checked {
  background-color: var(--accent);
  border-color: var(--accent);
}

.form-check-label {
  color: var(--text-secondary);
  font-size: 0.85rem;
}

.form-label {
  color: var(--text-secondary);
  font-size: 0.8rem;
  font-weight: 500;
  margin-bottom: 6px;
}

/* === Buttons === */
.btn-accent {
  background: var(--accent);
  color: white;
  border: none;
  font-weight: 500;
  font-size: 0.875rem;
  border-radius: var(--radius-xs);
  padding: 8px 20px;
  transition: all var(--transition);
}

.btn-accent:hover {
  background: #0e7490;
  color: white;
  transform: translateY(-1px);
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border-color);
  font-weight: 500;
  font-size: 0.875rem;
  border-radius: var(--radius-xs);
  padding: 8px 20px;
  transition: all var(--transition);
}

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

.btn-sm {
  padding: 4px 12px;
  font-size: 0.8rem;
}

/* === Toggle Switch === */
.toggle-switch {
  position: relative;
  width: 40px;
  height: 22px;
  cursor: pointer;
}

.toggle-switch input { display: none; }

.toggle-slider {
  position: absolute;
  inset: 0;
  background: var(--bg-tertiary);
  border-radius: 11px;
  transition: all var(--transition);
}

.toggle-slider::before {
  content: '';
  position: absolute;
  width: 16px;
  height: 16px;
  left: 3px;
  top: 3px;
  background: var(--text-muted);
  border-radius: 50%;
  transition: all var(--transition);
}

.toggle-switch input:checked + .toggle-slider { background: var(--accent); }
.toggle-switch input:checked + .toggle-slider::before {
  transform: translateX(18px);
  background: white;
}

/* === Color Picker === */
.color-dot {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 2px solid var(--border-light);
  cursor: pointer;
  transition: all var(--transition);
}

.color-dot:hover { transform: scale(1.15); }

/* === Badge === */
.badge-dark {
  background: var(--bg-tertiary);
  color: var(--text-secondary);
  font-weight: 500;
  font-size: 0.75rem;
  padding: 4px 10px;
  border-radius: 10px;
}

.badge-accent {
  background: var(--accent-bg);
  color: var(--accent-light);
  font-weight: 600;
  font-size: 0.75rem;
  padding: 4px 10px;
  border-radius: 10px;
}

/* === Unmapped Orders === */
.unmapped-section {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 100;
  max-height: 240px;
  background: var(--bg-secondary);
  border-top: 1px solid var(--border-color);
  overflow: hidden;
  transition: max-height var(--transition);
}

.unmapped-section.collapsed { max-height: 42px; }

.unmapped-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  cursor: pointer;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-secondary);
}

.unmapped-toggle:hover { color: var(--text-primary); }

.unmapped-body {
  overflow-y: auto;
  max-height: 198px;
  padding: 0 16px 12px;
}

/* === Modal === */
.modal-content {
  background: var(--bg-secondary) !important;
  border: 1px solid var(--border-color) !important;
  border-radius: var(--radius) !important;
}

.modal-header {
  border-bottom-color: var(--border-color) !important;
  padding: 20px 24px;
}

.modal-title {
  font-weight: 600;
  font-size: 1rem;
}

.modal-body { padding: 24px; }

.modal-footer {
  border-top-color: var(--border-color) !important;
  padding: 16px 24px;
}

.btn-close { filter: invert(0.7); }

/* === Login === */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #0f172a 0%, #1e293b 50%, #164e63 100%);
}

.login-card {
  width: 100%;
  max-width: 400px;
  background: rgba(30, 41, 59, 0.8);
  backdrop-filter: blur(20px);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  padding: 40px;
  box-shadow: var(--shadow);
}

.login-logo {
  text-align: center;
  margin-bottom: 32px;
}

.login-logo .icon {
  width: 56px;
  height: 56px;
  background: var(--accent);
  border-radius: var(--radius-sm);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  color: white;
  margin-bottom: 16px;
}

.login-logo h4 {
  color: var(--text-primary);
  font-weight: 700;
  font-size: 1.25rem;
  margin: 0;
}

.login-logo p {
  color: var(--text-muted);
  font-size: 0.85rem;
  margin: 4px 0 0;
}

/* === Page Header === */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
}

.page-title {
  font-size: 1.25rem;
  font-weight: 700;
  margin: 0;
}

/* === Balloon (Yandex Maps popup) === */
.balloon-content {
  font-family: 'Inter', sans-serif;
}

/* Fix Yandex Maps balloon */
[class*="balloon__content"] {
  overflow-y: auto !important;
  overflow-x: hidden !important;
}

[class*="balloon__layout"] {
  max-width: 360px !important;
}

.balloon-content h6 {
  color: var(--accent);
  margin-bottom: 8px;
  font-weight: 600;
}

.balloon-content p {
  margin-bottom: 4px;
  font-size: 13px;
}

.balloon-content ul {
  padding-left: 16px;
  font-size: 13px;
}

.balloon-content hr {
  margin: 8px 0;
  opacity: 0.15;
}

/* === Responsive === */
@media (max-width: 768px) {
  .map-sidebar {
    position: fixed;
    top: var(--navbar-height);
    left: -100%;
    width: 85vw;
    max-width: 360px;
    height: calc(100vh - var(--navbar-height));
    z-index: 200;
    transition: left 0.3s ease;
  }

  .map-sidebar.open {
    left: 0;
    box-shadow: 8px 0 24px rgba(0,0,0,0.5);
  }

  .sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 199;
  }

  .sidebar-overlay.open { display: block; }

  .mobile-toggle-sidebar {
    display: flex !important;
  }

  .map-stats {
    top: auto;
    bottom: 12px;
    right: 12px;
    flex-wrap: wrap;
    justify-content: flex-end;
  }
}

@media (max-width: 768px) {
  .page-content { padding: 1rem 0.75rem; }
  .page-header { flex-direction: column; gap: 12px; align-items: flex-start; }
  .page-title { font-size: 1.1rem; }

  .metric-card { padding: 16px; }
  .metric-value { font-size: 1.5rem; }
  .metric-icon { width: 40px; height: 40px; margin-bottom: 12px; }

  .dark-table { font-size: 0.8rem; }
  .dark-table thead th { padding: 8px 10px; font-size: 0.7rem; }
  .dark-table tbody td { padding: 10px; }

  .dark-card .card-body { padding: 12px; }
  .dark-card .card-header { padding: 12px 16px; }

  .navbar { padding: 0 0.75rem; }
  .navbar-brand { font-size: 1rem; }
  .nav-link { font-size: 0.8rem; padding: 0.4rem 0.6rem !important; }

  .modal-dialog { margin: 0.5rem; }

  /* Hide less important table columns on mobile */
  .hide-mobile { display: none !important; }
}

@media (min-width: 769px) {
  .mobile-toggle-sidebar { display: none !important; }
  .sidebar-overlay { display: none !important; }
}
