/* Vertair GCS — Layout: left sidebar nav, topbar, views, responsive */

/* TOPBAR */
#topbar {
  position:fixed; top:0; left:var(--sidebar-w); right:0;
  height:var(--topbar-h);
  background:var(--bg-card);
  border-bottom:1px solid var(--border);
  display:flex; align-items:center; justify-content:space-between;
  padding:0 20px;
  z-index:900;
}
.topbar-left { display:flex; align-items:center; gap:12px; }
.topbar-title { font-size:14px; font-weight:600; color:var(--text); }
.topbar-right { display:flex; align-items:center; gap:12px; }

.ws-indicator { display:flex; align-items:center; gap:6px; font-size:11px; font-weight:500; }
.ws-dot { width:6px; height:6px; border-radius:50%; }
.ws-indicator.online .ws-dot { background:var(--green); }
.ws-indicator.online .ws-label { color:var(--green); }
.ws-indicator.offline .ws-dot { background:var(--red); animation:blink 1.5s infinite; }
.ws-indicator.offline .ws-label { color:var(--red); }
@keyframes blink { 0%,100%{opacity:1} 50%{opacity:.3} }

/* LEFT SIDEBAR NAV */
#sidebar-nav {
  position:fixed; top:0; left:0; bottom:0;
  width:var(--sidebar-w);
  background:var(--bg-card);
  border-right:1px solid var(--border);
  display:flex; flex-direction:column;
  z-index:1000;
  transition:width 200ms ease;
  overflow:hidden;
}
#sidebar-nav:hover { width:var(--sidebar-w-expanded); }

.nav-header {
  height:var(--topbar-h);
  display:flex; align-items:center;
  padding:0 16px; gap:10px;
  border-bottom:1px solid var(--border);
  flex-shrink:0;
  overflow:hidden; white-space:nowrap;
}
.nav-logo { font-size:18px; font-weight:700; color:var(--text); flex-shrink:0; width:24px; text-align:center; }
.nav-logo-img { width:28px; height:28px; flex-shrink:0; }
.nav-logo-text { font-size:14px; font-weight:600; color:var(--text); opacity:0; transition:opacity 200ms; }
#sidebar-nav:hover .nav-logo-text { opacity:1; }

.nav-items { flex:1; display:flex; flex-direction:column; padding:8px 0; gap:2px; }

.nav-item {
  display:flex; align-items:center; gap:12px;
  padding:10px 16px;
  color:var(--text-muted);
  transition:all var(--ease);
  cursor:pointer;
  white-space:nowrap;
  overflow:hidden;
  border-left:2px solid transparent;
}
.nav-item:hover { color:var(--text-secondary); background:var(--bg-hover); }
.nav-item.active { color:var(--text); background:var(--accent-bg); border-left-color:var(--text); }
.nav-icon { width:24px; text-align:center; flex-shrink:0; font-size:16px; }
.nav-label { font-size:13px; font-weight:500; opacity:0; transition:opacity 200ms; }
#sidebar-nav:hover .nav-label { opacity:1; }

.nav-footer { padding:8px; border-top:1px solid var(--border); flex-shrink:0; }

/* MAIN AREA */
#app-main {
  position:fixed;
  top:var(--topbar-h);
  left:var(--sidebar-w);
  right:0; bottom:0;
  overflow:hidden;
}

.view { display:none; position:absolute; inset:0; overflow-y:auto; }
.view.active { display:block; }

/* VIEW CONTENT */
.page-scroll { padding:20px; max-width:900px; margin:0 auto; padding-bottom:80px; }

/* MAP VIEW */
#view-map { display:none; position:absolute; inset:0; }
#view-map.active { display:flex; }
#map-wrap { flex:1; position:relative; min-width:0; }
#map { width:100%; height:100%; }
.leaflet-container { background:var(--bg) !important; }

/* MAP RIGHT PANEL */
#map-panel {
  width:320px;
  background:var(--bg-card);
  border-left:1px solid var(--border);
  display:flex; flex-direction:column;
  overflow:hidden;
  flex-shrink:0;
}
.mp-tabs { display:flex; border-bottom:1px solid var(--border); flex-shrink:0; }
.mp-tab {
  flex:1; font-size:11px; font-weight:500; padding:10px; text-align:center;
  color:var(--text-muted); border-bottom:2px solid transparent; transition:all var(--ease);
  text-transform:uppercase; letter-spacing:0.04em;
}
.mp-tab:hover { color:var(--text-secondary); }
.mp-tab.active { color:var(--text); border-bottom-color:var(--text); }
.mp-panel { display:none; flex:1; overflow-y:auto; padding:12px; }
.mp-panel.active { display:block; }

