/* ============================================================================
   VOSP Control Panel — Dark Theme
   Colour palette sourced directly from VOSPLauncher/DarkTheme.xaml
   ============================================================================ */

/* ── Custom properties ──────────────────────────────────────────────────────── */
:root {
  --bg:               #0d1117;
  --surface:          #161b22;
  --surface-raised:   #1c2128;
  --border:           #30363d;
  --border-muted:     #21262d;

  --primary:          #3fb950;
  --primary-hover:    #4ac55b;
  --primary-dark:     #2ea043;
  --primary-subtle:   rgba(63,185,80,.12);

  --danger:           #da3633;
  --danger-hover:     #f85149;
  --danger-subtle:    rgba(218,54,51,.12);

  --warning:          #d29922;
  --warning-border:   #f0c869;
  --warning-subtle:   rgba(210,153,34,.12);

  --info:             #388bfd;
  --info-subtle:      rgba(56,139,253,.12);

  --text:             #f0f6fc;
  --text-muted:       #8b949e;
  --text-disabled:    #484f58;

  --radius:           6px;
  --radius-lg:        8px;
  --radius-pill:      999px;

  --sidebar-w:        220px;
  --header-h:         56px;

  --font:             "Segoe UI", system-ui, -apple-system, sans-serif;
  --font-mono:        "Cascadia Code", "Consolas", monospace;

  --transition:       120ms ease;
}

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

html { font-size: 14px; -webkit-text-size-adjust: 100%; }

body {
  font-family: var(--font);
  font-size: 1rem;
  line-height: 1.5;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

img { display: block; max-width: 100%; }

/* ── Layout — sidebar + main ────────────────────────────────────────────────── */
.layout {
  display: flex;
  min-height: 100vh;
}

/* Sidebar */
.sidebar {
  width: var(--sidebar-w);
  background: var(--surface);
  border-right: 1px solid var(--border);
  position: fixed;
  top: 0; bottom: 0; left: 0;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  overflow-x: hidden;
  z-index: 100;
}

.sidebar-logo-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 18px 16px 14px;
  border-bottom: 1px solid var(--border-muted);
  flex-shrink: 0;
}

.sidebar-logo {
  width: 28px;
  height: 28px;
  flex-shrink: 0;
}

.sidebar-wordmark {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: .3px;
}

.sidebar-nav {
  flex: 1;
  padding: 8px 0;
}

.nav-section-label {
  padding: 12px 16px 4px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-disabled);
  text-transform: uppercase;
  letter-spacing: .6px;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 7px 16px;
  color: var(--text-muted);
  font-size: 13px;
  transition: background var(--transition), color var(--transition);
  border-left: 2px solid transparent;
  text-decoration: none;
}

.nav-link:hover {
  background: var(--surface-raised);
  color: var(--text);
  text-decoration: none;
}

.nav-link.active {
  background: var(--primary-subtle);
  color: var(--primary);
  border-left-color: var(--primary);
  font-weight: 500;
}

.nav-icon {
  font-size: 15px;
  width: 18px;
  text-align: center;
  flex-shrink: 0;
}

.nav-badge {
  margin-left: auto;
  background: var(--danger);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: var(--radius-pill);
  line-height: 16px;
}

.sidebar-footer {
  flex-shrink: 0;
  border-top: 1px solid var(--border-muted);
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.sidebar-footer-username {
  font-size: 13px;
  color: var(--text-muted);
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sidebar-footer-logout {
  background: none;
  border: none;
  color: var(--text-disabled);
  font-size: 13px;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: var(--radius);
  transition: color var(--transition), background var(--transition);
}

.sidebar-footer-logout:hover {
  color: var(--danger-hover);
  background: var(--danger-subtle);
}

/* Admin separator */
.nav-divider {
  height: 1px;
  background: var(--border-muted);
  margin: 8px 0;
}

.nav-link.admin-link { color: var(--warning); }
.nav-link.admin-link:hover { color: var(--warning-border); background: var(--warning-subtle); }
.nav-link.admin-link.active {
  background: var(--warning-subtle);
  color: var(--warning-border);
  border-left-color: var(--warning);
}

/* ── Main content area ──────────────────────────────────────────────────────── */
.main {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.header {
  height: var(--header-h);
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 50;
  flex-shrink: 0;
}

.header-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
  flex: 1;
}

.header-meta {
  display: flex;
  align-items: center;
  gap: 12px;
}

.content {
  flex: 1;
  padding: 24px;
  max-width: 1200px;
  width: 100%;
}

/* ── Public layout (login / register) ───────────────────────────────────────── */
.public-layout {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.auth-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 32px;
  width: 100%;
  max-width: 380px;
}

.auth-logo-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-bottom: 24px;
}

.auth-logo {
  width: 36px;
  height: 36px;
}

.auth-wordmark {
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
}

.auth-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 20px;
  text-align: center;
}

.auth-footer {
  margin-top: 20px;
  text-align: center;
  font-size: 13px;
  color: var(--text-muted);
}

