/* =========================================================
   GVP Data Web — Design System
   ========================================================= */

:root {
  --navy-900: #131d33;
  --navy-800: #1b2946;
  --navy-700: #243457;
  --navy-600: #2c3f6b;
  --navy-500: #1e3a63;
  --surface: #ffffff;
  --surface-alt: #f5f7fb;
  --border: #e5e9f1;
  --border-subtle: #d3d9e6;
  --text-primary: #111827;
  --text-secondary: #4b5563;
  --text-muted: #9ca3af;
  --accent: #1e3a63;
  --accent-hover: #16305a;
  --success: #1f9d57;
  --success-bg: rgba(31, 157, 87, 0.10);
  --error: #dc2626;
  --error-bg: rgba(220, 38, 38, 0.08);
  --info-bg: rgba(30, 58, 99, 0.08);
  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 14px;
  --shadow-card: 0 1px 4px rgba(0,0,0,.06), 0 0 0 1px var(--border);
  --shadow-nav: 0 1px 0 var(--border);
  --font: 'Inter', system-ui, sans-serif;
  --transition: 150ms ease;
}

[data-theme="dark"] {
  --surface: #1a2035;
  --surface-alt: #131929;
  --border: #2a3550;
  --border-subtle: #2a3550;
  --text-primary: #f1f5f9;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --shadow-card: 0 1px 4px rgba(0,0,0,.3), 0 0 0 1px var(--border);
  --shadow-nav: 0 1px 0 var(--border);
  --success-bg: rgba(31, 157, 87, 0.15);
  --error-bg: rgba(220, 38, 38, 0.15);
  --info-bg: rgba(59, 130, 246, 0.10);
}

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

html { font-size: 16px; -webkit-font-smoothing: antialiased; }

body {
  font-family: var(--font);
  background: var(--surface-alt);
  color: var(--text-primary);
  min-height: 100vh;
  line-height: 1.5;
  transition: background var(--transition), color var(--transition);
}

/* ── Navbar ─────────────────────────────────────────────── */
.navbar {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--surface);
  box-shadow: var(--shadow-nav);
}
.navbar-inner {
  max-width: 1120px;
  margin: 0 auto;
  padding: 0 24px;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.nav-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--text-primary);
  font-weight: 700;
  font-size: 1rem;
}
.brand-icon { font-size: 1.4rem; color: var(--accent); }
.nav-actions { display: flex; align-items: center; gap: 12px; }

/* Theme toggle */
.theme-toggle {
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  width: 34px; height: 34px;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  font-size: .9rem;
  color: var(--text-secondary);
  transition: border-color var(--transition);
}
.theme-toggle:hover { border-color: var(--border-subtle); }

/* User card */
.user-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 10px 4px 6px;
  border: 1px solid var(--border);
  border-radius: 40px;
  background: var(--surface);
}
.user-avatar {
  width: 30px; height: 30px;
  border-radius: 50%;
  object-fit: cover;
}
.user-avatar-fallback {
  width: 30px; height: 30px;
  border-radius: 50%;
  background: var(--navy-600);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 600; font-size: .8rem;
}
.user-info { display: flex; flex-direction: column; gap: 1px; }
.user-name { font-size: .8rem; font-weight: 600; color: var(--text-primary); line-height: 1; }
.logout-btn {
  color: var(--text-muted);
  text-decoration: none;
  font-size: 1rem;
  padding: 2px 4px;
  border-radius: var(--radius-sm);
  transition: color var(--transition);
}
.logout-btn:hover { color: var(--error); }

/* Role badges */
.role-badge {
  font-size: .65rem;
  font-weight: 600;
  letter-spacing: .03em;
  text-transform: uppercase;
  padding: 1px 6px;
  border-radius: 20px;
  line-height: 1.5;
}
.role-admin { background: rgba(30, 58, 99, .13); color: var(--navy-600); }
.role-viewer { background: var(--success-bg); color: var(--success); }

/* ── Layout ─────────────────────────────────────────────── */
.main-content { min-height: calc(100vh - 60px); }
.auth-layout { min-height: 100vh; display: flex; }

.page-container {
  max-width: 1120px;
  margin: 0 auto;
  padding: 40px 24px 72px;
}
.page-container-narrow { max-width: 680px; }
.centered-page { display: flex; align-items: center; justify-content: center; min-height: calc(100vh - 140px); }

