/* ============================================================
   KLNavBot Dashboard Stylesheet
   Author: KLNavBot Team
   Version: 1.0.0
   ============================================================ */

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

html, body {
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: #0f172a;
  color: #1f2937;
}

/* ---------- Layout ---------- */
body {
  display: flex;
  overflow: hidden;
}

#map {
  flex: 1;
  height: 100vh;
}

/* ---------- Sidebar ---------- */
.sidebar {
  width: 340px;
  min-width: 340px;
  height: 100vh;
  overflow-y: auto;
  background: #f8fafc;
  border-right: 1px solid #e2e8f0;
  display: flex;
  flex-direction: column;
  gap: 0;
  padding: 0 0 24px 0;
  z-index: 10;
}

/* scrollbar */
.sidebar::-webkit-scrollbar { width: 6px; }
.sidebar::-webkit-scrollbar-track { background: transparent; }
.sidebar::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 3px; }

/* ---------- Header ---------- */
.sidebar-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 20px 20px 16px;
  background: linear-gradient(135deg, #1e40af 0%, #1d4ed8 100%);
  color: white;
  position: sticky;
  top: 0;
  z-index: 5;
}

.logo {
  font-size: 36px;
  line-height: 1;
}

.brand {
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.5px;
}

.sub {
  font-size: 11px;
  opacity: 0.8;
  margin-top: 2px;
}

/* ---------- Cards ---------- */
.card {
  margin: 12px 14px 0;
  background: white;
  border-radius: 14px;
  padding: 16px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.07);
  border: 1px solid #e2e8f0;
}

.card-title {
  font-size: 13px;
  font-weight: 700;
  color: #374151;
  margin-bottom: 12px;
  letter-spacing: 0.3px;
}

/* ---------- Form Elements ---------- */
.field-label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: #6b7280;
  margin-bottom: 5px;
}

.select-input {
  width: 100%;
  padding: 10px 12px;
  border: 2px solid #e5e7eb;
  border-radius: 9px;
  font-size: 13px;
  background: #fafafa;
  color: #1f2937;
  cursor: pointer;
  transition: border-color 0.2s;
  appearance: none;
}

.select-input:focus {
  outline: none;
  border-color: #3b82f6;
  box-shadow: 0 0 0 3px rgba(59,130,246,0.12);
}

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

.swap-btn {
  flex-shrink: 0;
  width: 38px;
  height: 38px;
  border: 2px solid #e5e7eb;
  border-radius: 9px;
  background: white;
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  color: #374151;
}

.swap-btn:hover {
  background: #f1f5f9;
  border-color: #94a3b8;
}

/* ---------- Route Banner ---------- */
.route-banner {
  margin-top: 12px;
  background: linear-gradient(135deg, #ef4444, #dc2626);
  color: white;
  padding: 12px 14px;
  border-radius: 10px;
  box-shadow: 0 4px 12px rgba(239,68,68,0.25);
}

.route-banner strong {
  display: block;
  font-size: 13px;
  margin-bottom: 3px;
}

.route-banner span {
  font-size: 11px;
  opacity: 0.9;
}

/* ---------- Status ---------- */
.status-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}

.badge {
  padding: 5px 13px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.3px;
}

