/* ============================================================
   AI Government Schemes Assistant — styles
   ============================================================ */

:root {
  --saffron: #FF9933;
  --saffron-dark: #E07A00;
  --india-green: #138808;
  --india-green-dark: #0d6606;
  --navy: #1a237e;
  --bg: #f7f7fb;
  --surface: #ffffff;
  --surface-alt: #f1f2f8;
  --border: #e3e4ee;
  --text: #1c1d26;
  --text-muted: #666a7a;
  --shadow: 0 4px 16px rgba(20, 20, 40, 0.08);
  --shadow-lg: 0 12px 32px rgba(20, 20, 40, 0.12);
  --radius: 14px;
  --radius-sm: 8px;
  --maxw: 1180px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14151d;
    --surface: #1c1e29;
    --surface-alt: #23253361;
    --surface-alt: #262838;
    --border: #33364a;
    --text: #eceef5;
    --text-muted: #a3a6b8;
    --shadow: 0 4px 16px rgba(0, 0, 0, 0.35);
    --shadow-lg: 0 12px 32px rgba(0, 0, 0, 0.45);
  }
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: 'Segoe UI', system-ui, -apple-system, Roboto, Helvetica, Arial, sans-serif;
  line-height: 1.5;
}

img, svg { max-width: 100%; }

.is-hidden { display: none !important; }

/* ---------------- header ---------------- */
.site-header {
  background: linear-gradient(90deg, var(--saffron) 0%, var(--saffron) 33%, var(--surface) 33%, var(--surface) 66%, var(--india-green) 66%, var(--india-green) 100%);
  border-bottom: 1px solid var(--border);
}
.site-header__inner {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 14px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  background: var(--surface);
  border-radius: 0 0 var(--radius) var(--radius);
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand__flag { display: inline-flex; flex-shrink: 0; }
.brand__flag svg {
  width: 40px; height: auto; display: block;
  border-radius: 3px;
  box-shadow: 0 0 0 1px rgba(0,0,0,.10), 0 1px 3px rgba(0,0,0,.14);
}
.brand__title { margin: 0; font-size: 1.3rem; font-weight: 800; color: var(--navy); }
.brand__subtitle { margin: 0; font-size: 0.85rem; color: var(--text-muted); }

.header-actions { display: flex; align-items: center; gap: 10px; }
.lang-picker {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 6px 10px;
}
.lang-picker__icon { font-size: 0.95rem; }
.lang-picker select {
  border: none;
  background: transparent;
  color: var(--text);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  max-width: 120px;
}
.lang-picker select:focus { outline: none; }

.scheme-note {
  margin: -6px 0 18px !important;
  font-size: 0.78rem !important;
  color: var(--text-muted);
  font-style: italic;
}

html[dir="rtl"] .site-header__inner { flex-direction: row-reverse; }
html[dir="rtl"] .brand { flex-direction: row-reverse; }
html[dir="rtl"] .header-actions { flex-direction: row-reverse; }
html[dir="rtl"] .chat-form { flex-direction: row-reverse; }
html[dir="rtl"] .bubble--user { align-self: flex-start; border-bottom-right-radius: var(--radius); border-bottom-left-radius: 4px; }
html[dir="rtl"] .bubble--assistant { align-self: flex-end; border-bottom-left-radius: var(--radius); border-bottom-right-radius: 4px; }
html[dir="rtl"] #profileForm .row { direction: rtl; }
html[dir="rtl"] .fieldset-inline { flex-direction: row-reverse; }
html[dir="rtl"] .scheme-card__top { flex-direction: row-reverse; }

.btn {
  border: none;
  cursor: pointer;
  font-weight: 600;
  border-radius: var(--radius-sm);
  padding: 10px 18px;
  font-size: 0.9rem;
  transition: transform 0.08s ease, box-shadow 0.15s ease, background 0.15s ease;
}
.btn:active { transform: scale(0.97); }
.btn--primary {
  background: linear-gradient(120deg, var(--saffron), var(--india-green));
  color: #fff;
  box-shadow: var(--shadow);
}
.btn--primary:hover { box-shadow: var(--shadow-lg); }
.btn--ghost {
  background: var(--surface-alt);
  color: var(--text);
  border: 1px solid var(--border);
}
.btn--ghost:hover { background: var(--border); }

/* ---------------- layout ---------------- */
.layout {
  max-width: var(--maxw);
  margin: 24px auto;
  padding: 0 20px;
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: 24px;
  align-items: start;
}

@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }
  .profile-panel {
    position: fixed;
    inset: 0;
    z-index: 40;
    transform: translateX(100%);
    transition: transform 0.25s ease;
    overflow-y: auto;
    max-width: none;
  }
  body.profile-open .profile-panel { transform: translateX(0); }
}

