/* ── Design Tokens ─────────────────────────────────────────────────────────── */
@import url('https://fonts.googleapis.com/css2?family=Cormorant+Garamond:wght@400;600&family=DM+Sans:wght@400;500;600&display=swap');

:root {
  --primary: #1e3a5f;
  --primary-light: #2c5282;
  --primary-hover: #163050;
  --accent: #b8975a;
  --accent-light: #d4b27a;
  --text: #1f2937;
  --text-muted: #6b7280;
  --border: #e5e7eb;
  --bg: #ffffff;
  --bg-soft: #f8f9fb;
  --bg-card: #ffffff;
  --error: #dc2626;
  --error-bg: #fef2f2;
  --success: #16a34a;
  --radius: 10px;
  --radius-sm: 6px;
  --shadow: 0 4px 32px rgba(30, 58, 95, 0.09);
  --shadow-sm: 0 2px 8px rgba(30, 58, 95, 0.06);
  --font-display: 'Cormorant Garamond', Georgia, serif;
  --font-body: 'DM Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --transition: 0.18s ease;
}

@media (prefers-color-scheme: dark) {
  :root {
    --primary: #5b9bd5;
    --primary-light: #7ab4e8;
    --primary-hover: #4a8bc5;
    --accent: #c9a96e;
    --accent-light: #d4b27a;
    --text: #f1f5f9;
    --text-muted: #94a3b8;
    --border: #2d3748;
    --bg: #0f1923;
    --bg-soft: #1a2535;
    --bg-card: #1a2535;
    --error: #f87171;
    --error-bg: #2d1515;
    --success: #4ade80;
    --shadow: 0 4px 32px rgba(0, 0, 0, 0.35);
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.2);
  }
}

/* ── Reset & Base ──────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 16px; scroll-behavior: smooth; }

body {
  font-family: var(--font-body);
  color: var(--text);
  background: var(--bg);
  line-height: 1.6;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* ── Survey Layout ─────────────────────────────────────────────────────────── */
.survey-page {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* ── Hero Header ───────────────────────────────────────────────────────────── */
.hero {
  background: var(--primary);
  padding: 52px 24px 56px;
  text-align: center;
  position: relative;
  overflow: hidden;
}

/* Subtle Mediterranean wave pattern */
.hero::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image:
    radial-gradient(ellipse 60% 40% at 50% 120%, rgba(184,151,90,0.18) 0%, transparent 70%),
    radial-gradient(ellipse 80% 60% at 80% -20%, rgba(255,255,255,0.05) 0%, transparent 60%);
  pointer-events: none;
}

.hero-inner {
  position: relative;
  max-width: 560px;
  margin: 0 auto;
}

.hero-eyebrow {
  font-family: var(--font-body);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--accent-light);
  margin-bottom: 12px;
}

.hero h1 {
  font-family: var(--font-display);
  font-size: clamp(2rem, 5vw, 2.8rem);
  font-weight: 600;
  color: #ffffff;
  line-height: 1.2;
  margin-bottom: 16px;
  letter-spacing: -0.01em;
}

.hero p {
  font-size: 15px;
  color: rgba(255,255,255,0.75);
  max-width: 440px;
  margin: 0 auto;
  line-height: 1.65;
}

/* Decorative line below hero */
.hero-bar {
  height: 3px;
  background: linear-gradient(90deg, transparent, var(--accent), transparent);
  opacity: 0.6;
}

/* ── Main Content ──────────────────────────────────────────────────────────── */
.main-content {
  flex: 1;
  background: var(--bg-soft);
  padding: 40px 16px 60px;
}

.form-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  max-width: 600px;
  margin: 0 auto;
  padding: 40px 36px;
}

@media (max-width: 480px) {
  .form-card { padding: 28px 20px; }
  .hero { padding: 40px 20px 44px; }
}

/* ── Form Elements ─────────────────────────────────────────────────────────── */
.form-group {
  margin-bottom: 32px;
}

