:root {
  --maccabi-red: #d6232a;
  --maccabi-red-dark: #a51a20;
  --wellcome-blue: #28a3d8;
  --wellcome-blue-dark: #1a7ca4;
  --text: #222;
  --text-muted: #666;
  --bg: #f3f5f8;
  --border: #d6dbe2;
  --border-light: #e9edf2;
  --card: #ffffff;
  --success: #1f9d55;
  --error: #c5302a;
  --shadow: 0 2px 8px rgba(0,0,0,0.06);
  --shadow-lg: 0 8px 24px rgba(0,0,0,0.10);
  --radius: 8px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  font-family: 'Heebo', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 15px;
  line-height: 1.55;
  color: var(--text);
  background: var(--bg);
  direction: rtl;
}

.page-wrapper {
  max-width: 980px;
  margin: 0 auto;
  padding: 24px 16px 80px;
}

/* ====== HEADER ====== */
.form-header {
  display: grid;
  grid-template-columns: 160px 1fr 160px;
  align-items: center;
  gap: 16px;
  background: var(--card);
  border-radius: var(--radius) var(--radius) 0 0;
  padding: 24px;
  border-bottom: 3px solid var(--maccabi-red);
  box-shadow: var(--shadow);
}
.brand { text-align: center; }
.brand-name {
  font-weight: 700;
  font-size: 28px;
  letter-spacing: -0.5px;
}
.brand-wellcome { color: var(--wellcome-blue); }
.brand-maccabi  { color: var(--maccabi-red); }
.brand-sub  { font-size: 14px; color: var(--text-muted); margin-top: 2px; }
.brand-tag  { font-size: 11px; color: var(--wellcome-blue-dark); margin-top: 4px; }

.brand-title { text-align: center; }
.title-he { font-size: 22px; margin: 0 0 4px; color: var(--text); font-weight: 700; }
.title-en { font-size: 16px; margin: 0 0 8px; color: var(--wellcome-blue-dark); font-weight: 600; }
.title-note { margin: 0; font-size: 12px; color: var(--text-muted); }

/* ====== PROGRESS BAR ====== */
.progress-bar {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  background: var(--card);
  padding: 12px;
  border-bottom: 1px solid var(--border-light);
  box-shadow: var(--shadow);
}
.progress-step {
  text-align: center;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  padding: 8px 4px;
  border-radius: 6px;
  position: relative;
}
.progress-step.active {
  color: white;
  background: var(--maccabi-red);
  font-weight: 600;
}
.progress-step.done {
  color: var(--success);
  font-weight: 600;
}
.progress-step.done::after {
  content: " ✓";
}

/* ====== FORM ====== */
form {
  background: var(--card);
  padding: 28px 24px;
  border-radius: 0 0 var(--radius) var(--radius);
  box-shadow: var(--shadow);
}

fieldset {
  border: none;
  padding: 0;
  margin: 0 0 24px;
}
fieldset.hidden { display: none; }

.section-title {
  font-size: 18px;
  color: var(--maccabi-red);
  border-bottom: 2px solid var(--maccabi-red);
  padding-bottom: 6px;
  margin: 24px 0 12px;
  font-weight: 700;
}
.section-title:first-child { margin-top: 0; }
.section-title .en {
  font-size: 14px;
  color: var(--text-muted);
  font-weight: 400;
  float: left;
}
.section-intro {
  margin: 0 0 16px;
  color: var(--text-muted);
  font-size: 14px;
}
.subsection {
  margin: 18px 0 8px;
  font-size: 15px;
  color: var(--wellcome-blue-dark);
  font-weight: 600;
  border-right: 4px solid var(--wellcome-blue);
  padding-right: 8px;
}

/* ====== INPUTS / GRID ====== */
.grid {
  display: grid;
  gap: 12px 16px;
  margin-bottom: 12px;
}
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.span-2 { grid-column: span 2; }
.span-3 { grid-column: span 3; }

label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
}
input[type=text], input[type=tel], input[type=number], input[type=date],
input[type=email], select, textarea {
  width: 100%;
  padding: 9px 10px;
  font: inherit;
  font-size: 14px;
  border: 1px solid var(--border);
  border-radius: 6px;
  margin-top: 4px;
  background: white;
  transition: border-color 0.15s, box-shadow 0.15s;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--wellcome-blue);
  box-shadow: 0 0 0 3px rgba(40, 163, 216, 0.15);
}
input[dir="ltr"] { text-align: left; }

.req { color: var(--error); }

/* ====== CHECKBOXES ====== */
.check-row {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  margin: 8px 0 16px;
  align-items: center;
}
.check-item {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border-radius: 6px;
  cursor: pointer;
  user-select: none;
}
.check-item:hover { background: var(--border-light); }
.check-item input[type=checkbox] {
  width: 18px; height: 18px;
  accent-color: var(--maccabi-red);
  margin: 0;
  flex-shrink: 0;
}
.check-item.important {
  background: #fff8e6;
  border: 1px solid #f0d27a;
  display: flex;
  width: 100%;
  margin-bottom: 8px;
}
.inline-field { display: inline-flex; align-items: center; gap: 8px; }
[data-show-when] { display: none; }
[data-show-when].show { display: block; }

