/* ─── DESIGN TOKENS ─── */
:root {
  --navy:        #1a3a6b;
  --navy-light:  #2a5098;
  --gold:        #c9a227;
  --gold-light:  #f0c940;
  --green:       #276749;
  --red:         #c0392b;
  --bg:          #eef2f7;
  --surface:     #ffffff;
  --border:      #dde3ec;
  --text:        #1a1a2e;
  --muted:       #6b7280;
  --shadow:      0 2px 8px rgba(0,0,0,.08), 0 1px 3px rgba(0,0,0,.05);
  --shadow-lg:   0 8px 30px rgba(0,0,0,.12);
  --radius:      14px;
  --radius-sm:   8px;
}

/* ─── RESET ─── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: 'Inter', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ─── HEADER ─── */
.header {
  background: linear-gradient(135deg, var(--navy) 0%, var(--navy-light) 100%);
  border-bottom: 4px solid var(--gold);
  box-shadow: var(--shadow-lg);
  position: sticky;
  top: 0;
  z-index: 100;
}
.header-inner {
  width: 100%;
  padding: 10px 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  box-sizing: border-box;
  position: relative;
}
.logo-group { display: flex; align-items: center; gap: 16px; }
.header-text {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  text-align: center;
  pointer-events: none;
}
.logo {
  width: auto;
  height: 40px;
  object-fit: contain;
  filter: drop-shadow(0 2px 6px rgba(0,0,0,.4));
}
.header-text h1 {
  font-family: 'Noto Sans Gujarati', sans-serif;
  font-size: 1.45rem;
  font-weight: 700;
  color: #fff;
  line-height: 1.25;
}
.header-text p {
  font-size: 0.78rem;
  color: rgba(255,255,255,.65);
  margin-top: 3px;
}

