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

:root {
  --gold:       #c9a84c;
  --gold-light: #e8d08a;
  --gold-dark:  #9a7530;
  --green:      #1a5c3a;
  --green-light:#2a7d51;
  --green-pale: #e8f5ee;
  --bg:         #f7f4ee;
  --surface:    #ffffff;
  --border:     #e2ddd4;
  --text:       #1e1a14;
  --text-muted: #6b6456;
  --red:        #c0392b;
  --red-pale:   #fdf0ee;
  --attending-color: #1a5c3a;
  --notatt-color:    #c0392b;
  --radius:     8px;
  --shadow:     0 2px 16px rgba(0,0,0,0.08);
}

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', sans-serif;
  font-size: 15px;
  line-height: 1.6;
}

/* ── HEADER ───────────────────────────────────────────────────────────────── */
.site-header {
  background: var(--green);
  border-bottom: 3px solid var(--gold);
  position: sticky;
  top: 0;
  z-index: 100;
}
.header-inner {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 24px;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.site-logo {
  display: flex;
  align-items: center;
  gap: 14px;
}
.logo-arabic {
  font-family: 'Amiri', serif;
  font-size: 2rem;
  color: var(--gold);
  line-height: 1;
}
.logo-text {
  display: flex;
  flex-direction: column;
}
.logo-title {
  color: #fff;
  font-size: 0.95rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}
.logo-sub {
  color: var(--gold-light);
  font-size: 0.72rem;
  font-weight: 400;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}
.header-nav {
  display: flex;
  align-items: center;
  gap: 16px;
}
.nav-sabeel {
  color: var(--gold-light);
  font-size: 0.85rem;
}
.btn-logout {
  background: transparent;
  border: 1px solid var(--gold);
  color: var(--gold-light);
  padding: 5px 14px;
  border-radius: 4px;
  font-size: 0.8rem;
  cursor: pointer;
  text-decoration: none;
  transition: all .2s;
}
.btn-logout:hover { background: var(--gold); color: var(--green); }

/* ── MAIN ─────────────────────────────────────────────────────────────────── */
.main-content {
  min-height: calc(100vh - 64px - 48px);
}

/* ── FOOTER ───────────────────────────────────────────────────────────────── */
.site-footer {
  text-align: center;
  padding: 14px;
  font-size: 0.75rem;
  color: var(--text-muted);
  border-top: 1px solid var(--border);
}

/* ── LOGIN PAGE ───────────────────────────────────────────────────────────── */
.login-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: calc(100vh - 112px);
  padding: 32px 16px;
}
.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-top: 3px solid var(--gold);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 40px 40px 36px;
  width: 100%;
  max-width: 420px;
  text-align: center;
}
.login-ornament { margin-bottom: 20px; }
.login-ornament svg { width: 120px; height: 20px; }
.login-heading {
  font-family: 'Amiri', serif;
  font-size: 2.2rem;
  color: var(--green);
  margin-bottom: 6px;
}
.login-subheading {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-bottom: 28px;
}
.login-form { text-align: left; }

/* ── FORMS ────────────────────────────────────────────────────────────────── */
.form-group { margin-bottom: 18px; }
.form-label {
  display: block;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 6px;
}
.form-input, .form-select {
  width: 100%;
  padding: 10px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  font-family: 'Inter', sans-serif;
  font-size: 0.95rem;
  color: var(--text);
  background: var(--surface);
  transition: border-color .2s, box-shadow .2s;
  outline: none;
  appearance: none;
}
.form-input:focus, .form-select:focus {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(201,168,76,0.15);
}
.form-select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%236b6456' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
  cursor: pointer;
}
.form-select:disabled {
  background: #f5f3ef;
  color: #bbb;
  cursor: default;
}