/* ---------------- chat panel ---------------- */
.chat-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
  box-shadow: var(--shadow);
  min-width: 0;
}

.hero h2 { margin: 0 0 8px; font-size: 1.5rem; color: var(--navy); }
.hero p { margin: 0 0 18px; color: var(--text-muted); max-width: 60ch; }

.chat-window {
  background: var(--surface-alt);
  border-radius: var(--radius);
  padding: 16px;
  max-height: 360px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 14px;
}

.bubble {
  max-width: 85%;
  padding: 12px 16px;
  border-radius: var(--radius);
  font-size: 0.95rem;
}
.bubble p { margin: 0 0 6px; }
.bubble p:last-child { margin-bottom: 0; }
.bubble--assistant {
  background: var(--surface);
  border: 1px solid var(--border);
  align-self: flex-start;
  border-bottom-left-radius: 4px;
}
.bubble--user {
  background: linear-gradient(120deg, var(--saffron), var(--saffron-dark));
  color: #fff;
  align-self: flex-end;
  border-bottom-right-radius: 4px;
}

.chat-form {
  display: flex;
  gap: 10px;
  align-items: flex-end;
}
.chat-form textarea {
  flex: 1;
  resize: vertical;
  min-height: 48px;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-family: inherit;
  font-size: 0.95rem;
}
.chat-form textarea:focus { outline: 2px solid var(--saffron); outline-offset: 1px; }

.example-chips {
  margin-top: 14px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.example-chip {
  background: var(--surface-alt);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 999px;
  padding: 7px 14px;
  font-size: 0.82rem;
  cursor: pointer;
  transition: background 0.15s ease;
}
.example-chip:hover { background: var(--border); }

/* ---------------- saved / "My Opportunities" panel ---------------- */
.saved-panel {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(380px, 100%);
  background: var(--surface);
  border-left: 1px solid var(--border);
  box-shadow: var(--shadow);
  padding: 20px;
  overflow-y: auto;
  z-index: 60;
  transform: translateX(100%);
  transition: transform 0.25s ease;
}
body.saved-open .saved-panel { transform: translateX(0); }
.saved-panel h3 { margin: 0 0 4px; color: var(--navy); }
.saved-panel-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.35);
  z-index: 55;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}
body.saved-open .saved-panel-backdrop { opacity: 1; pointer-events: auto; }

.saved-count-badge {
  background: var(--saffron-dark);
  color: #fff;
  font-size: 0.72rem;
  font-weight: 700;
  border-radius: 999px;
  padding: 1px 7px;
  margin-left: 2px;
}

.saved-list { display: flex; flex-direction: column; gap: 12px; margin-bottom: 16px; }
.saved-item {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px;
  background: var(--surface-alt);
}
.saved-item__top { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.saved-item__title { font-weight: 700; font-size: 0.9rem; color: var(--navy); margin: 0; }
.saved-item__remove { background: none; border: none; cursor: pointer; font-size: 0.9rem; color: var(--text-muted); }
.saved-item textarea {
  width: 100%;
  margin-top: 8px;
  min-height: 50px;
  font: inherit;
  font-size: 0.82rem;
  padding: 6px 8px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  resize: vertical;
}
.saved-empty { color: var(--text-muted); font-size: 0.88rem; }

.scheme-card { position: relative; }
.scheme-card__save {
  position: absolute;
  top: 12px;
  right: 12px;
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1.15rem;
  line-height: 1;
  color: #c9a13b;
}

@media print {
  body > *:not(#printChecklistArea) { display: none !important; }
  #printChecklistArea { display: block !important; }
}

/* ---------------- profile panel ---------------- */
.profile-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
}
.profile-panel h3 { margin: 0 0 4px; color: var(--navy); }
.profile-panel__hint { margin: 0 0 16px; font-size: 0.82rem; color: var(--text-muted); }

#profileForm { display: flex; flex-direction: column; gap: 14px; }
#profileForm label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-muted);
}
#profileForm input,
#profileForm select {
  font-family: inherit;
  font-size: 0.92rem;
  font-weight: 400;
  color: var(--text);
  padding: 9px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
}
#profileForm .row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.fieldset-inline {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
}
.fieldset-inline legend {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
  padding: 0 4px;
}
.radio, .checkbox {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.85rem;
  font-weight: 400;
  color: var(--text);
  cursor: pointer;
}

.profile-actions { display: flex; justify-content: flex-end; }