/* Status bar */
.status-bar { display: flex; gap: 10px; flex-wrap: wrap; }
.status-item {
  display: flex;
  align-items: center;
  gap: 7px;
  background: rgba(255,255,255,.1);
  border: 1px solid rgba(255,255,255,.15);
  padding: 5px 14px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 500;
  color: #fff;
}
.status-dot {
  width: 9px; height: 9px;
  border-radius: 50%;
  background: var(--muted);
  transition: background .3s;
}
.status-dot.ok      { background: #4ade80; box-shadow: 0 0 6px #4ade80; }
.status-dot.error   { background: #f87171; box-shadow: 0 0 6px #f87171; }
.status-dot.loading { background: var(--gold-light); animation: pulse 1s infinite; }
@keyframes pulse { 0%,100%{opacity:1} 50%{opacity:.4} }

/* ─── MAIN ─── */
.main {
  flex: 1;
  max-width: 1280px;
  width: 100%;
  margin: 32px auto;
  padding: 0 28px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

/* ─── CARD ─── */
.card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  overflow: hidden;
}

/* ─── UPLOAD CARD ─── */
.card-header {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 22px 26px;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(90deg, rgba(26,58,107,.04), transparent);
}
.card-header .icon { font-size: 2rem; line-height: 1; }
.card-header h2 { font-size: 1.05rem; font-weight: 700; color: var(--navy); }
.card-header .subtitle { font-size: 0.82rem; color: var(--muted); margin-top: 3px; }

/* Drop zone */
.drop-zone {
  margin: 24px;
  border: 2px dashed var(--border);
  border-radius: var(--radius-sm);
  padding: 52px 24px;
  text-align: center;
  cursor: pointer;
  transition: border-color .2s, background .2s, box-shadow .2s;
  background: #fafbfd;
  user-select: none;
}
/* hover — only highlight, no scale (scale shifts child positions and fires
   spurious dragleave events) */
.drop-zone:hover {
  border-color: var(--navy);
  background: rgba(26,58,107,.04);
}
/* active drag-over state */
.drop-zone.over {
  border-color: var(--navy);
  border-style: solid;
  background: rgba(26,58,107,.07);
  box-shadow: 0 0 0 4px rgba(26,58,107,.12);
}
/* file already selected — dim the zone */
.drop-zone.has-file {
  display: none;
}
.drop-icon  { font-size: 3.5rem; margin-bottom: 14px; display: block; pointer-events: none; }
.drop-title { font-family: 'Noto Sans Gujarati', sans-serif; font-size: 1.05rem; font-weight: 600; color: var(--navy); pointer-events: none; }
.drop-or    { color: var(--muted); font-size: .85rem; margin: 10px 0; pointer-events: none; }
.drop-formats { font-size: .78rem; color: var(--muted); margin-top: 14px; pointer-events: none; }

/* File info row */
.file-info { margin: 0 24px 4px; }
.file-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: rgba(26,58,107,.06);
  border: 1px solid rgba(26,58,107,.12);
  border-radius: var(--radius-sm);
}
.file-emoji { font-size: 1.6rem; }
.file-meta  { flex: 1; min-width: 0; }
.file-name  { display: block; font-weight: 600; color: var(--navy); font-size: .88rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.file-size  { font-size: .78rem; color: var(--muted); }
.btn-clear  { background: none; border: none; font-size: 1rem; color: var(--red); cursor: pointer; padding: 4px 8px; border-radius: 6px; transition: background .15s; }
.btn-clear:hover { background: rgba(192,57,43,.1); }

/* Model row */
.model-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 26px;
  margin-top: 18px;
}
.model-label { font-size: .88rem; font-weight: 600; color: var(--navy); white-space: nowrap; }
.model-select {
  padding: 8px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: .88rem;
  color: var(--text);
  background: #fff;
  cursor: pointer;
  min-width: 180px;
  outline: none;
}
.model-select:focus { border-color: var(--navy); box-shadow: 0 0 0 2px rgba(26,58,107,.15); }

/* Process button */
.btn-process {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: calc(100% - 52px);
  margin: 22px 26px;
  padding: 16px 24px;
  background: linear-gradient(135deg, var(--navy), var(--navy-light));
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-family: 'Noto Sans Gujarati', sans-serif;
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: .02em;
  box-shadow: 0 4px 16px rgba(26,58,107,.3);
  transition: transform .2s, box-shadow .2s, opacity .2s;
}
.btn-process:hover:not(:disabled) { transform: translateY(-2px); box-shadow: 0 6px 22px rgba(26,58,107,.4); }
.btn-process:active:not(:disabled){ transform: translateY(0); }
.btn-process:disabled { opacity: .45; cursor: not-allowed; }

/* Generic buttons */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 9px 18px;
  border-radius: var(--radius-sm);
  font-size: .85rem;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
  transition: background .15s, border-color .15s, transform .15s;
  text-decoration: none;
}
.btn-outline {
  background: #fff;
  color: var(--navy);
  border-color: var(--navy);
}
.btn-outline:hover { background: rgba(26,58,107,.06); }
.btn-dl {
  background: #fff;
  color: var(--navy);
  border-color: var(--border);
  font-size: .82rem;
  padding: 7px 14px;
}
.btn-dl:hover { border-color: var(--navy); background: var(--bg); transform: translateY(-1px); }

