/* ============================================================
   DroneLogBook AESA — CSS
   Estética DJI: oscuro, técnico, preciso
   Fuentes: Syne (display) + Space Mono (datos) + DM Sans (UI)
   ============================================================ */

:root {
  /* Paleta base */
  --bg-base:      #0a0c10;
  --bg-surface:   #111318;
  --bg-elevated:  #181c24;
  --bg-card:      #1c2130;
  --border:       rgba(255,255,255,.07);
  --border-light: rgba(255,255,255,.12);

  /* Texto */
  --text-primary:   #e8edf5;
  --text-secondary: #7a8899;
  --text-muted:     #3d4a5c;

  /* Acento DJI azul */
  --accent:        #1a6cf5;
  --accent-soft:   rgba(26,108,245,.15);
  --accent-glow:   rgba(26,108,245,.35);

  /* Marcas */
  --dji:   #1a6cf5;
  --xag:   #22c55e;
  --autel: #f59e0b;

  /* Estados */
  --success: #22c55e;
  --warning: #f59e0b;
  --danger:  #ef4444;
  --info:    #38bdf8;

  /* Sidebar */
  --sidebar-w: 240px;

  /* Transiciones */
  --t: 180ms ease;
}

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

html { font-size: 14px; }

body {
  font-family: 'DM Sans', sans-serif;
  background: var(--bg-base);
  color: var(--text-primary);
  min-height: 100vh;
  display: flex;
  overflow-x: hidden;
}

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

