/* ================================================================
   Naan Mudhalvan Trainer Form  ·  style.css
   ================================================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

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

:root {
  --navy:    #0d2b55;
  --blue:    #1a4f99;
  --accent:  #d4860a;
  --border:  #c5d0e0;
  --bg:      #edf1f8;
  --white:   #ffffff;
  --text:    #1c2333;
  --muted:   #6b7a99;
  --red:     #c0392b;
  --red-bg:  #fdf0ef;
  --green:   #1a6e3c;
  --green-bg:#edf7f2;
  --r:       8px;
}

body {
  font-family: 'Inter', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}
.hidden { display: none !important; }

/* ────────────────────────────────────────────────
   TOPBAR
──────────────────────────────────────────────── */
.form-topbar {
  background: var(--navy);
  border-bottom: 3px solid var(--accent);
  padding: 14px 0;
}
.form-topbar-inner {
  max-width: 860px;
  margin: auto;
  padding: 0 24px;
}
.topbar-brand { display: flex; align-items: center; gap: 16px; }
.topbar-logo  { height: 52px; width: auto; }
.topbar-title { font-size: 1.45rem; font-weight: 700; color: #fff; letter-spacing: .02em; }
.topbar-sub   { font-size: .82rem; color: #9ab0d0; margin-top: 2px; text-decoration: underline; text-underline-offset: 3px; }

/* ────────────────────────────────────────────────
   FORM CARD
──────────────────────────────────────────────── */
.form-body {
  max-width: 860px;
  margin: 32px auto 64px;
  padding: 0 20px;
}
.form-card {
  background: var(--white);
  border-radius: 12px;
  box-shadow: 0 2px 20px rgba(13,43,85,.10);
  overflow: hidden;
}
.form-card-header {
  background: linear-gradient(135deg, var(--navy) 0%, #1e4a8a 100%);
  padding: 24px 32px;
  border-bottom: 3px solid var(--accent);
}
.form-card-header h2  { color: #fff; font-size: 1.15rem; font-weight: 700; margin-bottom: 4px; }
.form-card-header p   { color: #9ab0d0; font-size: .85rem; }
.form-card-header strong { color: #f0c060; }

/* ── Photo row ── */
.photo-row {
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 24px 32px 4px;
}
.photo-box {
  display: block;
  width: 110px;
  height: 130px;
  border: 2px dashed var(--border);
  border-radius: 6px;
  cursor: pointer;
  overflow: hidden;
  flex-shrink: 0;
  background: #f4f7fc;
  transition: border-color .2s;
}
.photo-box:hover { border-color: var(--blue); }
.photo-box.invalid { border-color: var(--red); background: var(--red-bg); }
.photo-inner {
  width: 100%; height: 100%;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 8px; color: var(--muted);
  font-size: .75rem; text-align: center; padding: 8px;
}
.photo-inner img { width: 100%; height: 100%; object-fit: cover; border-radius: 4px; }
.photo-hint-text { font-size: .8rem; color: var(--muted); line-height: 1.6; }
.photo-hint-text em { font-size: .74rem; color: #9aaccc; }

/* ── Previous NM Training Experience ── */
.nm-exp-section {
  margin: 22px 32px 0;
  background: #f4f7fc;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  padding: 16px 20px 14px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 14px;
}
.nm-exp-label {
  font-size: .85rem;
  font-weight: 700;
  color: var(--navy);
  letter-spacing: .02em;
  text-transform: uppercase;
  flex-shrink: 0;
}
.nm-exp-toggle {
  display: flex;
  gap: 16px;
}
.nm-radio-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: .88rem;
  color: var(--dark);
  cursor: pointer;
  font-weight: 500;
}
.nm-radio-label input[type=radio] { accent-color: var(--blue); width: 16px; height: 16px; cursor: pointer; }
.nm-exp-toggle.invalid { outline: 2px solid var(--red); border-radius: 6px; padding: 6px 10px; background: var(--red-bg); }
.nm-exp-semesters {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.nm-exp-semesters.hidden { display: none; }
.nm-exp-sem-label { font-size: .8rem; color: var(--muted); font-weight: 600; }
.nm-exp-semesters textarea { resize: vertical; }

/* ── Aadhaar upload section ── */
.aadhaar-section {
  margin: 22px 32px 0;
  background: #f4f7fc;
  border: 1.5px dashed var(--border);
  border-radius: 8px;
  padding: 18px 22px 14px;
}
.aadhaar-section-title {
  font-size: .85rem;
  font-weight: 700;
  color: var(--navy);
  margin-bottom: 14px;
  letter-spacing: .02em;
  text-transform: uppercase;
}
.aadhaar-upload-row {
  display: flex;
  gap: 16px;
  flex-wrap: nowrap;
}
.aadhaar-upload-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  flex: 1;
  min-width: 0;
}
.aadhaar-box {
  display: block;
  width: 100%;
  aspect-ratio: 1.6 / 1;
  border: 2px dashed var(--border);
  border-radius: 6px;
  cursor: pointer;
  overflow: hidden;
  background: #fff;
  transition: border-color .2s;
}
.aadhaar-box:hover { border-color: var(--blue); }
.aadhaar-box.uploaded { border-color: #2e9e5b; border-style: solid; }
.aadhaar-box.invalid { border-color: var(--red); background: var(--red-bg); }
.aadhaar-inner {
  width: 100%; height: 100%;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 8px; color: var(--muted);
  font-size: .75rem; text-align: center; padding: 8px;
}
.aadhaar-inner img { width: 100%; height: 100%; object-fit: cover; border-radius: 4px; }
.aadhaar-hint { font-size: .78rem; color: var(--muted); margin: 0; }
.aadhaar-note { font-size: .78rem; color: #6a7faa; margin: 12px 0 0; }

/* ── Fields grid ── */
form { padding: 20px 32px 28px; }

.fields-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px 22px;
}
.fg { display: flex; flex-direction: column; gap: 5px; }
.fg.full { grid-column: 1 / -1; }
.fg.half { grid-column: span 1; }

.fg label {
  display: flex; align-items: center; gap: 8px;
  font-size: .78rem; font-weight: 600;
  color: var(--navy);
  text-transform: uppercase; letter-spacing: .04em;
}
.sno {
  display: inline-flex; align-items: center; justify-content: center;
  width: 20px; height: 20px;
  background: var(--blue); color: #fff;
  border-radius: 50%; font-size: .68rem; font-weight: 700; flex-shrink: 0;
}

/* ── Base inputs ── */
.fg input:not([type=file]),
.fg textarea,
.fg select {
  padding: 9px 12px;
  border: 1.5px solid var(--border);
  border-radius: 6px;
  font-family: inherit;
  font-size: .88rem;
  color: var(--text);
  background: #fafcff;
  transition: border-color .18s, box-shadow .18s;
  resize: vertical;
  width: 100%;
}
.fg input:focus,
.fg textarea:focus,
.fg select:focus {
  outline: none;
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(26,79,153,.12);
  background: #fff;
}

/* ── Error state ── */
.fg input.invalid,
.fg select.invalid,
.fg textarea.invalid {
  border-color: var(--red) !important;
  background: var(--red-bg) !important;
}
.fg input.valid,
.fg select.valid {
  border-color: var(--green) !important;
  background: var(--green-bg) !important;
}
.field-err {
  font-size: .74rem;
  color: var(--red);
  min-height: 16px;
  display: block;
  margin-top: 1px;
}

/* ── Phone wrap ── */
.phone-wrap {
  display: flex;
  align-items: stretch;
  border: 1.5px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
  background: #fafcff;
  transition: border-color .18s, box-shadow .18s;
}
.phone-wrap:focus-within {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(26,79,153,.12);
  background: #fff;
}
.phone-wrap.invalid { border-color: var(--red) !important; background: var(--red-bg) !important; }
.phone-wrap.valid   { border-color: var(--green) !important; background: var(--green-bg) !important; }

.phone-prefix {
  display: flex; align-items: center;
  padding: 0 12px;
  background: #e8eef8;
  color: var(--navy);
  font-weight: 700;
  font-size: .88rem;
  border-right: 1.5px solid var(--border);
  flex-shrink: 0;
  user-select: none;
}
.phone-wrap input {
  border: none !important;
  background: transparent !important;
  box-shadow: none !important;
  border-radius: 0 !important;
  padding: 9px 12px;
  flex: 1;
}
.phone-wrap input:focus {
  outline: none;
  border: none !important;
  box-shadow: none !important;
}

/* ── Select dropdown arrow ── */
.fg select {
  appearance: none;
  -webkit-appearance: none;
  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='%236b7a99' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 34px;
  cursor: pointer;
}

/* ────────────────────────────────────────────────
   DISTRICT MULTI-SELECT DROPDOWN
──────────────────────────────────────────────── */
.district-dropdown { position: relative; width: 100%; }

.district-trigger {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 9px 12px;
  border: 1.5px solid var(--border);
  border-radius: 6px;
  background: #fafcff;
  font-family: inherit;
  font-size: .88rem;
  color: var(--text);
  cursor: pointer;
  text-align: left;
  transition: border-color .18s, box-shadow .18s;
}
.district-trigger:hover,
.district-trigger.open {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(26,79,153,.12);
  background: #fff;
}
.district-trigger.invalid {
  border-color: var(--red);
  box-shadow: 0 0 0 3px rgba(239,68,68,.12);
  background: var(--red-bg);
}
.district-trigger svg { flex-shrink: 0; color: var(--muted); transition: transform .2s; }
.district-trigger.open svg { transform: rotate(180deg); }

#districtLabel {
  flex: 1;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  color: var(--muted);
}
#districtLabel.has-value { color: var(--text); }

.district-panel {
  position: absolute;
  top: calc(100% + 4px);
  left: 0; right: 0;
  background: #fff;
  border: 1.5px solid var(--blue);
  border-radius: 8px;
  box-shadow: 0 8px 28px rgba(13,43,85,.18);
  z-index: 999;
  overflow: hidden;
}

.district-search-wrap { padding: 10px 12px 6px; border-bottom: 1px solid var(--border); }
.district-search {
  width: 100%;
  padding: 7px 10px;
  border: 1.5px solid var(--border);
  border-radius: 6px;
  font-family: inherit;
  font-size: .85rem;
}
.district-search:focus { outline: none; border-color: var(--blue); }

.district-list {
  max-height: 220px;
  overflow-y: auto;
  padding: 6px 0;
}
.district-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 14px;
  cursor: pointer;
  font-size: .86rem;
  transition: background .12s;
  user-select: none;
}
.district-item:hover { background: #f0f4fc; }
.district-item input[type=checkbox] {
  width: 15px; height: 15px;
  accent-color: var(--blue);
  cursor: pointer;
  flex-shrink: 0;
  border: none; padding: 0;
}
.district-item label { cursor: pointer; flex: 1; color: var(--text); }

.district-actions {
  display: flex;
  gap: 8px;
  padding: 8px 12px;
  border-top: 1px solid var(--border);
  background: #f7f9fd;
}
.district-actions button {
  font-family: inherit;
  font-size: .78rem;
  font-weight: 600;
  padding: 5px 12px;
  border-radius: 5px;
  border: 1.5px solid var(--border);
  background: #fff;
  color: var(--blue);
  cursor: pointer;
  transition: background .15s;
}
.district-actions button:hover { background: #e8eef8; }

/* ── Buttons ── */
.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px solid #e8edf5;
}
.btn {
  font-family: inherit; font-size: .9rem; font-weight: 600;
  padding: 10px 22px; border-radius: 7px; border: none;
  cursor: pointer; transition: all .18s; letter-spacing: .02em;
}
.btn-reset   { background: #f0f3fa; color: var(--muted); border: 1.5px solid var(--border); }
.btn-reset:hover { background: #e4e9f5; }
.btn-preview { background: var(--blue); color: #fff; box-shadow: 0 3px 10px rgba(26,79,153,.28); }
.btn-preview:hover { background: var(--navy); transform: translateY(-1px); }
.btn-download { background: var(--accent); color: #fff; box-shadow: 0 3px 10px rgba(212,134,10,.3); }
.btn-download:hover { background: #b5720a; transform: translateY(-1px); }
.btn-save-record { background: #6a3fbf; color: #fff; box-shadow: 0 3px 10px rgba(106,63,191,.3); }
.btn-save-record:hover { background: #5230a0; transform: translateY(-1px); }
.btn-save-record:disabled { opacity: .7; cursor: not-allowed; transform: none; }
.btn-excel { background: #1e7e44; color: #fff; box-shadow: 0 3px 10px rgba(30,126,68,.3); }
.btn-excel:hover { background: #165f33; transform: translateY(-1px); }
.btn-back { background: rgba(255,255,255,.15); color: #fff; border: 1.5px solid rgba(255,255,255,.3); }
.btn-back:hover { background: rgba(255,255,255,.25); }
.btn-sample { background: #10b981; color: #fff; box-shadow: 0 3px 10px rgba(16,185,129,.28); }
.btn-sample:hover { background: #059669; transform: translateY(-1px); }

/* ── Aadhaar number private badge ── */
.field-badge-private { font-size:.72rem; font-weight:600; background:#fff3cd; color:#856404; border:1px solid #ffc107; border-radius:4px; padding:1px 7px; margin-left:8px; vertical-align:middle; }

/* ── Google Sheets config ── */
.gsheet-config { margin-top:16px; background:rgba(255,255,255,.08); border:1px solid rgba(255,255,255,.18); border-radius:8px; padding:14px 16px 12px; }
.gsheet-config-title { font-size:.8rem; font-weight:700; color:#9ab0d0; letter-spacing:.04em; text-transform:uppercase; margin-bottom:10px; }
.gsheet-row { display:flex; gap:8px; flex-wrap:wrap; }
.gsheet-row input { flex:1; min-width:0; padding:8px 12px; border-radius:6px; border:1.5px solid rgba(255,255,255,.2); background:rgba(255,255,255,.1); color:#fff; font-size:.82rem; }
.gsheet-row input::placeholder { color:rgba(255,255,255,.45); }
.gsheet-row input:focus { outline:none; border-color:rgba(255,255,255,.5); }
.btn-gsheet-save { background:#4285f4; color:#fff; border:none; border-radius:6px; padding:8px 14px; font-size:.8rem; font-weight:600; cursor:pointer; white-space:nowrap; transition:background .2s; }
.btn-gsheet-save:hover { background:#1a6fe8; }
.gsheet-status { font-size:.78rem; margin-top:7px; min-height:16px; }
.gsheet-status.ok  { color:#6ee7b7; }
.gsheet-status.err { color:#fca5a5; }
.gsheet-help { margin-top:10px; }
.gsheet-help summary { font-size:.78rem; color:#9ab0d0; cursor:pointer; user-select:none; }
.gsheet-help ol { margin:8px 0 8px 18px; font-size:.78rem; color:#c5d4e8; line-height:1.8; }
.gsheet-help strong { color:#fff; }
.gsheet-help em { color:#9ab0d0; }
.gsheet-script { background:rgba(0,0,0,.35); color:#a5f3a5; font-size:.7rem; line-height:1.6; border-radius:6px; padding:10px 12px; overflow-x:auto; white-space:pre; margin-top:8px; }

/* ── Toast ── */
.toast {
  position: fixed;
  bottom: 30px; left: 50%;
  transform: translateX(-50%);
  background: #1c2333;
  color: #fff;
  padding: 12px 24px;
  border-radius: 8px;
  font-size: .88rem;
  font-weight: 500;
  box-shadow: 0 6px 24px rgba(0,0,0,.25);
  z-index: 9999;
  max-width: 90vw;
  text-align: center;
  animation: toastIn .25s ease;
}
.toast.error  { background: var(--red); }
.toast.success{ background: var(--green); }
@keyframes toastIn { from { opacity:0; transform: translateX(-50%) translateY(12px); } to { opacity:1; transform: translateX(-50%) translateY(0); } }

/* ────────────────────────────────────────────────
   PREVIEW BAR
──────────────────────────────────────────────── */
.preview-bar {
  display: flex; align-items: center; justify-content: space-between;
  background: var(--navy); border-bottom: 3px solid var(--accent);
  padding: 12px 28px; position: sticky; top: 0; z-index: 200;
}
.preview-bar-title { color: #fff; font-weight: 600; font-size: .9rem; }

.preview-body {
  background: #dde3ee;
  min-height: calc(100vh - 52px);
  padding: 40px 20px 60px;
  display: flex; justify-content: center;
}

/* ================================================================
   NM DOCUMENT — PIXEL-PERFECT MATCH TO ORIGINAL
   ================================================================ */
.nm-doc {
  width: 794px;
  background: #fff;
  padding: 40px 44px 56px;
  box-shadow: 0 8px 40px rgba(0,0,0,.22);
  font-family: 'Times New Roman', Times, serif;
  font-size: 12.5px;
  color: #111;
}

/* ── Header ── */
.nm-doc-header {
  display: grid;
  grid-template-columns: 80px 1fr 96px;
  align-items: flex-start;
  margin-bottom: 20px;
  min-height: 90px;
}
.nm-logo-cell { padding-top: 4px; }
.nm-logo-cell img { width: 72px; height: auto; display: block; }

.nm-title-cell { text-align: center; padding: 0 12px; }
.nm-doc-title  { font-size: 18px; font-weight: bold; font-family: 'Times New Roman', serif; letter-spacing: .02em; margin-bottom: 4px; }
.nm-doc-subtitle { font-size: 13px; font-weight: bold; text-decoration: underline; text-underline-offset: 3px; }

.nm-photo-cell {
  width: 90px; height: 108px;
  border: 1px solid #444;
  display: flex; align-items: center; justify-content: center;
  background: #fafafa; overflow: hidden; flex-shrink: 0;
}
.nm-photo-cell img { width: 100%; height: 100%; object-fit: cover; display: block; }
.nm-photo-placeholder { font-family: Arial, sans-serif; font-size: 10px; color: #555; text-align: center; line-height: 1.6; }

/* ── Table ── */
.nm-table { width: 100%; border-collapse: collapse; margin-top: 4px; }

.nm-table thead tr th {
  border: 1px solid #333; padding: 7px 10px;
  background: #fff; font-size: 12.5px;
  text-align: left; font-family: 'Times New Roman', serif;
}
.th-sno   { width: 44px; text-align: center !important; }
.th-label { width: 220px; }

.nm-table tbody tr td {
  border: 1px solid #444; padding: 7px 10px;
  vertical-align: top; line-height: 1.6;
  font-size: 12.5px; font-family: 'Times New Roman', serif;
}
.nm-table tbody tr td:first-child { text-align: center; font-weight: 700; width: 44px; }
.nm-table tbody tr td:nth-child(2) { width: 220px; }

/* ────────────────────────────────────────────────
   AADHAAR PREVIEW CARD (Page 2)
──────────────────────────────────────────────── */
.aadhaar-preview-card {
  margin-top: 20px;
  font-family: 'Times New Roman', Times, serif;
}
.aadhaar-preview-heading {
  font-size: 14px;
  font-weight: bold;
  text-align: center;
  margin-bottom: 16px;
  border-bottom: 2px solid #333;
  padding-bottom: 10px;
  color: #111;
}
.aadhaar-preview-row {
  display: flex;
  gap: 16px;
  justify-content: center;
}
.aadhaar-preview-item {
  flex: 1;
  min-width: 160px;
  text-align: center;
}
.aadhaar-preview-label {
  font-size: 12px;
  font-weight: bold;
  margin-bottom: 8px;
  color: #555;
}
.aadhaar-preview-item img {
  width: 100%;
  border: 1px solid #ccc;
  border-radius: 4px;
  display: block;
}

/* ────────────────────────────────────────────────
   RESPONSIVE
──────────────────────────────────────────────── */
@media (max-width: 860px) {
  .nm-doc { width: 100%; padding: 24px 16px; }
  .nm-doc-header { grid-template-columns: 60px 1fr 80px; }
  .nm-doc-title { font-size: 15px; }
}
@media (max-width: 640px) {
  .fields-grid { grid-template-columns: 1fr; }
  .fg.half { grid-column: 1 / -1; }
  form { padding: 16px 20px 20px; }
  .photo-row { flex-direction: column; align-items: flex-start; }
  .form-card-header { padding: 18px 20px; }
  .preview-bar { flex-wrap: wrap; gap: 8px; padding: 10px 14px; }
  .preview-bar-title { order: 3; width: 100%; text-align: center; font-size: .8rem; }
  .aadhaar-upload-row { flex-direction: column; }
  .aadhaar-section { margin: 14px 12px 0; padding: 14px 14px 10px; }
  .nm-exp-section { margin: 14px 12px 0; padding: 12px 12px 10px; }
  .form-body { margin: 16px auto 40px; padding: 0 10px; }
  .form-actions { flex-direction: column-reverse; gap: 10px; }
  .form-actions .btn { width: 100%; text-align: center; }
  .btn { font-size: .85rem; padding: 10px 16px; }
  .topbar-title { font-size: 1.1rem; }
  .topbar-logo  { height: 40px; }
  .preview-bar .btn { flex: 1; text-align: center; font-size: .8rem; padding: 8px 10px; }
  .aadhaar-preview-row { flex-direction: column; }
}

@media (max-width: 400px) {
  .nm-doc-header { grid-template-columns: 50px 1fr 72px; }
  .nm-doc-title { font-size: 13px; }
  .nm-doc-subtitle { font-size: 11px; }
  .nm-photo-cell { width: 72px; height: 88px; }
}
