/* GridTrail Portal — Main Stylesheet */

:root {
  --bg: #0e1117;
  --surface: #161b2e;
  --surface-2: #1e2540;
  --border: #252d45;
  --border-subtle: #1a2238;

  --primary: #4f80e2;
  --primary-dark: #3a66c8;
  --primary-glow: rgba(79, 128, 226, 0.15);

  --success: #2dd4aa;
  --warning: #f59e0b;
  --danger: #f87171;
  --info: #60a5fa;
  --muted: #8b9dc3;

  --text: #e8ecf2;
  --text-muted: #8b9dc3;
  --text-dim: #5a6b8a;

  --font: 'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', 'Cascadia Code', monospace;

  --radius: 8px;
  --radius-sm: 5px;
  --radius-lg: 12px;

  --nav-height: 56px;
  --shadow: 0 2px 12px rgba(0,0,0,.4);
}

/* ======================== Reset & Base ======================== */

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

html { font-size: 16px; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

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

code {
  font-family: var(--font-mono);
  font-size: .85em;
  background: var(--surface-2);
  padding: .1em .4em;
  border-radius: 3px;
  color: var(--success);
}

pre code {
  display: block;
  padding: .75rem 1rem;
  font-size: .85rem;
  overflow-x: auto;
}

h1 { font-size: 1.6rem; font-weight: 700; }
h2 { font-size: 1.1rem; font-weight: 600; }
h3 { font-size: .95rem; font-weight: 600; }

/* ======================== Layout ======================== */

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 1.5rem;
}

.page-main {
  padding-top: 1.5rem;
  padding-bottom: 3rem;
  flex: 1;
}

.page-center {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
}

.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 1.5rem;
  gap: 1rem;
}

.two-col {
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: 1.5rem;
  align-items: start;
}

.section-title {
  font-size: .8rem;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--text-muted);
  margin-bottom: .75rem;
  font-weight: 600;
}

/* ======================== Navbar ======================== */

.navbar {
  height: var(--nav-height);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0 1.5rem;
  position: sticky;
  top: 0;
  z-index: 100;
}

.navbar-brand { display: flex; align-items: center; }

.brand-link {
  display: flex;
  align-items: center;
  gap: .5rem;
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--text);
  text-decoration: none;
}

.brand-icon {
  color: var(--primary);
  font-size: 1.2rem;
}

.brand-icon.large { font-size: 2.5rem; display: block; }

.brand-name { font-weight: 700; }

.brand-tagline {
  color: var(--text-muted);
  font-size: .875rem;
  margin-top: .25rem;
}

.navbar-nav {
  display: flex;
  list-style: none;
  gap: .25rem;
  margin-left: 1rem;
}

.nav-link {
  padding: .375rem .75rem;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: .875rem;
  font-weight: 500;
  transition: background .15s, color .15s;
}

.nav-link:hover, .nav-link.active {
  background: var(--primary-glow);
  color: var(--primary);
  text-decoration: none;
}

.nav-link-admin { color: var(--warning) !important; }
.nav-link-admin:hover { background: rgba(245,158,11,.1) !important; }

.navbar-user {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: .75rem;
}

.user-name { font-size: .875rem; font-weight: 500; color: var(--text); }

/* ======================== Auth pages ======================== */

.auth-container { width: 100%; padding: 1.5rem; }

.auth-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 2.5rem;
  width: 100%;
  max-width: 440px;
  margin: 0 auto;
  box-shadow: var(--shadow);
}

.brand-hero {
  text-align: center;
  margin-bottom: 2rem;
}

.auth-form { display: flex; flex-direction: column; gap: 1rem; }

.auth-links {
  margin-top: 1.5rem;
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: .5rem;
  font-size: .875rem;
  color: var(--text-muted);
}

/* ======================== Cards ======================== */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.card-muted { background: var(--bg); border-color: var(--border-subtle); }

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: .875rem 1.25rem;
  border-bottom: 1px solid var(--border);
}

.card-title { font-size: .9rem; font-weight: 600; margin: 0; }

.card-link { font-size: .8rem; color: var(--primary); }

.card-body { padding: 1.25rem; }

/* ======================== Dashboard grid ======================== */

.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 1.25rem;
}

/* ======================== Stat cards ======================== */

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 1rem;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  text-align: center;
}

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

.stat-card-label {
  font-size: .75rem;
  color: var(--text-muted);
  margin-top: .375rem;
  text-transform: uppercase;
  letter-spacing: .05em;
}