/* ─── Sidebar ─── */
.sidebar {
  width: var(--sidebar-w);
  min-height: 100vh;
  background: var(--bg-surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0;
  z-index: 100;
  padding-bottom: 16px;
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 24px 20px 20px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 8px;
}
.logo-mark { flex-shrink: 0; }
.logo-text { display: flex; flex-direction: column; line-height: 1.2; }
.logo-main {
  font-family: 'Syne', sans-serif;
  font-weight: 800;
  font-size: 16px;
  letter-spacing: -.5px;
  color: var(--text-primary);
}
.logo-sub {
  font-family: 'Space Mono', monospace;
  font-size: 9px;
  color: var(--accent);
  letter-spacing: 1px;
  text-transform: uppercase;
}

.sidebar-section-label {
  font-family: 'Space Mono', monospace;
  font-size: 9px;
  letter-spacing: 1.5px;
  color: var(--text-muted);
  text-transform: uppercase;
  padding: 14px 20px 6px;
}

.sidebar-nav { display: flex; flex-direction: column; gap: 2px; padding: 0 10px; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: 8px;
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 13px;
  font-weight: 400;
  transition: var(--t);
  position: relative;
}
.nav-item svg { width: 18px; height: 18px; flex-shrink: 0; }
.nav-item:hover { background: rgba(255,255,255,.04); color: var(--text-primary); }
.nav-item.active {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 500;
}
.nav-item.active::before {
  content: '';
  position: absolute;
  left: 0; top: 20%; bottom: 20%;
  width: 3px;
  background: var(--accent);
  border-radius: 0 2px 2px 0;
}

.sidebar-footer { margin-top: auto; padding: 0 10px; }

.user-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 10px;
}
.user-avatar {
  width: 32px; height: 32px;
  background: var(--accent);
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-family: 'Syne', sans-serif;
  font-weight: 700; font-size: 12px;
  color: #fff;
  flex-shrink: 0;
}
.user-info { flex: 1; min-width: 0; }
.user-name  { display: block; font-size: 13px; font-weight: 500; color: var(--text-primary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role  { display: block; font-family: 'Space Mono', monospace; font-size: 9px; color: var(--accent); letter-spacing: 1px; }
.logout-btn { color: var(--text-muted); display: flex; }
.logout-btn svg { width: 16px; }
.logout-btn:hover { color: var(--danger); }

/* ─── Main Content ─── */
.main-content {
  margin-left: var(--sidebar-w);
  flex: 1;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ─── Topbar ─── */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 32px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-surface);
  position: sticky;
  top: 0;
  z-index: 50;
}
.page-title {
  font-family: 'Syne', sans-serif;
  font-weight: 700;
  font-size: 22px;
  letter-spacing: -.5px;
}
.page-subtitle { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.topbar-actions { display: flex; gap: 10px; align-items: center; }

/* ─── Page Body ─── */
.page-body { padding: 28px 32px; flex: 1; }

/* ─── Buttons ─── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 9px 18px;
  border-radius: 8px;
  font-family: 'DM Sans', sans-serif;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  border: none;
  text-decoration: none;
  transition: var(--t);
  white-space: nowrap;
}
.btn svg { width: 15px; height: 15px; }
.btn-primary  { background: var(--accent); color: #fff; }
.btn-primary:hover { background: #2979ff; box-shadow: 0 0 20px var(--accent-glow); }
.btn-ghost    { background: transparent; color: var(--text-secondary); border: 1px solid var(--border-light); }
.btn-ghost:hover { background: rgba(255,255,255,.04); color: var(--text-primary); }
.btn-danger   { background: rgba(239,68,68,.15); color: var(--danger); border: 1px solid rgba(239,68,68,.25); }
.btn-danger:hover { background: rgba(239,68,68,.25); }
.btn-sm { padding: 6px 12px; font-size: 12px; }

/* ─── Cards / Grid ─── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 28px;
}

.stat-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
  position: relative;
  overflow: hidden;
  transition: var(--t);
}
.stat-card::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(26,108,245,.06) 0%, transparent 60%);
  pointer-events: none;
}
.stat-card:hover { border-color: var(--border-light); transform: translateY(-1px); }
.stat-label { font-size: 11px; letter-spacing: .8px; text-transform: uppercase; color: var(--text-muted); font-family: 'Space Mono', monospace; }
.stat-value { font-family: 'Syne', sans-serif; font-size: 32px; font-weight: 700; line-height: 1.1; margin: 8px 0 4px; color: var(--text-primary); }
.stat-detail { font-size: 12px; color: var(--text-secondary); }
.stat-icon { position: absolute; right: 20px; top: 20px; opacity: .12; font-size: 40px; }

/* ─── Tabla ─── */
.table-container {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
}
.table-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}
.table-title { font-family: 'Syne', sans-serif; font-size: 15px; font-weight: 600; }

table.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
table.data-table thead { background: var(--bg-elevated); }
table.data-table th {
  padding: 11px 16px;
  text-align: left;
  font-family: 'Space Mono', monospace;
  font-size: 10px;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--text-muted);
  white-space: nowrap;
  border-bottom: 1px solid var(--border);
}
table.data-table td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  color: var(--text-secondary);
  vertical-align: middle;
}
table.data-table tr:last-child td { border-bottom: none; }
table.data-table tbody tr:hover { background: rgba(255,255,255,.02); }
.td-primary { color: var(--text-primary) !important; font-weight: 500; }
.td-mono { font-family: 'Space Mono', monospace; font-size: 12px; }