/* ─── PROGRESS CARD ─── */
.progress-card { padding: 28px 26px 20px; }
.steps-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0;
  margin-bottom: 20px;
}
.step {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  min-width: 52px;
}
.step-circle {
  width: 36px; height: 36px;
  border-radius: 50%;
  border: 2px solid var(--border);
  background: var(--bg);
  color: var(--muted);
  font-weight: 700;
  font-size: .88rem;
  display: flex; align-items: center; justify-content: center;
  transition: all .3s;
}
.step.active .step-circle { border-color: var(--navy); background: var(--navy); color: #fff; box-shadow: 0 0 0 4px rgba(26,58,107,.15); }
.step.done   .step-circle { border-color: var(--green); background: var(--green); color: #fff; }
.step-label  { font-size: .68rem; color: var(--muted); font-weight: 500; text-align: center; transition: color .3s; }
.step.active .step-label, .step.done .step-label { color: var(--navy); font-weight: 600; }

.step-connector {
  flex: 1;
  height: 3px;
  background: var(--border);
  margin-bottom: 26px;
  transition: background .4s;
  border-radius: 2px;
}
.step-connector.done { background: var(--green); }

.progress-msg {
  text-align: center;
  font-family: 'Noto Sans Gujarati', sans-serif;
  font-size: .95rem;
  font-weight: 500;
  color: var(--navy);
  padding-top: 4px;
}

/* ─── RESULTS ─── */
.results-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
}
@media (max-width: 800px) {
  .results-grid { grid-template-columns: 1fr; }
  .header-inner { flex-direction: column; align-items: flex-start; }
  .logo { height: 34px; }
  .header-text h1 { font-size: 1.1rem; }
}

.result-panel { display: flex; flex-direction: column; }
.panel-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(90deg, rgba(26,58,107,.03), transparent);
}
.panel-header h3 { font-size: .95rem; font-weight: 700; color: var(--navy); flex: 1; }
.badge {
  font-size: .68rem;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 999px;
  background: rgba(26,58,107,.1);
  color: var(--navy);
  letter-spacing: .04em;
  text-transform: uppercase;
}
.badge-green { background: rgba(39,103,73,.1); color: var(--green); }

.panel-body {
  flex: 1;
  overflow-y: auto;
  max-height: 480px;
  padding: 18px 20px;
}
.text-output {
  white-space: pre-wrap;
  word-break: break-word;
  font-size: .82rem;
  line-height: 1.85;
  color: #2c2c3e;
  font-family: 'Inter', monospace;
}
.gujarati {
  font-family: 'Noto Sans Gujarati', 'Shruti', sans-serif !important;
  font-size: .93rem;
  line-height: 2.15;
}

/* Blinking cursor */
.cursor {
  display: inline-block;
  width: 2px;
  height: 1.1em;
  background: var(--navy);
  vertical-align: text-bottom;
  margin-left: 1px;
  animation: blink .7s step-end infinite;
}
@keyframes blink { 0%,100%{opacity:1} 50%{opacity:0} }

/* Download bar */
.download-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding: 14px 20px;
  border-top: 1px solid var(--border);
  background: #fafbfd;
}
.dl-label { font-size: .82rem; font-weight: 600; color: var(--muted); white-space: nowrap; }

.new-doc-row { display: flex; justify-content: center; padding: 8px 0; }

/* ─── ERROR TOAST ─── */
/* Default: hidden. display:none here beats the [hidden] attribute so both
   the CSS class approach and the HTML attribute agree. */
.error-toast {
  display: none;              /* hidden by default */
  position: fixed;
  bottom: 28px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--red);
  color: #fff;
  padding: 13px 20px;
  border-radius: var(--radius-sm);
  align-items: center;
  gap: 10px;
  box-shadow: var(--shadow-lg);
  z-index: 999;
  max-width: 520px;
  font-size: .9rem;
  opacity: 0;
  transition: transform .25s ease, opacity .25s ease;
}
/* Shown state — toggled by JS adding/removing .show class */
.error-toast.show {
  display: flex;
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}
.error-toast button { background: none; border: none; color: #fff; cursor: pointer; font-size: 1.1rem; padding: 0 6px; line-height: 1; }

/* ─── FOOTER ─── */
.footer {
  text-align: center;
  padding: 20px 28px;
  font-size: .78rem;
  color: var(--muted);
  border-top: 1px solid var(--border);
  margin-top: auto;
}

/* ─── SPINNER ─── */
.spinner {
  width: 18px; height: 18px;
  border: 2px solid rgba(255,255,255,.35);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin .75s linear infinite;
  display: inline-block;
  vertical-align: middle;
}
@keyframes spin { to { transform: rotate(360deg); } }
