/* ==========================================================================
   Shoe Size Report Portal — Gonegandla Mandal
   Design matched to the official SRVM portal:
   white header · maroon serif title · pastel gradient hero · colorful accents
   ========================================================================== */

:root {
  --maroon: #9c2542;
  --maroon-deep: #7d1c34;
  --navy: #1b2a6b;
  --green: #1c7a3d;
  --ink: #22262c;
  --grey: #5c6672;
  --line: #d5dae1;
  --bg: #f7f8fb;
  --card: #ffffff;

  --acc-blue: #3ba3e0;
  --acc-purple: #7161d6;
  --acc-teal: #22b8c9;
  --acc-pink: #e0559c;
  --acc-orange: #f0863a;

  --font-display: 'Playfair Display', Georgia, serif;
  --font-ui: 'Libre Franklin', 'Segoe UI', Arial, sans-serif;
  --font-mono: 'IBM Plex Mono', 'Consolas', monospace;
}

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

[hidden] { display: none !important; }

html { scroll-behavior: smooth; }

body {
  font-family: var(--font-ui);
  background: var(--bg);
  color: var(--ink);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.mono { font-family: var(--font-mono); }

/* ---------------- Top bar (white, like the official portal) ---------------- */
.topbar {
  background: #ffffff;
  border-bottom: 1px solid #e7eaef;
  position: sticky;
  top: 0;
  z-index: 50;
  box-shadow: 0 2px 10px rgba(30, 40, 70, .07);
}

.topbar-inner {
  max-width: 1100px;
  margin: 0 auto;
  padding: 12px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.brand { display: flex; align-items: center; gap: 14px; min-width: 0; }

.emblem {
  width: 56px;
  height: 56px;
  object-fit: contain;
  flex-shrink: 0;
}

.brand-text { display: flex; flex-direction: column; min-width: 0; }

.brand-title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.22rem;
  color: var(--maroon);
  line-height: 1.2;
}

.brand-sub {
  font-size: .78rem;
  font-weight: 700;
  color: var(--ink);
  margin-top: 3px;
  letter-spacing: .01em;
}

/* ---------------- Buttons ---------------- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-ui);
  font-weight: 700;
  font-size: .88rem;
  padding: 10px 20px;
  border-radius: 24px;
  border: none;
  cursor: pointer;
  transition: background .15s ease, transform .1s ease, box-shadow .15s ease;
  white-space: nowrap;
}

.btn:active { transform: translateY(1px); }

.btn-print {
  background: var(--navy);
  color: #fff;
  box-shadow: 0 3px 10px rgba(27, 42, 107, .3);
}
.btn-print:hover:not(:disabled) { background: #24358a; }
.btn-print:disabled { opacity: .38; cursor: not-allowed; box-shadow: none; }

/* ---------------- Hero / search (pastel gradient, like the portal banner) -- */
.hero {
  position: relative;
  overflow: hidden;
  padding: 30px 20px 40px;
  border-bottom: 1px solid #eadff0;
  isolation: isolate;
  background:
    radial-gradient(700px 340px at 12% 18%, rgba(255, 182, 213, .5), transparent 65%),
    radial-gradient(760px 380px at 88% 12%, rgba(167, 199, 255, .55), transparent 65%),
    radial-gradient(620px 340px at 50% 112%, rgba(255, 241, 205, .75), transparent 62%),
    radial-gradient(500px 300px at 25% 95%, rgba(186, 240, 233, .5), transparent 60%),
    linear-gradient(135deg, #fce7f1 0%, #ece8fb 45%, #ddeefe 100%);
}

/* Floating school-theme icons in the banner colors */
.hero-icons { position: absolute; inset: 0; z-index: -1; pointer-events: none; }

.ico {
  position: absolute;
  opacity: .5;
  animation: icoFloat 7s ease-in-out infinite;
}

.ico-1 { color: var(--acc-purple); width: 74px; height: 74px; left: 4%;  top: 12%; }
.ico-2 { color: var(--acc-blue);   width: 60px; height: 60px; right: 6%; top: 10%; animation-delay: 1.1s; }
.ico-3 { color: var(--maroon);     width: 56px; height: 56px; left: 10%; bottom: 12%; animation-delay: 2.2s; }
.ico-4 { color: var(--acc-orange); width: 46px; height: 46px; right: 13%; bottom: 18%; animation-delay: 3s; }
.ico-5 { color: var(--acc-teal);   width: 64px; height: 64px; left: 22%; top: 6%; animation-delay: 1.7s; }
.ico-6 { color: var(--acc-pink);   width: 48px; height: 48px; right: 24%; top: 28%; animation-delay: 2.6s; }
.ico-7 { color: var(--acc-orange); width: 58px; height: 58px; left: 40%; bottom: 6%; animation-delay: .6s; }
.ico-8 { color: var(--acc-blue);   width: 42px; height: 42px; right: 38%; bottom: 26%; animation-delay: 3.5s; }

@keyframes icoFloat {
  0%, 100% { transform: translateY(0) rotate(-3deg); }
  50%      { transform: translateY(-12px) rotate(3deg); }
}

/* Gentle entrance for hero content */
.hero-eyebrow, .stats-row, .search-box-wrap {
  animation: riseIn .6s ease both;
}
.stats-row { animation-delay: .12s; }
.search-box-wrap { animation-delay: .24s; }

@keyframes riseIn {
  from { opacity: 0; transform: translateY(14px); }
  to   { opacity: 1; transform: none; }
}

/* Soft float for stat cards */
.stat { animation: floaty 6s ease-in-out infinite; }
.stat-purple { animation-delay: 1.2s; }
.stat-teal   { animation-delay: 2.4s; }
.stat-pink   { animation-delay: 3.6s; }

@keyframes floaty {
  0%, 100% { transform: translateY(0); }
  50%      { transform: translateY(-5px); }
}

@media (prefers-reduced-motion: reduce) {
  .ico, .stat, .hero-eyebrow, .stats-row, .search-box-wrap { animation: none; }
}

/* Before a school is selected, let the banner fill the screen
   so there is no blank gap between the search area and the footer. */
body:has(#reportWrapper[hidden]) .hero { flex: 1; }

.hero-inner { max-width: 880px; margin: 0 auto; }

.hero-eyebrow {
  text-align: center;
  font-size: .8rem;
  font-weight: 800;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--maroon);
  margin-bottom: 20px;
}

.stats-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin-bottom: 26px;
}

.stat {
  background: rgba(255, 255, 255, .88);
  border-radius: 14px;
  padding: 14px 10px;
  text-align: center;
  box-shadow: 0 4px 16px rgba(90, 70, 120, .12);
  border-top: 4px solid transparent;
  backdrop-filter: blur(3px);
}

.stat-blue   { border-top-color: var(--acc-blue); }
.stat-purple { border-top-color: var(--acc-purple); }
.stat-teal   { border-top-color: var(--acc-teal); }
.stat-pink   { border-top-color: var(--acc-pink); }

.stat-ico {
  width: 26px;
  height: 26px;
  margin-bottom: 4px;
}

.stat-blue .stat-ico   { color: var(--acc-blue); }
.stat-purple .stat-ico { color: var(--acc-purple); }
.stat-teal .stat-ico   { color: var(--acc-teal); }
.stat-pink .stat-ico   { color: var(--acc-pink); }

.stat-num {
  display: block;
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: 1.5rem;
}

.stat-blue .stat-num   { color: var(--acc-blue); }
.stat-purple .stat-num { color: var(--acc-purple); }
.stat-teal .stat-num   { color: var(--acc-teal); }
.stat-pink .stat-num   { color: var(--acc-pink); }

.stat-label {
  display: block;
  font-size: .7rem;
  font-weight: 700;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--grey);
  margin-top: 3px;
}