/* OVERVIEW: MINI MAP */
.mini-map-wrap {
  width:100%; height:200px;
  border-radius:var(--radius);
  overflow:hidden;
  border:1px solid var(--border);
  margin-bottom:16px;
}
#mini-map { width:100%; height:100%; }
.mini-map-wrap .leaflet-container { background:var(--bg) !important; }

/* OVERVIEW HERO STATS */
.overview-hero {
  display:flex; align-items:center; justify-content:center; gap:0;
  background:var(--bg-card); border:1px solid var(--border); border-radius:var(--radius-lg);
  padding:24px 16px; margin-bottom:16px;
}
.hero-stat { flex:1; text-align:center; }
.hero-stat-value { font-family:var(--font-mono); font-size:28px; font-weight:800; letter-spacing:-0.03em; color:var(--text); }
.hero-stat-value.hero-green { color:var(--green); }
.hero-stat-label { font-size:10px; font-weight:600; color:var(--text-muted); text-transform:uppercase; letter-spacing:0.08em; margin-top:2px; }
.hero-divider { width:1px; height:40px; background:var(--border); flex-shrink:0; }

/* OVERVIEW 2-COL GRID */
.overview-grid { display:grid; grid-template-columns:1fr 1fr; gap:14px; margin-bottom:14px; }
.overview-map-card .mini-map-wrap { height:220px; }
.overview-right-col { display:flex; flex-direction:column; gap:14px; }

/* SUMMARY ROW (orders page) */
.summary-row { display:grid; grid-template-columns:repeat(4,1fr); gap:10px; margin-bottom:20px; }
.summary-card {
  background:var(--bg-card); border:1px solid var(--border); border-radius:var(--radius);
  padding:14px; text-align:center;
}
.summary-label { display:block; font-size:10px; font-weight:500; color:var(--text-muted); text-transform:uppercase; letter-spacing:0.05em; margin-bottom:4px; }
.summary-value { display:block; font-family:var(--font-mono); font-size:22px; font-weight:700; color:var(--text); }

/* SECTION CARD */
.section-card {
  background:var(--bg-card); border:1px solid var(--border); border-radius:var(--radius);
  padding:16px; margin-bottom:14px;
}
.section-title { font-size:13px; font-weight:600; color:var(--text); margin-bottom:12px; display:flex; align-items:center; justify-content:space-between; }

/* TOAST */
#toast-container { position:fixed; bottom:20px; left:50%; transform:translateX(-50%); display:flex; flex-direction:column; gap:8px; z-index:9999; pointer-events:none; }
.toast { padding:10px 18px; border-radius:var(--radius); font-size:12px; font-weight:500; animation:toastIn 200ms ease,toastOut 300ms ease 3.5s forwards; pointer-events:auto; }
.toast.info { background:var(--bg-surface); color:var(--text); border:1px solid var(--border); }
.toast.success { background:var(--green-bg); color:var(--green); border:1px solid rgba(52,208,88,.2); }
.toast.error { background:var(--red-bg); color:var(--red); border:1px solid rgba(248,81,73,.2); }
.toast.warning { background:var(--yellow-bg); color:var(--yellow); border:1px solid rgba(210,153,34,.2); }
@keyframes toastIn { from{opacity:0;transform:translateY(10px)}to{opacity:1;transform:translateY(0)} }
@keyframes toastOut { from{opacity:1}to{opacity:0} }

/* DIALOG */
.dialog-overlay { position:fixed; inset:0; background:rgba(0,0,0,.6); display:flex; align-items:center; justify-content:center; z-index:10000; }
.dialog-box { background:var(--bg-card); border:1px solid var(--border-light); border-radius:var(--radius-lg); padding:24px; min-width:320px; max-width:400px; }
.dialog-title { font-size:15px; font-weight:600; margin-bottom:8px; }
.dialog-msg { font-size:13px; color:var(--text-secondary); margin-bottom:20px; line-height:1.6; }
.dialog-actions { display:flex; gap:8px; justify-content:flex-end; }

/* COMMAND CENTER: side-by-side map + steps */
.cmd-center-row { display:flex; gap:14px; margin-bottom:14px; }
.cmd-center-map { flex:1; min-width:0; height:400px; border-radius:var(--radius); overflow:hidden; border:1px solid var(--border); }
.cmd-center-map > div { width:100%; height:100%; }
.cmd-center-steps { width:320px; flex-shrink:0; overflow-y:auto; max-height:400px; }