.badge-idle    { background: #e5e7eb; color: #4b5563; }
.badge-active  { background: #dcfce7; color: #166534; }
.badge-paused  { background: #fef3c7; color: #92400e; }
.badge-error   { background: #fee2e2; color: #991b1b; }

.state-text {
  font-size: 11px;
  color: #6b7280;
  font-weight: 600;
}

/* ---------- Info Grid ---------- */
.info-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.info-item {
  background: #f9fafb;
  padding: 10px 12px;
  border-radius: 9px;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.info-label {
  font-size: 10px;
  color: #9ca3af;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.info-val {
  font-size: 14px;
  font-weight: 700;
  color: #111827;
}

/* ---------- Obstacle Alert ---------- */
.obstacle-alert {
  display: none;
  margin-top: 10px;
  padding: 10px 13px;
  background: #fee2e2;
  border-left: 4px solid #ef4444;
  border-radius: 8px;
  font-size: 12px;
  color: #991b1b;
  font-weight: 700;
  animation: pulse 1s infinite;
}

.obstacle-alert.show { display: block; }

@keyframes pulse {
  0%,100% { opacity: 1; }
  50%      { opacity: 0.7; }
}

/* ---------- OTP ---------- */
.otp-hint {
  font-size: 12px;
  color: #6b7280;
  margin-bottom: 10px;
}

.otp-row {
  display: flex;
  gap: 8px;
}

.otp-input {
  flex: 1;
  padding: 10px;
  border: 2px solid #e5e7eb;
  border-radius: 9px;
  font-size: 20px;
  font-weight: 700;
  text-align: center;
  letter-spacing: 8px;
  color: #1f2937;
  transition: border-color 0.2s;
}

.otp-input:focus {
  outline: none;
  border-color: #3b82f6;
}

.otp-msg {
  margin-top: 8px;
  font-size: 12px;
  font-weight: 700;
  min-height: 18px;
}

.otp-msg.success { color: #10b981; }
.otp-msg.error   { color: #ef4444; }

/* ---------- Delivery ---------- */
.delivery-card {
  background: #f0fdf4;
  border-left: 4px solid #10b981;
  padding: 12px 14px;
  border-radius: 9px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.delivery-card strong {
  font-size: 13px;
  color: #1f2937;
}

.delivery-card span {
  font-size: 11px;
  color: #6b7280;
}

/* ---------- D-Pad ---------- */
.dpad {
  display: grid;
  grid-template-columns: repeat(3, 60px);
  grid-template-rows: repeat(3, 60px);
  gap: 8px;
  justify-content: center;
}

.dpad-btn {
  border: none;
  border-radius: 12px;
  font-size: 22px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  transition: all 0.15s;
  box-shadow: 0 3px 8px rgba(0,0,0,0.12);
}

.dpad-btn:active { transform: scale(0.93); }
.dpad-btn:disabled { opacity: 0.3; cursor: not-allowed; }

.dpad-btn.fwd  { grid-column: 2; grid-row: 1; background: #10b981; color: white; }
.dpad-btn.left { grid-column: 1; grid-row: 2; background: #f59e0b; color: white; }
.dpad-btn.stop { grid-column: 2; grid-row: 2; background: #ef4444; color: white; }
.dpad-btn.right{ grid-column: 3; grid-row: 2; background: #f59e0b; color: white; }
.dpad-btn.bwd  { grid-column: 2; grid-row: 3; background: #10b981; color: white; }

/* ---------- Route Controls ---------- */
.controls-row {
  display: flex;
  gap: 8px;
}

.btn {
  flex: 1;
  padding: 11px 6px;
  border: none;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
  box-shadow: 0 2px 6px rgba(0,0,0,0.1);
}

.btn:disabled { opacity: 0.45; cursor: not-allowed; }

.btn-primary { background: #3b82f6; color: white; }
.btn-primary:hover:not(:disabled) { background: #2563eb; transform: translateY(-1px); }

.btn-warning { background: #f59e0b; color: white; }
.btn-warning:hover:not(:disabled) { background: #d97706; transform: translateY(-1px); }

.btn-danger  { background: #ef4444; color: white; }
.btn-danger:hover:not(:disabled)  { background: #dc2626; transform: translateY(-1px); }

/* ---------- Legend ---------- */
.legend {
  position: fixed;
  bottom: 20px;
  left: 356px;
  background: rgba(255,255,255,0.97);
  backdrop-filter: blur(8px);
  padding: 12px 16px;
  border-radius: 12px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.15);
  font-size: 12px;
  z-index: 20;
}

.legend h3 {
  font-size: 12px;
  font-weight: 700;
  margin-bottom: 8px;
  color: #374151;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 5px;
  color: #4b5563;
}

.dot {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  border: 2px solid white;
  box-shadow: 0 1px 3px rgba(0,0,0,0.25);
  flex-shrink: 0;
}

.line {
  width: 28px;
  height: 4px;
  border-radius: 2px;
  flex-shrink: 0;
}

/* ---------- Responsive ---------- */
@media (max-width: 700px) {
  .sidebar { width: 100vw; height: auto; }
  body { flex-direction: column; }
  #map { height: 45vh; }
  .legend { left: 10px; }
}