/* ─── Badges ─── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 9px;
  border-radius: 20px;
  font-family: 'Space Mono', monospace;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .5px;
  text-transform: uppercase;
  white-space: nowrap;
}
.badge-dji    { background: rgba(26,108,245,.15);  color: var(--dji);     border: 1px solid rgba(26,108,245,.3); }
.badge-xag    { background: rgba(34,197,94,.15);   color: var(--xag);     border: 1px solid rgba(34,197,94,.3); }
.badge-autel  { background: rgba(245,158,11,.15);  color: var(--autel);   border: 1px solid rgba(245,158,11,.3); }
.badge-other  { background: rgba(148,163,184,.1);  color: #94a3b8;        border: 1px solid rgba(148,163,184,.2); }
.badge-success{ background: rgba(34,197,94,.12);   color: var(--success); border: 1px solid rgba(34,197,94,.25); }
.badge-warning{ background: rgba(245,158,11,.12);  color: var(--warning); border: 1px solid rgba(245,158,11,.25); }
.badge-danger { background: rgba(239,68,68,.12);   color: var(--danger);  border: 1px solid rgba(239,68,68,.25); }
.badge-info   { background: rgba(56,189,248,.12);  color: var(--info);    border: 1px solid rgba(56,189,248,.25); }

/* ─── Formularios ─── */
.form-grid  { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 18px; }
.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-group.full { grid-column: 1 / -1; }
label { font-size: 11px; font-family: 'Space Mono', monospace; letter-spacing: .8px; text-transform: uppercase; color: var(--text-secondary); }
input, select, textarea {
  background: var(--bg-elevated);
  border: 1px solid var(--border-light);
  border-radius: 8px;
  padding: 10px 12px;
  color: var(--text-primary);
  font-family: 'DM Sans', sans-serif;
  font-size: 13px;
  width: 100%;
  transition: var(--t);
  outline: none;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
select option { background: var(--bg-card); }
textarea { resize: vertical; min-height: 80px; }
.form-hint { font-size: 11px; color: var(--text-muted); margin-top: 2px; }

.card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 24px;
  margin-bottom: 20px;
}
.card-title {
  font-family: 'Syne', sans-serif;
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 18px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.card-title::before {
  content: '';
  width: 3px; height: 16px;
  background: var(--accent);
  border-radius: 2px;
}

/* ─── Alert banners ─── */
.alert {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 16px;
  border-radius: 8px;
  font-size: 13px;
  margin-bottom: 16px;
}
.alert-warning { background: rgba(245,158,11,.1); border: 1px solid rgba(245,158,11,.25); color: #fbbf24; }
.alert-danger  { background: rgba(239,68,68,.1);  border: 1px solid rgba(239,68,68,.25);  color: #f87171; }
.alert-info    { background: rgba(56,189,248,.1); border: 1px solid rgba(56,189,248,.25); color: #7dd3fc; }
.alert-success { background: rgba(34,197,94,.1);  border: 1px solid rgba(34,197,94,.25);  color: #86efac; }

/* ─── Progress bars ─── */
.progress { background: var(--bg-elevated); border-radius: 4px; height: 6px; overflow: hidden; }
.progress-bar { height: 100%; border-radius: 4px; transition: width .6s ease; }
.progress-bar.accent  { background: var(--accent); }
.progress-bar.success { background: var(--success); }
.progress-bar.warning { background: var(--warning); }
.progress-bar.danger  { background: var(--danger); }

/* ─── Upload Zone ─── */
.upload-zone {
  border: 2px dashed var(--border-light);
  border-radius: 12px;
  padding: 48px;
  text-align: center;
  transition: var(--t);
  cursor: pointer;
}
.upload-zone:hover, .upload-zone.dragover {
  border-color: var(--accent);
  background: var(--accent-soft);
}
.upload-zone-icon { font-size: 48px; opacity: .3; margin-bottom: 12px; }
.upload-zone-label { font-family: 'Syne', sans-serif; font-size: 16px; font-weight: 600; margin-bottom: 6px; }
.upload-zone-hint  { font-size: 12px; color: var(--text-muted); }

/* ─── Map placeholder ─── */
.map-container {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 12px;
  height: 320px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Space Mono', monospace;
  font-size: 12px;
  color: var(--text-muted);
  position: relative;
  overflow: hidden;
}
.map-container::before {
  content: '';
  position: absolute;
  inset: 0;
  background:
    linear-gradient(var(--border) 1px, transparent 1px),
    linear-gradient(90deg, var(--border) 1px, transparent 1px);
  background-size: 32px 32px;
}

/* ─── Dashboard chart placeholder ─── */
.chart-area {
  background: var(--bg-elevated);
  border-radius: 8px;
  height: 160px;
  display: flex;
  align-items: flex-end;
  gap: 6px;
  padding: 16px;
  overflow: hidden;
}
.chart-bar {
  flex: 1;
  background: var(--accent);
  border-radius: 3px 3px 0 0;
  opacity: .7;
  min-height: 4px;
  transition: opacity var(--t);
}
.chart-bar:hover { opacity: 1; }

/* ─── Drone card ─── */
.drone-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }
.drone-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 0;
  overflow: hidden;
  transition: var(--t);
  text-decoration: none;
  color: inherit;
  display: block;
}
.drone-card:hover { border-color: var(--border-light); transform: translateY(-2px); box-shadow: 0 12px 40px rgba(0,0,0,.4); }
.drone-card-header {
  padding: 20px;
  position: relative;
  overflow: hidden;
}
.drone-brand-tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: 'Space Mono', monospace;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
  margin-bottom: 10px;
}
.drone-card-model { font-family: 'Syne', sans-serif; font-size: 18px; font-weight: 700; }
.drone-card-reg   { font-family: 'Space Mono', monospace; font-size: 11px; color: var(--text-muted); margin-top: 4px; }
.drone-card-body  { padding: 16px 20px; border-top: 1px solid var(--border); }
.drone-stat-row   { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.drone-stat-row:last-child { margin-bottom: 0; }
.drone-stat-k { font-size: 11px; color: var(--text-muted); }
.drone-stat-v { font-family: 'Space Mono', monospace; font-size: 12px; color: var(--text-primary); }

/* ─── Tabs ─── */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 24px; }
.tab {
  padding: 10px 18px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: var(--t);
  text-decoration: none;
}
.tab:hover { color: var(--text-primary); }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); }