/* SETTINGS VIEW */
.settings-section { margin-bottom:20px; }
.settings-section-title { font-size:12px; font-weight:700; color:var(--text); text-transform:uppercase; letter-spacing:.05em; margin-bottom:10px; padding-bottom:6px; border-bottom:1px solid var(--border); }
.settings-toggle { display:flex; align-items:center; justify-content:space-between; padding:10px 12px; background:var(--bg-surface); border:1px solid var(--border); border-radius:var(--radius); margin-bottom:8px; cursor:pointer; transition:all var(--ease); }
.settings-toggle:hover { border-color:var(--border-light); background:var(--bg-hover); }
.settings-toggle-label { font-size:13px; font-weight:500; }
.settings-toggle-desc { font-size:11px; color:var(--text-muted); margin-top:2px; }
.settings-toggle-switch { width:40px; height:22px; border-radius:11px; background:var(--border); position:relative; flex-shrink:0; transition:background 200ms; }
.settings-toggle-switch.on { background:var(--green); }
.settings-toggle-switch::after { content:''; position:absolute; top:2px; left:2px; width:18px; height:18px; border-radius:50%; background:#fff; transition:left 200ms; }
.settings-toggle-switch.on::after { left:20px; }

/* ORDERS TABLE */
.orders-table { width:100%; border-collapse:collapse; }
.orders-table th { font-size:10px; font-weight:600; color:var(--text-muted); text-transform:uppercase; letter-spacing:.04em; text-align:left; padding:8px; border-bottom:1px solid var(--border); }
.orders-table td { font-size:12px; padding:8px; border-bottom:1px solid var(--border); color:var(--text-secondary); }
.orders-table tr:hover td { background:var(--bg-hover); }

/* FLEET CAMERA */
.fleet-camera-mini { width:100%; height:120px; background:var(--bg); border:1px solid var(--border); border-radius:var(--radius); overflow:hidden; position:relative; margin-bottom:10px; }
.fleet-camera-mini img { width:100%; height:100%; object-fit:cover; }
.fleet-camera-placeholder { display:flex; flex-direction:column; align-items:center; justify-content:center; width:100%; height:100%; gap:4px; }
.fleet-camera-placeholder span { font-size:10px; color:var(--text-muted); }

/* RESPONSIVE */
@media(max-width:480px) { .summary-row { grid-template-columns:repeat(2,1fr); } }

@media(max-width:768px) {
  #sidebar-nav { top:auto; left:0; right:0; bottom:0; width:100% !important; height:56px; flex-direction:row; border-right:none; border-top:1px solid var(--border); }
  #sidebar-nav:hover { width:100% !important; }
  .nav-header { display:none; }
  .nav-items { flex-direction:row; padding:0; gap:0; justify-content:space-around; }
  .nav-item { flex-direction:column; padding:6px 0; gap:2px; border-left:none; border-top:2px solid transparent; justify-content:center; flex:1; }
  .nav-item.active { border-left-color:transparent; border-top-color:var(--text); }
  .nav-label { opacity:1 !important; font-size:9px; }
  .nav-icon { font-size:18px; }
  .nav-footer { display:none; }

  #topbar { left:0; }
  #app-main { left:0; bottom:56px; }

  #map-panel { position:absolute; top:auto; left:0; right:0; bottom:0; width:100%; height:44vh; border-left:none; border-top:1px solid var(--border); border-radius:12px 12px 0 0; }
  .page-scroll { padding:14px 12px 80px; }

  /* Mobile delivery map: ensure proper sizing and touch interaction */
  #delivery-mini-map { height:250px !important; min-height:200px; touch-action:pan-x pan-y; }
  #delivery-route-map-wrap { height:200px !important; }
  #delivery-route-map { height:100% !important; touch-action:pan-x pan-y; }
  .delivery-map-wrap { display:block !important; }

  /* Overview grid stacks on mobile */
  .overview-grid { grid-template-columns:1fr; }
  .overview-hero { flex-wrap:wrap; gap:8px; }
  .hero-divider { display:none; }
  .hero-stat { min-width:40%; }

  /* Command center stacks on mobile */
  .cmd-center-row { flex-direction:column; }
  .cmd-center-map { height:250px; }
  .cmd-center-steps { width:100%; max-height:300px; }

  /* Make address search results visible above keyboard */
  .search-wrap .dropdown { max-height:160px; }

  /* Delivery target info: stack on mobile for better visibility */
  #delivery-target-info > div:first-child { flex-direction:column; gap:4px; }
}
