/* ═══════════════════════════════════════════════
   DRONE TRACKER — Industrial Dark Theme
   ═══════════════════════════════════════════════ */

:root {
  --bg-base: #08090b;
  --bg-surface: #101114;
  --bg-elevated: #181a1f;
  --bg-input: #0d0e11;
  --border: #23262e;
  --border-focus: #9a958e;
  --text: #e2e4e9;
  --text-muted: #6e717b;
  --text-dim: #3d3f47;
  --accent: #c8c2b9;
  --accent-hover: #d8d3cb;
  --accent-muted: rgba(200, 194, 185, 0.06);
  --accent-glow: rgba(200, 194, 185, 0.12);
  --success: #22c55e;
  --success-bg: rgba(34, 197, 94, 0.1);
  --error: #ef4444;
  --error-bg: rgba(239, 68, 68, 0.1);
  --radius: 4px;
  --font-ui: 'Barlow', sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
}

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

html {
  font-family: var(--font-ui);
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  background: var(--bg-base);
  color: var(--text);
  min-height: 100vh;
}

/* Dot-grid background — engineering paper */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background-image: radial-gradient(circle, var(--border) 0.5px, transparent 0.5px);
  background-size: 24px 24px;
  opacity: 0.3;
  pointer-events: none;
  z-index: 0;
}

/* ═══════════════════════════════════════════════
   TOP BAR
   ═══════════════════════════════════════════════ */

.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  height: 48px;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(12px);
}

@media (min-width: 768px) {
  .topbar { padding: 0 32px; }
}

.topbar-brand {
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text);
}

.topbar-status {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-muted);
  letter-spacing: 0.04em;
}

.topbar-status .dot {
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--success);
  margin-right: 6px;
  vertical-align: middle;
  box-shadow: 0 0 6px var(--success);
  animation: pulse-dot 2s ease-in-out infinite;
}

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

/* ═══════════════════════════════════════════════
   FORM LAYOUT — Responsive panels
   ═══════════════════════════════════════════════ */

.form-shell {
  position: relative;
  z-index: 1;
  max-width: 440px;
  margin: 0 auto;
  padding: 16px 16px 120px;
}

.form-layout {
  display: flex;
  flex-direction: column;
  gap: 0;
}

/* ── Panel (shared) ── */
.panel {
  padding: 20px 0;
}

.panel--left {
  border-bottom: 1px solid var(--border);
  padding-bottom: 24px;
}

.panel--right {
  padding-top: 24px;
}

.panel-header {
  margin-bottom: 16px;
}

.panel-tag {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-dim);
  padding: 3px 8px;
  border: 1px solid var(--border);
  border-radius: 3px;
  background: var(--bg-elevated);
}

/* Desktop submit hidden on mobile */
.submit-btn--desktop {
  display: none;
}

/* ── Desktop: side-by-side panels ── */
@media (min-width: 768px) {
  .form-shell {
    max-width: 820px;
    padding: 32px 32px 48px;
  }

  .form-layout {
    flex-direction: row;
    gap: 0;
  }

  .panel {
    padding: 24px;
  }

  .panel--left {
    flex: 1 1 50%;
    border-bottom: none;
    border-right: 1px solid var(--border);
    padding-bottom: 24px;
    padding-left: 0;
  }

  .panel--right {
    flex: 1 1 50%;
    padding-top: 24px;
    padding-right: 0;
  }

  /* Show inline submit on desktop, hide sticky dock */
  .submit-btn--desktop {
    display: block;
    margin-top: 8px;
  }

  .submit-dock {
    display: none;
  }
}

/* ── Extra wide: even roomier ── */
@media (min-width: 1024px) {
  .form-shell {
    max-width: 900px;
    padding: 48px 48px 64px;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: 6px;
    margin-top: 48px;
  }

  .panel {
    padding: 28px 32px;
  }

  .panel--left { padding-left: 0; }
  .panel--right { padding-right: 0; }
}

/* ═══════════════════════════════════════════════
   LABELS
   ═══════════════════════════════════════════════ */

.field-label {
  display: block;
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.field-label .optional {
  font-weight: 400;
  color: var(--text-dim);
  text-transform: none;
  letter-spacing: 0;
  font-size: 10px;
}

/* ═══════════════════════════════════════════════
   INPUTS
   ═══════════════════════════════════════════════ */

.input {
  width: 100%;
  padding: 12px 14px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 15px;
  font-weight: 400;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.input::placeholder {
  color: var(--text-dim);
  font-weight: 300;
}

.input:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 2px var(--accent-glow), inset 0 0 0 1px var(--border-focus);
}

.input.input--upper {
  text-transform: uppercase;
  letter-spacing: 0.15em;
}

/* Remove number spinners */
.input[type="number"]::-webkit-inner-spin-button,
.input[type="number"]::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
.input[type="number"] { -moz-appearance: textfield; }

/* ═══════════════════════════════════════════════
   FIELD GROUP / PAIR
   ═══════════════════════════════════════════════ */

.field-group {
  margin-bottom: 20px;
}

.field-pair {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 20px;
}

/* ═══════════════════════════════════════════════
   PHASE GRID
   ═══════════════════════════════════════════════ */

.phase-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
}

