/* ManualGen — RACV CES brand styling. */

:root {
  --racv-yellow: #F8DB00;
  --racv-navy: #001657;
  --racv-bright-blue: #0067F6;
  --racv-cyan: #43E6EB;
  --racv-stone: #F3F2EC;
  --racv-logo-blue: #1F5AA5;
  --racv-ink: #0E1430;
  --racv-grey-700: #3F4757;
  --racv-grey-500: #6E7689;
  --racv-grey-300: #C9CDD7;
  --racv-grey-200: #E6E8EE;
  --racv-grey-100: #F4F5F8;
  --racv-white: #FFFFFF;
  --racv-danger: #C2261A;
  --shadow-card: 0 1px 2px rgba(0, 22, 87, 0.06), 0 4px 16px rgba(0, 22, 87, 0.08);
}

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

html,
body {
  margin: 0;
  padding: 0;
  font-family: "Poppins", "Helvetica Neue", Arial, sans-serif;
  color: var(--racv-ink);
  background: var(--racv-stone);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a {
  color: var(--racv-bright-blue);
  text-decoration: none;
}
a:hover { text-decoration: underline; }

.app-body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* --- Header ------------------------------------------------------------- */
.app-header {
  background: var(--racv-navy);
  color: var(--racv-white);
  border-bottom: 4px solid var(--racv-yellow);
}
.app-header__inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 24px;
  display: flex;
  align-items: center;
  gap: 24px;
  height: 64px;
}
.app-header__brand {
  display: flex;
  align-items: center;
  gap: 12px;
  color: inherit;
}
.app-header__brand img {
  height: 32px;
  width: auto;
}
.app-header__title {
  font-weight: 600;
  font-size: 18px;
  letter-spacing: 0.5px;
}
.app-header__nav {
  display: flex;
  gap: 8px;
  margin-left: 24px;
  flex: 1;
}
.app-header__link {
  color: var(--racv-white);
  padding: 6px 12px;
  border-radius: 6px;
  font-weight: 500;
  font-size: 14px;
}
.app-header__link:hover {
  background: rgba(255, 255, 255, 0.08);
  text-decoration: none;
}
.app-header__link--muted {
  color: rgba(255, 255, 255, 0.55);
  cursor: not-allowed;
}
.app-header__user {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 14px;
}
.app-header__user-name { font-weight: 600; }
.app-header__user-role {
  background: rgba(255, 255, 255, 0.1);
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 12px;
}

/* --- Main / footer ------------------------------------------------------ */
.app-main {
  flex: 1;
  max-width: 1200px;
  width: 100%;
  margin: 0 auto;
  padding: 32px 24px;
}
.app-footer {
  text-align: center;
  font-size: 12px;
  color: var(--racv-grey-500);
  padding: 16px;
}

