/* Can I Ask You Something? - Teal/Ocean Theme with Light + Dark modes */

/* ---- CSS Variables ---- */
:root {
  --bg: #f0f9ff;
  --card: #ffffff;
  --card-border: #e0f2fe;
  --muted: #0891b2;
  --ink: #334155;
  --pri: #0891b2;
  --pri-dark: #0e7490;
  --accent: #06b6d4;
  --danger: #dc2626;
  --success: #16a34a;
  --warning: #d97706;
  --header-bg: #ffffff;
  --input-bg: #ffffff;
  --input-border: #cbd5e1;
  --shadow: rgba(8, 145, 178, 0.08);
  --shadow-lg: rgba(8, 145, 178, 0.15);
  --gradient: linear-gradient(135deg, #06b6d4 0%, #0891b2 100%);
}

[data-theme="dark"] {
  --bg: #0f172a;
  --card: #1e293b;
  --card-border: #334155;
  --muted: #22d3ee;
  --ink: #e2e8f0;
  --pri: #22d3ee;
  --pri-dark: #06b6d4;
  --accent: #67e8f9;
  --danger: #f87171;
  --success: #4ade80;
  --warning: #fbbf24;
  --header-bg: #1e293b;
  --input-bg: #0f172a;
  --input-border: #475569;
  --shadow: rgba(34, 211, 238, 0.06);
  --shadow-lg: rgba(34, 211, 238, 0.12);
}

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

html { scroll-behavior: smooth; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.6;
  min-height: 100vh;
}

[data-theme="dark"] body {
  background-image:
    radial-gradient(circle at 20% 80%, rgba(6,182,212,0.06) 0%, transparent 50%),
    radial-gradient(circle at 80% 20%, rgba(14,116,144,0.06) 0%, transparent 50%);
}

a { color: var(--pri); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---- Layout ---- */
.container { max-width: 900px; margin: 0 auto; padding: 24px 16px; }

/* ---- Topbar ---- */
.topbar {
  position: sticky; top: 0; z-index: 100;
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 20px;
  background: var(--header-bg);
  border-bottom: 2px solid var(--card-border);
  box-shadow: 0 2px 8px var(--shadow);
}

.brand {
  display: flex; align-items: center; gap: 10px;
  font-weight: 700; font-size: 1.1rem; color: var(--pri);
  text-decoration: none;
}

.brand .logo {
  width: 36px; height: 36px;
  background: var(--gradient);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 800; font-size: 1.1rem;
}

.nav { display: flex; align-items: center; gap: 12px; }

.nav a {
  padding: 6px 14px; border-radius: 20px;
  font-size: 0.85rem; font-weight: 500;
  color: var(--muted); transition: all 0.2s;
}
.nav a:hover {
  background: var(--card-border); text-decoration: none;
  color: var(--pri);
}

.theme-toggle {
  background: var(--card-border); border: none;
  width: 34px; height: 34px; border-radius: 50%;
  cursor: pointer; font-size: 1.1rem;
  display: flex; align-items: center; justify-content: center;
  transition: all 0.2s; color: var(--ink);
}
.theme-toggle:hover { background: var(--pri); color: #fff; }

/* ---- Cards ---- */
.card {
  background: var(--card);
  border: 2px solid var(--card-border);
  border-radius: 14px;
  padding: 24px;
  margin-bottom: 20px;
  box-shadow: 0 2px 12px var(--shadow);
}

.card h2, .card h3 {
  color: var(--pri); margin-bottom: 16px;
  font-size: 1.15rem;
}

.card.highlight {
  border-color: var(--pri);
  border-width: 3px;
}

/* ---- Headings ---- */
h1 {
  font-size: 1.8rem; font-weight: 800;
  background: var(--gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 8px;
}

h2 { font-size: 1.3rem; color: var(--pri); margin-bottom: 12px; }
h3 { font-size: 1.1rem; color: var(--ink); margin-bottom: 8px; }

/* ---- Forms ---- */
.form-group { margin-bottom: 18px; }

.form-group label {
  display: block; margin-bottom: 5px;
  font-weight: 600; font-size: 0.9rem; color: var(--ink);
}

.form-control {
  width: 100%; padding: 10px 14px;
  border: 2px solid var(--input-border);
  border-radius: 10px; font-size: 0.95rem;
  background: var(--input-bg); color: var(--ink);
  transition: border-color 0.2s, box-shadow 0.2s;
}
.form-control:focus {
  outline: none; border-color: var(--pri);
  box-shadow: 0 0 0 3px rgba(8,145,178,0.15);
}
[data-theme="dark"] .form-control:focus {
  box-shadow: 0 0 0 3px rgba(34,211,238,0.15);
}

textarea.form-control { resize: vertical; min-height: 80px; }
select.form-control { cursor: pointer; }

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

.checkbox-label, .radio-label {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px; margin: 4px 0;
  background: var(--card); border: 2px solid var(--card-border);
  border-radius: 10px; cursor: pointer;
  transition: all 0.2s; font-size: 0.95rem;
}
.checkbox-label:hover, .radio-label:hover {
  border-color: var(--pri); background: var(--card-border);
}
.checkbox-label input, .radio-label input {
  width: 18px; height: 18px; accent-color: var(--pri); cursor: pointer;
}

.checkbox-inline {
  display: flex; align-items: center; gap: 8px;
  cursor: pointer; font-weight: normal; font-size: 0.95rem;
}
.checkbox-inline input { width: 18px; height: 18px; accent-color: var(--pri); cursor: pointer; }

.required { color: var(--danger); font-weight: 700; }

/* ---- Buttons ---- */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 10px 20px; border: none; border-radius: 10px;
  font-size: 0.9rem; font-weight: 600;
  cursor: pointer; transition: all 0.2s;
  text-decoration: none; color: var(--ink);
  background: var(--card-border);
}
.btn:hover { transform: translateY(-1px); box-shadow: 0 4px 12px var(--shadow-lg); }

.btn.primary { background: var(--gradient); color: #fff; }
.btn.primary:hover { opacity: 0.9; }

.btn.danger { background: var(--danger); color: #fff; }
.btn.danger:hover { opacity: 0.9; }

.btn.success { background: var(--success); color: #fff; }

.btn.small { padding: 6px 12px; font-size: 0.8rem; border-radius: 8px; }

.btn.lg { padding: 14px 28px; font-size: 1.05rem; }

.btn-group { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---- Link Copy Box ---- */
.link-box { margin-bottom: 14px; }
.link-box label {
  display: block; font-weight: 600; font-size: 0.85rem;
  color: var(--muted); margin-bottom: 4px;
}
.link-copy {
  display: flex; gap: 8px;
}
.link-copy input {
  flex: 1; padding: 8px 12px;
  border: 2px solid var(--card-border); border-radius: 8px;
  font-size: 0.85rem; font-family: monospace;
  background: var(--input-bg); color: var(--ink);
}
.link-copy input:focus { outline: none; border-color: var(--pri); }

/* ---- Question Cards ---- */
.question-card {
  background: var(--card); border: 2px solid var(--card-border);
  border-radius: 12px; padding: 20px; margin: 14px 0;
}
.question-num {
  font-weight: 700; color: var(--pri);
  font-size: 0.85rem; margin-bottom: 4px;
}
.question-text {
  font-weight: 600; font-size: 1.05rem; margin-bottom: 14px;
}

.question-card.text-display {
  background: transparent; border: none;
  padding: 12px 0; box-shadow: none;
}
.text-display-heading {
  font-size: 1.2rem; font-weight: 700; color: var(--ink); margin-bottom: 6px;
}
.text-display-body {
  font-size: 0.95rem; color: var(--ink);
  white-space: pre-wrap; line-height: 1.6;
}

.question-spacer { padding: 16px 0; }
.survey-divider { border: none; border-top: 2px solid var(--card-border); }

/* ---- Question Builder (create page) ---- */
.q-builder-item {
  background: var(--card-border); border-radius: 12px;
  padding: 16px; margin: 12px 0; position: relative;
}
.q-builder-item .q-builder-actions {
  position: absolute; top: 8px; right: 8px;
  display: flex; gap: 4px; align-items: center;
}
.q-builder-item .q-move {
  background: var(--card); color: var(--muted); border: 1px solid var(--card-border);
  width: 28px; height: 28px; border-radius: 6px;
  cursor: pointer; font-size: 0.75rem; display: flex;
  align-items: center; justify-content: center;
}
.q-builder-item .q-move:hover { border-color: var(--pri); color: var(--pri); }
.q-builder-item .q-remove {
  background: var(--danger); color: #fff; border: none;
  width: 28px; height: 28px; border-radius: 50%;
  cursor: pointer; font-size: 1rem; display: flex;
  align-items: center; justify-content: center;
}
.q-builder-item .form-group { margin-bottom: 10px; }
.q-builder-item .form-group label { font-size: 0.8rem; }

/* ---- Question List (manage page) ---- */
.q-list-item {
  display: flex; align-items: flex-start; gap: 12px;
  background: var(--card); border: 2px solid var(--card-border);
  border-radius: 10px; padding: 14px; margin: 8px 0;
}
.q-list-item .q-info { flex: 1; }
.q-list-item .q-info h4 { font-size: 0.95rem; margin-bottom: 2px; }
.q-list-item .q-info .q-type {
  font-size: 0.75rem; color: var(--muted);
  background: var(--card-border); padding: 2px 8px;
  border-radius: 8px; display: inline-block;
}
.q-list-item .q-actions { display: flex; gap: 4px; flex-shrink: 0; }

/* ---- Response Table ---- */
.table-wrap { overflow-x: auto; border-radius: 10px; border: 2px solid var(--card-border); }

.response-table {
  width: 100%; border-collapse: collapse; font-size: 0.85rem;
}
.response-table th, .response-table td {
  padding: 10px 12px; text-align: left;
  border-bottom: 1px solid var(--card-border);
}
.response-table th {
  background: var(--card-border); font-weight: 700;
  color: var(--pri); white-space: nowrap; position: sticky; top: 0;
}
.response-table tr:hover { background: var(--card-border); }

/* ---- Stat Bars (MC/MS results) ---- */
.stat-bar {
  display: flex; align-items: center; gap: 8px;
  margin: 6px 0; font-size: 0.85rem;
}
.stat-bar-label { min-width: 140px; max-width: 200px; word-break: break-word; }
.stat-bar-fill {
  height: 22px; border-radius: 6px;
  background: var(--gradient); transition: width 0.4s ease;
  min-width: 2px;
}
.stat-bar-count { color: var(--muted); font-weight: 600; min-width: 30px; }
.stat-count { font-size: 2rem; font-weight: 800; color: var(--pri); }

/* ---- Charts Grid ---- */
.charts-panel {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 16px; margin: 16px 0;
}
.chart-card {
  background: var(--card); border: 1px solid var(--card-border);
  border-radius: 12px; padding: 16px;
}
.chart-card h4 { margin: 0 0 12px; font-size: 0.95rem; }

/* ---- Text Responses (flowing colored spans) ---- */
.text-responses-card { grid-column: 1 / -1; }
.text-responses-flow { line-height: 2.2; font-size: 0.95rem; }
.text-responses-flow .resp-text {
  display: inline; padding: 4px 10px; border-radius: 4px;
  margin: 2px 4px; cursor: pointer;
  transition: opacity 0.2s, transform 0.2s, box-shadow 0.2s;
}
.text-responses-flow .resp-text:hover { transform: scale(1.02); }
.text-responses-flow .resp-text.resp-dimmed { opacity: 0.25; }
.text-responses-flow .resp-text.resp-highlighted {
  box-shadow: 0 0 0 3px rgba(0,0,0,0.3); transform: scale(1.05);
  z-index: 1; position: relative;
}
[data-theme="dark"] .text-responses-flow .resp-text.resp-highlighted {
  box-shadow: 0 0 0 3px rgba(255,255,255,0.4);
}
[data-theme="dark"] .text-responses-flow .resp-text {
  color: #1e293b;
}

/* ---- Respondent List ---- */
.resp-list { display: flex; flex-direction: column; gap: 6px; }
.resp-list-item {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 12px; background: var(--card); border-radius: 8px;
  border: 1px solid var(--card-border); font-size: 0.9rem;
  transition: opacity 0.2s;
}
.resp-list-item.resp-dimmed { opacity: 0.25; }
.resp-list-label { font-weight: 600; }

/* ---- Inline Question Edit ---- */
.q-edit-inline {
  background: var(--card-border); border-radius: 8px; padding: 12px;
}
.q-edit-inline .form-group { margin-bottom: 8px; }
.q-edit-inline label { font-size: 0.8rem; }

/* ---- Status Badges ---- */
.badge {
  display: inline-block; padding: 3px 10px;
  border-radius: 12px; font-size: 0.75rem; font-weight: 600;
}
.badge.active { background: #dcfce7; color: #166534; }
.badge.closed { background: #fee2e2; color: #991b1b; }
[data-theme="dark"] .badge.active { background: #064e3b; color: #6ee7b7; }
[data-theme="dark"] .badge.closed { background: #7f1d1d; color: #fca5a5; }

/* ---- Banners ---- */
.error-banner {
  background: #fee2e2; color: #991b1b;
  padding: 14px 20px; border-radius: 10px;
  font-weight: 600; text-align: center; margin-bottom: 18px;
}
[data-theme="dark"] .error-banner {
  background: #450a0a; color: #fca5a5;
}

.closed-banner {
  background: #fee2e2; color: #991b1b;
  text-align: center; font-weight: 600;
  padding: 14px; border-radius: 10px; margin-bottom: 18px;
}
[data-theme="dark"] .closed-banner {
  background: #450a0a; color: #fca5a5;
}

.success-message {
  text-align: center; padding: 40px 20px;
}
.success-message h2 {
  color: var(--success); font-size: 1.5rem; margin-bottom: 8px;
  -webkit-text-fill-color: var(--success);
}

.tip-callout {
  background: var(--card-border); border-left: 4px solid var(--pri);
  padding: 14px 18px; border-radius: 0 10px 10px 0;
  margin: 16px 0; font-size: 0.9rem;
}

.warn-callout {
  background: #fffbeb; border-left: 4px solid var(--warning);
  padding: 14px 18px; border-radius: 0 10px 10px 0;
  margin: 16px 0; font-size: 0.9rem;
}
[data-theme="dark"] .warn-callout {
  background: #451a03; border-color: var(--warning); color: #fef3c7;
}

/* ---- Footer ---- */
.site-footer {
  text-align: center; padding: 30px 16px;
  color: var(--muted); font-size: 0.8rem;
  border-top: 2px solid var(--card-border);
  margin-top: 40px;
}
.site-footer a { color: var(--pri); margin: 0 6px; }
.donate-row { margin-top: 6px; }

/* ---- Utilities ---- */
.hidden { display: none !important; }
.text-center { text-align: center; }
.text-muted { color: var(--muted); font-size: 0.85rem; }
.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 16px; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.gap-1 { gap: 8px; }

/* ---- Scrollbar ---- */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: var(--card-border); }
::-webkit-scrollbar-thumb { background: var(--muted); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--pri); }

/* ---- Responsive ---- */
@media (max-width: 600px) {
  .topbar {
    flex-direction: column; gap: 8px;
    padding: 10px 14px; text-align: center;
  }
  .nav { flex-wrap: wrap; justify-content: center; }
  .container { padding: 16px 10px; }
  .card { padding: 16px; }
  h1 { font-size: 1.4rem; }
  .form-row { grid-template-columns: 1fr; }
  .btn-group { flex-direction: column; }
  .btn-group .btn { width: 100%; justify-content: center; }
  .q-list-item { flex-direction: column; }
  .stat-bar-label { min-width: 100px; max-width: 140px; }
  .response-table { font-size: 0.78rem; }
  .response-table th, .response-table td { padding: 8px 6px; }
  .link-copy { flex-direction: column; }
  .link-copy input { width: 100%; }
}

/* ---- Animations ---- */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}
.card { animation: fadeIn 0.3s ease; }
