/* ============================================================
   Polestar 4 Hub — Stylesheet
   Design: Dark automotive dashboard, TeslaFi-inspired
   Fonts: DM Sans (UI) + Space Mono (data/versions)
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=DM+Sans:wght@300;400;500;600;700&family=Space+Mono:wght@400;700&display=swap');

:root {
  --bg:         #080A10;
  --bg-2:       #0D0F1A;
  --bg-3:       #131626;
  --sidebar-w:  240px;
  --card:       #111422;
  --card-hover: #161929;
  --border:     #1C2035;
  --border-2:   #252A40;
  --accent:     #00CFFF;
  --accent-dim: rgba(0, 207, 255, 0.1);
  --accent-2:   #FF6B2B;
  --gold:       #F0C040;
  --text:       #DDE2F0;
  --text-2:     #8A91AD;
  --text-3:     #525875;
  --green:      #00E67A;
  --red:        #FF4455;
  --orange:     #FF9000;
  --radius:     8px;
  --radius-lg:  14px;
  --shadow:     0 4px 24px rgba(0,0,0,0.5);
  --shadow-lg:  0 8px 48px rgba(0,0,0,0.7);
  --transition: 0.18s ease;
  --font:       'DM Sans', sans-serif;
  --mono:       'Space Mono', monospace;
}

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

html { font-size: 15px; scroll-behavior: smooth; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; transition: opacity var(--transition); }
a:hover { opacity: 0.8; }

/* ── Layout ─────────────────────────────────────────────── */

.layout {
  display: flex;
  min-height: 100vh;
}

/* ── Sidebar ─────────────────────────────────────────────── */

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

.sidebar-logo {
  padding: 24px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 12px;
}

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

.sidebar-logo-text {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
}

.sidebar-logo-text strong {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text);
  letter-spacing: 0.04em;
}

.sidebar-logo-text span {
  font-size: 0.7rem;
  color: var(--accent);
  font-family: var(--mono);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.sidebar-nav {
  padding: 16px 12px;
  flex: 1;
}

.nav-label {
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-3);
  padding: 12px 8px 6px;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: 7px;
  color: var(--text-2);
  font-size: 0.875rem;
  font-weight: 500;
  transition: all var(--transition);
  margin-bottom: 2px;
}

.nav-link svg { width: 18px; height: 18px; flex-shrink: 0; opacity: 0.7; }
.nav-link:hover { background: var(--bg-3); color: var(--text); opacity: 1; }
.nav-link:hover svg { opacity: 1; }
.nav-link.active { background: var(--accent-dim); color: var(--accent); }
.nav-link.active svg { opacity: 1; color: var(--accent); }

.sidebar-footer {
  padding: 16px 12px;
  border-top: 1px solid var(--border);
}

.user-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 8px;
  background: var(--bg-3);
  cursor: pointer;
  transition: background var(--transition);
}

.user-chip:hover { background: var(--border); }

.user-avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: var(--accent-dim);
  border: 2px solid var(--accent);
  display: flex; align-items: center; justify-content: center;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--accent);
  flex-shrink: 0;
}

.user-chip-info { flex: 1; min-width: 0; }
.user-chip-name { font-size: 0.8rem; font-weight: 600; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-chip-role { font-size: 0.65rem; color: var(--text-3); font-family: var(--mono); }

/* ── Main Content ─────────────────────────────────────────── */

.main {
  margin-left: var(--sidebar-w);
  flex: 1;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.topbar {
  height: 56px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 28px;
  gap: 16px;
  background: rgba(8, 10, 16, 0.8);
  backdrop-filter: blur(12px);
  position: sticky;
  top: 0;
  z-index: 50;
}

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

.page-content {
  padding: 28px;
  flex: 1;
}

/* ── Cards ───────────────────────────────────────────────── */

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

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

.card-title {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text);
  letter-spacing: 0.02em;
}

.card-body { padding: 20px; }

/* ── Stats Grid ──────────────────────────────────────────── */

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  transition: border-color var(--transition);
}

.stat-card:hover { border-color: var(--border-2); }

.stat-label {
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-3);
}

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

.stat-value.accent { color: var(--accent); }
.stat-value.green  { color: var(--green); }
.stat-value.gold   { color: var(--gold); }

.stat-sub {
  font-size: 0.72rem;
  color: var(--text-3);
}