.search-label {
  display: block;
  font-size: .8rem;
  font-weight: 800;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--maroon);
  margin-bottom: 8px;
}

/* ---- District + Mandal selection panel ---- */
.select-panel {
  display: grid;
  grid-template-columns: 1fr 1.6fr;
  gap: 16px;
  margin-bottom: 20px;
  animation: riseIn .6s ease both;
  animation-delay: .18s;
}

.field-label {
  display: block;
  font-size: .8rem;
  font-weight: 800;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--maroon);
  margin-bottom: 8px;
}

.district-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #fff;
  border-radius: 14px;
  padding: 15px 16px;
  font-weight: 800;
  letter-spacing: .04em;
  color: var(--navy);
  box-shadow: 0 10px 30px rgba(90, 70, 120, .14);
  border: 2px solid transparent;
}

.district-pill svg { color: var(--maroon); flex-shrink: 0; }

.select-wrap { position: relative; }

#mandalSelect {
  width: 100%;
  appearance: none;
  -webkit-appearance: none;
  border: 2px solid transparent;
  outline: none;
  background: #fff;
  border-radius: 14px;
  padding: 15px 44px 15px 16px;
  font-family: var(--font-ui);
  font-size: .98rem;
  font-weight: 600;
  color: var(--ink);
  cursor: pointer;
  box-shadow: 0 10px 30px rgba(90, 70, 120, .14);
  transition: border-color .15s ease;
}