/* ─── Telemetry strip ─── */
.telem-strip {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 1px;
  background: var(--border);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  margin: 20px 0;
}
.telem-cell {
  background: var(--bg-elevated);
  padding: 14px 16px;
}
.telem-k { font-family: 'Space Mono', monospace; font-size: 9px; letter-spacing: 1px; text-transform: uppercase; color: var(--text-muted); }
.telem-v { font-family: 'Space Mono', monospace; font-size: 18px; font-weight: 700; color: var(--text-primary); margin-top: 4px; }
.telem-u { font-size: 10px; color: var(--text-secondary); }

/* ─── Login page ─── */
.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: var(--bg-base);
  margin-left: 0 !important;
}
.login-box {
  width: 100%;
  max-width: 400px;
  padding: 20px;
}
.login-logo { text-align: center; margin-bottom: 36px; }
.login-logo .logo-main { font-family: 'Syne', sans-serif; font-size: 28px; font-weight: 800; display: block; }
.login-logo .logo-sub  { font-family: 'Space Mono', monospace; font-size: 10px; color: var(--accent); letter-spacing: 2px; text-transform: uppercase; }
.login-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 32px;
}
.login-card h2 { font-family: 'Syne', sans-serif; font-size: 20px; font-weight: 700; margin-bottom: 24px; }
.login-card .form-group { margin-bottom: 16px; }
.login-card .btn { width: 100%; justify-content: center; margin-top: 8px; padding: 12px; }

/* ─── Utility ─── */
.flex { display: flex; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.mt-4  { margin-top: 16px; }
.mt-6  { margin-top: 24px; }
.mb-4  { margin-bottom: 16px; }
.text-muted   { color: var(--text-muted); }
.text-success { color: var(--success); }
.text-warning { color: var(--warning); }
.text-danger  { color: var(--danger); }
.text-accent  { color: var(--accent); }
.mono { font-family: 'Space Mono', monospace; font-size: 12px; }
.divider { height: 1px; background: var(--border); margin: 20px 0; }

/* ─── Responsive ─── */
@media (max-width: 900px) {
  :root { --sidebar-w: 0px; }
  .sidebar { transform: translateX(-240px); width: 240px; }
  .main-content { margin-left: 0; }
}

/* ─── Animations ─── */
@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
.fade-in { animation: fadeIn .35s ease forwards; }

@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: .5; } }
.pulse { animation: pulse 2s infinite; }

/* status dot */
.status-dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  display: inline-block;
  margin-right: 5px;
}
.dot-active    { background: var(--success); box-shadow: 0 0 6px var(--success); }
.dot-maintenance{ background: var(--warning); }
.dot-retired   { background: var(--text-muted); }
.dot-lost      { background: var(--danger); }
