/* ============================================================
   ABJU DASHBOARD — 0xFOX-INSPIRED DESIGN SYSTEM
   ============================================================ */

/* ---------- Root Variables ---------- */
:root {
  --bg: #fdf4ff;
  --fg: #1c1c1c;
  --fg-muted: #6b6b6b;
  --pop-pink: #FF107A;
  --pop-purple: #7928CA;
  --pop-cyan: #00E1FF;
  --pop-yellow: #FFEB3B;
  --pop-orange: #FF5100;
  --pop-green: #39FF14;
  --card-bg: rgba(255, 255, 255, 0.9);
  --card-border: #ffffff;
  --card-border-width: 4px;
  --shadow-sm: 0 8px 24px rgba(255, 16, 122, 0.08);
  --shadow-lg: 0 24px 48px rgba(121, 40, 202, 0.12);
  --topbar-bg: rgba(255, 255, 255, 0.75);
  --pill-bg: rgba(255, 255, 255, 0.6);
  --input-bg: rgba(255, 255, 255, 0.7);
  --input-border: #e0d0e8;
  --transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  --radius-xl: 32px;
  --radius-lg: 24px;
  --radius-md: 16px;
  --blob-opacity: 0.45;
  --log-alt: rgba(121, 40, 202, 0.03);
}

/* ---------- Dark Mode ---------- */
[data-theme="dark"] {
  --bg: #0a0a0a;
  --fg: #f0f0f0;
  --fg-muted: #999;
  --card-bg: rgba(17, 17, 17, 0.9);
  --card-border: #2a2a2a;
  --card-border-width: 1px;
  --shadow-sm: 0 8px 24px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 24px 48px rgba(0, 0, 0, 0.4);
  --topbar-bg: rgba(10, 10, 10, 0.8);
  --pill-bg: rgba(30, 30, 30, 0.7);
  --input-bg: rgba(30, 30, 30, 0.7);
  --input-border: #333;
  --blob-opacity: 0.12;
  --log-alt: rgba(255, 255, 255, 0.02);
}

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

html, body {
  max-width: 100vw;
  overflow-x: hidden;
  background: var(--bg);
  color: var(--fg);
  font-family: 'Outfit', system-ui, -apple-system, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  min-height: 100vh;
  padding-top: 72px;
}

/* ---------- Background Blobs ---------- */
.bg-blobs {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  overflow: hidden;
  z-index: 0;
  pointer-events: none;
}

.blob {
  position: absolute;
  border-radius: 50%;
  filter: blur(140px);
  opacity: var(--blob-opacity);
  animation: float-blob 25s infinite alternate ease-in-out;
}