#mandalSelect:focus { border-color: var(--acc-purple); }

.select-caret {
  position: absolute;
  right: 16px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--grey);
  pointer-events: none;
}

/* Loading status */
.load-status {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
  font-size: .82rem;
  font-weight: 600;
  color: var(--acc-purple);
}

.load-spinner {
  width: 14px;
  height: 14px;
  border: 2.5px solid rgba(113, 97, 214, .25);
  border-top-color: var(--acc-purple);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.search-box-wrap { position: relative; }

.search-box {
  display: flex;
  align-items: center;
  background: #fff;
  border-radius: 14px;
  padding: 4px 8px 4px 16px;
  box-shadow: 0 10px 30px rgba(90, 70, 120, .18);
  border: 2px solid transparent;
  transition: border-color .15s ease;
}

.search-box:focus-within { border-color: var(--acc-purple); }

.search-icon { color: var(--grey); flex-shrink: 0; }

#schoolSearch {
  flex: 1;
  border: none;
  outline: none;
  font-family: var(--font-ui);
  font-size: 1.02rem;
  padding: 13px 12px;
  color: var(--ink);
  background: transparent;
  min-width: 0;
}

#schoolSearch::placeholder { color: #9aa4b0; }

#schoolSearch:disabled { cursor: not-allowed; }