.form-group:last-of-type {
  margin-bottom: 0;
}

label.field-label {
  display: block;
  font-weight: 600;
  font-size: 14px;
  color: var(--text);
  margin-bottom: 6px;
  letter-spacing: 0.01em;
}

label.field-label .optional {
  font-weight: 400;
  color: var(--text-muted);
  font-size: 13px;
}

.field-hint {
  font-size: 12.5px;
  color: var(--text-muted);
  margin-bottom: 8px;
  line-height: 1.5;
}

.field-required {
  font-size: 12.5px;
  color: var(--text-muted);
  margin-top: 4px;
}

input[type="text"],
textarea {
  width: 100%;
  padding: 12px 14px;
  font-family: var(--font-body);
  font-size: 15px;
  color: var(--text);
  background: var(--bg);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
  resize: vertical;
  min-height: 44px;
}

input[type="text"]:focus,
textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(30,58,95,0.1);
}

@media (prefers-color-scheme: dark) {
  input[type="text"]:focus,
  textarea:focus {
    box-shadow: 0 0 0 3px rgba(91,155,213,0.15);
  }
}

textarea { min-height: 108px; }

/* ── Custom Radio Buttons ──────────────────────────────────────────────────── */
.radio-group {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 4px;
}

.radio-option {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 13px 16px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: border-color var(--transition), background var(--transition);
  min-height: 44px;
  user-select: none;
}

.radio-option:hover {
  border-color: var(--primary-light);
  background: var(--bg-soft);
}

.radio-option input[type="radio"] {
  appearance: none;
  -webkit-appearance: none;
  width: 20px;
  height: 20px;
  border: 2px solid var(--border);
  border-radius: 50%;
  flex-shrink: 0;
  transition: border-color var(--transition), background var(--transition);
  position: relative;
  cursor: pointer;
}

.radio-option input[type="radio"]::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0);
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--primary);
  transition: transform 0.15s ease;
}

.radio-option input[type="radio"]:checked {
  border-color: var(--primary);
}

.radio-option input[type="radio"]:checked::after {
  transform: translate(-50%, -50%) scale(1);
}

.radio-option:has(input:checked) {
  border-color: var(--primary);
  background: rgba(30,58,95,0.04);
}

@media (prefers-color-scheme: dark) {
  .radio-option:has(input:checked) {
    background: rgba(91,155,213,0.08);
  }
  .radio-option input[type="radio"]::after {
    background: var(--primary-light);
  }
}

.radio-label {
  font-size: 15px;
  color: var(--text);
  cursor: pointer;
  flex: 1;
}

.radio-sub {
  display: block;
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}

/* ── Section Divider ───────────────────────────────────────────────────────── */
.section-divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 36px 0;
}

.section-title {
  font-family: var(--font-display);
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--primary);
  margin-bottom: 20px;
  letter-spacing: -0.01em;
}

/* ── Validation Error ──────────────────────────────────────────────────────── */
.field-error {
  font-size: 13px;
  color: var(--error);
  margin-top: 6px;
  display: none;
}

.field-error.visible { display: block; }

.radio-group.has-error .radio-option {
  border-color: var(--error);
}

.radio-group.has-error .radio-option:has(input:checked) {
  border-color: var(--primary);
}

/* ── Submit Button ─────────────────────────────────────────────────────────── */
.btn-submit {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 15px 24px;
  margin-top: 36px;
  font-family: var(--font-body);
  font-size: 16px;
  font-weight: 600;
  color: #ffffff;
  background: var(--primary);
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background var(--transition), transform var(--transition), box-shadow var(--transition);
  min-height: 52px;
  letter-spacing: 0.01em;
}

.btn-submit:hover:not(:disabled) {
  background: var(--primary-hover);
  box-shadow: 0 4px 16px rgba(30,58,95,0.25);
  transform: translateY(-1px);
}

.btn-submit:active:not(:disabled) {
  transform: translateY(0);
}

.btn-submit:disabled {
  opacity: 0.65;
  cursor: not-allowed;
}