.blob-1 {
  top: -15%; left: -10%; width: 65vw; height: 65vw;
  background: radial-gradient(circle, #ffb6c1 0%, transparent 70%);
  animation-delay: 0s;
}

.blob-2 {
  top: 35%; right: -20%; width: 55vw; height: 55vw;
  background: radial-gradient(circle, #c9a0dc 0%, transparent 70%);
  animation-delay: -8s;
}

.blob-3 {
  bottom: -25%; left: 15%; width: 70vw; height: 70vw;
  background: radial-gradient(circle, #a0e9f0 0%, transparent 70%);
  animation-delay: -16s;
}

@keyframes float-blob {
  0%   { transform: translate(0, 0) rotate(0deg) scale(1); }
  33%  { transform: translate(8%, 12%) rotate(15deg) scale(1.08); }
  66%  { transform: translate(-6%, 10%) rotate(-10deg) scale(0.92); }
  100% { transform: translate(0, 0) rotate(0deg) scale(1); }
}

/* ---------- Top Bar ---------- */
.top-bar {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  height: 64px;
  background: var(--topbar-bg);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border-bottom: 1px solid var(--card-border);
}

.top-bar-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.logo-img {
  border-radius: 8px;
}

/* Show correct logo per theme */
[data-theme="dark"] .logo-light { display: none; }
[data-theme="dark"] .logo-dark  { display: inline-block; }
[data-theme="light"] .logo-light { display: inline-block; }
[data-theme="light"] .logo-dark  { display: none; }
/* Default (no explicit light) */
:root:not([data-theme="light"]) .logo-light { display: none; }

.logo-text-group {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
}

.logo-name {
  font-size: 20px;
  font-weight: 800;
  background: linear-gradient(135deg, var(--pop-pink), var(--pop-purple));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.logo-tagline {
  font-size: 11px;
  color: var(--fg-muted);
  font-weight: 500;
}

.top-bar-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* ---------- Pills ---------- */
.status-pill,
.battery-pill,
.last-seen-pill {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border-radius: 100px;
  background: var(--pill-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  font-size: 13px;
  font-weight: 600;
  border: 1px solid var(--card-border);
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #aaa;
  transition: background 0.3s;
}

.status-dot.online {
  background: var(--pop-green);
  box-shadow: 0 0 8px var(--pop-green);
  animation: pulse-dot 2s infinite;
}

.status-dot.offline {
  background: #FF4444;
}

.status-dot.stale {
  background: var(--pop-yellow);
}

@keyframes pulse-dot {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

.icon-btn {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: var(--pill-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-radius: 50%;
  font-size: 18px;
  cursor: pointer;
  transition: var(--transition);
  border: 1px solid var(--card-border);
}

.icon-btn:hover {
  transform: translateY(-2px) scale(1.05);
  box-shadow: var(--shadow-sm);
}

/* ---------- SOS Banner ---------- */
.sos-banner {
  position: fixed;
  top: 64px; left: 0; right: 0;
  z-index: 99;
  background: linear-gradient(135deg, var(--pop-pink), #FF4444);
  color: #fff;
  padding: 14px 24px;
  animation: sos-pulse 1s infinite;
}

.sos-banner.hidden {
  display: none;
}

.sos-content {
  display: flex;
  align-items: center;
  gap: 16px;
  max-width: 1400px;
  margin: 0 auto;
}

.sos-icon {
  font-size: 28px;
  animation: sos-shake 0.4s infinite;
}

.sos-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.sos-info strong {
  font-size: 16px;
  font-weight: 800;
  letter-spacing: 1px;
}

.sos-info span {
  font-size: 13px;
  opacity: 0.9;
}

.btn-sos-locate,
.btn-sos-dismiss {
  padding: 8px 18px;
  border-radius: 100px;
  font-weight: 700;
  font-size: 13px;
  cursor: pointer;
  transition: var(--transition);
  border: none;
}

.btn-sos-locate {
  background: #fff;
  color: var(--pop-pink);
}

.btn-sos-dismiss {
  background: rgba(255,255,255,0.2);
  color: #fff;
  border: 1px solid rgba(255,255,255,0.4);
}

.btn-sos-locate:hover,
.btn-sos-dismiss:hover {
  transform: translateY(-2px);
}

@keyframes sos-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.85; }
}

@keyframes sos-shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-3px); }
  75% { transform: translateX(3px); }
}

/* ---------- Dashboard Layout ---------- */
.dashboard {
  position: relative;
  z-index: 1;
  max-width: 1400px;
  margin: 0 auto;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.row {
  display: grid;
  gap: 24px;
}

.row-top {
  grid-template-columns: 1.5fr 1fr;
}

.row-mid {
  grid-template-columns: 1fr 1fr;
}

.row-log,
.row-timeline {
  grid-template-columns: 1fr;
}

/* ---------- Glass Cards ---------- */
.glass-card {
  background: var(--card-bg);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border: var(--card-border-width) solid var(--card-border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  padding: 24px;
  transition: var(--transition);
  overflow: hidden;
}

.glass-card:hover {
  transform: translateY(-6px) scale(1.01);
  box-shadow: 0 32px 64px rgba(121, 40, 202, 0.15);
}

[data-theme="dark"] .glass-card:hover {
  box-shadow: 0 32px 64px rgba(0, 0, 0, 0.5);
}

.card-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 15px;
  font-weight: 700;
  margin-bottom: 16px;
  color: var(--fg);
}

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

.dot-pink   { background: var(--pop-pink); box-shadow: 0 0 8px var(--pop-pink); }
.dot-purple { background: var(--pop-purple); box-shadow: 0 0 8px var(--pop-purple); }
.dot-cyan   { background: var(--pop-cyan); box-shadow: 0 0 8px var(--pop-cyan); }
.dot-orange { background: var(--pop-orange); box-shadow: 0 0 8px var(--pop-orange); }
.dot-green  { background: var(--pop-green); box-shadow: 0 0 8px var(--pop-green); }
.dot-yellow { background: var(--pop-yellow); box-shadow: 0 0 8px var(--pop-yellow); }

/* ---------- Map Actions ---------- */
.map-actions {
  margin-left: auto;
  display: flex;
  gap: 6px;
}

.mini-btn {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: var(--pill-bg);
  border-radius: 10px;
  font-size: 14px;
  cursor: pointer;
  transition: var(--transition);
  border: 1px solid var(--card-border);
}

.mini-btn:hover,
.mini-btn.active {
  background: linear-gradient(135deg, var(--pop-pink), var(--pop-orange));
  color: var(--pop-yellow);
  border-color: transparent;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(255, 16, 122, 0.3);
}

/* ---------- Status Grid ---------- */
.status-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.stat-item {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.stat-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--fg-muted);
}

.stat-value {
  font-size: 15px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Battery Bar */
.battery-bar {
  flex: 1;
  height: 10px;
  background: var(--input-bg);
  border-radius: 100px;
  overflow: hidden;
  border: 1px solid var(--input-border);
}

.battery-fill {
  height: 100%;
  width: 0%;
  border-radius: 100px;
  background: linear-gradient(90deg, var(--pop-green), var(--pop-cyan));
  transition: width 0.6s ease;
}

.battery-fill.low {
  background: linear-gradient(90deg, #FF4444, var(--pop-orange));
}

.battery-fill.medium {
  background: linear-gradient(90deg, var(--pop-orange), var(--pop-yellow));
}

/* State Badge */
.state-badge {
  display: inline-block;
  padding: 3px 12px;
  border-radius: 100px;
  font-size: 12px;
  font-weight: 700;
  background: var(--pill-bg);
  border: 1px solid var(--card-border);
}

.state-badge.foreground {
  background: rgba(57, 255, 20, 0.15);
  color: var(--pop-green);
  border-color: var(--pop-green);
}

.state-badge.background {
  background: rgba(0, 225, 255, 0.15);
  color: var(--pop-cyan);
  border-color: var(--pop-cyan);
}

.state-badge.killed,
.state-badge.unknown {
  background: rgba(255, 68, 68, 0.15);
  color: #FF4444;
  border-color: #FF4444;
}

/* ---------- Trip Card ---------- */
.trip-idle {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px;
  font-size: 16px;
  font-weight: 600;
  color: var(--fg-muted);
}

.trip-active {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.trip-stat-row {
  display: flex;
  justify-content: space-between;
}

.trip-stat {
  text-align: center;
}

.trip-stat .val {
  font-size: 22px;
  font-weight: 800;
  background: linear-gradient(135deg, var(--pop-pink), var(--pop-purple));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.trip-stat .lbl {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--fg-muted);
  font-weight: 600;
}

/* ---------- SOS List ---------- */
.sos-list {
  max-height: 200px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.sos-entry {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-radius: var(--radius-md);
  background: var(--pill-bg);
  border-left: 4px solid var(--pop-pink);
  transition: var(--transition);
}

.sos-entry:hover {
  transform: translateX(4px);
}

.sos-entry.resolved {
  border-left-color: var(--pop-green);
  opacity: 0.7;
}

.sos-entry-icon {
  font-size: 20px;
}

.sos-entry-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.sos-entry-type {
  font-size: 13px;
  font-weight: 700;
}

.sos-entry-time {
  font-size: 11px;
  color: var(--fg-muted);
}

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

.sos-resolve-btn {
  padding: 4px 12px;
  border-radius: 100px;
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
  background: linear-gradient(135deg, var(--pop-pink), var(--pop-orange));
  color: var(--pop-yellow);
  border: none;
  transition: var(--transition);
}

.sos-resolve-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(255, 16, 122, 0.3);
}

.count-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  height: 22px;
  padding: 0 6px;
  border-radius: 100px;
  background: linear-gradient(135deg, var(--pop-pink), var(--pop-orange));
  color: #fff;
  font-size: 11px;
  font-weight: 800;
  margin-left: 8px;
}

/* ---------- Activity Log ---------- */
.card-log {
  max-height: 420px;
  display: flex;
  flex-direction: column;
}

.log-actions {
  margin-left: auto;
  display: flex;
  gap: 6px;
}

.filter-pill {
  padding: 5px 14px;
  border-radius: 100px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  background: var(--pill-bg);
  border: 1px solid var(--card-border);
  color: var(--fg);
  transition: var(--transition);
}

.filter-pill:hover {
  border-color: var(--pop-orange);
  color: var(--pop-orange);
}

.filter-pill.active {
  background: linear-gradient(135deg, var(--pop-orange), var(--pop-pink));
  color: #fff;
  border-color: transparent;
  box-shadow: 0 4px 12px rgba(255, 81, 0, 0.25);
}

.log-search-bar {
  margin-bottom: 12px;
}

.log-search-bar input {
  width: 100%;
  padding: 10px 16px;
  border-radius: var(--radius-md);
  border: 1px solid var(--input-border);
  background: var(--input-bg);
  color: var(--fg);
  font-family: 'Outfit', sans-serif;
  font-size: 13px;
  font-weight: 500;
  outline: none;
  transition: var(--transition);
}

.log-search-bar input:focus {
  border-color: var(--pop-purple);
  box-shadow: 0 0 0 3px rgba(121, 40, 202, 0.15);
}

.log-list {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.log-entry {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 10px 14px;
  border-radius: 12px;
  transition: var(--transition);
  font-size: 13px;
}

.log-entry:nth-child(even) {
  background: var(--log-alt);
}

.log-entry:hover {
  background: rgba(121, 40, 202, 0.06);
}

[data-theme="dark"] .log-entry:hover {
  background: rgba(255, 255, 255, 0.04);
}

.log-icon {
  font-size: 16px;
  flex-shrink: 0;
  width: 24px;
  text-align: center;
}

.log-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.log-msg {
  font-weight: 600;
  line-height: 1.3;
}

.log-meta {
  font-size: 11px;
  color: var(--fg-muted);
}

.log-entry.type-sos { border-left: 3px solid var(--pop-pink); }
.log-entry.type-safety { border-left: 3px solid var(--pop-orange); }
.log-entry.type-navigation { border-left: 3px solid var(--pop-cyan); }
.log-entry.type-system { border-left: 3px solid var(--pop-purple); }
.log-entry.type-gps_gap { border-left: 3px solid var(--pop-yellow); }

/* ---------- Trip Timeline ---------- */
.card-timeline {
  min-height: 120px;
}

.timeline-date {
  margin-left: auto;
  font-size: 12px;
  font-weight: 500;
  color: var(--fg-muted);
}

#tripTimeline {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.timeline-entry {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  border-radius: var(--radius-md);
  background: var(--pill-bg);
  transition: var(--transition);
}

.timeline-entry:hover {
  transform: translateX(4px);
}

.timeline-icon {
  font-size: 22px;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--pop-cyan), var(--pop-purple));
  border-radius: 12px;
  flex-shrink: 0;
}

.timeline-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.timeline-title {
  font-size: 14px;
  font-weight: 700;
}

.timeline-detail {
  font-size: 12px;
  color: var(--fg-muted);
}

.timeline-bar-wrap {
  height: 6px;
  border-radius: 100px;
  background: var(--input-bg);
  overflow: hidden;
  margin-top: 4px;
}

.timeline-bar {
  height: 100%;
  border-radius: 100px;
  background: linear-gradient(90deg, var(--pop-pink), var(--pop-orange));
}

.timeline-stats {
  display: flex;
  gap: 16px;
  flex-shrink: 0;
}

.timeline-stat {
  text-align: center;
}

.timeline-stat .ts-val {
  font-size: 16px;
  font-weight: 800;
  color: var(--pop-purple);
}

[data-theme="dark"] .timeline-stat .ts-val {
  color: var(--pop-cyan);
}

.timeline-stat .ts-lbl {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--fg-muted);
  font-weight: 600;
}

/* ---------- Empty State ---------- */
.empty-msg {
  text-align: center;
  padding: 24px;
  color: var(--fg-muted);
  font-size: 14px;
  font-weight: 500;
}

/* ---------- Scrollbar ---------- */
.sos-list::-webkit-scrollbar,
.log-list::-webkit-scrollbar {
  width: 6px;
}

.sos-list::-webkit-scrollbar-track,
.log-list::-webkit-scrollbar-track {
  background: transparent;
}

.sos-list::-webkit-scrollbar-thumb,
.log-list::-webkit-scrollbar-thumb {
  background: rgba(121, 40, 202, 0.2);
  border-radius: 100px;
}

[data-theme="dark"] .sos-list::-webkit-scrollbar-thumb,
[data-theme="dark"] .log-list::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
}

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  .row-top,
  .row-mid {
    grid-template-columns: 1fr;
  }

  .dashboard {
    padding: 16px;
    gap: 16px;
  }

  .top-bar {
    padding: 0 16px;
  }

  .top-bar-right {
    gap: 6px;
  }

  .battery-pill,
  .last-seen-pill {
    display: none;
  }

  .glass-card {
    padding: 18px;
    border-radius: var(--radius-lg);
  }

  .log-actions {
    flex-wrap: wrap;
  }

  .timeline-stats {
    flex-direction: column;
    gap: 4px;
  }

  .timeline-entry {
    flex-wrap: wrap;
  }
}

@media (max-width: 600px) {
  .logo-tagline {
    display: none;
  }

  .status-grid {
    grid-template-columns: 1fr;
  }

  .map-actions {
    display: none;
  }
}

/* ---------- Animations ---------- */
@keyframes fade-in {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}

.glass-card {
  animation: fade-in 0.5s ease-out both;
}

.row-top .glass-card:nth-child(1) { animation-delay: 0.05s; }
.row-top .glass-card:nth-child(2) { animation-delay: 0.1s; }
.row-mid .glass-card:nth-child(1) { animation-delay: 0.15s; }
.row-mid .glass-card:nth-child(2) { animation-delay: 0.2s; }
.row-log .glass-card  { animation-delay: 0.25s; }
.row-timeline .glass-card { animation-delay: 0.3s; }