/* ── Update List ─────────────────────────────────────────── */

.update-list { display: flex; flex-direction: column; gap: 12px; }

.update-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px 22px;
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 18px;
  align-items: start;
  transition: border-color var(--transition), background var(--transition);
  cursor: pointer;
  text-decoration: none;
  color: inherit;
}

.update-card:hover {
  border-color: var(--accent);
  background: var(--card-hover);
  opacity: 1;
}

.severity-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  margin-top: 6px;
  flex-shrink: 0;
}

.severity-dot.major    { background: var(--accent); box-shadow: 0 0 8px var(--accent); }
.severity-dot.minor    { background: var(--green); }
.severity-dot.patch    { background: var(--text-3); }
.severity-dot.security { background: var(--red); box-shadow: 0 0 8px var(--red); }

.update-version {
  font-family: var(--mono);
  font-size: 0.75rem;
  color: var(--accent);
  margin-bottom: 4px;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.update-title {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 6px;
}

.update-desc {
  font-size: 0.8rem;
  color: var(--text-2);
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.update-meta {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
  white-space: nowrap;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border-radius: 20px;
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.badge.major    { background: rgba(0,207,255,0.12); color: var(--accent); }
.badge.minor    { background: rgba(0,230,122,0.1); color: var(--green); }
.badge.patch    { background: rgba(82,88,117,0.2); color: var(--text-2); }
.badge.security { background: rgba(255,68,85,0.12); color: var(--red); }
.badge.region   { background: rgba(255,255,255,0.05); color: var(--text-3); }

.update-date {
  font-size: 0.72rem;
  color: var(--text-3);
  font-family: var(--mono);
}

.update-comments-count {
  font-size: 0.72rem;
  color: var(--text-3);
}

/* ── Feature List ────────────────────────────────────────── */

.feature-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.feature-list li {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  font-size: 0.85rem;
  color: var(--text-2);
  line-height: 1.5;
}

.feature-list li::before {
  content: '';
  display: block;
  width: 5px; height: 5px;
  border-radius: 50%;
  background: var(--accent);
  margin-top: 8px;
  flex-shrink: 0;
}

/* ── Comments ────────────────────────────────────────────── */

.comments-section { margin-top: 24px; }

.comment {
  display: flex;
  gap: 12px;
  padding: 14px 0;
  border-bottom: 1px solid var(--border);
}

.comment:last-child { border-bottom: none; }

.comment-avatar {
  width: 34px; height: 34px;
  border-radius: 50%;
  background: var(--bg-3);
  border: 1.5px solid var(--border-2);
  display: flex; align-items: center; justify-content: center;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-2);
  flex-shrink: 0;
}

.comment-body { flex: 1; }
.comment-header { display: flex; align-items: baseline; gap: 8px; margin-bottom: 4px; }
.comment-author { font-size: 0.8rem; font-weight: 600; color: var(--text); }
.comment-time   { font-size: 0.7rem; color: var(--text-3); font-family: var(--mono); }
.comment-text   { font-size: 0.85rem; color: var(--text-2); line-height: 1.6; }

/* ── Forum ───────────────────────────────────────────────── */

.forum-table { width: 100%; border-collapse: collapse; }

.forum-table th {
  text-align: left;
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-3);
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
}

.forum-table td {
  padding: 14px 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

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

.forum-table tr:hover td { background: var(--bg-3); }

.post-title {
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text);
  display: block;
  margin-bottom: 3px;
}

.post-title:hover { color: var(--accent); }

.post-meta {
  font-size: 0.72rem;
  color: var(--text-3);
}

.cat-badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 8px;
  border-radius: 20px;
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  white-space: nowrap;
}

.cat-general     { background: rgba(255,255,255,0.06); color: var(--text-2); }
.cat-software    { background: rgba(0,207,255,0.1);   color: var(--accent); }
.cat-charging    { background: rgba(0,230,122,0.1);   color: var(--green); }
.cat-adas        { background: rgba(255,160,0,0.1);   color: var(--orange); }
.cat-modifications { background: rgba(255,107,43,0.1); color: var(--accent-2); }
.cat-buying-advice { background: rgba(240,192,64,0.1); color: var(--gold); }
.cat-media       { background: rgba(150,100,255,0.1); color: #A078FF; }

/* ── Forms ───────────────────────────────────────────────── */

.form-group { margin-bottom: 16px; }

label {
  display: block;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-2);
  margin-bottom: 6px;
  letter-spacing: 0.04em;
}