/* Spinner */
.spinner {
  width: 18px;
  height: 18px;
  border: 2.5px solid rgba(255,255,255,0.35);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  display: none;
}

.btn-submit.loading .spinner { display: block; }
.btn-submit.loading .btn-text { opacity: 0.8; }

@keyframes spin { to { transform: rotate(360deg); } }

/* ── Success State ─────────────────────────────────────────────────────────── */
.success-state {
  display: none;
  text-align: center;
  padding: 60px 24px;
}

.success-state.visible { display: block; }

.success-icon {
  width: 64px;
  height: 64px;
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 24px;
}

.success-icon svg {
  width: 32px;
  height: 32px;
  stroke: #fff;
  stroke-width: 2.5;
  fill: none;
}

.success-state h2 {
  font-family: var(--font-display);
  font-size: 1.75rem;
  color: var(--primary);
  margin-bottom: 12px;
  font-weight: 600;
}

.success-state p {
  color: var(--text-muted);
  font-size: 15px;
  margin-bottom: 20px;
}

/* Already submitted state */
.already-submitted {
  display: none;
  text-align: center;
  padding: 40px 24px;
}

.already-submitted.visible { display: block; }

.already-submitted p {
  color: var(--text-muted);
  margin-bottom: 16px;
}

.link-subtle {
  font-size: 14px;
  color: var(--primary);
  text-decoration: underline;
  cursor: pointer;
  background: none;
  border: none;
  font-family: var(--font-body);
  padding: 0;
}

.link-subtle:hover { color: var(--primary-light); }

/* ── Footer ────────────────────────────────────────────────────────────────── */
.site-footer {
  text-align: center;
  padding: 20px 16px;
  font-size: 12px;
  color: var(--text-muted);
  border-top: 1px solid var(--border);
  background: var(--bg);
}

/* ── Admin Layout ──────────────────────────────────────────────────────────── */
.admin-page {
  min-height: 100vh;
  background: var(--bg-soft);
}

.admin-header {
  background: var(--primary);
  padding: 28px 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 16px;
}

.admin-header-left h1 {
  font-family: var(--font-display);
  font-size: 1.6rem;
  font-weight: 600;
  color: #fff;
  letter-spacing: -0.01em;
}

.admin-header-left .eyebrow {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--accent-light);
  margin-bottom: 6px;
}

.admin-header-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.total-badge {
  background: rgba(255,255,255,0.15);
  border: 1px solid rgba(255,255,255,0.25);
  color: #fff;
  padding: 6px 16px;
  border-radius: 20px;
  font-size: 14px;
  font-weight: 500;
}

.total-badge span {
  font-weight: 700;
  font-size: 16px;
}

.btn-icon {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 9px 18px;
  background: rgba(255,255,255,0.12);
  border: 1px solid rgba(255,255,255,0.25);
  border-radius: var(--radius-sm);
  color: #fff;
  font-size: 14px;
  font-weight: 500;
  font-family: var(--font-body);
  cursor: pointer;
  transition: background var(--transition);
  text-decoration: none;
}

.btn-icon:hover { background: rgba(255,255,255,0.22); }

.admin-main {
  max-width: 1100px;
  margin: 0 auto;
  padding: 32px 24px 64px;
}

/* ── Admin Cards ───────────────────────────────────────────────────────────── */
.admin-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 28px 32px;
  margin-bottom: 24px;
}

@media (max-width: 600px) {
  .admin-card { padding: 20px 16px; }
  .admin-header { padding: 20px 16px; }
  .admin-main { padding: 20px 12px 48px; }
}

.admin-card-title {
  font-family: var(--font-display);
  font-size: 1.2rem;
  font-weight: 600;
  color: var(--primary);
  margin-bottom: 20px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border);
  letter-spacing: -0.01em;
}