/* ── Flash / alert messages ─────────────────────────────────────────────────── */
.alerts {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 20px;
}

.alert {
  padding: 10px 14px;
  border-radius: var(--radius);
  font-size: 13px;
  border: 1px solid transparent;
  border-left-width: 3px;
}

.alert-error, .alert-danger {
  background: var(--danger-subtle);
  border-color: var(--danger);
  color: #ffa198;
}

.alert-success {
  background: var(--primary-subtle);
  border-color: var(--primary);
  color: #7ee787;
}

.alert-warning {
  background: var(--warning-subtle);
  border-color: var(--warning);
  color: var(--warning-border);
}

.alert-info {
  background: var(--info-subtle);
  border-color: var(--info);
  color: #79c0ff;
}

/* ── Form elements ──────────────────────────────────────────────────────────── */
.field {
  margin-bottom: 14px;
}

.field label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  margin-bottom: 5px;
}

.field input,
.field select,
.field textarea {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-family: var(--font);
  font-size: 13px;
  padding: 8px 12px;
  height: 38px;
  transition: border-color var(--transition), box-shadow var(--transition);
  outline: none;
}

.field textarea {
  height: auto;
  resize: vertical;
  min-height: 80px;
}

.field input::placeholder,
.field textarea::placeholder {
  color: var(--text-disabled);
}

.field input:focus,
.field select:focus,
.field textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-subtle);
}

.field input[type="color"] {
  padding: 2px 4px;
  cursor: pointer;
}

.field-hint {
  font-size: 12px;
  color: var(--text-disabled);
  margin-top: 4px;
}

.field-error {
  font-size: 12px;
  color: #ffa198;
  margin-top: 4px;
}

/* Select */
select {
  background-color: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px 12px;
  font-size: 13px;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%238b949e' d='M1 1l5 5 5-5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 32px;
  cursor: pointer;
}

select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-subtle);
}

/* Checkbox */
.checkbox-field {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-size: 13px;
  color: var(--text-muted);
}

.checkbox-field input[type="checkbox"] {
  width: 15px;
  height: 15px;
  accent-color: var(--primary);
  cursor: pointer;
}

/* ── Buttons ────────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 7px 16px;
  border-radius: var(--radius);
  font-family: var(--font);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid var(--border);
  background: var(--surface-raised);
  color: var(--text);
  transition: background var(--transition), border-color var(--transition),
              color var(--transition);
  text-decoration: none;
  white-space: nowrap;
  height: 34px;
}

.btn:hover {
  background: var(--border);
  border-color: var(--text-disabled);
  text-decoration: none;
}

.btn:disabled, .btn[disabled] {
  opacity: .5;
  cursor: not-allowed;
}

/* Primary (green gradient) */
.btn-primary {
  background: linear-gradient(180deg, var(--primary) 0%, var(--primary-dark) 100%);
  border-color: transparent;
  color: #fff;
}

.btn-primary:hover {
  background: linear-gradient(180deg, var(--primary-hover) 0%, var(--primary) 100%);
  border-color: transparent;
  color: #fff;
}

/* Danger (red gradient) */
.btn-danger {
  background: linear-gradient(180deg, var(--danger-hover) 0%, var(--danger) 100%);
  border-color: transparent;
  color: #fff;
}