/* ====== HEALTH QUESTIONS ====== */
.health-q {
  border: 1px solid var(--border-light);
  border-radius: 6px;
  padding: 12px;
  margin-bottom: 8px;
  background: #fafbfd;
  transition: background 0.15s;
}
.health-q:hover { background: white; }
.health-q-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: start;
}
.health-q-text {
  font-size: 14px;
  line-height: 1.5;
}
.health-q-num {
  display: inline-block;
  background: var(--wellcome-blue);
  color: white;
  width: 24px;
  height: 24px;
  line-height: 24px;
  border-radius: 50%;
  text-align: center;
  font-size: 12px;
  font-weight: 700;
  margin-left: 6px;
  flex-shrink: 0;
}
.health-q-en {
  display: block;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 400;
  margin-top: 2px;
  direction: ltr;
  text-align: left;
}
.yn-toggle {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}
.yn-toggle label {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  background: white;
  font-weight: 500;
}
.yn-toggle input[type=radio] {
  width: 14px;
  height: 14px;
  accent-color: var(--maccabi-red);
  margin: 0;
}
.yn-toggle label:has(input:checked) {
  background: var(--maccabi-red);
  color: white;
  border-color: var(--maccabi-red);
}
.yn-toggle label:has(input[value="No"]:checked) {
  background: #555;
  border-color: #555;
}
.health-q-detail {
  margin-top: 10px;
  display: none;
}
.health-q-detail textarea {
  min-height: 60px;
  resize: vertical;
}
.health-q.has-yes .health-q-detail { display: block; }

/* ====== LEGAL TEXT ====== */
.legal-text {
  background: #f7f9fb;
  border: 1px solid var(--border-light);
  border-radius: 6px;
  padding: 14px 16px;
  margin: 12px 0;
  font-size: 13px;
  line-height: 1.7;
  max-height: 240px;
  overflow-y: auto;
  color: #333;
}
.legal-text p:first-child { margin-top: 0; }
.legal-text ul { margin: 0; padding-right: 20px; }
.legal-text li { margin-bottom: 6px; }

.consent-block {
  margin: 16px 0;
}

/* ====== SIGNATURE ====== */
.signature-area {
  margin: 16px 0;
}
.signature-label {
  display: block;
  font-weight: 600;
  margin-bottom: 6px;
}
.signature-wrapper {
  border: 2px dashed var(--border);
  border-radius: 6px;
  background: white;
  padding: 8px;
  position: relative;
  text-align: center;
}
#signature-pad {
  width: 100%;
  max-width: 100%;
  height: 200px;
  cursor: crosshair;
  touch-action: none;
  background: white;
}
.btn-link {
  background: none;
  border: none;
  color: var(--wellcome-blue-dark);
  cursor: pointer;
  font: inherit;
  text-decoration: underline;
  padding: 4px 8px;
}

/* ====== NAV BUTTONS ====== */
.form-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 24px;
  padding-top: 16px;
  border-top: 1px solid var(--border-light);
  gap: 12px;
}
.btn {
  padding: 10px 22px;
  font: inherit;
  font-size: 15px;
  font-weight: 600;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  transition: transform 0.05s, background 0.15s, opacity 0.15s;
}
.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }
.btn-primary  { background: var(--wellcome-blue); color: white; }
.btn-primary:hover:not(:disabled)  { background: var(--wellcome-blue-dark); }
.btn-secondary{ background: var(--border); color: var(--text); }
.btn-secondary:hover:not(:disabled){ background: #c0c6cf; }
.btn-success  { background: var(--maccabi-red); color: white; padding: 12px 32px; font-size: 16px; }
.btn-success:hover:not(:disabled)  { background: var(--maccabi-red-dark); }
.btn.hidden, .hidden { display: none !important; }
.step-indicator {
  font-size: 14px;
  color: var(--text-muted);
  font-weight: 500;
}
.step-indicator #current-step { color: var(--maccabi-red); font-weight: 700; font-size: 18px; }

/* ====== MESSAGES ====== */
.form-message {
  margin-top: 16px;
  padding: 14px;
  border-radius: 6px;
  font-size: 14px;
}
.form-message.success {
  background: #e6f7ee;
  border: 1px solid var(--success);
  color: #0e6135;
}
.form-message.error {
  background: #fdecea;
  border: 1px solid var(--error);
  color: #8a1f1a;
}

/* ====== LOADING OVERLAY ====== */
.loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(255,255,255,0.92);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  gap: 16px;
}
.spinner {
  width: 48px;
  height: 48px;
  border: 4px solid var(--border);
  border-top-color: var(--maccabi-red);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ====== RESPONSIVE ====== */
@media (max-width: 720px) {
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .span-2, .span-3 { grid-column: span 1; }
  .form-header { grid-template-columns: 1fr; text-align: center; }
  .progress-bar { grid-template-columns: repeat(2, 1fr); gap: 4px; }
  .progress-step { font-size: 11px; }
  .health-q-row { grid-template-columns: 1fr; }
  .yn-toggle { justify-content: flex-start; }
  .title-he { font-size: 18px; }
  .title-en { font-size: 14px; }
}

/* ====== ADMIN ====== */
.admin-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 16px;
  font-size: 14px;
}
.admin-table th, .admin-table td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--border-light);
  text-align: right;
}
.admin-table th {
  background: var(--maccabi-red);
  color: white;
  font-weight: 600;
}
.admin-table tr:nth-child(even) { background: #fafbfd; }
.admin-table a { color: var(--wellcome-blue-dark); text-decoration: none; font-weight: 600; }
.admin-table a:hover { text-decoration: underline; }
