/* ═══════════════════════════════════════════════════════════
   LedaEye Dashboard – Dark Violet / Cyan Theme
   Palette from Android app:
     bg_primary      #0A0B1E
     bg_card         #111230
     bg_card_stroke  #252560
     accent_violet   #7C3AED
     accent_cyan     #22D3EE
     accent_pink     #EC4899
     accent_green    #4ADE80
     text_primary    #F0EFFF
     text_secondary  #7878A8
   ═══════════════════════════════════════════════════════════ */

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

/* ── Root vars ──────────────────────────────────────────── */
:root {
  --bg:          #0A0B1E;
  --bg-card:     #111230;
  --bg-stroke:   #252560;
  --violet:      #7C3AED;
  --violet-lt:   #A78BFA;
  --cyan:        #22D3EE;
  --pink:        #EC4899;
  --green:       #4ADE80;
  --red:         #F87171;
  --text:        #F0EFFF;
  --text-muted:  #7878A8;
  --sidebar-w:   240px;
  --topbar-h:    60px;
  --radius:      12px;
  --trans:       0.2s ease;
}

/* ── Global ─────────────────────────────────────────────── */
body.leda-body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  min-height: 100vh;
  overflow-x: hidden;
}

#wrapper {
  min-height: 100vh;
}

/* ── Scrollbar ──────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--bg-stroke); border-radius: 3px; }

/* ══════════════════════════════════════════════════════════
   LOGIN PAGE
   ══════════════════════════════════════════════════════════ */
.leda-login-card {
  background: var(--bg-card);
  border: 1px solid var(--bg-stroke);
  border-radius: 20px;
  width: 100%;
  max-width: 420px;
  box-shadow: 0 0 60px rgba(124,58,237,.25);
}

.leda-title {
  color: var(--text);
  font-weight: 700;
  letter-spacing: 1px;
}

.leda-subtitle {
  color: var(--text-muted);
  font-size: .9rem;
  margin-bottom: 0;
}

/* ══════════════════════════════════════════════════════════
   FORMS
   ══════════════════════════════════════════════════════════ */
.leda-label {
  display: block;
  color: var(--text-muted);
  font-size: .85rem;
  margin-bottom: .4rem;
}

.leda-input {
  display: block;
  width: 100%;
  padding: .55rem .9rem;
  background: #0D0E28;
  border: 1px solid var(--bg-stroke);
  border-radius: 8px;
  color: var(--text);
  font-size: .95rem;
  transition: border-color var(--trans), box-shadow var(--trans);
}

.leda-input:focus {
  outline: none;
  border-color: var(--violet);
  box-shadow: 0 0 0 3px rgba(124,58,237,.25);
  background: #0D0E28;
}