/* Page header */
.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 32px;
}
.page-header-left { display: flex; align-items: center; gap: 16px; }
.page-icon-tile {
  width: 48px; height: 48px;
  background: var(--navy-800);
  color: #fff;
  border-radius: var(--radius);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.3rem;
  flex-shrink: 0;
}
.page-title { font-size: 1.5rem; font-weight: 700; color: var(--text-primary); }
.page-subtitle { font-size: .875rem; color: var(--text-secondary); margin-top: 2px; }
.page-header-actions { display: flex; align-items: center; gap: 10px; padding-top: 4px; }

/* ── Cards ─────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
}
.card-title { font-size: 1rem; font-weight: 600; }
.card-body { padding: 24px; }
.card-body.centered { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 12px; }

/* ── Buttons ─────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: 8px;
  font-size: .875rem;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  border: 1px solid transparent;
  transition: background var(--transition), box-shadow var(--transition), opacity var(--transition);
  white-space: nowrap;
}
.btn:disabled { opacity: .5; cursor: not-allowed; }

.btn-primary { background: var(--navy-500); color: #fff; border-color: var(--navy-500); }
.btn-primary:hover { background: var(--accent-hover); }

.btn-secondary { background: var(--surface); color: var(--text-primary); border-color: var(--border-subtle); }
.btn-secondary:hover { background: var(--surface-alt); }

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

.btn-danger-ghost { background: none; color: var(--error); }
.btn-danger-ghost:hover { background: var(--error-bg); }

.btn-sm { padding: 5px 12px; font-size: .8rem; }

/* Google SSO button */
.btn-google {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  width: 100%;
  padding: 12px 20px;
  background: var(--surface);
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
  font-size: .9375rem;
  font-weight: 500;
  color: var(--text-primary);
  text-decoration: none;
  cursor: pointer;
  transition: box-shadow var(--transition), border-color var(--transition);
  box-shadow: 0 1px 3px rgba(0,0,0,.06);
}
.btn-google:hover {
  border-color: var(--navy-600);
  box-shadow: 0 2px 8px rgba(0,0,0,.10);
}

/* ── Badges ─────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 10px;
  border-radius: 20px;
  font-size: .75rem;
  font-weight: 600;
}
.badge-neutral { background: var(--surface-alt); color: var(--text-secondary); border: 1px solid var(--border); }

/* ── Tables ─────────────────────────────────────────────── */
.table-wrapper { overflow-x: auto; }
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .875rem;
}
.data-table thead tr {
  background: var(--navy-800);
}
.data-table thead th {
  color: #fff;
  font-size: .7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .08em;
  padding: 12px 20px;
  text-align: left;
  white-space: nowrap;
}
.data-table tbody tr {
  border-bottom: 1px solid var(--border);
  transition: background var(--transition);
}
.data-table tbody tr:last-child { border-bottom: none; }
.data-table tbody tr:hover { background: #f5f7fa; }
[data-theme="dark"] .data-table tbody tr:hover { background: rgba(255,255,255,.03); }
.data-table td { padding: 14px 20px; vertical-align: middle; }

.mono-chip {
  font-family: 'Cascadia Code', 'Fira Code', monospace;
  font-size: .82em;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 2px 6px;
  color: var(--text-primary);
}
.link-external { color: var(--accent); text-decoration: none; }
.link-external:hover { text-decoration: underline; }
.ext-icon { font-size: .75em; opacity: .7; }
.row-actions { display: flex; align-items: center; gap: 8px; }
.text-muted { color: var(--text-muted); font-size: .82rem; }

/* ── Alerts ─────────────────────────────────────────────── */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius);
  font-size: .875rem;
  margin-bottom: 24px;
  border: 1px solid transparent;
}
.alert-success { background: var(--success-bg); color: var(--success); border-color: rgba(31,157,87,.25); }
.alert-error { background: var(--error-bg); color: var(--error); border-color: rgba(220,38,38,.2); }
.alert-info { background: var(--info-bg); color: var(--navy-600); border-color: rgba(30,58,99,.2); }

/* ── Empty state ─────────────────────────────────────────── */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 48px 24px;
  gap: 12px;
  color: var(--text-secondary);
}
.empty-icon { font-size: 2.5rem; }

