/* Modern, crisp typography & sleek styling for PolyPoll (Light & Dark theme support) */
@import url('https://fonts.googleapis.com/css2?family=Geist+Mono:wght@400;500;600;700&family=Geist:wght@400;500;600;700;800&family=Inter:ital,wght@0,300;0,400;0,500;0,600;0,700;0,800;1,400;1,600&display=swap');

:root {
  /* Dark Theme (Default) */
  --bg: #090d16;
  --bg-card: rgba(18, 26, 43, 0.75);
  --bg-card-hover: rgba(26, 37, 61, 0.85);
  --bg-card-solid: #131b2e;
  --bg-subtle: rgba(255, 255, 255, 0.03);
  --border: rgba(255, 255, 255, 0.09);
  --border-focus: #38bdf8;
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --text-dim: #64748b;
  --navbar-bg: rgba(9, 13, 22, 0.82);
  
  --primary: #38bdf8;
  --primary-glow: rgba(56, 189, 248, 0.25);
  --primary-dark: #0284c7;
  --accent: #f43f5e;
  --accent-purple: #a855f7;
  --accent-emerald: #10b981;
  --accent-amber: #f59e0b;
  
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-full: 9999px;
  
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 10px 30px -10px rgba(0, 0, 0, 0.5);
  --shadow-lg: 0 20px 40px -15px rgba(0, 0, 0, 0.7);
  --shadow-glow: 0 0 35px rgba(56, 189, 248, 0.18);

  --body-gradient: radial-gradient(circle at 15% 15%, rgba(56, 189, 248, 0.07) 0%, transparent 40%),
                   radial-gradient(circle at 85% 80%, rgba(168, 85, 247, 0.06) 0%, transparent 45%),
                   radial-gradient(circle at 50% 50%, rgba(15, 23, 42, 0.5) 0%, transparent 100%);
}

/* Light Theme Variables */
[data-theme="light"] {
  --bg: #f8fafc;
  --bg-card: rgba(255, 255, 255, 0.9);
  --bg-card-hover: #ffffff;
  --bg-card-solid: #ffffff;
  --bg-subtle: rgba(0, 0, 0, 0.02);
  --border: rgba(15, 23, 42, 0.1);
  --border-focus: #0284c7;
  --text-main: #0f172a;
  --text-muted: #475569;
  --text-dim: #94a3b8;
  --navbar-bg: rgba(255, 255, 255, 0.85);

  --primary: #0284c7;
  --primary-glow: rgba(2, 132, 199, 0.15);
  --primary-dark: #0369a1;

  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.06);
  --shadow-md: 0 10px 25px -5px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 20px 35px -10px rgba(0, 0, 0, 0.12);
  --shadow-glow: 0 0 30px rgba(2, 132, 199, 0.12);

  --body-gradient: radial-gradient(circle at 15% 15%, rgba(2, 132, 199, 0.06) 0%, transparent 40%),
                   radial-gradient(circle at 85% 80%, rgba(168, 85, 247, 0.04) 0%, transparent 45%),
                   radial-gradient(circle at 50% 50%, rgba(241, 245, 249, 0.8) 0%, transparent 100%);
}

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

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  background-color: var(--bg);
  color: var(--text-main);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background-image: var(--body-gradient);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
  transition: background-color 0.25s ease, color 0.25s ease;
}

/* Nav */
.navbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 2rem;
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(14px);
  background: var(--navbar-bg);
  position: sticky;
  top: 0;
  z-index: 50;
  transition: background 0.25s ease, border-color 0.25s ease;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  text-decoration: none;
  color: var(--text-main);
  font-weight: 700;
  font-size: 1.25rem;
  letter-spacing: -0.02em;
}

.brand-icon {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #0284c7, #7c3aed);
  border-radius: var(--radius-sm);
  box-shadow: 0 0 15px rgba(56, 189, 248, 0.35);
  font-size: 1.3rem;
}

.nav-user {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

/* Theme Toggle Button */
.theme-toggle-btn {
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.45rem 0.65rem;
  cursor: pointer;
  color: var(--text-main);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  transition: all 0.15s ease;
}

.theme-toggle-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: var(--primary);
}

