/* ═══════════════════════════════════════════════════════════════
   BNI Live Vote — Mobile Voting Interface
   Premium dark theme with glassmorphism, optimized for phones.
   ═══════════════════════════════════════════════════════════════ */

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

:root {
  --bg-deep: #0f0f1a;
  --bg-card: rgba(30, 30, 55, 0.7);
  --bg-card-hover: rgba(40, 40, 70, 0.8);
  --border-glass: rgba(255, 255, 255, 0.08);
  --border-glass-hover: rgba(255, 255, 255, 0.15);

  --accent-bni: #cf2e2e;
  --accent-gold: #f5a623;
  --accent-green: #10b981;
  --accent-blue: #6366f1;
  --accent-purple: #a855f7;

  --text-primary: #f1f5f9;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;

  --radius-sm: 12px;
  --radius-md: 16px;
  --radius-lg: 24px;

  --shadow-glow: 0 0 40px rgba(99, 102, 241, 0.15);
  --shadow-card: 0 8px 32px rgba(0, 0, 0, 0.4);

  --font: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
}

html, body {
  height: 100%;
  font-family: var(--font);
  background: var(--bg-deep);
  color: var(--text-primary);
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

body {
  background:
    radial-gradient(ellipse at 20% 0%, rgba(207, 46, 46, 0.15) 0%, transparent 60%),
    radial-gradient(ellipse at 80% 100%, rgba(245, 166, 35, 0.1) 0%, transparent 60%),
    var(--bg-deep);
}

/* ── Screens ── */
.screen {
  display: none;
  min-height: 100vh;
  padding: 20px;
  animation: fadeIn 0.4s ease;
}

.screen.active {
  display: flex;
  align-items: center;
  justify-content: center;
}

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

/* ── Glass Card ── */
.glass-card {
  background: var(--bg-card);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-md);
  padding: 24px;
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  box-shadow: var(--shadow-card);
}

/* ═══════════════════════════════════════
   Screen 1: JOIN
   ═══════════════════════════════════════ */
.join-container {
  width: 100%;
  max-width: 400px;
  text-align: center;
}

.logo-area {
  margin-bottom: 32px;
}

.bni-logo {
  width: 140px;
  height: auto;
  margin-bottom: 16px;
  animation: float 4s ease-in-out infinite;
  filter: drop-shadow(0 8px 24px rgba(207, 46, 46, 0.3));
}

@keyframes float {
  0%, 100% { transform: translateY(0); }
  50%      { transform: translateY(-8px); }
}

.logo-area h1 {
  font-size: 28px;
  font-weight: 800;
  background: linear-gradient(135deg, #ffffff, #f1f5f9);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  letter-spacing: -0.5px;
}

.subtitle {
  color: var(--text-secondary);
  font-size: 16px;
  margin-top: 4px;
}

.pin-card {
  text-align: center;
}

.pin-card label {
  display: block;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 16px;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.pin-input-row {
  margin-bottom: 20px;
}

#pin-input {
  width: 100%;
  max-width: 220px;
  font-size: 36px;
  font-weight: 800;
  text-align: center;
  letter-spacing: 12px;
  padding: 16px;
  border: 2px solid var(--border-glass);
  border-radius: var(--radius-sm);
  background: rgba(15, 15, 26, 0.6);
  color: var(--text-primary);
  outline: none;
  transition: border-color 0.3s, box-shadow 0.3s;
  caret-color: var(--accent-gold);
}

#pin-input:focus {
  border-color: var(--accent-blue);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2);
}

#pin-input::placeholder {
  color: var(--text-muted);
  letter-spacing: 16px;
  font-size: 28px;
}

/* ── Buttons ── */
.btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 16px 24px;
  font-size: 17px;
  font-weight: 700;
  font-family: var(--font);
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  color: white;
  background: linear-gradient(135deg, var(--accent-bni), #e53935);
  box-shadow: 0 4px 15px rgba(207, 46, 46, 0.3);
}