input, textarea, select {
  width: 100%;
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 14px;
  color: var(--text);
  font-family: var(--font);
  font-size: 0.875rem;
  transition: border-color var(--transition);
  outline: none;
}

input:focus, textarea:focus, select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(0,207,255,0.08);
}

input::placeholder, textarea::placeholder { color: var(--text-3); }

textarea { resize: vertical; min-height: 100px; }

select option { background: var(--bg-2); }

/* ── Buttons ─────────────────────────────────────────────── */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 9px 18px;
  border-radius: var(--radius);
  font-family: var(--font);
  font-size: 0.85rem;
  font-weight: 600;
  border: none;
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
  text-decoration: none;
}

.btn-primary {
  background: var(--accent);
  color: #000;
}

.btn-primary:hover {
  background: #00E5FF;
  box-shadow: 0 0 20px rgba(0,207,255,0.3);
  opacity: 1;
  color: #000;
}

.btn-ghost {
  background: transparent;
  color: var(--text-2);
  border: 1px solid var(--border);
}

.btn-ghost:hover {
  background: var(--bg-3);
  color: var(--text);
  border-color: var(--border-2);
  opacity: 1;
}

.btn-danger {
  background: rgba(255,68,85,0.1);
  color: var(--red);
  border: 1px solid rgba(255,68,85,0.2);
}

.btn-danger:hover { background: rgba(255,68,85,0.2); opacity: 1; }

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

.btn-sm { padding: 6px 12px; font-size: 0.78rem; }
.btn-lg { padding: 12px 28px; font-size: 0.95rem; }

/* ── Divider ─────────────────────────────────────────────── */

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

/* ── Tag ─────────────────────────────────────────────────── */

.tag {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 0.65rem;
  font-weight: 700;
  font-family: var(--mono);
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

/* ── Auth Pages ──────────────────────────────────────────── */

.auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  padding: 20px;
  position: relative;
  overflow: hidden;
}

.auth-bg {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse 60% 50% at 50% -10%, rgba(0,207,255,0.08) 0%, transparent 70%),
    radial-gradient(ellipse 40% 40% at 80% 80%, rgba(0,207,255,0.04) 0%, transparent 60%);
  pointer-events: none;
}

.auth-card {
  width: 100%;
  max-width: 420px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 36px;
  box-shadow: var(--shadow-lg);
  position: relative;
  z-index: 1;
}

.auth-logo {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-bottom: 28px;
}

.auth-logo svg { width: 40px; height: 40px; }

.auth-logo-text strong {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--text);
  letter-spacing: 0.03em;
}

.auth-logo-text span {
  display: block;
  font-size: 0.7rem;
  color: var(--accent);
  font-family: var(--mono);
  letter-spacing: 0.1em;
}

.auth-title {
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 4px;
}

.auth-subtitle {
  font-size: 0.82rem;
  color: var(--text-3);
  margin-bottom: 24px;
}

.alert {
  padding: 10px 14px;
  border-radius: var(--radius);
  font-size: 0.82rem;
  margin-bottom: 16px;
  display: none;
}

.alert.error   { background: rgba(255,68,85,0.1); border: 1px solid rgba(255,68,85,0.2); color: var(--red); }
.alert.success { background: rgba(0,230,122,0.1); border: 1px solid rgba(0,230,122,0.2); color: var(--green); }

/* ── Grid Utilities ──────────────────────────────────────── */

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; }

/* ── Flex Utilities ──────────────────────────────────────── */