/* ======================== Stat list ======================== */

.stat-list { display: flex; flex-direction: column; gap: .4rem; }

.stat-item {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: .5rem;
  font-size: .875rem;
}

.stat-label { color: var(--text-muted); flex-shrink: 0; }
.stat-value { font-weight: 500; text-align: right; }

/* ======================== Status indicators ======================== */

.status-row { display: flex; align-items: center; gap: .5rem; font-size: .875rem; }

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

.status-online { background: var(--success); box-shadow: 0 0 6px var(--success); }
.status-stale  { background: var(--warning); }
.status-offline{ background: var(--text-dim); }

/* ======================== Badges ======================== */

.badge {
  display: inline-flex;
  align-items: center;
  padding: .2em .65em;
  border-radius: 999px;
  font-size: .72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .04em;
}

.badge-solo        { background: rgba(79,128,226,.15); color: var(--primary); }
.badge-host        { background: rgba(45,212,170,.15); color: var(--success); }
.badge-admin       { background: rgba(245,158,11,.15); color: var(--warning); }
.badge-active      { background: rgba(45,212,170,.15); color: var(--success); }
.badge-ended,
.badge-expired,
.badge-deleted,
.badge-neutral     { background: var(--surface-2); color: var(--text-muted); }
.badge-suspended   { background: rgba(248,113,113,.15); color: var(--danger); }
.badge-info        { background: rgba(96,165,250,.15); color: var(--info); }
.badge-warning     { background: rgba(245,158,11,.15); color: var(--warning); }
.badge-maintenance { background: rgba(248,113,113,.15); color: var(--danger); }
.badge-important   { background: rgba(248,113,113,.2); color: var(--danger); border: 1px solid rgba(248,113,113,.3); }

/* User badge in navbar */
.user-badge {
  font-size: .7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .05em;
  padding: .15em .5em;
  border-radius: 999px;
}

.user-badge-host { background: rgba(45,212,170,.2); color: var(--success); }
.user-badge-solo { background: rgba(79,128,226,.2); color: var(--primary); }

/* ======================== Alerts ======================== */

.alert {
  padding: .875rem 1.1rem;
  border-radius: var(--radius);
  font-size: .875rem;
  border-left: 3px solid;
}

.alert-success     { background: rgba(45,212,170,.1);  border-color: var(--success); color: var(--success); }
.alert-danger      { background: rgba(248,113,113,.1); border-color: var(--danger);  color: var(--danger); }
.alert-warning     { background: rgba(245,158,11,.1);  border-color: var(--warning); color: var(--warning); }
.alert-info        { background: rgba(96,165,250,.1);  border-color: var(--info);    color: var(--info); }
.alert-maintenance { background: rgba(248,113,113,.1); border-color: var(--danger);  color: var(--danger); }
.alert-important   { background: rgba(248,113,113,.15);border-color: var(--danger);  color: var(--danger); }

.news-stack { display: flex; flex-direction: column; gap: .5rem; margin-bottom: 1.5rem; }

/* ======================== Buttons ======================== */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .375rem;
  padding: .5rem 1.25rem;
  border-radius: var(--radius-sm);
  font-size: .875rem;
  font-weight: 600;
  border: none;
  cursor: pointer;
  transition: background .15s, opacity .15s;
  text-decoration: none;
  white-space: nowrap;
  line-height: 1.4;
}

.btn:hover { text-decoration: none; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.btn-primary   { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }

.btn-secondary { background: var(--surface-2); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--border); }

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

.btn-warning { background: rgba(245,158,11,.15); color: var(--warning); border: 1px solid rgba(245,158,11,.3); }
.btn-warning:hover { background: rgba(245,158,11,.25); }

.btn-success { background: rgba(45,212,170,.15); color: var(--success); border: 1px solid rgba(45,212,170,.3); }
.btn-success:hover { background: rgba(45,212,170,.25); }

.btn-sm { padding: .35rem .85rem; font-size: .8rem; }
.btn-xs { padding: .2rem .5rem; font-size: .75rem; }
.btn-full { width: 100%; }

.btn-danger-text { color: var(--danger) !important; }
.btn-danger-text:hover { background: rgba(248,113,113,.1) !important; }

.btn-group { display: flex; gap: .5rem; align-items: center; }

/* ======================== Forms ======================== */

.form-group { display: flex; flex-direction: column; gap: .35rem; }