.search-box:has(#schoolSearch:disabled) { opacity: .65; }

.clear-btn {
  border: none;
  background: #f0f2f6;
  color: var(--grey);
  width: 32px;
  height: 32px;
  border-radius: 10px;
  font-size: 1.2rem;
  line-height: 1;
  cursor: pointer;
  flex-shrink: 0;
}
.clear-btn:hover { background: #e2e6ec; color: var(--ink); }

.hint {
  margin-top: 10px;
  font-size: .8rem;
  color: #7a6a86;
}
.hint code {
  font-family: var(--font-mono);
  background: rgba(255, 255, 255, .75);
  padding: 1px 6px;
  border-radius: 4px;
  color: var(--maroon);
  border: 1px solid #ecdce6;
}

/* Suggestions dropdown */
.suggestions {
  position: absolute;
  left: 0; right: 0;
  top: calc(100% - 34px);
  margin-top: 6px;
  background: #fff;
  border-radius: 14px;
  box-shadow: 0 18px 48px rgba(50, 40, 80, .25);
  max-height: 340px;
  overflow-y: auto;
  z-index: 60;
  border: 1px solid var(--line);
}

.suggestion {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 11px 16px;
  cursor: pointer;
  border-bottom: 1px solid #f0f2f5;
  color: var(--ink);
}
.suggestion:last-child { border-bottom: none; }
.suggestion:hover, .suggestion.active { background: #f6f2fb; }

.sug-name { font-weight: 600; font-size: .92rem; }
.sug-name mark, .sug-code mark {
  background: #ffe9a8;
  color: inherit;
  border-radius: 2px;
  padding: 0 1px;
}

.sug-meta { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }

.sug-code {
  font-family: var(--font-mono);
  font-size: .78rem;
  color: var(--grey);
}

.sug-count {
  font-size: .72rem;
  font-weight: 700;
  background: var(--acc-purple);
  color: #fff;
  border-radius: 20px;
  padding: 3px 9px;
}

.no-result {
  padding: 16px;
  text-align: center;
  color: var(--grey);
  font-size: .9rem;
}

/* ---------------- Report page (A4) ---------------- */
.report-wrapper {
  display: flex;
  justify-content: center;
  padding: 24px 14px 60px;
  flex: 1;
}

.a4-page {
  background: var(--card);
  width: 210mm;
  max-width: 100%;
  min-height: 297mm;
  padding: 13mm 13mm 15mm;
  box-shadow: 0 4px 24px rgba(15, 34, 58, .15);
  border: 1px solid var(--line);
  border-top: 6px solid var(--maroon);
  animation: pageIn .35s ease;
}

@keyframes pageIn {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: none; }
}

@media (prefers-reduced-motion: reduce) {
  .a4-page { animation: none; }
}

/* Report header */
.report-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  border-bottom: 3px double var(--maroon);
  padding-bottom: 12px;
  margin-bottom: 14px;
}

.gov-logo {
  width: 82px;
  height: 82px;
  object-fit: contain;
  flex-shrink: 0;
}

.shoe-logo {
  width: 84px;
  height: 84px;
  object-fit: contain;
  flex-shrink: 0;
}

.header-text { text-align: center; flex: 1; }

.header-text h1 {
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 700;
  color: var(--maroon);
  letter-spacing: .01em;
}

.header-text h2 {
  font-size: 12.5px;
  font-weight: 600;
  margin-top: 3px;
  color: #3a4450;
}

.header-text h3 {
  font-size: 14.5px;
  font-weight: 700;
  margin-top: 7px;
  color: var(--ink);
  display: inline-block;
}

/* School info */
.school-info {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  background: #faf5f7;
  border: 1px solid #e8d8de;
  border-left: 4px solid var(--maroon);
  border-radius: 6px;
  padding: 10px 16px;
  font-size: 13.5px;
  margin-bottom: 18px;
  flex-wrap: wrap;
}

.info-label {
  display: block;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--grey);
  margin-bottom: 2px;
}

.school-info > div > span:last-child { font-weight: 600; font-size: 14px; }

/* Sections */
.student-section { margin-bottom: 20px; }

.section-title {
  font-size: 13.5px;
  font-weight: 700;
  color: #fff;
  padding: 6px 12px;
  border-radius: 5px 5px 0 0;
  letter-spacing: .03em;
}

.boys-title  { background: var(--navy); }
.girls-title { background: var(--maroon); }

table { border-collapse: collapse; width: 100%; }

.report-table { font-size: 11.5px; margin-bottom: 5px; }

.report-table th, .report-table td { border: 1px solid var(--line); }

.report-table th {
  background: #eef0f4;
  text-align: center;
  vertical-align: middle;
  line-height: 1.3;
  padding: 5px 6px;
  font-size: 11px;
}

.report-table td {
  text-align: center;
  vertical-align: middle;
  padding: 4px 6px;
}

.report-table tbody tr:nth-child(even) { background: #f8fafc; }

.report-table td.name-cell { text-align: left; }
.report-table td.id-cell { font-family: var(--font-mono); font-size: 10.5px; }

.count-line {
  text-align: right;
  font-size: 12.5px;
  margin: 3px 4px 0 0;
}

/* Breakdown tables */
.breakdown-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 8px;
}