.flex     { display: flex; }
.flex-col { display: flex; flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-8    { gap: 8px; }
.gap-12   { gap: 12px; }
.gap-16   { gap: 16px; }
.gap-20   { gap: 20px; }
.flex-1   { flex: 1; }

/* ── Spacing ─────────────────────────────────────────────── */

.mb-8   { margin-bottom: 8px; }
.mb-12  { margin-bottom: 12px; }
.mb-16  { margin-bottom: 16px; }
.mb-20  { margin-bottom: 20px; }
.mb-24  { margin-bottom: 24px; }
.mb-32  { margin-bottom: 32px; }
.mt-12  { margin-top: 12px; }
.mt-16  { margin-top: 16px; }
.mt-20  { margin-top: 20px; }
.mt-24  { margin-top: 24px; }

/* ── Text Utilities ──────────────────────────────────────── */

.text-sm    { font-size: 0.82rem; }
.text-xs    { font-size: 0.72rem; }
.text-muted { color: var(--text-2); }
.text-dim   { color: var(--text-3); }
.text-accent { color: var(--accent); }
.text-green  { color: var(--green); }
.text-red    { color: var(--red); }
.text-mono   { font-family: var(--mono); }
.font-bold   { font-weight: 700; }
.font-600    { font-weight: 600; }

/* ── Loading / Skeleton ──────────────────────────────────── */

@keyframes skeleton-pulse {
  0%, 100% { opacity: 0.5; }
  50%       { opacity: 1; }
}

.skeleton {
  background: var(--bg-3);
  border-radius: 6px;
  animation: skeleton-pulse 1.5s ease infinite;
}

.loading-spinner {
  width: 20px; height: 20px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  flex-shrink: 0;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ── Hamburger (mobile) ──────────────────────────────────── */

.hamburger {
  display: none;
  background: none;
  border: none;
  color: var(--text);
  cursor: pointer;
  padding: 8px;
  border-radius: 6px;
}

.hamburger:hover { background: var(--bg-3); }

/* ── Responsive ──────────────────────────────────────────── */

@media (max-width: 900px) {
  .sidebar {
    transform: translateX(-100%);
    transition: transform 0.25s ease;
  }

  .sidebar.open { transform: translateX(0); box-shadow: var(--shadow-lg); }

  .main { margin-left: 0; }

  .hamburger { display: block; }

  .page-content { padding: 16px; }

  .topbar { padding: 0 16px; }

  .grid-2, .grid-3 { grid-template-columns: 1fr; }

  .stats-grid { grid-template-columns: 1fr 1fr; }

  .update-card { grid-template-columns: auto 1fr; }
  .update-card .update-meta { display: none; }
}

@media (max-width: 500px) {
  .stats-grid { grid-template-columns: 1fr; }
  .auth-card  { padding: 24px 20px; }
}

/* ── Page-specific: Version Detail ──────────────────────── */

.version-header {
  padding: 28px;
  background: linear-gradient(135deg, var(--card) 0%, var(--bg-2) 100%);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  margin-bottom: 20px;
}

.version-number {
  font-family: var(--mono);
  font-size: 0.9rem;
  color: var(--accent);
  margin-bottom: 8px;
  font-weight: 700;
}

.version-title {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 12px;
}

.version-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

/* ── Empty State ─────────────────────────────────────────── */

.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-3);
}

.empty-state svg {
  width: 48px; height: 48px;
  margin-bottom: 16px;
  opacity: 0.3;
}

.empty-state h3 {
  font-size: 1rem;
  color: var(--text-2);
  margin-bottom: 6px;
}

.empty-state p { font-size: 0.82rem; }

/* ── Pinned icon ─────────────────────────────────────────── */

.pin-icon {
  color: var(--gold);
  font-size: 0.7rem;
  margin-right: 4px;
}

/* ── Overlay (mobile sidebar) ────────────────────────────── */

.overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 99;
}

.overlay.active { display: block; }

/* ── Footer ──────────────────────────────────────────────── */

.site-footer {
  margin-left: var(--sidebar-w);
  border-top: 1px solid var(--border);
  padding: 14px 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  background: var(--bg-2);
}

.site-footer .footer-left {
  font-size: 0.72rem;
  color: var(--text-3);
}

.site-footer .footer-left a {
  color: var(--text-2);
  font-weight: 600;
}

.site-footer .footer-left a:hover { color: var(--accent); }

.site-footer .footer-right {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 0.72rem;
  color: var(--text-3);
  font-family: var(--mono);
}

.footer-version-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: 20px;
  background: var(--accent-dim);
  border: 1px solid rgba(0,207,255,0.15);
  color: var(--accent);
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  font-family: var(--mono);
  text-decoration: none;
}

.footer-version-badge:hover {
  background: rgba(0,207,255,0.15);
  opacity: 1;
}

/* Auth pages don't have sidebar margin */
.auth-page + .site-footer { margin-left: 0; }

@media (max-width: 900px) {
  .site-footer { margin-left: 0; padding: 12px 16px; }
}
