/* ============================================
   Maple Arts — Modern Design System
   Logo palette: green, blue, red, orange, yellow
   Fonts: Inter (Latin) + Cairo (Arabic)
   ============================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&family=Cairo:wght@400;500;600;700;800&display=swap');

:root {
  /* Logo-derived palette */
  --brand:           #1E88E5;
  --brand-dark:      #1565C0;
  --green:           #27AE60;
  --green-dark:      #1E8449;
  --red:             #E84545;
  --orange:          #F39C12;
  --yellow:          #F4D03F;

  /* Neutral system */
  --text:            #1a202c;
  --text-soft:       #4a5568;
  --muted:           #718096;
  --border:          #e2e8f0;
  --border-soft:     #edf2f7;
  --bg:              #f7fafc;
  --bg-soft:         #fafbfc;
  --card:            #ffffff;
  --shadow-sm:       0 1px 3px rgba(15, 23, 42, .04), 0 1px 2px rgba(15, 23, 42, .03);
  --shadow:          0 4px 16px rgba(15, 23, 42, .06), 0 2px 6px rgba(15, 23, 42, .04);
  --shadow-lg:       0 20px 40px rgba(15, 23, 42, .08), 0 8px 16px rgba(15, 23, 42, .05);

  /* Semantic */
  --success:         #27AE60;
  --error:           #E84545;
  --warning:         #F39C12;

  /* Gradients (drawn from logo colors) */
  --grad-primary:    linear-gradient(135deg, #1E88E5 0%, #27AE60 100%);
  --grad-warm:       linear-gradient(135deg, #F39C12 0%, #E84545 100%);
  --grad-soft:       linear-gradient(135deg, #fff 0%, #f7fafc 100%);
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: 'Inter', 'Cairo', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  background:
    radial-gradient(circle at 0% 0%, rgba(30, 136, 229, .07), transparent 40%),
    radial-gradient(circle at 100% 100%, rgba(39, 174, 96, .07), transparent 40%),
    var(--bg);
  color: var(--text);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Apply min-height only when NOT embedded as an iframe */
html:not(.is-embedded) body { min-height: 100vh; }

/* Arabic text uses Cairo for better shaping */
[lang="ar"], .rtl-text {
  font-family: 'Cairo', 'Inter', system-ui, sans-serif;
}

.container {
  max-width: 860px;
  margin: 0 auto;
  padding: 40px 20px 80px;
}

/* ============================================
   Logo header
   ============================================ */

.brand-header {
  text-align: center;
  margin-bottom: 36px;
}

.brand-logo {
  width: 150px;
  height: auto;
  margin: 0 auto 20px;
  display: block;
  filter: drop-shadow(0 8px 24px rgba(30, 136, 229, .12));
  animation: logoFloat 6s ease-in-out infinite;
}

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

.brand-name {
  font-size: .75rem;
  font-weight: 700;
  letter-spacing: .2em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0 0 4px;
}

h1 {
  font-size: clamp(1.8rem, 4vw, 2.4rem);
  margin: 0 0 8px;
  font-weight: 800;
  line-height: 1.15;
  background: var(--grad-primary);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  letter-spacing: -.02em;
}

.event-date {
  color: var(--text-soft);
  font-size: 1rem;
  margin: 0 0 20px;
  font-weight: 500;
}

.lead {
  font-size: 1.08rem;
  margin: 0 0 12px;
  color: var(--text-soft);
  line-height: 1.65;
  max-width: 620px;
  margin-left: auto;
  margin-right: auto;
}

.lead-ar {
  font-family: 'Cairo', system-ui, sans-serif;
  font-size: 1.08rem;
  direction: rtl;
  text-align: center;
  margin: 0 auto 28px;
  line-height: 1.85;
  color: var(--text-soft);
  max-width: 620px;
  font-weight: 500;
}

/* ============================================
   Counter bar (sticky)
   ============================================ */

.counter-bar {
  position: sticky;
  top: 12px;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 12px;
  background: rgba(255, 255, 255, .92);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  padding: 14px 22px;
  border-radius: 999px;
  border: 2px solid var(--border);
  box-shadow: var(--shadow);
  margin-bottom: 20px;
  font-size: .95rem;
  font-weight: 600;
  transition: all .3s ease;
}

.counter-icon { font-size: 1.3rem; }

#pick-counter-text { color: var(--text); font-weight: 700; }

.counter-hint {
  color: var(--muted);
  font-size: .85rem;
  font-weight: 500;
  margin-left: auto;
}

.counter-bar.counter-empty { border-color: var(--border); }

.counter-bar.counter-good {
  border-color: var(--brand);
  background: linear-gradient(135deg, rgba(30, 136, 229, .08), rgba(39, 174, 96, .08));
}
.counter-bar.counter-good #pick-counter-text {
  background: var(--grad-primary);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.counter-bar.counter-full {
  border-color: var(--orange);
  background: linear-gradient(135deg, rgba(243, 156, 18, .10), rgba(232, 69, 69, .08));
}
.counter-bar.counter-full #pick-counter-text { color: #b76b00; }
.counter-bar.counter-full .counter-hint { color: #b76b00; }

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

.card {
  background: var(--card);
  border: 1px solid var(--border-soft);
  border-radius: 16px;
  padding: 28px;
  margin-bottom: 22px;
  box-shadow: var(--shadow);
  transition: box-shadow .2s ease, transform .2s ease;
}

/* ============================================
   Song groups & options
   ============================================ */

.song-group {
  margin-bottom: 24px;
  animation: slideUp .5s ease backwards;
}

.song-group:nth-child(1) { animation-delay: .05s; }
.song-group:nth-child(2) { animation-delay: .1s; }
.song-group:nth-child(3) { animation-delay: .15s; }
.song-group:nth-child(4) { animation-delay: .2s; }
.song-group:nth-child(5) { animation-delay: .25s; }
.song-group:nth-child(6) { animation-delay: .3s; }
.song-group:nth-child(7) { animation-delay: .35s; }
.song-group:nth-child(8) { animation-delay: .4s; }

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

.song-group:last-child { margin-bottom: 0; }

.song-group-header {
  font-family: 'Cairo', system-ui, sans-serif;
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text);
  padding: 0 0 10px;
  margin: 0 0 12px;
  border-bottom: 2px solid var(--border-soft);
  direction: rtl;
  text-align: right;
  position: relative;
}

.song-group-header::after {
  content: '';
  position: absolute;
  bottom: -2px;
  right: 0;
  width: 60px;
  height: 2px;
  background: var(--grad-primary);
  border-radius: 2px;
}

/* Rotate accent color per group */
.song-group:nth-child(5n+1) .song-group-header::after { background: linear-gradient(90deg, #1E88E5, #27AE60); }
.song-group:nth-child(5n+2) .song-group-header::after { background: linear-gradient(90deg, #27AE60, #F4D03F); }
.song-group:nth-child(5n+3) .song-group-header::after { background: linear-gradient(90deg, #F39C12, #E84545); }
.song-group:nth-child(5n+4) .song-group-header::after { background: linear-gradient(90deg, #E84545, #1E88E5); }
.song-group:nth-child(5n+5) .song-group-header::after { background: linear-gradient(90deg, #F4D03F, #F39C12); }

.song-option {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  margin: 6px 0;
  border: 2px solid var(--border-soft);
  border-radius: 10px;
  cursor: pointer;
  direction: rtl;
  text-align: right;
  background: #fff;
  transition: all .2s cubic-bezier(.4, 0, .2, 1);
  font-family: 'Cairo', system-ui, sans-serif;
  font-size: 1rem;
  font-weight: 500;
  color: var(--text);
  position: relative;
}

.song-option:hover {
  border-color: var(--brand);
  background: rgba(30, 136, 229, .04);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(30, 136, 229, .08);
}

.song-option input[type="checkbox"],
.song-option input[type="radio"] {
  width: 20px;
  height: 20px;
  accent-color: var(--brand);
  cursor: pointer;
  flex-shrink: 0;
}

.song-option.selected {
  background: linear-gradient(135deg, rgba(30, 136, 229, .08), rgba(39, 174, 96, .08));
  border-color: var(--brand);
  font-weight: 700;
  box-shadow: 0 4px 16px rgba(30, 136, 229, .12);
}

.song-option.option-disabled {
  opacity: .4;
  cursor: not-allowed;
}

.song-option.option-disabled:hover {
  border-color: var(--border-soft);
  background: #fff;
  transform: none;
  box-shadow: none;
}

/* ============================================
   Form
   ============================================ */

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-top: 18px;
}

@media (max-width: 540px) {
  .form-row { grid-template-columns: 1fr; }
}

h2 {
  font-size: 1.25rem;
  font-weight: 700;
  margin: 0 0 8px;
  color: var(--text);
  letter-spacing: -.01em;
}

label {
  display: block;
  font-size: .88rem;
  color: var(--text-soft);
  margin-bottom: 6px;
  font-weight: 600;
}

input[type="email"],
input[type="tel"],
input[type="text"] {
  width: 100%;
  padding: 13px 16px;
  border: 2px solid var(--border);
  border-radius: 10px;
  font-size: 1rem;
  font-family: inherit;
  font-weight: 500;
  background: #fff;
  transition: all .2s ease;
  color: var(--text);
}

input[type="email"]:focus,
input[type="tel"]:focus,
input[type="text"]:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 4px rgba(30, 136, 229, .12);
}

.helper {
  font-size: .87rem;
  color: var(--muted);
  margin-top: 4px;
  font-weight: 500;
}

/* Honeypot — hidden */
.hp-field {
  position: absolute;
  left: -9999px;
  top: -9999px;
  width: 1px;
  height: 1px;
  overflow: hidden;
}

/* Consent block */
.consent-block {
  margin: 22px 0 0;
  padding: 18px 20px;
  background: var(--bg-soft);
  border-radius: 12px;
  border: 1px solid var(--border-soft);
}

.checkbox-row {
  display: grid;
  grid-template-columns: 22px 1fr;
  gap: 12px;
  align-items: start;
  font-size: .92rem;
  line-height: 1.5;
  margin-bottom: 14px;
  cursor: pointer;
  color: var(--text-soft);
}

.checkbox-row:last-child { margin-bottom: 0; }

.checkbox-row input[type="checkbox"] {
  margin-top: 3px;
  width: 20px;
  height: 20px;
  accent-color: var(--brand);
}

.checkbox-row a {
  color: var(--brand);
  text-decoration: none;
  font-weight: 600;
}
.checkbox-row a:hover { text-decoration: underline; }

.required-mark {
  color: var(--error);
  font-weight: 700;
  margin-left: 2px;
}

/* hCaptcha wrap */
.hcaptcha-wrap {
  margin-top: 18px;
  display: flex;
  justify-content: center;
}

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

.submit-row {
  margin-top: 28px;
  text-align: center;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 14px 36px;
  font-size: 1rem;
  font-weight: 700;
  border-radius: 12px;
  border: 2px solid transparent;
  cursor: pointer;
  font-family: inherit;
  transition: all .25s cubic-bezier(.4, 0, .2, 1);
  text-decoration: none;
  letter-spacing: -.01em;
  position: relative;
  overflow: hidden;
}

.btn-primary {
  background: var(--grad-primary);
  color: #fff;
  box-shadow: 0 8px 20px rgba(30, 136, 229, .25);
}

.btn-primary:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 12px 28px rgba(30, 136, 229, .35);
}

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

.btn-primary:disabled {
  background: #cbd5e0;
  color: #fff;
  cursor: not-allowed;
  box-shadow: none;
  opacity: .65;
}

.btn-outline {
  background: transparent;
  color: var(--brand);
  border-color: var(--brand);
}

.btn-outline:hover {
  background: var(--brand);
  color: #fff;
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(30, 136, 229, .2);
}

/* ============================================
   Messages
   ============================================ */

.message {
  margin: 18px 0 0;
  padding: 14px 18px;
  border-radius: 10px;
  font-size: .95rem;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 10px;
  animation: messageSlide .3s ease;
}

@keyframes messageSlide {
  from { opacity: 0; transform: translateY(-6px); }
  to { opacity: 1; transform: translateY(0); }
}

.message.error {
  background: rgba(232, 69, 69, .08);
  color: #b91c1c;
  border: 1px solid rgba(232, 69, 69, .25);
}

.message.success {
  background: rgba(39, 174, 96, .08);
  color: var(--green-dark);
  border: 1px solid rgba(39, 174, 96, .25);
}

.hidden { display: none !important; }

.empty-state {
  text-align: center;
  color: var(--muted);
  padding: 40px 20px;
  font-size: 1rem;
}

/* ============================================
   Results page
   ============================================ */

.results-header {
  text-align: center;
  margin-bottom: 30px;
}

.total-votes {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: var(--grad-primary);
  color: #fff;
  padding: 10px 22px;
  border-radius: 999px;
  font-weight: 700;
  font-size: 1rem;
  margin-top: 12px;
  box-shadow: 0 8px 20px rgba(30, 136, 229, .25);
}

.live-indicator {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--success);
  font-size: .9rem;
  margin-top: 12px;
  font-weight: 600;
}

.live-dot {
  width: 10px;
  height: 10px;
  background: var(--success);
  border-radius: 50%;
  animation: pulse 1.8s infinite;
  box-shadow: 0 0 0 0 rgba(39, 174, 96, .5);
}

@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(39, 174, 96, .6); }
  70% { box-shadow: 0 0 0 12px rgba(39, 174, 96, 0); }
  100% { box-shadow: 0 0 0 0 rgba(39, 174, 96, 0); }
}

.result-bar {
  display: grid;
  grid-template-columns: 1fr 70px;
  align-items: center;
  gap: 14px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border-soft);
  animation: slideUp .4s ease backwards;
}

.result-bar:last-child { border-bottom: none; }

.bar-track {
  position: relative;
  background: #f1f5f9;
  border-radius: 8px;
  height: 38px;
  overflow: hidden;
}

.bar-fill {
  position: absolute;
  inset: 0;
  background: var(--grad-primary);
  border-radius: 8px;
  transition: width .8s cubic-bezier(.4, 0, .2, 1);
  width: 0%;
}

.result-bar:nth-child(1) .bar-fill { background: linear-gradient(90deg, #1E88E5, #27AE60); }
.result-bar:nth-child(2) .bar-fill { background: linear-gradient(90deg, #27AE60, #F4D03F); }
.result-bar:nth-child(3) .bar-fill { background: linear-gradient(90deg, #F39C12, #E84545); }

.bar-label {
  position: absolute;
  top: 50%;
  right: 14px;
  transform: translateY(-50%);
  color: var(--text);
  font-weight: 600;
  font-size: .95rem;
  font-family: 'Cairo', system-ui, sans-serif;
  direction: rtl;
  text-align: right;
  z-index: 1;
  pointer-events: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: calc(100% - 28px);
}

.vote-count {
  text-align: center;
  font-weight: 800;
  color: var(--brand);
  font-size: 1.15rem;
  font-variant-numeric: tabular-nums;
}

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

footer {
  text-align: center;
  color: var(--muted);
  font-size: .85rem;
  margin-top: 40px;
  font-weight: 500;
}

footer a {
  color: var(--brand);
  text-decoration: none;
  font-weight: 600;
}
footer a:hover { text-decoration: underline; }

/* ============================================
   Admin page
   ============================================ */

.admin-container { max-width: 1180px; }

.admin-header { text-align: left; margin-bottom: 28px; }
.admin-header .brand-logo { margin: 0 0 16px; width: 110px; height: auto; }
.admin-header h1 {
  font-size: 1.8rem;
  text-align: left;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 22px;
}

@media (max-width: 700px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
}

.stat-card {
  background: var(--card);
  border: 1px solid var(--border-soft);
  border-radius: 14px;
  padding: 20px 22px;
  box-shadow: var(--shadow-sm);
  position: relative;
  overflow: hidden;
  transition: transform .2s ease, box-shadow .2s ease;
}

.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}

.stat-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--grad-primary);
}

.stat-card:nth-child(2)::before { background: linear-gradient(90deg, #27AE60, #F4D03F); }
.stat-card:nth-child(3)::before { background: linear-gradient(90deg, #F39C12, #E84545); }
.stat-card:nth-child(4)::before { background: linear-gradient(90deg, #E84545, #1E88E5); }

.stat-label {
  font-size: .8rem;
  color: var(--muted);
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: .08em;
  font-weight: 700;
}

.stat-value {
  font-size: 2.2rem;
  font-weight: 800;
  color: var(--text);
  line-height: 1;
  font-variant-numeric: tabular-nums;
  letter-spacing: -.02em;
}

.export-row {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}

.export-row .btn { padding: 11px 22px; font-size: .92rem; }

.voters-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .94rem;
}

.voters-table th {
  text-align: left;
  padding: 12px 14px;
  border-bottom: 2px solid var(--border);
  color: var(--muted);
  font-weight: 700;
  font-size: .78rem;
  text-transform: uppercase;
  letter-spacing: .08em;
}

.voters-table td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border-soft);
  vertical-align: middle;
  color: var(--text);
}

.voters-table tr.voter-row { transition: background .15s ease; }
.voters-table tr.voter-row:hover { background: rgba(30, 136, 229, .03); }

.voters-table .muted { color: var(--muted); font-size: .87rem; }

.badge {
  display: inline-block;
  padding: 4px 12px;
  border-radius: 999px;
  font-size: .78rem;
  font-weight: 700;
  letter-spacing: .03em;
}

.badge-yes {
  background: rgba(39, 174, 96, .12);
  color: var(--green-dark);
}
.badge-no {
  background: #f1f5f9;
  color: #94a3b8;
}

.link-button {
  background: none;
  border: 0;
  color: var(--brand);
  cursor: pointer;
  font-weight: 700;
  font-size: .92rem;
  padding: 5px 10px;
  border-radius: 6px;
  font-family: inherit;
  transition: background .15s ease;
}
.link-button:hover { background: rgba(30, 136, 229, .08); }

.btn-danger {
  background: transparent;
  color: var(--error);
  border: 1.5px solid rgba(232, 69, 69, .35);
  padding: 6px 14px;
  border-radius: 7px;
  font-size: .82rem;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: all .15s ease;
}
.btn-danger:hover {
  background: var(--error);
  color: #fff;
  border-color: var(--error);
}

.picks-cell {
  background: var(--bg-soft);
  padding: 14px 20px !important;
  direction: rtl;
  text-align: right;
  font-family: 'Cairo', system-ui, sans-serif;
}
.picks-cell strong {
  direction: ltr;
  display: inline-block;
  margin-bottom: 8px;
  color: var(--text-soft);
  font-family: 'Inter', sans-serif;
  font-weight: 700;
  font-size: .85rem;
  text-transform: uppercase;
  letter-spacing: .05em;
}

.picks-list {
  margin: 0;
  padding-right: 22px;
  padding-left: 0;
  list-style: none;
}
.picks-list li {
  margin-bottom: 4px;
  position: relative;
  padding-right: 14px;
}
.picks-list li::before {
  content: '🎵';
  position: absolute;
  right: -6px;
  top: 0;
  font-size: .85rem;
}

/* ============================================
   Reduced motion
   ============================================ */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    transition-duration: .01ms !important;
  }
}