.breakdown-table { font-size: 11.5px; }

.breakdown-table th, .breakdown-table td {
  border: 1px solid var(--line);
  text-align: center;
  padding: 3px 8px;
}

.breakdown-table th { background: #eef0f4; font-size: 10.5px; }

.breakdown-total-row { background: #f1f3f6; font-weight: 700; }

/* Summary */
.summary-box {
  margin: 20px 0;
  border: 1px solid var(--line);
  border-left: 4px solid var(--green);
  border-radius: 6px;
  padding: 12px 16px 16px;
  background: #fbfcfb;
}

.summary-box h4 {
  font-size: 14px;
  font-weight: 800;
  color: var(--green);
  letter-spacing: .04em;
  text-transform: uppercase;
}

.summary-subtitle {
  font-size: 12px;
  font-weight: 700;
  color: var(--navy);
  margin: 12px 0 5px;
}

.summary-breakdown { max-width: 440px; }

.summary-table { font-size: 13px; max-width: 340px; }

.summary-table td { border: 1px solid var(--line); padding: 5px 12px; }

.summary-table td:first-child { font-weight: 500; }
.summary-table td:last-child { text-align: center; width: 90px; font-family: var(--font-mono); }

.grand-row { background: #eef1f5; font-weight: 700; }

/* Footer / signature */
.report-footer {
  margin-top: 30px;
  display: flex;
  justify-content: flex-end;
}

.signature-block { text-align: center; width: 230px; }

.signature-line {
  border-top: 1.5px solid #333;
  margin-top: 44px;
  margin-bottom: 6px;
}

.signature-block p { font-size: 12.5px; font-weight: 600; }

/* Site footer */
.site-footer {
  text-align: center;
  padding: 16px 10px;
  font-size: .78rem;
  color: #8b95a1;
  border-top: 1px solid #e7eaef;
  background: #fff;
  margin-top: auto;
}

.site-footer p {
  white-space: nowrap;
  font-size: clamp(.6rem, 2.6vw, .78rem);
}

.dev-name {
  font-weight: 800;
  color: var(--maroon);
  animation: blinkName 1.4s ease-in-out infinite;
}

@keyframes blinkName {
  0%, 100% { opacity: 1; }
  50%      { opacity: .18; }
}

@media (prefers-reduced-motion: reduce) {
  .dev-name { animation: none; }
}

/* ---------------- Responsive ---------------- */
@media (max-width: 720px) {
  .brand-title { font-size: 1rem; }
  .brand-sub { font-size: .68rem; }
  .topbar-inner { flex-wrap: wrap; }
  .stats-row { grid-template-columns: repeat(2, 1fr); }
  .select-panel { grid-template-columns: 1fr; }
  .a4-page { padding: 8mm 5mm; min-height: auto; }
  .report-header { flex-direction: column; text-align: center; }
  .school-info { flex-direction: column; gap: 8px; }
  .breakdown-row { grid-template-columns: 1fr; }
}

/* ---------------- Print ---------------- */
@media print {
  @page { size: A4 portrait; margin: 12mm 12mm 14mm; }

  body { background: #fff; }

  .no-print { display: none !important; }

  .report-wrapper { padding: 0; display: block; }

  .a4-page {
    box-shadow: none;
    border: none;
    width: 100%;
    min-height: auto;
    padding: 0;
    margin: 0;
    animation: none;
  }

  .girls-section {
    page-break-before: always;
    break-before: page;
  }

  .report-table thead { display: table-header-group; }

  .report-table tr,
  .breakdown-table tr {
    page-break-inside: avoid;
    break-inside: avoid;
  }

  .summary-box, .report-footer {
    page-break-inside: avoid;
    break-inside: avoid;
  }

  .report-table tbody tr:nth-child(even) { background: #fff; }
}