.btn-primary:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 6px 25px rgba(207, 46, 46, 0.45);
}

.btn-primary:active:not(:disabled) {
  transform: translateY(0);
}

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

.error-text {
  color: var(--accent-bni);
  font-size: 14px;
  margin-top: 12px;
  min-height: 20px;
}

/* ═══════════════════════════════════════
   Screen 2: VOTE
   ═══════════════════════════════════════ */
.vote-container {
  width: 100%;
  max-width: 440px;
}

.question-card {
  margin-bottom: 20px;
  text-align: center;
}

.question-badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  color: var(--accent-gold);
  background: rgba(245, 166, 35, 0.12);
  padding: 4px 14px;
  border-radius: 20px;
  letter-spacing: 2px;
  margin-bottom: 12px;
}

#vote-question {
  font-size: 22px;
  font-weight: 700;
  line-height: 1.3;
}

.name-card {
  margin-bottom: 20px;
}

.name-card label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

#voter-name {
  width: 100%;
  padding: 14px 16px;
  font-size: 16px;
  font-family: var(--font);
  border: 2px solid var(--border-glass);
  border-radius: var(--radius-sm);
  background: rgba(15, 15, 26, 0.6);
  color: var(--text-primary);
  outline: none;
  transition: border-color 0.3s;
}

#voter-name:focus {
  border-color: var(--accent-blue);
}

/* ── Options Grid ── */
.options-grid {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.option-btn {
  position: relative;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 18px 20px;
  font-size: 18px;
  font-weight: 600;
  font-family: var(--font);
  color: var(--text-primary);
  background: var(--bg-card);
  border: 2px solid var(--border-glass);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  overflow: hidden;
  text-align: left;
  -webkit-tap-highlight-color: transparent;
}

.option-btn::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(207, 46, 46, 0.15), rgba(245, 166, 35, 0.1));
  opacity: 0;
  transition: opacity 0.3s;
}

.option-btn:hover::before,
.option-btn:active::before {
  opacity: 1;
}

.option-btn:active {
  transform: scale(0.97);
}

.option-btn .option-letter {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  font-size: 15px;
  font-weight: 700;
  flex-shrink: 0;
  background: rgba(207, 46, 46, 0.15);
  color: var(--accent-bni);
}

.option-btn .option-text {
  flex: 1;
  z-index: 1;
}

/* Emoji options (larger, centered) */
.options-grid.emoji-mode {
  flex-direction: row;
  flex-wrap: wrap;
  justify-content: center;
  gap: 14px;
}

.options-grid.emoji-mode .option-btn {
  width: auto;
  flex: 0 0 auto;
  padding: 16px 20px;
  justify-content: center;
  font-size: 40px;
  border-radius: var(--radius-lg);
  min-width: 72px;
}

.options-grid.emoji-mode .option-btn .option-letter {
  display: none;
}

/* Yes/No special styling */
.option-btn.yes-btn {
  border-color: rgba(16, 185, 129, 0.3);
}
.option-btn.yes-btn:hover, .option-btn.yes-btn:active {
  border-color: var(--accent-green);
  background: rgba(16, 185, 129, 0.1);
}
.option-btn.yes-btn .option-letter {
  background: rgba(16, 185, 129, 0.15);
  color: var(--accent-green);
}

.option-btn.no-btn {
  border-color: rgba(207, 46, 46, 0.3);
}
.option-btn.no-btn:hover, .option-btn.no-btn:active {
  border-color: var(--accent-bni);
  background: rgba(207, 46, 46, 0.1);
}
.option-btn.no-btn .option-letter {
  background: rgba(207, 46, 46, 0.15);
  color: var(--accent-bni);
}

/* Selected state */
.option-btn.selected {
  border-color: var(--accent-green) !important;
  background: rgba(16, 185, 129, 0.12) !important;
}