[data-theme="light"] .theme-toggle-btn:hover {
  background: rgba(0, 0, 0, 0.05);
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.25rem 0.65rem;
  border-radius: var(--radius-full);
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.badge-admin {
  background: rgba(56, 189, 248, 0.15);
  color: var(--primary);
  border: 1px solid rgba(56, 189, 248, 0.3);
}

.badge-green {
  background: rgba(16, 185, 129, 0.15);
  color: var(--accent-emerald);
  border: 1px solid rgba(16, 185, 129, 0.3);
}

.badge-amber {
  background: rgba(245, 158, 11, 0.15);
  color: var(--accent-amber);
  border: 1px solid rgba(245, 158, 11, 0.3);
}

.badge-red {
  background: rgba(244, 63, 94, 0.15);
  color: var(--accent);
  border: 1px solid rgba(244, 63, 94, 0.3);
}

.badge-gray {
  background: rgba(148, 163, 184, 0.15);
  color: var(--text-dim);
  border: 1px solid rgba(148, 163, 184, 0.3);
}

/* Container */
.container {
  max-width: 1180px;
  margin: 0 auto;
  padding: 2.5rem 1.5rem;
  width: 100%;
}

.container-narrow {
  max-width: 780px;
}

/* Hero Section */
.hero {
  text-align: center;
  padding: 3rem 1rem 3.5rem;
  position: relative;
}

.hero-octopus-logo {
  width: 90px;
  height: 90px;
  margin: 0 auto 1.5rem;
  background: radial-gradient(circle, rgba(56, 189, 248, 0.2) 0%, rgba(124, 58, 237, 0.1) 70%);
  border: 1px solid rgba(56, 189, 248, 0.3);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 30px rgba(56, 189, 248, 0.2);
}

.hero-title {
  font-size: 2.75rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.15;
  margin-bottom: 1rem;
  background: linear-gradient(135deg, var(--text-main) 40%, var(--text-muted) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.hero-subtitle {
  font-size: 1.15rem;
  color: var(--text-muted);
  max-width: 650px;
  margin: 0 auto 2rem;
}

/* Grid & Cards */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 1.5rem;
  margin-top: 1rem;
}

.card {
  background: var(--bg-card);
  backdrop-filter: blur(16px);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 1.75rem;
  transition: all 0.2s ease;
  position: relative;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.card:hover {
  transform: translateY(-2px);
  border-color: rgba(56, 189, 248, 0.35);
  box-shadow: var(--shadow-glow);
}

.card-tool {
  display: flex;
  flex-direction: column;
  height: 100%;
}

.card-icon {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-sm);
  background: rgba(56, 189, 248, 0.1);
  border: 1px solid rgba(56, 189, 248, 0.25);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  margin-bottom: 1.25rem;
}

.card-title {
  font-size: 1.35rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
  color: var(--text-main);
}

.card-desc {
  color: var(--text-muted);
  font-size: 0.95rem;
  flex-grow: 1;
  margin-bottom: 1.5rem;
}

.card-badge-upcoming {
  position: absolute;
  top: 1.25rem;
  right: 1.25rem;
  background: var(--bg-subtle);
  color: var(--text-dim);
  border: 1px solid var(--border);
  padding: 0.2rem 0.5rem;
  border-radius: var(--radius-full);
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.75rem 1.4rem;
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
  text-decoration: none;
  border: none;
  font-family: inherit;
}

.btn-primary {
  background: linear-gradient(135deg, #0284c7, #2563eb);
  color: white !important;
  box-shadow: 0 4px 14px rgba(2, 132, 199, 0.35);
}

.btn-primary:hover {
  background: linear-gradient(135deg, #0369a1, #1d4ed8);
  box-shadow: 0 6px 20px rgba(2, 132, 199, 0.5);
  transform: translateY(-1px);
}

.btn-secondary {
  background: var(--bg-subtle);
  color: var(--text-main);
  border: 1px solid var(--border);
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.25);
}

[data-theme="light"] .btn-secondary:hover {
  background: rgba(0, 0, 0, 0.05);
  border-color: rgba(0, 0, 0, 0.2);
}

.btn-accent {
  background: linear-gradient(135deg, #e11d48, #be123c);
  color: white !important;
}

.btn-accent:hover {
  background: linear-gradient(135deg, #be123c, #9f1239);
}

.btn-danger-outline {
  background: transparent;
  color: #f43f5e;
  border: 1px solid rgba(244, 63, 94, 0.3);
}

.btn-danger-outline:hover {
  background: rgba(244, 63, 94, 0.1);
  border-color: #f43f5e;
}

.btn-success {
  background: linear-gradient(135deg, #10b981, #059669);
  color: white !important;
}

.btn-sm {
  padding: 0.4rem 0.8rem;
  font-size: 0.85rem;
}

.btn-xs {
  padding: 0.25rem 0.5rem;
  font-size: 0.75rem;
}

.btn-block {
  width: 100%;
}

/* Form inputs */
.form-group {
  margin-bottom: 1.5rem;
}

.form-label {
  display: block;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-main);
  margin-bottom: 0.5rem;
}

.form-sublabel {
  display: block;
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
}

.form-input, .form-textarea, .form-select {
  width: 100%;
  padding: 0.75rem 1rem;
  background: var(--bg-card-solid);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-main);
  font-size: 0.95rem;
  font-family: inherit;
  transition: all 0.15s ease;
}

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

.form-textarea {
  min-height: 110px;
  resize: vertical;
}

/* Quote banner */
.quote-box {
  background: rgba(56, 189, 248, 0.05);
  border-left: 3px solid var(--primary);
  padding: 1.25rem 1.5rem;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  margin: 2rem 0;
  font-style: italic;
  color: var(--text-muted);
}

.quote-box footer {
  margin-top: 0.5rem;
  font-style: normal;
  font-size: 0.85rem;
  color: var(--text-dim);
}

/* Option builder */
.option-item-row {
  display: flex;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
  align-items: center;
}

/* Pairwise Arena */
.pairwise-arena {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 2rem;
  text-align: center;
  position: relative;
  overflow: hidden;
}

.pairwise-card-container {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 1.5rem;
  align-items: center;
  margin: 2rem 0;
}

.pairwise-btn {
  background: var(--bg-card-solid);
  border: 2px solid var(--border);
  border-radius: var(--radius-md);
  padding: 2rem 1.5rem;
  color: var(--text-main);
  text-align: center;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 180px;
}

.pairwise-btn:hover {
  border-color: var(--primary);
  transform: translateY(-4px) scale(1.02);
  box-shadow: 0 12px 30px var(--primary-glow);
  background: var(--bg-card-hover);
}

.pairwise-title {
  font-size: 1.35rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
}

.pairwise-desc {
  font-size: 0.875rem;
  color: var(--text-muted);
}

.pairwise-vs {
  font-weight: 800;
  font-size: 1.25rem;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

/* Progress bar */
.progress-bar-container {
  width: 100%;
  height: 8px;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  overflow: hidden;
  margin: 1rem 0 0.5rem;
}

.progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, #38bdf8, #818cf8);
  transition: width 0.3s ease;
}

/* Point Allocation UX for Straw Poll */
.straw-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 1rem 1.25rem;
  margin-bottom: 0.75rem;
}

.straw-controls {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.point-btn {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-card-solid);
  color: var(--text-main);
  font-size: 1.25rem;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.1s ease;
}

.point-btn:hover:not(:disabled) {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}

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

.point-display {
  font-family: 'Geist Mono', monospace;
  font-size: 1.25rem;
  font-weight: 700;
  min-width: 36px;
  text-align: center;
  color: var(--primary);
}

/* Stats and Admin Panel */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

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

.stat-value {
  font-size: 2rem;
  font-weight: 800;
  font-family: 'Geist Mono', monospace;
  color: var(--primary);
  line-height: 1;
  margin-bottom: 0.35rem;
}

.stat-label {
  font-size: 0.8rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* Results Rank Table */
.results-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 1rem;
}

.results-table th, .results-table td {
  padding: 0.85rem 1rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

.results-table th {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-dim);
  background: var(--bg-subtle);
}

.rank-badge {
  display: inline-flex;
  width: 28px;
  height: 28px;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  font-weight: 700;
  font-size: 0.85rem;
  background: var(--bg-subtle);
}

.rank-1 {
  background: linear-gradient(135deg, #eab308, #ca8a04);
  color: #000;
  box-shadow: 0 0 10px rgba(234, 179, 8, 0.4);
}

.rank-2 {
  background: linear-gradient(135deg, #94a3b8, #64748b);
  color: #fff;
}

.rank-3 {
  background: linear-gradient(135deg, #d97706, #b45309);
  color: #fff;
}

/* Live participant pill */
.participant-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.35rem 0.75rem;
  border-radius: var(--radius-full);
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  font-size: 0.85rem;
  margin-right: 0.5rem;
  margin-bottom: 0.5rem;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-dim);
}

.status-dot.active {
  background: #10b981;
  box-shadow: 0 0 8px #10b981;
}

.status-dot.voted {
  background: #38bdf8;
  box-shadow: 0 0 8px #38bdf8;
}

/* Quick Action Dropdown / Toolbar */
.action-toolbar {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  flex-wrap: wrap;
}

/* Toast */
.toast-msg {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  background: var(--bg-card-solid);
  border: 1px solid var(--primary);
  color: var(--text-main);
  padding: 0.75rem 1.25rem;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg);
  font-size: 0.9rem;
  z-index: 100;
  animation: slideUp 0.2s ease;
}

@keyframes slideUp {
  from { transform: translateY(20px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

@media (max-width: 640px) {
  .pairwise-card-container {
    grid-template-columns: 1fr;
    gap: 1rem;
  }
  .pairwise-vs {
    margin: -0.5rem 0;
  }
  .navbar {
    padding: 1rem;
  }
  .container {
    padding: 1.5rem 1rem;
  }
}

h1, h2, h3, h4, h5, h6, .font-display {
  font-family: 'Geist', -apple-system, BlinkMacSystemFont, sans-serif;
  letter-spacing: -0.025em;
}

h1 {
  letter-spacing: -0.035em;
}