/* ── Stats Bar Charts ──────────────────────────────────────────────────────── */
.stat-bars {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.stat-bar-row {
  display: grid;
  grid-template-columns: 160px 1fr 80px;
  align-items: center;
  gap: 14px;
}

@media (max-width: 500px) {
  .stat-bar-row { grid-template-columns: 1fr; gap: 6px; }
  .stat-bar-track { height: 8px; }
}

.stat-bar-label {
  font-size: 13.5px;
  font-weight: 500;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.stat-bar-track {
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 20px;
  height: 10px;
  overflow: hidden;
}

.stat-bar-fill {
  height: 100%;
  border-radius: 20px;
  background: linear-gradient(90deg, var(--primary), var(--primary-light));
  transition: width 0.6s cubic-bezier(0.4, 0, 0.2, 1);
  min-width: 3px;
}

.stat-bar-fill.accent {
  background: linear-gradient(90deg, var(--accent), var(--accent-light));
}

.stat-bar-fill.muted {
  background: var(--border);
}

.stat-bar-value {
  font-size: 13px;
  color: var(--text-muted);
  text-align: right;
  white-space: nowrap;
}

/* ── Response Table ────────────────────────────────────────────────────────── */
.table-wrapper {
  overflow-x: auto;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}

.responses-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}

.responses-table th {
  background: var(--bg-soft);
  color: var(--text-muted);
  font-weight: 600;
  font-size: 11.5px;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  padding: 11px 14px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.responses-table td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
  color: var(--text);
  max-width: 220px;
}

.responses-table tr:last-child td { border-bottom: none; }

.responses-table tr:hover td { background: var(--bg-soft); }

.cell-text {
  display: block;
  white-space: pre-wrap;
  word-break: break-word;
  min-width: 150px;
  max-width: 350px;
}

.text-link {
  color: var(--primary);
  cursor: pointer;
  text-decoration: underline;
  font-size: 12px;
  margin-top: 2px;
  display: inline-block;
  background: none;
  border: none;
  font-family: var(--font-body);
  padding: 0;
}

.text-link:hover { color: var(--primary-light); }

.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}

.badge-nixe { background: rgba(30,58,95,0.1); color: var(--primary); }
.badge-maricel { background: rgba(184,151,90,0.15); color: #8a6d2e; }
.badge-third, .badge-new { background: var(--bg-soft); color: var(--text-muted); border: 1px solid var(--border); }

@media (prefers-color-scheme: dark) {
  .badge-maricel { color: var(--accent-light); }
}

.btn-delete {
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  cursor: pointer;
  padding: 5px 9px;
  font-size: 15px;
  transition: border-color var(--transition), color var(--transition);
  line-height: 1;
}

.btn-delete:hover {
  border-color: var(--error);
  color: var(--error);
}

.empty-state {
  text-align: center;
  padding: 48px 16px;
  color: var(--text-muted);
  font-size: 15px;
}

/* ── Export Section ────────────────────────────────────────────────────────── */
.export-section {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

.btn-export {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 11px 22px;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: background var(--transition);
  min-height: 44px;
}

.btn-export:hover { background: var(--primary-hover); }

.export-hint {
  font-size: 13px;
  color: var(--text-muted);
}

/* ── Modal ─────────────────────────────────────────────────────────────────── */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15,25,35,0.65);
  backdrop-filter: blur(4px);
  z-index: 100;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal-overlay.visible { display: flex; }

.modal-box {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 20px 60px rgba(0,0,0,0.2);
  max-width: 540px;
  width: 100%;
  max-height: 80vh;
  overflow-y: auto;
  padding: 32px;
}

.modal-title {
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--primary);
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}

.modal-body {
  font-size: 15px;
  color: var(--text);
  line-height: 1.7;
  white-space: pre-wrap;
}

.modal-close {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 20px;
  padding: 9px 18px;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: var(--font-body);
  font-size: 14px;
  cursor: pointer;
  color: var(--text);
  transition: background var(--transition);
}

.modal-close:hover { background: var(--border); }

/* Loading */
.loading-state {
  text-align: center;
  padding: 40px;
  color: var(--text-muted);
}