@media (min-width: 768px) {
  .phase-grid {
    grid-template-columns: repeat(5, 1fr);
  }
}

.phase-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 48px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.12s ease;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

@media (min-width: 768px) {
  .phase-btn { height: 44px; font-size: 13px; }
}

.phase-btn:hover {
  background: var(--accent-muted);
  border-color: var(--accent);
  color: var(--text);
}

.phase-btn:active {
  transform: scale(0.96);
}

.phase-btn.active {
  background: rgba(226, 228, 233, 0.1);
  border-color: var(--text);
  color: var(--text);
  font-weight: 700;
  box-shadow: 0 0 8px rgba(226, 228, 233, 0.06);
}

/* ═══════════════════════════════════════════════
   TIME PRESETS
   ═══════════════════════════════════════════════ */

.preset-row {
  display: flex;
  gap: 6px;
  margin-top: 8px;
}

.preset-btn {
  flex: 1;
  height: 36px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.12s ease;
  -webkit-tap-highlight-color: transparent;
}

.preset-btn:hover {
  border-color: var(--accent);
  color: var(--text);
  background: var(--accent-muted);
}

.preset-btn:active { transform: scale(0.96); }

.preset-btn.active {
  border-color: var(--text-muted);
  color: var(--text);
  background: rgba(226, 228, 233, 0.06);
}

/* ═══════════════════════════════════════════════
   SUBMIT BUTTON
   ═══════════════════════════════════════════════ */

/* Mobile sticky dock */
.submit-dock {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 30;
  padding: 12px 16px;
  padding-bottom: max(12px, env(safe-area-inset-bottom));
  background: linear-gradient(to top, var(--bg-base) 70%, transparent);
}

.submit-dock .inner {
  max-width: 440px;
  margin: 0 auto;
}

.submit-btn {
  width: 100%;
  height: 52px;
  background: var(--text);
  border: none;
  border-radius: var(--radius);
  color: var(--bg-base);
  font-family: var(--font-ui);
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  cursor: pointer;
  transition: all 0.15s ease;
  box-shadow: 0 2px 12px rgba(226, 228, 233, 0.08);
}

.submit-btn:hover {
  background: #fff;
  box-shadow: 0 4px 20px rgba(226, 228, 233, 0.12);
}

.submit-btn:active {
  transform: scale(0.98);
}

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

@media (min-width: 768px) {
  .submit-btn { height: 48px; font-size: 14px; }
}

/* ═══════════════════════════════════════════════
   TOAST
   ═══════════════════════════════════════════════ */

.toast {
  position: fixed;
  top: 60px;
  left: 50%;
  transform: translateX(-50%) translateY(-12px);
  z-index: 100;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  background: var(--success-bg);
  border: 1px solid var(--success);
  border-radius: var(--radius);
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 500;
  color: var(--success);
  letter-spacing: 0.04em;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
}

.toast.visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
  pointer-events: auto;
}

.toast .check {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--success);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.toast .check svg {
  width: 8px;
  height: 8px;
  stroke: #000;
  stroke-width: 3;
  fill: none;
}

/* ═══════════════════════════════════════════════
   ERROR ALERT
   ═══════════════════════════════════════════════ */

.alert-error {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  background: var(--error-bg);
  border: 1px solid rgba(239, 68, 68, 0.3);
  border-radius: var(--radius);
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--error);
  margin-bottom: 16px;
}

/* ═══════════════════════════════════════════════
   DIVIDER
   ═══════════════════════════════════════════════ */

.divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 24px 0;
  opacity: 0.5;
}

/* ═══════════════════════════════════════════════
   LOGIN PAGE
   ═══════════════════════════════════════════════ */

.login-wrapper {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  position: relative;
  z-index: 1;
}

.login-card {
  width: 100%;
  max-width: 380px;
  padding: 40px 28px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 6px;
}

.login-header {
  text-align: center;
  margin-bottom: 32px;
}

.login-header .brand {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.login-header h1 {
  font-family: var(--font-ui);
  font-size: 20px;
  font-weight: 600;
  color: var(--text);
}

.login-link {
  display: block;
  text-align: center;
  margin-top: 20px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-dim);
  text-decoration: none;
  letter-spacing: 0.02em;
  transition: color 0.15s;
}

.login-link:hover { color: var(--text-muted); }

/* ═══════════════════════════════════════════════
   DASHBOARD NAV
   ═══════════════════════════════════════════════ */

.dash-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  height: 52px;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  position: relative;
  z-index: 1;
}

@media (min-width: 768px) {
  .dash-nav { padding: 0 32px; }
}

.dash-nav-brand {
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text);
}

.dash-nav-right {
  display: flex;
  align-items: center;
  gap: 16px;
}

.dash-nav-user {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-muted);
}