/* ── BUTTONS ──────────────────────────────────────────────────────────────── */
.btn-primary {
  background: var(--green);
  color: #fff;
  border: none;
  padding: 11px 24px;
  border-radius: var(--radius);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: background .2s, opacity .2s;
  letter-spacing: 0.02em;
}
.btn-primary:hover:not(:disabled) { background: var(--green-light); }
.btn-primary:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-secondary {
  background: transparent;
  color: var(--green);
  border: 1.5px solid var(--green);
  padding: 10px 20px;
  border-radius: var(--radius);
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: all .2s;
}
.btn-secondary:hover { background: var(--green-pale); }
.btn-full { width: 100%; margin-top: 4px; }
.btn-sm { padding: 6px 14px; font-size: 0.8rem; }

/* ── ALERTS ───────────────────────────────────────────────────────────────── */
.alert {
  padding: 10px 16px;
  border-radius: var(--radius);
  font-size: 0.88rem;
  margin-bottom: 16px;
}
.alert-error  { background: var(--red-pale); color: var(--red); border: 1px solid #f5c6c2; }
.alert-success { background: var(--green-pale); color: var(--green); border: 1px solid #b8dfc8; }

/* ── SURVEY PAGE ──────────────────────────────────────────────────────────── */
.survey-wrap {
  max-width: 1000px;
  margin: 0 auto;
  padding: 32px 24px 48px;
}
.survey-header { margin-bottom: 24px; }
.survey-title {
  font-family: 'Amiri', serif;
  font-size: 1.8rem;
  color: var(--green);
  margin-bottom: 4px;
}
.survey-desc { color: var(--text-muted); font-size: 0.92rem; }

/* ── MEMBERS TABLE ────────────────────────────────────────────────────────── */
.members-table-wrap {
  overflow-x: auto;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}
.members-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
}
.members-table thead tr {
  background: var(--green);
  color: #fff;
}
.members-table th {
  padding: 12px 16px;
  text-align: left;
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  white-space: nowrap;
}
.members-table td {
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.members-table tbody tr:last-child td { border-bottom: none; }
.members-table tbody tr:hover { background: #fbf9f5; }
.members-table tbody tr.row-done { background: #f0f9f4; }

.its-badge {
  font-size: 0.82rem;
  font-family: monospace;
  color: var(--text-muted);
  background: #f0ece4;
  padding: 2px 8px;
  border-radius: 4px;
  white-space: nowrap;
}
.col-name { font-weight: 500; min-width: 200px; }
.col-its  { min-width: 120px; }
.col-status { min-width: 180px; }
.col-place  { min-width: 200px; }

/* Gender pills */
.gender-pill {
  font-size: 0.75rem;
  font-weight: 600;
  padding: 2px 10px;
  border-radius: 20px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.gender-male   { background: #dbeafe; color: #1e40af; }
.gender-female { background: #fce7f3; color: #9d174d; }

/* Attending select colors */
select.attending-select option[value="yes"]  { color: var(--attending-color); font-weight: 600; }
select.attending-select option[value="no"]   { color: var(--notatt-color); font-weight: 600; }
select.attending-select.val-yes { border-color: var(--attending-color); color: var(--attending-color); font-weight: 600; }
select.attending-select.val-no  { border-color: var(--notatt-color); color: var(--notatt-color); font-weight: 600; }

/* Submit row */
.submit-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 24px;
  padding: 16px 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.submit-info {
  color: var(--text-muted);
  font-size: 0.9rem;
}
.submit-info #filledCount { font-weight: 700; color: var(--green); font-size: 1.1rem; }
.btn-submit { padding: 12px 32px; font-size: 1rem; }

/* ── MODAL ────────────────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.5);
  display: flex; align-items: center; justify-content: center;
  z-index: 1000;
}
.modal-box {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 32px 36px;
  max-width: 440px;
  width: 90%;
  box-shadow: 0 8px 40px rgba(0,0,0,0.18);
  border-top: 3px solid var(--gold);
}
.modal-title {
  font-family: 'Amiri', serif;
  font-size: 1.4rem;
  color: var(--green);
  margin-bottom: 12px;
}
.modal-text { font-size: 0.92rem; color: var(--text-muted); margin-bottom: 10px; }
.modal-actions { display: flex; gap: 12px; margin-top: 20px; justify-content: flex-end; }

/* ── TOAST ────────────────────────────────────────────────────────────────── */
.toast {
  position: fixed;
  bottom: 24px; right: 24px;
  padding: 12px 20px;
  border-radius: var(--radius);
  font-size: 0.9rem;
  font-weight: 500;
  box-shadow: 0 4px 20px rgba(0,0,0,0.15);
  z-index: 2000;
  transition: opacity .3s;
}
.toast.success { background: var(--green); color: #fff; }
.toast.error   { background: var(--red);   color: #fff; }

/* ── ANALYTICS ────────────────────────────────────────────────────────────── */
.analytics-wrap {
  max-width: 900px;
  margin: 0 auto;
  padding: 32px 24px 48px;
}
.analytics-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 28px;
}
.analytics-title {
  font-family: 'Amiri', serif;
  font-size: 1.8rem;
  color: var(--green);
}

/* Stats cards */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 16px;
  margin-bottom: 36px;
}
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  text-align: center;
  box-shadow: var(--shadow);
}
.stat-value {
  font-size: 2.4rem;
  font-weight: 700;
  line-height: 1;
  margin-bottom: 6px;
}
.stat-label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
}
.stat-total       .stat-value { color: var(--text); }
.stat-responded   .stat-value { color: var(--gold-dark); }
.stat-attending   .stat-value { color: var(--attending-color); }
.stat-notattending .stat-value { color: var(--notatt-color); }
.stat-sabeels     .stat-value { color: var(--green); }

/* Analytics sections */
.analytics-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 24px;
  box-shadow: var(--shadow);
}
.section-heading {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.07em;
  margin-bottom: 18px;
}
.section-icon { color: var(--gold); margin-right: 6px; }

/* Analytics table */
.analytics-table-wrap { overflow-x: auto; }
.analytics-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
}
.analytics-table th {
  text-align: left;
  padding: 8px 14px;
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  border-bottom: 2px solid var(--border);
}
.analytics-table td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
}
.analytics-table tfoot th {
  padding: 10px 14px;
  border-top: 2px solid var(--border);
  border-bottom: none;
  font-weight: 700;
  color: var(--text);
  background: #faf8f4;
}
.analytics-table .num { text-align: right; }
.analytics-table .total-col { font-weight: 700; }
.analytics-table .attending-col { color: var(--attending-color); }
.analytics-table .notattending-col { color: var(--notatt-color); }

/* Badges */
.count-badge {
  display: inline-block;
  font-weight: 700;
  font-size: 1rem;
  min-width: 30px;
}
.attending-badge   { color: var(--attending-color); }
.notattending-badge { color: var(--notatt-color); }
.pct { font-size: 0.78rem; color: var(--text-muted); margin-left: 4px; }

.place-pill {
  background: #eef4f9;
  color: #1a3c5a;
  padding: 2px 10px;
  border-radius: 4px;
  font-size: 0.85rem;
  font-weight: 600;
}

/* Split bar */
.split-bar-wrap { }
.split-bar {
  display: flex;
  height: 36px;
  border-radius: 6px;
  overflow: hidden;
  margin-bottom: 10px;
}
.split-bar-fill {
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 0.82rem;
  font-weight: 700;
  transition: width .5s;
}
.attending-fill    { background: var(--attending-color); }
.notattending-fill { background: var(--notatt-color); }
.split-legend {
  font-size: 0.82rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 4px;
}
.legend-dot {
  display: inline-block;
  width: 10px; height: 10px;
  border-radius: 50%;
}
.attending-dot    { background: var(--attending-color); }
.notattending-dot { background: var(--notatt-color); }

/* ── RESPONSIVE ───────────────────────────────────────────────────────────── */
@media (max-width: 600px) {
  .header-inner { padding: 0 14px; }
  .logo-arabic  { font-size: 1.5rem; }
  .logo-title   { font-size: 0.82rem; }
  .survey-wrap, .analytics-wrap { padding: 20px 12px 40px; }
  .login-card   { padding: 28px 20px; }
  .submit-row   { flex-direction: column; gap: 12px; text-align: center; }
  .btn-submit   { width: 100%; }
  .stats-grid   { grid-template-columns: repeat(2, 1fr); }
}
