/* ============================================================
   Robogenz — Student Admission Form
   Brand palette:
     Sunspun Amber   #FFA500
     Deep Amethyst   #A020F0
     Onyx Sheen      #050505
     Stark Chalk     #FCFCFC
   ============================================================ */

:root {
  --amber:        #FFA500;
  --amber-deep:   #F08A00;
  --amethyst:     #A020F0;
  --amethyst-deep:#7C14C4;
  --onyx:         #050505;
  --onyx-2:       #15151c;
  --onyx-3:       #20202a;
  --chalk:        #FCFCFC;
  --ink:          #1d1d24;
  --muted:        #6c6c78;
  --line:         #e6e6ec;
  --line-strong:  #d4d4dd;
  --field:        #ffffff;
  --field-focus:  #fff8ec;
  --danger:       #d83a3a;
  --ok:           #16a34a;
  --grad:         linear-gradient(90deg, var(--amber) 0%, var(--amethyst) 100%);
  --grad-soft:    linear-gradient(135deg, rgba(255,165,0,.12), rgba(160,32,240,.12));
  --radius:       14px;
  --radius-sm:    10px;
  --shadow:       0 1px 2px rgba(5,5,5,.04), 0 8px 30px rgba(5,5,5,.06);
  --shadow-lg:    0 18px 50px rgba(5,5,5,.16);
  --font:         "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: var(--font);
  color: var(--ink);
  background:
    radial-gradient(1200px 500px at 80% -200px, rgba(160,32,240,.06), transparent 60%),
    radial-gradient(1000px 400px at -10% 0, rgba(255,165,0,.07), transparent 55%),
    var(--chalk);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

img { max-width: 100%; display: block; }

/* ---------- Header ---------- */
.site-header {
  background: var(--onyx);
  color: #fff;
  position: relative;
  overflow: hidden;
}
.site-header::after { /* gradient hairline */
  content: "";
  position: absolute; left: 0; right: 0; bottom: 0; height: 4px;
  background: var(--grad);
}
.site-header::before { /* subtle glow */
  content: "";
  position: absolute; inset: 0;
  background:
    radial-gradient(600px 200px at 85% 120%, rgba(160,32,240,.35), transparent 60%),
    radial-gradient(600px 220px at 10% -40%, rgba(255,165,0,.28), transparent 60%);
  pointer-events: none;
}
.header-inner {
  max-width: 980px; margin: 0 auto;
  padding: 26px 24px 30px;
  position: relative; z-index: 1;
  display: flex; flex-direction: column; gap: 18px;
}
.brand-row { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.brand-logo { height: 64px; width: auto; max-width: 100%; }
.header-title h1 {
  margin: 0; font-size: clamp(1.5rem, 3.4vw, 2.15rem); font-weight: 800;
  letter-spacing: -.01em;
}
.header-title p { margin: 6px 0 0; color: rgba(255,255,255,.72); max-width: 60ch; font-size: 15px; }

/* ---------- Layout ---------- */
.wrap { max-width: 980px; margin: 0 auto; padding: 0 24px; }
/* main is <main class="wrap">; .wrap controls horizontal padding, so set vertical
   spacing with the higher-specificity main.wrap (top gap comes from the header). */
main.wrap { padding-bottom: 40px; }

/* ---------- Section card ---------- */
.section {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin: 0 0 22px;
  overflow: hidden;
}
.section-head {
  display: flex; align-items: center; gap: 14px;
  padding: 18px 22px;
  border-bottom: 1px solid var(--line);
  background: var(--grad-soft);
}
.section-num {
  flex: 0 0 auto;
  width: 38px; height: 38px; border-radius: 11px;
  display: grid; place-items: center;
  background: var(--grad); color: #fff;
  font-weight: 800; font-size: 15px; letter-spacing: .02em;
  box-shadow: 0 4px 14px rgba(160,32,240,.28);
}
.section-head h2 { margin: 0; font-size: 1.06rem; font-weight: 800; letter-spacing: -.01em; }
.section-head .sub { margin: 2px 0 0; font-size: 13px; color: var(--muted); font-weight: 500; }
.section-body { padding: 22px; }

/* ---------- Grid + fields ---------- */
.grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px 20px; }
.field.col-2 { grid-column: span 2; }
@media (max-width: 640px) {
  .grid { grid-template-columns: 1fr; }
  .field.col-2 { grid-column: span 1; }
}

.field { display: flex; flex-direction: column; gap: 7px; min-width: 0; }
.field > label, .group-label {
  font-size: 13px; font-weight: 700; color: #3a3a44; letter-spacing: .01em;
}
.req { color: var(--amethyst); font-weight: 800; }
.hint { font-size: 12px; color: var(--muted); font-weight: 500; }

input[type="text"], input[type="email"], input[type="tel"], input[type="number"],
input[type="date"], select, textarea {
  width: 100%;
  font: inherit; font-size: 15px; color: var(--ink);
  background: var(--field);
  border: 1.5px solid var(--line-strong);
  border-radius: var(--radius-sm);
  padding: 11px 13px;
  transition: border-color .15s, box-shadow .15s, background .15s;
  appearance: none;
}
textarea { resize: vertical; min-height: 92px; }
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--amber);
  background: var(--field-focus);
  box-shadow: 0 0 0 3.5px rgba(255,165,0,.18);
}
select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%236c6c78' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center;
  padding-right: 38px;
}
input::placeholder, textarea::placeholder { color: #adadb8; }

/* prefix inputs (Emirates ID / mobile) */
.prefixed { display: flex; align-items: stretch; }
.prefixed .prefix {
  display: inline-flex; align-items: center;
  padding: 0 13px;
  background: #f4f4f7; border: 1.5px solid var(--line-strong); border-right: none;
  border-radius: var(--radius-sm) 0 0 var(--radius-sm);
  font-weight: 700; color: #50505a; font-size: 14px; white-space: nowrap;
}
.prefixed input { border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }
.prefixed:focus-within .prefix { border-color: var(--amber); }

/* ---------- Choice chips (radio / checkbox) ---------- */
.choice-row { display: flex; flex-wrap: wrap; gap: 10px; }
.choice {
  position: relative;
  display: inline-flex; align-items: center; gap: 9px;
  padding: 10px 16px;
  border: 1.5px solid var(--line-strong); border-radius: 999px;
  background: #fff; cursor: pointer; font-weight: 600; font-size: 14px;
  transition: all .14s; user-select: none;
}
.choice:hover { border-color: var(--amber); }
.choice input { position: absolute; opacity: 0; pointer-events: none; }
.choice .dot {
  width: 16px; height: 16px; border-radius: 50%;
  border: 2px solid var(--line-strong); transition: all .14s; flex: 0 0 auto;
}
.choice.check .dot { border-radius: 5px; }
.choice:has(input:checked) {
  border-color: var(--amethyst);
  background: linear-gradient(0deg, rgba(160,32,240,.07), rgba(160,32,240,.07));
  color: var(--amethyst-deep);
}
.choice:has(input:checked) .dot {
  border-color: var(--amethyst); background: var(--amethyst);
  box-shadow: inset 0 0 0 3px #fff;
}
.choice.check:has(input:checked) .dot {
  background: var(--amethyst) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='20 6 9 17 4 12'/%3E%3C/svg%3E") center/11px no-repeat;
  box-shadow: none;
}
/* Fallback for browsers without :has() — the dot/checkmark still shows selection */
.choice input:checked ~ .dot {
  border-color: var(--amethyst); background: var(--amethyst);
  box-shadow: inset 0 0 0 3px #fff;
}
.choice.check input:checked ~ .dot {
  background: var(--amethyst) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='20 6 9 17 4 12'/%3E%3C/svg%3E") center/11px no-repeat;
  box-shadow: none;
}
.choice:focus-within { box-shadow: 0 0 0 3.5px rgba(160,32,240,.16); }

/* ---------- Photo upload ---------- */
.photo-row { display: flex; gap: 22px; align-items: flex-start; flex-wrap: wrap; }
.photo-box {
  flex: 0 0 auto;
  width: 150px; height: 188px;
  border: 2px dashed var(--line-strong); border-radius: 12px;
  background: #fafafb; overflow: hidden;
  display: grid; place-items: center; text-align: center;
  position: relative;
}
.photo-box img { width: 100%; height: 100%; object-fit: cover; }
.photo-box .ph-placeholder { color: var(--muted); font-size: 12.5px; padding: 12px; }
.photo-box .ph-placeholder svg { margin: 0 auto 8px; opacity: .55; }
.photo-meta { flex: 1 1 170px; min-width: 160px; }

/* ---------- Signature pad ---------- */
.sig-wrap { display: flex; flex-direction: column; gap: 8px; }
.sig-pad {
  position: relative;
  border: 1.5px solid var(--line-strong); border-radius: var(--radius-sm);
  background:
    linear-gradient(0deg, transparent 38px, rgba(160,32,240,.16) 38px, transparent 39px),
    #fff;
  touch-action: none; cursor: crosshair; overflow: hidden;
}
.sig-pad canvas { display: block; width: 100%; height: 150px; }
.sig-pad .sig-hint {
  position: absolute; left: 14px; bottom: 12px;
  color: #8a8a96; font-size: 13px; pointer-events: none; font-style: italic;
}
.sig-pad.has-ink .sig-hint { display: none; }
.sig-pad:focus-visible { outline: none; border-color: var(--amethyst); box-shadow: 0 0 0 3.5px rgba(160,32,240,.16); }

/* ---------- Buttons ---------- */
.btn {
  font: inherit; font-weight: 700; font-size: 15px;
  border: none; border-radius: 11px; padding: 13px 26px; cursor: pointer;
  display: inline-flex; align-items: center; gap: 9px;
  transition: transform .08s, box-shadow .15s, background .15s, color .15s;
}
.btn:active { transform: translateY(1px); }
.btn-primary {
  background: var(--grad); color: #fff;
  box-shadow: 0 8px 22px rgba(160,32,240,.32);
}
.btn-primary:hover { box-shadow: 0 10px 28px rgba(160,32,240,.42); }
.btn-ghost {
  background: #fff; color: #44444e; border: 1.5px solid var(--line-strong);
}
.btn-ghost:hover { border-color: var(--amethyst); color: var(--amethyst-deep); }
.btn-sm { padding: 8px 15px; font-size: 13px; border-radius: 9px; }
.btn:disabled { opacity: .6; cursor: not-allowed; }

/* file input as button */
.file-btn { position: relative; overflow: hidden; }
.file-btn input[type=file] { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.file-btn:focus-within { outline: none; box-shadow: 0 0 0 3.5px rgba(160,32,240,.16); }

/* ---------- Action buttons (inline, bottom of form) ---------- */
.form-actions {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px 20px; flex-wrap: wrap;
  margin-top: 4px; padding-top: 20px;
  border-top: 1px solid var(--line);
}
.form-actions .status { font-size: 13.5px; color: var(--muted); }
.form-actions .btns { display: flex; gap: 12px; }

/* ---------- Policy box ---------- */
.policy {
  background: #faf7fe; border: 1px solid #ecdcff; border-radius: 12px;
  padding: 16px 18px; margin-bottom: 18px; font-size: 13.5px; color: #463a55;
}
.policy h3 { margin: 0 0 8px; font-size: 13px; text-transform: uppercase; letter-spacing: .08em; color: var(--amethyst-deep); }
.policy p { margin: 0 0 8px; }
.policy p:last-child { margin-bottom: 0; }
.policy strong { color: var(--amethyst-deep); }

/* ---------- Validation ---------- */
.field.invalid input, .field.invalid select, .field.invalid textarea { border-color: var(--danger); background: #fdf3f3; }
.field.invalid .err-msg { display: block; }
.err-msg { display: none; color: var(--danger); font-size: 12.5px; font-weight: 600; }
.field-error-ring { box-shadow: 0 0 0 3.5px rgba(216,58,58,.16) !important; }

.group.invalid .err-msg { display: block; }

/* ---------- Conditional reveal ---------- */
.conditional { display: none; }
.conditional.show { display: block; animation: fade .2s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(-4px);} to {opacity:1; transform:none;} }

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%) translateY(20px);
  background: var(--onyx); color: #fff; padding: 14px 22px; border-radius: 12px;
  box-shadow: var(--shadow-lg); font-weight: 600; font-size: 14px;
  display: flex; align-items: center; gap: 10px;
  opacity: 0; pointer-events: none; transition: all .25s; z-index: 60; max-width: 90vw;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.ok { border-left: 4px solid var(--amber); }
.toast.bad { border-left: 4px solid var(--danger); }

/* ---------- Footer ---------- */
.site-footer { border-top: 1px solid var(--line); background: #fff; }
.site-footer .wrap { padding: 22px 24px; display: flex; gap: 14px 26px; flex-wrap: wrap; align-items: center; justify-content: space-between; }
.site-footer .contact { font-size: 13px; color: var(--muted); display: flex; gap: 8px 18px; flex-wrap: wrap; }
.site-footer .contact a { color: var(--amethyst-deep); text-decoration: none; }
.site-footer .contact a:hover { text-decoration: underline; }
.site-footer .mark { height: 26px; opacity: .8; }

.visually-hidden { position:absolute!important; width:1px;height:1px;overflow:hidden;clip:rect(0 0 0 0); white-space:nowrap; }

/* ---------- Helpers added for admission-form updates ---------- */
.opt { color: var(--muted); font-weight: 500; font-size: .9em; }
.soft-rule { border: none; border-top: 1px dashed var(--line-strong); margin: 2px 0 0; }
.photo-field { margin-top: 4px; }
.photo-actions { display: flex; flex-direction: column; align-items: flex-start; gap: 10px; }
.photo-actions .btn { width: 100%; max-width: 210px; justify-content: center; }
.sig-bar { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }

/* Consent checkboxes (full-width, top-aligned, wrapping text) */
.field.group + .field.group { margin-top: 10px; }
.choice.check.consent {
  display: flex; align-items: flex-start; gap: 12px;
  width: 100%; border-radius: 12px; padding: 13px 16px;
  font-weight: 500; font-size: 14px; line-height: 1.5;
}
.choice.check.consent .dot { margin-top: 2px; flex: 0 0 auto; }

/* ---------- Camera capture modal ---------- */
.modal {
  position: fixed; inset: 0; z-index: 100; padding: 20px; overflow-y: auto;
  display: grid; place-items: center;
  background: rgba(5,5,5,.6); backdrop-filter: blur(3px);
}
.modal-card {
  background: #fff; border-radius: 16px; width: min(540px, 100%);
  box-shadow: var(--shadow-lg); overflow: auto;
  animation: pop .18s ease;
  display: flex; flex-direction: column;
  max-height: calc(100vh - 40px);
  max-height: calc(100dvh - 40px); /* survive short/landscape phones */
}
@keyframes pop { from { transform: scale(.96); opacity: 0; } to { transform: none; opacity: 1; } }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 15px 20px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: #fff; z-index: 2; flex: 0 0 auto; }
.modal-head h3 { margin: 0; font-size: 1.05rem; font-weight: 800; }
.modal-x { border: none; background: transparent; font-size: 26px; line-height: 1; cursor: pointer; color: var(--muted); width: 36px; height: 36px; border-radius: 9px; }
.modal-x:hover { background: #f2f2f5; color: var(--ink); }
.cam-stage { background: #0c0c10; aspect-ratio: 4 / 3; display: grid; place-items: center; flex: 0 1 auto; min-height: 0; max-height: 55vh; max-height: 55dvh; }
.cam-stage video, .cam-stage canvas { width: 100%; height: 100%; object-fit: cover; display: block; }
.cam-msg { margin: 0; padding: 11px 20px 0; color: var(--danger); font-size: 13px; font-weight: 600; flex: 0 0 auto; }
.cam-msg:empty { display: none; }
.cam-actions { display: flex; gap: 10px; flex-wrap: wrap; padding: 14px 20px; justify-content: flex-end; position: sticky; bottom: 0; background: #fff; border-top: 1px solid var(--line); flex: 0 0 auto; }
/* short / landscape phones: shrink the video so header + buttons always fit */
@media (max-height: 560px) { .cam-stage { max-height: 42vh; max-height: 42dvh; } }
@media (max-width: 480px) {
  .cam-actions { justify-content: stretch; }
  .cam-actions .btn { flex: 1; justify-content: center; }
}

/* ============================================================
   Responsive — laptop / tablet / phone
   (the 2-col grid → 1-col collapse lives at max-width:640 above)
   ============================================================ */
@media (max-width: 1024px) {
  .section-body { padding: 20px; }
}
@media (max-width: 768px) {
  .header-inner { padding: 24px 20px 28px; }
  .section-head { padding: 16px 18px; }
  .section-body { padding: 18px; }
}
/* Prevent iOS Safari from zooming in on focus (needs >=16px font) */
@media (max-width: 640px) {
  input[type="text"], input[type="email"], input[type="tel"], input[type="number"],
  input[type="date"], select, textarea { font-size: 16px; }
}
@media (max-width: 560px) {
  .form-actions { flex-direction: column; align-items: stretch; }
  .form-actions .status { text-align: center; }
  .form-actions .btns { width: 100%; }
  .form-actions .btns .btn { flex: 1; justify-content: center; }
  .site-footer .wrap { flex-direction: column; align-items: flex-start; gap: 14px; }
}
@media (max-width: 430px) {
  .wrap, .header-inner { padding-left: 16px; padding-right: 16px; }
  .section-body { padding: 16px; }
  .section-head { padding: 14px 16px; gap: 11px; }
  .section-num { width: 34px; height: 34px; border-radius: 10px; font-size: 14px; }
  .photo-actions .btn { max-width: none; } /* full-width once stacked under the box */
  .sig-bar { flex-direction: column; align-items: stretch; }
  .sig-bar .btn { width: 100%; justify-content: center; }
}