.leda-input option { background: #0D0E28; color: var(--text); }

.leda-select-sm {
  padding: .25rem .5rem;
  background: #0D0E28;
  border: 1px solid var(--bg-stroke);
  border-radius: 6px;
  color: var(--text);
  font-size: .82rem;
}

.leda-select-sm option { background: #0D0E28; }

/* ══════════════════════════════════════════════════════════
   BUTTONS
   ══════════════════════════════════════════════════════════ */
.leda-btn {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  padding: .5rem 1.1rem;
  border: none;
  border-radius: 8px;
  font-size: .9rem;
  font-weight: 600;
  cursor: pointer;
  transition: filter var(--trans), transform var(--trans);
  text-decoration: none;
}

.leda-btn:hover { filter: brightness(1.12); transform: translateY(-1px); }
.leda-btn:active { transform: translateY(0); }

.leda-btn-primary  { background: linear-gradient(135deg,#5B21B6,#7C3AED); color: #fff; }
.leda-btn-violet   { background: linear-gradient(135deg,#6D28D9,#7C3AED); color: #fff; }
.leda-btn-green    { background: linear-gradient(135deg,#15803D,#4ADE80); color: #0A0B1E; }
.leda-btn-red      { background: linear-gradient(135deg,#991B1B,#F87171); color: #fff; }
.leda-btn-cyan     { background: linear-gradient(135deg,#0E7490,#22D3EE); color: #0A0B1E; }
.leda-btn.btn-sm   { padding: .25rem .65rem; font-size: .8rem; border-radius: 6px; }
.leda-btn.w-100    { width: 100%; justify-content: center; }

/* ══════════════════════════════════════════════════════════
   SIDEBAR
   ══════════════════════════════════════════════════════════ */
#sidebar-wrapper {
  position: fixed;
  top: 0; left: 0;
  width: var(--sidebar-w);
  height: 100vh;
  background: var(--bg-card);
  border-right: 1px solid var(--bg-stroke);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  z-index: 1000;
  transition: transform var(--trans);
}

.sidebar-brand {
  display: flex;
  align-items: center;
  padding: 1.2rem 1rem;
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text);
  border-bottom: 1px solid var(--bg-stroke);
  letter-spacing: .5px;
  background: linear-gradient(90deg, rgba(124,58,237,.15), transparent);
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .9rem 1rem;
  border-bottom: 1px solid var(--bg-stroke);
}

.sidebar-avatar {
  width: 38px; height: 38px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--violet), var(--cyan));
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 1rem; color: #fff;
  flex-shrink: 0;
}

.sidebar-uname { font-size: .9rem; font-weight: 600; color: var(--text); line-height: 1.2; }
.sidebar-role  { font-size: .75rem; color: var(--text-muted); }

.sidebar-nav {
  list-style: none;
  padding: .5rem 0;
  margin: 0;
  flex: 1;
}

.sidebar-nav li { margin: 0; }

.sidebar-nav .nav-link {
  display: flex;
  align-items: center;
  gap: .5rem;
  padding: .7rem 1.1rem;
  color: var(--text-muted);
  text-decoration: none;
  font-size: .9rem;
  border-radius: 8px;
  margin: 2px .5rem;
  transition: background var(--trans), color var(--trans);
}

.sidebar-nav .nav-link:hover {
  background: rgba(124,58,237,.15);
  color: var(--text);
}

.sidebar-nav .nav-link.active {
  background: linear-gradient(90deg, rgba(124,58,237,.35), rgba(124,58,237,.1));
  color: var(--violet-lt);
  font-weight: 600;
}

.nav-logout { color: var(--red) !important; }
.nav-logout:hover { background: rgba(248,113,113,.12) !important; color: var(--red) !important; }

.sidebar-divider { border-top: 1px solid var(--bg-stroke); margin: .4rem .5rem; }

.sidebar-devices {
  padding: .75rem 1rem 1rem;
  border-top: 1px solid var(--bg-stroke);
}

.sidebar-devices-title { font-size: .75rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: .8px; margin-bottom: .5rem; }
.sidebar-no-device     { font-size: .82rem; color: var(--text-muted); }

.sidebar-device-item {
  display: flex;
  align-items: center;
  gap: .5rem;
  font-size: .85rem;
  color: var(--text);
  padding: .2rem 0;
}

.device-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 6px var(--green);
  flex-shrink: 0;
}

/* ══════════════════════════════════════════════════════════
   TOPBAR
   ══════════════════════════════════════════════════════════ */
#page-content-wrapper {
  margin-left: var(--sidebar-w);
  min-height: 100vh;
  width: calc(100% - var(--sidebar-w));
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-width: 0;
}

.leda-topbar {
  height: var(--topbar-h);
  background: var(--bg-card);
  border-bottom: 1px solid var(--bg-stroke);
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0 1.5rem;
  position: sticky;
  top: 0;
  z-index: 900;
}

.leda-menu-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.2rem;
  cursor: pointer;
  padding: .25rem .5rem;
  border-radius: 6px;
  transition: background var(--trans);
  display: none;
}

.leda-menu-btn:hover { background: rgba(255,255,255,.07); }

.topbar-title {
  font-weight: 600;
  font-size: 1rem;
  color: var(--text);
  flex: 1;
}

.topbar-right { margin-left: auto; }

.leda-device-select {
  padding: .35rem .75rem;
  background: #0D0E28;
  border: 1px solid var(--bg-stroke);
  border-radius: 8px;
  color: var(--text);
  font-size: .88rem;
  min-width: 200px;
}

.leda-device-select:focus {
  outline: none;
  border-color: var(--violet);
  box-shadow: 0 0 0 2px rgba(124,58,237,.2);
}

.leda-device-select option { background: #0D0E28; }

/* ══════════════════════════════════════════════════════════
   CONTENT + TABS
   ══════════════════════════════════════════════════════════ */
.leda-content {
  padding: 1.75rem;
  flex: 1;
}

.tab-pane { display: none !important; }
.tab-pane.active { display: block !important; }

.leda-page-title {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 1.25rem;
  padding-bottom: .5rem;
  border-bottom: 1px solid var(--bg-stroke);
}

/* ── Cards ──────────────────────────────────────────────── */
.leda-card {
  background: var(--bg-card);
  border: 1px solid var(--bg-stroke);
  border-radius: var(--radius);
  overflow: hidden;
}

.leda-card-header {
  padding: .85rem 1.25rem;
  font-weight: 600;
  font-size: .95rem;
  color: var(--text);
  border-bottom: 1px solid var(--bg-stroke);
  background: rgba(255,255,255,.025);
}

.leda-card-body { padding: 1.25rem; }

.leda-card-footer {
  padding: .65rem 1.25rem;
  border-top: 1px solid var(--bg-stroke);
  font-size: .85rem;
  color: var(--text-muted);
  background: rgba(255,255,255,.015);
}

/* ── Stat cards ─────────────────────────────────────────── */
.stat-card {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1.1rem 1.25rem;
}

.stat-icon {
  width: 52px; height: 52px;
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.6rem;
  flex-shrink: 0;
}

.stat-label { font-size: .8rem; color: var(--text-muted); margin-bottom: .15rem; }
.stat-value { font-size: 1.4rem; font-weight: 700; color: var(--text); line-height: 1.1; }
.stat-value.small { font-size: .85rem; font-weight: 500; }

/* ── Command cards ──────────────────────────────────────── */
.cmd-card {
  padding: 2rem 1.5rem;
  text-align: center;
}

.cmd-icon { font-size: 2.5rem; margin-bottom: .75rem; }
.cmd-title { font-size: 1.05rem; font-weight: 700; margin-bottom: .5rem; color: var(--text); }
.cmd-desc { font-size: .87rem; color: var(--text-muted); margin-bottom: 1.2rem; }

/* ── Tables ─────────────────────────────────────────────── */
.leda-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .88rem;
}

.leda-table thead th {
  padding: .6rem 1rem;
  text-align: left;
  color: var(--text-muted);
  font-weight: 600;
  font-size: .78rem;
  text-transform: uppercase;
  letter-spacing: .5px;
  border-bottom: 1px solid var(--bg-stroke);
  background: rgba(255,255,255,.02);
}

.leda-table tbody td {
  padding: .65rem 1rem;
  border-bottom: 1px solid rgba(37,37,96,.5);
  color: var(--text);
  vertical-align: middle;
}

.leda-table tbody tr:last-child td { border-bottom: none; }
.leda-table tbody tr:hover td { background: rgba(124,58,237,.06); }

/* ── Badges ─────────────────────────────────────────────── */
.leda-badge {
  padding: .2rem .65rem;
  border-radius: 20px;
  font-size: .77rem;
  font-weight: 600;
}

.badge-super { background: rgba(124,58,237,.25); color: var(--violet-lt); }
.badge-admin { background: rgba(34,211,238,.15); color: var(--cyan); }

/* ── Misc ───────────────────────────────────────────────── */
.leda-code {
  background: rgba(255,255,255,.06);
  border: 1px solid var(--bg-stroke);
  padding: .15rem .45rem;
  border-radius: 5px;
  font-family: monospace;
  font-size: .82rem;
  color: var(--cyan);
}

.leda-muted { color: var(--text-muted); font-size: .9rem; }

.leda-alert {
  background: rgba(34,211,238,.1);
  border: 1px solid rgba(34,211,238,.3);
  color: var(--cyan);
  border-radius: 10px;
  padding: .85rem 1.1rem;
  font-size: .9rem;
}

.leda-alert-err {
  background: rgba(248,113,113,.1);
  border: 1px solid rgba(248,113,113,.3);
  color: var(--red);
  border-radius: 10px;
  padding: .85rem 1.1rem;
}

/* ── Alert override ─────────────────────────────────────── */
.alert-danger {
  background: rgba(248,113,113,.12) !important;
  border: 1px solid rgba(248,113,113,.3) !important;
  color: var(--red) !important;
  border-radius: 10px;
}

/* ── Media cards ────────────────────────────────────────── */
.media-thumb {
  width: 100%;
  height: 160px;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid var(--bg-stroke);
  cursor: pointer;
  transition: transform var(--trans), box-shadow var(--trans);
}

.media-thumb:hover { transform: scale(1.02); box-shadow: 0 4px 20px rgba(124,58,237,.3); }

.media-time { font-size: .78rem; color: var(--text-muted); margin-top: .4rem; }

/* ── Leaflet dark ───────────────────────────────────────── */
.leaflet-container { background: #0A0B1E !important; }

/* ── Responsive: mobile sidebar ────────────────────────── */
@media (max-width: 767px) {
  #sidebar-wrapper { transform: translateX(-100%); }
  #sidebar-wrapper.open { transform: translateX(0); }
  #page-content-wrapper { margin-left: 0; width: 100%; }
  .leda-menu-btn { display: block !important; }
  .leda-device-select { min-width: 140px; }
}

/* ══════════════════════════════════════════════════════════
   CHART.JS dark override
   ══════════════════════════════════════════════════════════ */
canvas { max-width: 100%; }