/* ---------------- results ---------------- */
.results {
  max-width: var(--maxw);
  margin: 8px auto 24px;
  padding: 0 20px;
}
.results__header {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 14px;
}
.results__header h2 { margin: 0; color: var(--navy); }
.results__count { margin: 2px 0 0; color: var(--text-muted); font-size: 0.9rem; }

.business-snapshot {
  background: #fff7e6;
  border: 1px solid #f0c869;
  border-radius: 8px;
  padding: 10px 14px;
  margin: 0 0 14px;
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--navy);
}

.chips-row { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  background: var(--navy);
  color: #fff;
  font-size: 0.78rem;
  padding: 5px 12px;
  border-radius: 999px;
  opacity: 0.9;
}

.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 18px;
}
.tab {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-muted);
  padding: 7px 14px;
  border-radius: 999px;
  font-size: 0.82rem;
  cursor: pointer;
  font-weight: 600;
}
.tab.is-active {
  background: var(--navy);
  color: #fff;
  border-color: var(--navy);
}

/* Type-filter tab row sits above the category tabs */
.tabs--type { margin-bottom: 10px; }
.tab--type { background: #fff; }
.tab--type.is-active { background: var(--india-green-dark, #0b6b2e); color: #fff; border-color: var(--india-green-dark, #0b6b2e); }

.results-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}

.scheme-card__type {
  align-self: flex-start;
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--navy, #000080);
  background: rgba(0, 0, 128, 0.08);
  padding: 2px 8px;
  border-radius: 999px;
}

/* Loan comparison table */
.loan-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  font-size: 0.85rem;
}
.loan-table th, .loan-table td {
  padding: 10px 12px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}
.loan-table thead th {
  background: var(--navy, #000080);
  color: #fff;
  font-size: 0.78rem;
  white-space: nowrap;
}
.loan-table tbody tr:nth-child(even) { background: rgba(0, 0, 0, 0.02); }
.loan-table__min { font-size: 0.72rem; color: var(--text-muted); font-style: italic; }
.loan-table a { color: var(--india-green-dark); font-weight: 700; white-space: nowrap; }

@media (max-width: 720px) {
  .loan-table thead { display: none; }
  .loan-table, .loan-table tbody, .loan-table tr, .loan-table td { display: block; width: 100%; }
  .loan-table tr { border-bottom: 2px solid var(--border); padding: 6px 0; }
  .loan-table td { border: none; padding: 5px 12px; }
  .loan-table td::before {
    content: attr(data-label) ": ";
    font-weight: 700;
    color: var(--text-muted);
  }
  .loan-table td[data-label=""]::before { content: ""; }
}

.scheme-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 8px;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.scheme-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }

.scheme-card__top { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.badge {
  font-size: 0.72rem;
  font-weight: 700;
  padding: 4px 9px;
  border-radius: 999px;
}
.badge--yes { background: rgba(19, 136, 8, 0.15); color: var(--india-green-dark); }
.badge--maybe { background: rgba(255, 153, 51, 0.18); color: var(--saffron-dark); }
.badge--browse { background: rgba(0, 0, 128, 0.10); color: #000080; }
.scheme-card__category { font-size: 0.75rem; color: var(--text-muted); white-space: nowrap; }

.scheme-card__title { margin: 0; font-size: 1.02rem; color: var(--text); }
.scheme-card__ministry { margin: 0; font-size: 0.78rem; color: var(--text-muted); font-style: italic; }
.scheme-card__benefit { margin: 4px 0 8px; font-size: 0.88rem; color: var(--text); flex: 1; }
.scheme-card__link {
  align-self: flex-start;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--india-green-dark);
  text-decoration: none;
}
.scheme-card__link:hover { text-decoration: underline; }

/* ---------------- empty state ---------------- */
.empty-state {
  max-width: var(--maxw);
  margin: 0 auto 24px;
  padding: 40px 20px;
  text-align: center;
  color: var(--text-muted);
}

/* ---------------- footer ---------------- */
.site-footer {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 20px;
  border-top: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 0.82rem;
}
.site-footer a { color: var(--navy); }
.site-footer__credit { margin-top: 6px; opacity: 0.8; }

@media (prefers-color-scheme: dark) {
  .site-footer a { color: #8ab4ff; }
  .badge--yes { background: rgba(19, 136, 8, 0.25); color: #7CFC7C; }
  .badge--maybe { background: rgba(255, 153, 51, 0.25); color: #ffc477; }
  .badge--browse { background: rgba(138, 180, 255, 0.20); color: #8ab4ff; }
  .chip { opacity: 1; }
}

/* ---------------- hub nav (rebrand nav shell) ---------------- */
.hub-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 18px;
  width: 100%;
  order: 3;
  padding: 4px 0 0;
  font-size: 0.82rem;
}
.hub-nav__item {
  color: var(--text-muted);
  text-decoration: none;
  font-weight: 600;
  padding: 2px 0;
  border-bottom: 2px solid transparent;
}
.hub-nav__item.is-active { color: var(--navy); border-bottom-color: var(--saffron); }
.hub-nav__item:not(.hub-nav__item--soon):hover { color: var(--navy); }
.hub-nav__item--soon { cursor: default; opacity: 0.6; }
.hub-nav__item--soon em { font-style: normal; font-weight: 400; }
@media (prefers-color-scheme: dark) { .hub-nav__item.is-active { color: #8ab4ff; } }

/* ---------------- Recurring Application Windows (calendar) ---------------- */
.calendar-section { padding: 32px 20px; }
.calendar-section__inner { max-width: var(--maxw); margin: 0 auto; }
.calendar-section__inner h2 { margin: 0 0 6px; color: var(--navy); }
.calendar-section__desc { color: var(--text-muted); margin: 0 0 20px; max-width: 820px; }
.calendar-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; }
.calendar-card__month {
  display: inline-block;
  background: var(--navy);
  color: #fff;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 3px 9px;
  border-radius: 999px;
  letter-spacing: 0.02em;
}
.calendar-card__month--rolling { background: var(--text-muted); }

/* ---------------- Sports Organizations section ---------------- */
.org-section {
  background: var(--surface-alt);
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  padding: 32px 20px;
}
.org-section__inner { max-width: var(--maxw); margin: 0 auto; }
.org-section__inner h2 { margin: 0 0 6px; color: var(--navy); }
.org-section__desc { color: var(--text-muted); margin: 0 0 20px; max-width: 760px; }

.org-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  max-width: 760px;
}
.org-form .row { display: flex; gap: 14px; flex-wrap: wrap; }
.org-form .row label { flex: 1 1 220px; }
.org-form label { display: flex; flex-direction: column; gap: 4px; font-size: 0.85rem; font-weight: 600; color: var(--text); }
.org-form input, .org-form select {
  font: inherit;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
}

#orgResultsSection { margin-top: 24px; }
#orgResultsSection h3 { margin: 0 0 2px; color: var(--navy); }
#orgResultsSection .results-grid { margin-top: 14px; }
.org-empty { color: var(--text-muted); }

.scheme-card__source { margin: 4px 0 8px; font-size: 0.78rem; }
.scheme-card__source a { color: var(--text-muted); }

.scheme-card__docs { margin: 6px 0 10px; font-size: 0.82rem; }
.scheme-card__docs summary { cursor: pointer; font-weight: 600; color: var(--navy); }
.doc-list { list-style: none; margin: 8px 0 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.doc-item { font-size: 0.82rem; }
.doc-item--not_required { color: var(--text-muted); text-decoration: line-through; }
.doc-item--conditional { color: #a06a00; }

.transparency-note {
  max-width: 760px;
  margin-top: 28px;
  background: var(--surface);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
}
.transparency-note h3 { margin: 0 0 6px; font-size: 1rem; color: var(--navy); }
.transparency-note p { margin: 0 0 10px; color: var(--text-muted); font-size: 0.85rem; }
.transparency-note ul { margin: 0; padding-left: 20px; font-size: 0.85rem; }

/* ---------------- business/loan-context profile fields ---------------- */
#businessLoanFields { display: flex; flex-direction: column; gap: 14px; }

/* ---------------- loan comparison ---------------- */
.loan-compare-hint { margin: 0 0 10px; font-size: 0.82rem; color: var(--text-muted); }
.loan-table td[data-label] input.loan-compare-check { width: 18px; height: 18px; cursor: pointer; }
.loan-compare-result {
  margin-top: 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
  overflow-x: auto;
}
.loan-compare-result h3 { margin: 0 0 10px; color: var(--navy); font-size: 1rem; }
.loan-compare-table { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
.loan-compare-table th, .loan-compare-table td {
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: top;
}
.loan-compare-table thead th { background: var(--navy, #000080); color: #fff; font-size: 0.8rem; }
.loan-compare-table tbody th[scope="row"] { font-weight: 700; color: var(--text-muted); background: rgba(0, 0, 0, 0.02); white-space: nowrap; }
.loan-compare-table a { color: var(--india-green-dark); font-weight: 700; white-space: nowrap; }
.transparency-note li { margin-bottom: 4px; }