/* ── Forms ─────────────────────────────────────────────── */
.upload-form { display: flex; flex-direction: column; gap: 28px; padding: 28px; }
.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-label { font-size: .875rem; font-weight: 600; color: var(--text-primary); }
.required { color: var(--error); }
.form-hint { font-size: .78rem; color: var(--text-muted); line-height: 1.6; }

.input-prefix-wrap { display: flex; align-items: center; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; background: var(--surface); }
.input-prefix {
  padding: 0 12px;
  background: var(--surface-alt);
  border-right: 1px solid var(--border);
  color: var(--text-secondary);
  font-size: .9rem;
  height: 42px;
  display: flex; align-items: center;
  font-family: monospace;
  flex-shrink: 0;
}
.form-input {
  border: none;
  outline: none;
  padding: 10px 14px;
  font-size: .9rem;
  font-family: monospace;
  color: var(--text-primary);
  background: var(--surface);
  width: 100%;
}

/* File drop zone */
.file-drop-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius-lg);
  padding: 40px 24px;
  text-align: center;
  cursor: pointer;
  transition: border-color var(--transition), background var(--transition);
  position: relative;
}
.file-drop-zone:hover, .file-drop-zone.drag-over {
  border-color: var(--accent);
  background: var(--info-bg);
}
.file-input-hidden {
  position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; height: 100%;
}
.drop-zone-inner {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  pointer-events: none; font-size: .875rem; color: var(--text-secondary);
}
.drop-icon { font-size: 2rem; pointer-events: none; }
.drop-hint { font-size: .78rem; color: var(--text-muted); }
.file-browse-link { color: var(--accent); cursor: pointer; font-weight: 500; pointer-events: all; }

.form-actions { display: flex; justify-content: flex-end; gap: 10px; padding-top: 4px; }

/* ── Login page ─────────────────────────────────────────── */
.login-body { background: var(--navy-900); }

.login-split {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1fr 480px;
}

.login-hero {
  background: radial-gradient(1200px 600px at 75% -10%, var(--navy-600), var(--navy-800) 55%, var(--navy-900));
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 48px;
  position: relative;
  overflow: hidden;
}
.hero-glow {
  position: absolute;
  width: 600px; height: 600px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(59,130,246,.12) 0%, transparent 70%);
  top: -100px; right: -150px;
  pointer-events: none;
}
.hero-content { position: relative; z-index: 1; max-width: 420px; }
.hero-icon { font-size: 3rem; color: rgba(255,255,255,.9); margin-bottom: 24px; }
.hero-title { font-size: 2.25rem; font-weight: 700; color: #fff; line-height: 1.2; margin-bottom: 16px; }
.hero-subtitle { font-size: 1rem; color: rgba(255,255,255,.65); line-height: 1.6; }

.login-panel {
  background: var(--surface);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 48px 40px;
}
.login-card { width: 100%; max-width: 360px; display: flex; flex-direction: column; gap: 28px; }
.login-card-header h2 { font-size: 1.5rem; font-weight: 700; color: var(--text-primary); margin-bottom: 6px; }
.login-card-header p { font-size: .875rem; color: var(--text-secondary); line-height: 1.6; }
.login-note { font-size: .78rem; color: var(--text-muted); text-align: center; }

/* ── Error page ─────────────────────────────────────────── */
.error-card {
  text-align: center;
  padding: 48px 32px;
  max-width: 480px;
}
.error-code {
  font-size: 6rem;
  font-weight: 800;
  color: var(--border-subtle);
  line-height: 1;
  margin-bottom: 16px;
}
.error-title { font-size: 1.5rem; font-weight: 700; margin-bottom: 12px; }
.error-message { color: var(--text-secondary); margin-bottom: 28px; }
.error-actions { display: flex; justify-content: center; gap: 12px; }

/* ── Viewer welcome ─────────────────────────────────────── */
.viewer-welcome .card-body { padding: 48px 24px; }
.welcome-icon { font-size: 2.5rem; }

/* ── Responsive ─────────────────────────────────────────── */
@media (max-width: 768px) {
  .login-split { grid-template-columns: 1fr; }
  .login-hero { display: none; }
  .login-panel { padding: 32px 20px; }
  .page-header { flex-direction: column; align-items: flex-start; }
  .data-table thead th:nth-child(3) { display: none; }
  .data-table td:nth-child(3) { display: none; }
}

@media (max-width: 480px) {
  .navbar-inner { padding: 0 16px; }
  .brand-name { display: none; }
  .page-container { padding: 24px 16px 48px; }
}