.form-row {
  display: flex;
  gap: 1rem;
  align-items: flex-start;
}

.form-control {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  padding: .5rem .75rem;
  font-size: .875rem;
  font-family: var(--font);
  width: 100%;
  transition: border-color .15s;
}

.form-control:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-glow);
}

.form-control::placeholder { color: var(--text-dim); }

textarea.form-control { resize: vertical; }

select.form-control { cursor: pointer; }

.form-control-sm { padding: .3rem .6rem; font-size: .8rem; }

.form-hint { font-size: .75rem; color: var(--text-muted); }

.form-actions {
  display: flex;
  gap: .75rem;
  align-items: center;
  margin-top: 1.5rem;
}

label {
  font-size: .8rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .04em;
}

.required { color: var(--danger); }

.inline-form {
  display: flex;
  align-items: center;
  gap: .5rem;
  flex-wrap: wrap;
}

.checkbox-group { display: flex; flex-direction: column; gap: .5rem; }

.checkbox-label {
  display: flex;
  align-items: center;
  gap: .5rem;
  font-size: .875rem;
  font-weight: 400;
  color: var(--text);
  text-transform: none;
  letter-spacing: 0;
  cursor: pointer;
}

.input-with-unit { position: relative; }
.input-with-unit .form-control { padding-right: 2rem; }
.input-unit {
  position: absolute;
  right: .75rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: .8rem;
  pointer-events: none;
}

/* ======================== Tables ======================== */

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .875rem;
}

.data-table th {
  padding: .625rem 1rem;
  text-align: left;
  font-size: .72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
}

.data-table td {
  padding: .75rem 1rem;
  border-bottom: 1px solid var(--border-subtle);
  vertical-align: middle;
}

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

.data-table tbody tr:hover { background: var(--surface-2); }

.text-right { text-align: right; }
.text-center { text-align: center; }

.table-footer { border-top: 1px solid var(--border); }

/* ======================== Filters ======================== */

.filter-bar {
  display: flex;
  gap: .75rem;
  margin-bottom: 1rem;
  align-items: center;
  flex-wrap: wrap;
}

/* ======================== Action items ======================== */

.action-list { display: flex; flex-direction: column; gap: .5rem; }

.action-item {
  display: flex;
  align-items: center;
  gap: .875rem;
  padding: .625rem .875rem;
  border-radius: var(--radius-sm);
  text-decoration: none;
  color: var(--text);
  transition: background .15s;
  border: 1px solid transparent;
}

.action-item:hover {
  background: var(--surface-2);
  border-color: var(--border);
  text-decoration: none;
}

.action-icon { font-size: 1.25rem; flex-shrink: 0; }

.action-list-v { display: flex; flex-direction: column; gap: .75rem; }

/* ======================== Item lists ======================== */

.item-list { list-style: none; display: flex; flex-direction: column; }

.item-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: .5rem 0;
  border-bottom: 1px solid var(--border-subtle);
  font-size: .875rem;
  gap: .5rem;
}

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

/* ======================== Trails ======================== */

.trail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 1rem;
}

.trail-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: .5rem;
}

.trail-card-header { display: flex; justify-content: space-between; align-items: center; }

.trail-card-title { font-size: 1rem; font-weight: 600; }
.trail-card-title a { color: var(--text); }

.trail-card-footer { display: flex; gap: .5rem; margin-top: .5rem; }

/* ======================== Join code ======================== */

.join-code-display {
  font-size: 2.5rem;
  font-weight: 700;
  font-family: var(--font-mono);
  letter-spacing: .3em;
  color: var(--primary);
  padding: 1rem;
  background: var(--primary-glow);
  border-radius: var(--radius);
  border: 1px solid rgba(79,128,226,.3);
}

code.join-code {
  font-size: .9rem;
  font-family: var(--font-mono);
  letter-spacing: .15em;
  background: var(--primary-glow);
  color: var(--primary);
  padding: .2em .6em;
}

/* ======================== Participants ======================== */

.participant-list { margin-top: .75rem; display: flex; flex-direction: column; gap: .25rem; }

.participant-list-full { list-style: none; display: flex; flex-direction: column; }

.participant-item {
  display: flex;
  align-items: center;
  gap: .625rem;
  padding: .5rem 0;
  border-bottom: 1px solid var(--border-subtle);
  font-size: .875rem;
}

.participant-item:last-child { border-bottom: none; }

/* ======================== Tags ======================== */