.btn-danger:hover {
  background: linear-gradient(180deg, #ff6b61 0%, var(--danger-hover) 100%);
  border-color: transparent;
  color: #fff;
}

/* Warning */
.btn-warning {
  background: var(--warning);
  border-color: var(--warning-border);
  color: var(--bg);
}

.btn-warning:hover {
  background: var(--warning-border);
  color: var(--bg);
}

/* Ghost / link-style */
.btn-ghost {
  background: transparent;
  border-color: transparent;
  color: var(--text-muted);
}

.btn-ghost:hover {
  background: var(--surface-raised);
  color: var(--text);
}

/* Size modifiers */
.btn-sm { height: 28px; padding: 4px 10px; font-size: 12px; }
.btn-lg { height: 44px; padding: 10px 24px; font-size: 15px; font-weight: 600; }
.btn-block { width: 100%; }

/* Icon-only button */
.btn-icon {
  width: 32px;
  height: 32px;
  padding: 0;
  border-radius: var(--radius);
}

/* ── Cards ──────────────────────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border-muted);
}

.card-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}

.card-subtitle {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}

/* ── Stat cards (dashboard) ─────────────────────────────────────────────────── */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

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

.stat-label {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: .4px;
}

.stat-value {
  font-size: 28px;
  font-weight: 700;
  color: var(--text);
  line-height: 1;
}

.stat-value.green { color: var(--primary); }
.stat-value.amber { color: var(--warning); }

/* ── Tables ─────────────────────────────────────────────────────────────────── */
.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

thead th {
  text-align: left;
  padding: 8px 12px;
  color: var(--text-muted);
  font-weight: 500;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .4px;
  border-bottom: 1px solid var(--border);
}

tbody tr {
  border-bottom: 1px solid var(--border-muted);
  transition: background var(--transition);
}

tbody tr:hover { background: var(--surface-raised); }
tbody tr:last-child { border-bottom: none; }

tbody td {
  padding: 10px 12px;
  color: var(--text);
  vertical-align: middle;
}

/* ── Badges / chips ─────────────────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 8px;
  border-radius: var(--radius-pill);
  font-size: 11px;
  font-weight: 600;
  border: 1px solid var(--border);
  background: var(--surface-raised);
  color: var(--text-muted);
}

.badge-green  { background: var(--primary-subtle);  border-color: var(--primary);       color: var(--primary);       }
.badge-red    { background: var(--danger-subtle);   border-color: var(--danger);        color: #ffa198;              }
.badge-amber  { background: var(--warning-subtle);  border-color: var(--warning);       color: var(--warning-border);}
.badge-blue   { background: var(--info-subtle);     border-color: var(--info);          color: #79c0ff;              }

.dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
}
.dot-green  { background: var(--primary); }
.dot-red    { background: var(--danger);  }
.dot-amber  { background: var(--warning); }

/* ── Page sections ──────────────────────────────────────────────────────────── */
.page-header {
  margin-bottom: 24px;
}

.page-header h1 {
  font-size: 20px;
  font-weight: 700;
  color: var(--text);
}

.page-header p {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 4px;
}

.section-gap { margin-bottom: 24px; }
.section-gap-sm { margin-bottom: 14px; }

/* ── Utility ────────────────────────────────────────────────────────────────── */
.flex         { display: flex; }
.flex-center  { display: flex; align-items: center; }
.gap-8        { gap: 8px; }
.gap-12       { gap: 12px; }
.gap-16       { gap: 16px; }
.ml-auto      { margin-left: auto; }
.text-muted   { color: var(--text-muted); }
.text-sm      { font-size: 12px; }
.text-danger  { color: #ffa198; }
.text-success { color: var(--primary); }
.fw-600       { font-weight: 600; }
.mono         { font-family: var(--font-mono); }

/* Crew colour swatch */
.colour-swatch {
  width: 14px; height: 14px;
  border-radius: 3px;
  border: 1px solid rgba(255,255,255,.15);
  display: inline-block;
  flex-shrink: 0;
}

/* Crew tag display */
.crew-tag {
  font-family: var(--font-mono);
  font-size: 12px;
  background: var(--surface-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1px 6px;
  color: var(--text-muted);
}

/* Plate display */
.plate {
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 700;
  background: var(--surface-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 3px 10px;
  color: var(--text);
  letter-spacing: 2px;
  text-transform: uppercase;
}

/* ── Scrollbar (webkit) ─────────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #3a414a; border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: #4a5260; }

/* ── Info rows (account settings key/value display) ────────────────────────── */
.info-rows {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.info-row {
  display: flex;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid var(--border-muted);
  gap: 16px;
}

.info-row:last-child {
  border-bottom: none;
}

.info-label {
  font-size: 13px;
  color: var(--text-muted);
  width: 180px;
  flex-shrink: 0;
}

.info-value {
  font-size: 13px;
  color: var(--text);
}

/* ── Dashboard — section labels ─────────────────────────────────────────────── */
.section-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-disabled);
  text-transform: uppercase;
  letter-spacing: .6px;
  margin-bottom: 10px;
}

/* ── Dashboard — stat sub-line ──────────────────────────────────────────────── */
.stat-sub {
  margin-top: 6px;
  font-size: 12px;
}

.stat-sub a {
  color: var(--text-muted);
}

.stat-sub a:hover {
  color: var(--primary);
}

/* ── Dashboard — quick links grid ───────────────────────────────────────────── */
.quick-links {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
}

.quick-link-card {
  display: block;
  color: var(--text);
  text-decoration: none;
  transition: border-color var(--transition), background var(--transition);
}

.quick-link-card:hover {
  border-color: var(--primary);
  background: var(--surface-raised);
  text-decoration: none;
}

.quick-link-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 4px;
}

.quick-link-desc {
  font-size: 12px;
  color: var(--text-muted);
}

/* ── Crew permission checkboxes ─────────────────────────────────────────────── */
.perm-checkboxes {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.perm-check {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  color: var(--text-muted);
  cursor: pointer;
  white-space: nowrap;
}

.perm-check input[type="checkbox"] {
  accent-color: var(--primary);
  width: 13px;
  height: 13px;
}

/* ── Filter bar (UGC browser, admin lists) ──────────────────────────────────── */
.filter-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.filter-search {
  flex: 1;
  min-width: 160px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-family: var(--font);
  font-size: 13px;
  padding: 7px 12px;
  height: 34px;
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
}

.filter-search:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-subtle);
}

/* ── Pagination ─────────────────────────────────────────────────────────────── */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-top: 16px;
}

/* ── Responsive ─────────────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  :root { --sidebar-w: 0px; }
  .sidebar { transform: translateX(-220px); transition: transform .2s ease; }
  .sidebar.open { transform: translateX(0); width: 220px; }
  .main { margin-left: 0; }
}