.dash-nav-logout {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.04em;
  color: var(--text-dim);
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 5px 12px;
  cursor: pointer;
  transition: all 0.15s;
}

.dash-nav-logout:hover {
  border-color: var(--error);
  color: var(--error);
}

/* ═══════════════════════════════════════════════
   DASHBOARD CONTENT
   ═══════════════════════════════════════════════ */

.dash-content {
  position: relative;
  z-index: 1;
  max-width: 1100px;
  margin: 0 auto;
  padding: 32px 20px;
}

@media (min-width: 768px) {
  .dash-content { padding: 48px 32px; }
}

.dash-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 80px 0;
  text-align: center;
}

.dash-empty-icon {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-dim);
}

.dash-empty p {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--text-dim);
  letter-spacing: 0.02em;
}

/* ═══════════════════════════════════════════════
   DASHBOARD — Filters
   ═══════════════════════════════════════════════ */

.dash-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: flex-end;
  margin-bottom: 24px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border);
}

.filter-group {
  flex: 1 1 140px;
  min-width: 120px;
}

.filter-actions {
  display: flex;
  gap: 8px;
  align-items: flex-end;
  padding-bottom: 1px;
}

.input--sm {
  padding: 8px 10px;
  font-size: 13px;
}

select.input {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg width='10' height='6' viewBox='0 0 10 6' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1L5 5L9 1' stroke='%236e717b' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 28px;
}

.btn-outline {
  height: 38px;
  padding: 0 16px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.04em;
  cursor: pointer;
  transition: all 0.12s;
  white-space: nowrap;
}

.btn-outline:hover {
  border-color: var(--text-muted);
  color: var(--text);
}

/* ═══════════════════════════════════════════════
   DASHBOARD — Summary Cards
   ═══════════════════════════════════════════════ */

.summary-row {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin-bottom: 24px;
}

@media (min-width: 768px) {
  .summary-row {
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
  }
}

.summary-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.summary-label {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.summary-value {
  font-family: var(--font-mono);
  font-size: 24px;
  font-weight: 500;
  color: var(--text);
  line-height: 1;
}

/* ═══════════════════════════════════════════════
   DASHBOARD — Charts
   ═══════════════════════════════════════════════ */

.charts-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  margin-bottom: 24px;
}

@media (min-width: 768px) {
  .charts-grid {
    grid-template-columns: 1fr 1fr;
  }
}

.chart-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}

.chart-title {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 12px;
}

.chart-card canvas {
  width: 100% !important;
  height: 180px !important;
}

/* ═══════════════════════════════════════════════
   DASHBOARD — Data Table
   ═══════════════════════════════════════════════ */

.table-wrap {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow-x: auto;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--font-mono);
  font-size: 12px;
}

.data-table th {
  text-align: left;
  padding: 10px 12px;
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  background: var(--bg-elevated);
  white-space: nowrap;
}

.data-table td {
  padding: 8px 12px;
  color: var(--text);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.data-table tbody tr:last-child td {
  border-bottom: none;
}

.data-table tbody tr:hover td {
  background: var(--bg-elevated);
}

.table-empty {
  padding: 32px 16px;
  text-align: center;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-dim);
}

/* ═══════════════════════════════════════════════
   ADMIN PAGE
   ═══════════════════════════════════════════════ */

.admin-section {
  margin-bottom: 36px;
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.section-title {
  font-family: var(--font-ui);
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
}

.admin-form {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 16px;
}

.admin-form-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: flex-end;
}

.admin-form-grid > div {
  flex: 1 1 160px;
  min-width: 140px;
}

.admin-form-actions {
  display: flex;
  align-items: flex-end;
  padding-bottom: 1px;
}

.btn-primary {
  height: 38px;
  padding: 0 20px;
  background: var(--text);
  border: none;
  border-radius: var(--radius);
  color: var(--bg-base);
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.04em;
  cursor: pointer;
  transition: all 0.12s;
  white-space: nowrap;
}

.btn-primary:hover {
  background: #fff;
}

.btn-sm {
  height: 28px;
  padding: 0 10px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.02em;
  cursor: pointer;
  transition: all 0.12s;
  white-space: nowrap;
}

.btn-sm:hover {
  border-color: var(--text-muted);
  color: var(--text);
}

.badge {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.04em;
  padding: 2px 8px;
  border-radius: 3px;
}

.badge--active {
  color: var(--success);
  background: var(--success-bg);
}

.badge--inactive {
  color: var(--text-dim);
  background: var(--bg-elevated);
}

/* ═══════════════════════════════════════════════
   UTILITY
   ═══════════════════════════════════════════════ */

.hidden { display: none !important; }

/* ═══════════════════════════════════════════════
   SCROLLBAR
   ═══════════════════════════════════════════════ */

::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--bg-base); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-dim); }

/* ═══════════════════════════════════════════════
   SELECTION
   ═══════════════════════════════════════════════ */

::selection {
  background: rgba(226, 228, 233, 0.25);
  color: var(--text);
}