.tag {
  display: inline-block;
  padding: .15em .5em;
  border-radius: 3px;
  font-size: .72rem;
  font-weight: 700;
  font-family: var(--font-mono);
  letter-spacing: .04em;
  background: var(--surface-2);
  color: var(--text-muted);
  border: 1px solid var(--border);
}

.tag-start, .tag-finish { background: rgba(45,212,170,.1); color: var(--success); border-color: rgba(45,212,170,.3); }
.tag-hazard { background: rgba(248,113,113,.1); color: var(--danger); border-color: rgba(248,113,113,.3); }
.tag-muster, .tag-dock { background: rgba(79,128,226,.1); color: var(--primary); border-color: rgba(79,128,226,.3); }
.tag-party { background: rgba(245,158,11,.1); color: var(--warning); border-color: rgba(245,158,11,.3); }

/* ======================== Admin nav ======================== */

.admin-nav-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 1rem;
}

.admin-nav-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  display: flex;
  align-items: flex-start;
  gap: 1rem;
  color: var(--text);
  text-decoration: none;
  transition: border-color .15s, background .15s;
}

.admin-nav-card:hover {
  border-color: var(--primary);
  background: var(--surface-2);
  text-decoration: none;
}

.admin-nav-icon { font-size: 1.5rem; flex-shrink: 0; }

/* ======================== Toggle switch ======================== */

.toggle-list { display: flex; flex-direction: column; gap: 0; }

.toggle-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 0;
  border-bottom: 1px solid var(--border-subtle);
}

.toggle-item:last-child { border-bottom: none; }

.toggle-switch { position: relative; display: inline-flex; cursor: pointer; }

.toggle-switch input { opacity: 0; width: 0; height: 0; position: absolute; }

.toggle-track {
  width: 44px;
  height: 24px;
  background: var(--surface-2);
  border-radius: 999px;
  border: 1px solid var(--border);
  transition: background .2s;
  position: relative;
  flex-shrink: 0;
}

.toggle-track::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--text-dim);
  transition: transform .2s, background .2s;
}

.toggle-switch input:checked + .toggle-track { background: var(--primary); border-color: var(--primary); }
.toggle-switch input:checked + .toggle-track::after { transform: translateX(20px); background: #fff; }

/* ======================== Info block ======================== */

.info-block {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: .875rem 1rem;
}

.info-block-title {
  font-size: .72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-muted);
  margin-bottom: .375rem;
}

/* ======================== Map page ======================== */

.map-page { overflow: hidden; }

.map-layout {
  display: flex;
  height: calc(100vh - var(--nav-height));
}

.map-sidebar {
  width: 280px;
  min-width: 280px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: .75rem;
}

.sidebar-section {
  border-bottom: 1px solid var(--border-subtle);
  padding-bottom: .75rem;
}

.sidebar-section:last-child { border-bottom: none; }

.sidebar-title {
  font-size: .7rem;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--text-muted);
  font-weight: 700;
  margin-bottom: .5rem;
}

.trail-info { font-size: .875rem; }

.map-canvas { flex: 1; background: #1a1a2e; }

.control-group { display: flex; gap: .5rem; flex-wrap: wrap; }

.map-canvas .leaflet-container { background: #141428; }

/* ======================== Empty state ======================== */

.empty-state {
  text-align: center;
  padding: 4rem 2rem;
}

.empty-icon { font-size: 3rem; margin-bottom: 1rem; }

/* ======================== Footer ======================== */

.site-footer {
  text-align: center;
  padding: 1.5rem;
  border-top: 1px solid var(--border);
  font-size: .8rem;
  color: var(--text-dim);
  margin-top: auto;
}

/* ======================== Utility ======================== */

.text-muted { color: var(--text-muted); }
.text-dim   { color: var(--text-dim); }
.text-sm    { font-size: .875rem; }
.text-xs    { font-size: .75rem; }
.text-warning { color: var(--warning); }
.text-danger  { color: var(--danger); }

.link-small { font-size: .8rem; color: var(--primary); }

/* ======================== Responsive ======================== */

@media (max-width: 768px) {
  .two-col { grid-template-columns: 1fr; }
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .dashboard-grid { grid-template-columns: 1fr; }
  .map-sidebar { display: none; }
  .filter-bar { flex-direction: column; }
  .page-header { flex-direction: column; }
  .data-table { font-size: .8rem; }
  .data-table th, .data-table td { padding: .5rem .75rem; }
}