.option-btn.selected::after {
  content: '✓';
  position: absolute;
  right: 16px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 20px;
  color: var(--accent-green);
  font-weight: 800;
}

/* ── Word Cloud Input ── */
#wordcloud-area label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

#word-input {
  width: 100%;
  padding: 14px 16px;
  font-size: 18px;
  font-family: var(--font);
  border: 2px solid var(--border-glass);
  border-radius: var(--radius-sm);
  background: rgba(15, 15, 26, 0.6);
  color: var(--text-primary);
  outline: none;
  margin-bottom: 14px;
  transition: border-color 0.3s;
}

#word-input:focus {
  border-color: var(--accent-purple);
}

/* ═══════════════════════════════════════
   Screen 3: CONFIRMED
   ═══════════════════════════════════════ */
.confirmed-container, .ended-container {
  width: 100%;
  max-width: 440px;
  text-align: center;
}

.confirmed-icon, .ended-icon {
  font-size: 72px;
  margin-bottom: 16px;
  animation: popIn 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes popIn {
  0%   { transform: scale(0); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}

.confirmed-container h2, .ended-container h2 {
  font-size: 26px;
  font-weight: 800;
  margin-bottom: 8px;
}

.confirmed-container p {
  color: var(--text-secondary);
  font-size: 16px;
  margin-bottom: 24px;
}

/* ── Mini Results (on confirmation screen) ── */
.results-mini {
  text-align: left;
  margin-top: 20px;
}

.results-mini h3 {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 16px;
}

.result-bar-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}

.result-bar-label {
  width: 80px;
  font-size: 14px;
  font-weight: 600;
  text-align: right;
  flex-shrink: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.result-bar-track {
  flex: 1;
  height: 32px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 8px;
  overflow: hidden;
  position: relative;
}

.result-bar-fill {
  height: 100%;
  border-radius: 8px;
  transition: width 0.6s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  align-items: center;
  padding-left: 10px;
  font-size: 13px;
  font-weight: 700;
  color: white;
  min-width: fit-content;
}

.result-bar-fill.bar-0 { background: linear-gradient(90deg, #cf2e2e, #ef4444); }
.result-bar-fill.bar-1 { background: linear-gradient(90deg, #f5a623, #fbbf24); }
.result-bar-fill.bar-2 { background: linear-gradient(90deg, #10b981, #34d399); }
.result-bar-fill.bar-3 { background: linear-gradient(90deg, #3b82f6, #60a5fa); }
.result-bar-fill.bar-4 { background: linear-gradient(90deg, #8b5cf6, #a78bfa); }
.result-bar-fill.bar-5 { background: linear-gradient(90deg, #ec4899, #f472b6); }

.result-bar-count {
  font-size: 14px;
  font-weight: 700;
  width: 36px;
  text-align: right;
  flex-shrink: 0;
  color: var(--text-secondary);
}

.result-total {
  text-align: center;
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 16px;
  padding-top: 12px;
  border-top: 1px solid var(--border-glass);
}

/* ═══════════════════════════════════════
   Screen 4: ENDED
   ═══════════════════════════════════════ */
#final-results {
  text-align: left;
  margin-top: 20px;
}

/* ── Utilities ── */
.haptic {
  animation: hapticPulse 0.15s ease;
}

@keyframes hapticPulse {
  0%   { transform: scale(1); }
  50%  { transform: scale(0.95); }
  100% { transform: scale(1); }
}

/* ── Loading Spinner ── */
.spinner {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 3px solid rgba(255, 255, 255, 0.2);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

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

/* ── Responsive ── */
@media (max-width: 380px) {
  .screen { padding: 14px; }
  .glass-card { padding: 18px; }
  .logo-area h1 { font-size: 26px; }
  #vote-question { font-size: 19px; }
  .option-btn { padding: 14px 16px; font-size: 16px; }
}