/* --- Auth --------------------------------------------------------------- */
.auth-shell {
  min-height: calc(100vh - 80px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background:
    radial-gradient(circle at top left, rgba(0, 103, 246, 0.10), transparent 50%),
    radial-gradient(circle at bottom right, rgba(67, 230, 235, 0.15), transparent 50%),
    var(--racv-stone);
}
.auth-card {
  background: var(--racv-white);
  border-radius: 16px;
  padding: 40px 36px;
  width: 100%;
  max-width: 420px;
  box-shadow: var(--shadow-card);
  border-top: 6px solid var(--racv-yellow);
}
.auth-card__brand {
  display: flex;
  justify-content: center;
  margin-bottom: 16px;
}
.auth-card__brand img {
  height: 72px;
  width: auto;
}
.auth-card__heading {
  text-align: center;
  font-size: 22px;
  font-weight: 600;
  color: var(--racv-navy);
  margin: 0 0 4px;
}
.auth-card__subheading {
  text-align: center;
  color: var(--racv-grey-500);
  margin: 0 0 24px;
  font-size: 14px;
}
.auth-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* --- Form fields -------------------------------------------------------- */
.field { display: flex; flex-direction: column; gap: 6px; }
.field__label {
  font-size: 13px;
  font-weight: 600;
  color: var(--racv-grey-700);
}
.field__input {
  font: inherit;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid var(--racv-grey-300);
  background: var(--racv-white);
  color: var(--racv-ink);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.field__input:focus {
  outline: none;
  border-color: var(--racv-bright-blue);
  box-shadow: 0 0 0 3px rgba(0, 103, 246, 0.15);
}
.field__help {
  font-size: 12px;
  color: var(--racv-grey-500);
}

/* --- Buttons ------------------------------------------------------------ */
.btn {
  font: inherit;
  font-weight: 600;
  font-size: 14px;
  padding: 10px 18px;
  border-radius: 8px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}
.btn--primary {
  background: var(--racv-yellow);
  color: var(--racv-navy);
}
.btn--primary:hover { background: #ffe632; }
.btn--ghost {
  background: transparent;
  color: var(--racv-white);
  border-color: rgba(255, 255, 255, 0.4);
}
.btn--ghost:hover { background: rgba(255, 255, 255, 0.08); }
.btn--block { display: block; width: 100%; }

/* --- Alerts ------------------------------------------------------------- */
.alert {
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 14px;
  margin-bottom: 16px;
}
.alert--error {
  background: #FBEAE8;
  color: var(--racv-danger);
  border: 1px solid rgba(194, 38, 26, 0.25);
}

/* --- Page chrome -------------------------------------------------------- */
.page-section { display: flex; flex-direction: column; gap: 24px; }
.page-section__header {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
}
.page-title {
  font-size: 24px;
  font-weight: 600;
  color: var(--racv-navy);
  margin: 0;
}
.page-subtitle {
  margin: 4px 0 0;
  color: var(--racv-grey-500);
  font-size: 14px;
}

/* --- Tiles -------------------------------------------------------------- */
.tile-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
}
.tile {
  background: var(--racv-white);
  border-radius: 12px;
  padding: 20px;
  box-shadow: var(--shadow-card);
  border-left: 4px solid var(--racv-yellow);
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.tile__label {
  font-size: 13px;
  color: var(--racv-grey-500);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.tile__value {
  font-size: 32px;
  font-weight: 700;
  color: var(--racv-navy);
}

/* --- Cards / tables ----------------------------------------------------- */
.card {
  background: var(--racv-white);
  border-radius: 12px;
  padding: 24px;
  box-shadow: var(--shadow-card);
}
.card__heading {
  margin: 0 0 16px;
  font-size: 16px;
  font-weight: 600;
  color: var(--racv-navy);
}
.card__empty {
  color: var(--racv-grey-500);
  font-size: 14px;
  margin: 0;
}
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
.data-table th,
.data-table td {
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid var(--racv-grey-200);
}
.data-table th {
  color: var(--racv-grey-500);
  font-weight: 600;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.data-table tr:last-child td { border-bottom: none; }

.status {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
}
.status--draft     { background: var(--racv-grey-200); color: var(--racv-grey-700); }
.status--queued    { background: #E8F0FE; color: var(--racv-bright-blue); }
.status--running   { background: #FFF6CC; color: #8A6C00; }
.status--completed { background: #E0F6E8; color: #1B7A3E; }
.status--failed    { background: #FBEAE8; color: var(--racv-danger); }
.status--expired   { background: var(--racv-grey-200); color: var(--racv-grey-500); }

/* --- Header link active state ------------------------------------------ */
.app-header__link.is-active {
  background: rgba(248, 219, 0, 0.18);
  color: var(--racv-yellow);
}

/* --- Flash banners ------------------------------------------------------ */
.flash-stack { display: flex; flex-direction: column; gap: 8px; margin-bottom: 16px; }
.flash {
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 14px;
  border: 1px solid transparent;
}
.flash--success { background: #E0F6E8; color: #1B7A3E; border-color: rgba(27, 122, 62, 0.2); }
.flash--error   { background: #FBEAE8; color: var(--racv-danger); border-color: rgba(194, 38, 26, 0.25); }
.flash--info    { background: #E8F0FE; color: var(--racv-bright-blue); border-color: rgba(0, 103, 246, 0.2); }
.flash--warning { background: #FFF6CC; color: #8A6C00; border-color: rgba(138, 108, 0, 0.25); }

/* --- Breadcrumbs / action bars ----------------------------------------- */
.breadcrumbs {
  font-size: 13px;
  color: var(--racv-grey-500);
  margin: 0 0 4px;
}
.breadcrumbs a { color: var(--racv-grey-500); }
.breadcrumbs a:hover { color: var(--racv-bright-blue); }
.breadcrumbs__sep { margin: 0 6px; color: var(--racv-grey-300); }

.action-bar {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}
.action-bar__actions { display: flex; gap: 8px; }

/* --- Filter row -------------------------------------------------------- */
.filter-row {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  align-items: end;
  background: var(--racv-white);
  padding: 12px 16px;
  border-radius: 10px;
  box-shadow: var(--shadow-card);
  margin-bottom: 16px;
}
.filter-row .field { min-width: 180px; }
.filter-row select,
.filter-row input {
  font: inherit;
  padding: 8px 10px;
  border: 1px solid var(--racv-grey-300);
  border-radius: 8px;
  background: var(--racv-white);
}

/* --- Buttons (extras) -------------------------------------------------- */
.btn--secondary {
  background: var(--racv-white);
  color: var(--racv-navy);
  border-color: var(--racv-grey-300);
}
.btn--secondary:hover { border-color: var(--racv-navy); }
.btn--danger {
  background: var(--racv-white);
  color: var(--racv-danger);
  border-color: rgba(194, 38, 26, 0.4);
}
.btn--danger:hover { background: #FBEAE8; }
.btn--sm { padding: 6px 12px; font-size: 13px; }
.btn--link {
  background: transparent;
  border: none;
  color: var(--racv-bright-blue);
  padding: 0;
  font-weight: 500;
}
.btn--link:hover { text-decoration: underline; }

/* --- Badges / pills ---------------------------------------------------- */
.pill {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  background: var(--racv-grey-200);
  color: var(--racv-grey-700);
}
.pill--ok       { background: #E0F6E8; color: #1B7A3E; }
.pill--off      { background: var(--racv-grey-200); color: var(--racv-grey-500); }
.pill--category { background: rgba(0, 103, 246, 0.10); color: var(--racv-bright-blue); }
.pill--role     { background: rgba(0, 22, 87, 0.08); color: var(--racv-navy); }

/* --- File pills (uploaded doc indicators) ------------------------------ */
.file-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 12px;
  border: 1px solid var(--racv-grey-200);
  background: var(--racv-grey-100);
  color: var(--racv-grey-700);
  text-decoration: none;
}
.file-pill:hover { background: var(--racv-white); border-color: var(--racv-bright-blue); text-decoration: none; }
.file-pill--empty { color: var(--racv-grey-500); font-style: italic; }
.file-pill__dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--racv-bright-blue);
}

/* --- Forms (admin pages) ---------------------------------------------- */
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 16px;
}
.form-grid .field--full { grid-column: 1 / -1; }
.form-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 24px;
}
.form-section {
  border-top: 1px solid var(--racv-grey-200);
  margin-top: 24px;
  padding-top: 16px;
}
.form-section__heading {
  font-size: 14px;
  font-weight: 600;
  color: var(--racv-navy);
  margin: 0 0 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

textarea.field__input { font-family: inherit; min-height: 80px; resize: vertical; }
select.field__input { appearance: none; background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='8'><path fill='%236E7689' d='M0 0l6 8 6-8z'/></svg>"); background-repeat: no-repeat; background-position: right 12px center; padding-right: 32px; }

.field__input--file {
  padding: 8px;
  background: var(--racv-grey-100);
}

.field__hint-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

/* --- Table action column ---------------------------------------------- */
.data-table td.actions,
.data-table th.actions {
  text-align: right;
  white-space: nowrap;
}
.data-table td.actions form { display: inline; }
.data-table .col-thin { width: 1%; white-space: nowrap; }

.empty-state {
  padding: 32px;
  text-align: center;
  color: var(--racv-grey-500);
  font-size: 14px;
}

/* --- Errors ------------------------------------------------------------- */
.error-shell {
  min-height: 60vh;
  display: flex;
  align-items: center;
  justify-content: center;
}
.error-card {
  text-align: center;
  background: var(--racv-white);
  padding: 48px;
  border-radius: 16px;
  box-shadow: var(--shadow-card);
}
.error-card__code {
  font-size: 64px;
  font-weight: 700;
  color: var(--racv-navy);
  margin: 0;
}
.error-card__detail {
  color: var(--racv-grey-500);
  margin: 8px 0 24px;
}

/* --- Phase 3: generation form + history helpers --- */
.field__help--error { color: var(--racv-danger); }
.text-muted { color: var(--racv-grey-500); font-size: 12px; }
.page-section__actions { margin-left: auto; }
.tile--link { text-decoration: none; color: inherit; transition: box-shadow .15s ease; }
.tile--link:hover { box-shadow: 0 6px 18px rgba(0,30,80,.08); }
.data-table__actions { display: flex; gap: 6px; justify-content: flex-end; white-space: nowrap; }
.data-table--lines td { vertical-align: top; }
.data-table--lines .field__input { width: 100%; }
.kv-grid {
  display: grid;
  grid-template-columns: 200px 1fr;
  gap: 8px 16px;
  margin: 8px 0 0;
  font-size: 14px;
}
.kv-grid dt { color: var(--racv-grey-500); font-weight: 500; }
.kv-grid dd { margin: 0; color: var(--racv-grey-900); }
.error-box {
  background: #FBEAE8;
  color: var(--racv-danger);
  border-radius: 8px;
  padding: 12px 16px;
  margin: 8px 0 16px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  white-space: pre-wrap;
}

/* --- Phase 5: analytics dashboard --- */
.tile--cta .tile__value { color: var(--racv-bright-blue); font-size: 22px; }
.chart-grid {
  display: grid;
  gap: 24px;
  margin-top: 12px;
}
.chart-grid--two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (max-width: 880px) {
  .chart-grid--two { grid-template-columns: 1fr; }
}
.chart-block {
  background: var(--racv-grey-100);
  border-radius: 10px;
  padding: 16px;
  min-height: 220px;
}
.chart-block__title {
  margin: 0 0 12px;
  font-size: 14px;
  font-weight: 600;
  color: var(--racv-grey-700);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.chart-block canvas { max-width: 100%; }

/* --- Phase 5: history filter bar --- */
.filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin: 12px 0 16px;
}
.filter-bar__input {
  flex: 1 1 280px;
  min-width: 220px;
  padding: 8px 12px;
  border: 1px solid var(--racv-grey-300);
  border-radius: 8px;
  font: inherit;
  background: var(--racv-white);
}
.filter-bar__input:focus,
.filter-bar__select:focus { outline: 2px solid var(--racv-bright-blue); outline-offset: 1px; }
.filter-bar__select {
  padding: 8px 12px;
  border: 1px solid var(--racv-grey-300);
  border-radius: 8px;
  font: inherit;
  background: var(--racv-white);
}
