/*
 * Strata Portal design tokens.
 * Palette + type pulled directly from stratalang.com (computed styles / CSS vars), so the
 * portal reads as the same brand as the marketing site, not a generic admin skin.
 */

:root {
  /* Brand */
  --strata-navy: #0d2399;        /* primary — headers, nav, primary buttons */
  --strata-navy-dark: #0c1d7b;   /* hover/active state, deep backgrounds */
  --strata-blue: #37abff;        /* secondary accent — highlights, badges */
  --strata-link: #188bf6;        /* links, interactive text */
  --strata-tint: #e3f4f9;        /* light blue tint — section backgrounds, cards */

  /* Neutrals */
  --strata-black: #000000;
  --strata-ink: #414141;         /* body text */
  --strata-gray: #595959;        /* secondary text */
  --strata-border: #cdcdcd;      /* borders, dividers */
  --strata-smoke: #f5f5f5;       /* page background */
  --strata-white: #ffffff;

  /* Status (kept distinct from brand blues so state is scannable at a glance) */
  --strata-success: #2f9e44;
  --strata-warning: #f6ad55;
  --strata-danger: #e93d3d;

  /* Type */
  --font-heading: "Poppins", "Inter", system-ui, sans-serif;
  --font-body: "Inter", "Poppins", system-ui, sans-serif;

  /* Rhythm */
  --radius: 8px;
  --shadow-sm: 0 1px 2px rgba(13, 35, 153, 0.08);
  --shadow-md: 0 4px 16px rgba(13, 35, 153, 0.12);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--strata-smoke);
  color: var(--strata-ink);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.5;
}

body {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-heading);
  color: var(--strata-navy);
  font-weight: 600;
  margin: 0 0 0.5em;
}

a {
  color: var(--strata-link);
  text-decoration: none;
}
a:hover { text-decoration: underline; }

/* --- Layout shell --- */
.app-header {
  background: var(--strata-navy);
  color: var(--strata-white);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1.5rem;
  box-shadow: var(--shadow-sm);
}
.app-header .brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 1.25rem;
  color: var(--strata-white);
}
.app-header .brand .mark {
  width: 28px; height: 28px;
  border-radius: 6px;
  background: var(--strata-blue);
  display: inline-flex; align-items: center; justify-content: center;
  color: var(--strata-navy-dark);
  font-weight: 800;
}
.app-header nav a {
  color: var(--strata-white);
  opacity: 0.85;
  margin-left: 1.25rem;
  font-weight: 500;
}
.app-header nav a:hover { opacity: 1; text-decoration: none; }
.app-header .user-chip {
  font-size: 0.85rem;
  opacity: 0.85;
}

/* --- Header tab strip (Phase 9: "Portal | Assets", PM-only — see
   templates/partials/header_tabs.html) --- */
.header-tabs {
  display: flex;
  gap: 0.25rem;
  padding: 0 1.5rem;
  background: var(--strata-navy-dark, var(--strata-navy));
  border-bottom: 1px solid var(--strata-border);
}
.header-tab {
  padding: 0.6rem 1.1rem;
  color: var(--strata-white);
  opacity: 0.75;
  font-weight: 600;
  font-size: 0.9rem;
  border-bottom: 3px solid transparent;
}
.header-tab:hover {
  opacity: 1;
  text-decoration: none;
}
.header-tab.active {
  opacity: 1;
  border-bottom-color: var(--strata-blue);
}

.app-shell {
  display: flex;
  align-items: stretch;
  flex: 1;
  width: 100%;
}

.app-main {
  flex: 1;
  min-width: 0; /* allow horizontally-scrolling content (e.g. the interpretation kanban board) to shrink below its content size instead of overflowing the shell */
  max-width: 1120px;
  margin: 0 auto;
  padding: 2rem 1.5rem 4rem;
}

/* --- Sidebar nav --- */
.app-sidebar {
  width: 240px;
  flex-shrink: 0;
  background: var(--strata-white);
  border-right: 1px solid var(--strata-border);
}

.sidebar-nav {
  list-style: none;
  margin: 0;
  padding: 1.25rem 0;
}

.sidebar-nav li { margin: 0; }

.sidebar-nav a {
  display: block;
  padding: 0.6rem 1.5rem;
  color: var(--strata-ink);
  font-weight: 500;
  font-size: 0.92rem;
  border-left: 3px solid transparent;
}
.sidebar-nav a:hover {
  background: var(--strata-tint);
  text-decoration: none;
}
.sidebar-nav a.active {
  background: var(--strata-tint);
  color: var(--strata-navy);
  font-weight: 600;
  border-left-color: var(--strata-navy);
}

.sidebar-group-label {
  margin: 1.25rem 0 0.35rem;
  padding: 0 1.5rem;
  font-family: var(--font-heading);
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--strata-gray);
}

.sidebar-nav a.sidebar-cta {
  margin: 0.35rem 0.75rem;
  padding: 0.5rem 0.75rem;
  border-left: none;
  border-radius: var(--radius);
  background: var(--strata-tint);
  color: var(--strata-navy);
  font-weight: 600;
  font-size: 0.85rem;
}
.sidebar-nav a.sidebar-cta:hover {
  background: var(--strata-blue);
  color: var(--strata-navy-dark);
}
.sidebar-nav a.sidebar-cta.active {
  background: var(--strata-navy);
  color: var(--strata-white);
}

/* --- Hamburger toggle (mobile only, see <768px breakpoint below) --- */
.hamburger-btn {
  display: none;
  flex-direction: column;
  justify-content: center;
  gap: 4px;
  width: 32px;
  height: 32px;
  padding: 0;
  margin-right: 0.75rem;
  background: transparent;
  border: none;
  cursor: pointer;
}
.hamburger-btn span {
  display: block;
  width: 100%;
  height: 2px;
  background: var(--strata-white);
  border-radius: 2px;
  transition: transform 0.2s ease, opacity 0.2s ease;
}
.hamburger-btn.is-active span:nth-child(1) { transform: translateY(6px) rotate(45deg); }
.hamburger-btn.is-active span:nth-child(2) { opacity: 0; }
.hamburger-btn.is-active span:nth-child(3) { transform: translateY(-6px) rotate(-45deg); }

@media (max-width: 767px) {
  .hamburger-btn { display: flex; }

  .app-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 40;
    transform: translateX(-100%);
    transition: transform 0.2s ease;
    box-shadow: var(--shadow-md);
  }
  .app-sidebar.is-open {
    transform: translateX(0);
  }
}

.app-footer {
  text-align: center;
  padding: 1.5rem;
  color: var(--strata-gray);
  font-size: 0.85rem;
  border-top: 1px solid var(--strata-border);
}

/* --- Components --- */
.card {
  background: var(--strata-white);
  border: 1px solid var(--strata-border);
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: var(--shadow-sm);
}

.card + .card { margin-top: 1rem; }

.tint-panel {
  background: var(--strata-tint);
  border-radius: var(--radius);
  padding: 1.25rem 1.5rem;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  border: none;
  border-radius: var(--radius);
  padding: 0.55rem 1.1rem;
  font-family: var(--font-heading);
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
  text-decoration: none;
}
.btn-primary {
  background: var(--strata-navy);
  color: var(--strata-white);
}
.btn-primary:hover { background: var(--strata-navy-dark); text-decoration: none; }
.btn-secondary {
  background: var(--strata-blue);
  color: var(--strata-navy-dark);
}
.btn-secondary:hover { filter: brightness(0.95); text-decoration: none; }
.btn-outline {
  background: transparent;
  color: var(--strata-navy);
  border: 1px solid var(--strata-navy);
}

.badge {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
  background: var(--strata-tint);
  color: var(--strata-navy);
}
.badge-success { background: #eafaf0; color: var(--strata-success); }
.badge-warning { background: #fff6ea; color: #b9770e; }
.badge-danger  { background: #fdecec; color: var(--strata-danger); }

.grid-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
}

table.data-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--strata-white);
  border-radius: var(--radius);
  overflow: hidden;
}
table.data-table th, table.data-table td {
  text-align: left;
  padding: 0.7rem 1rem;
  border-bottom: 1px solid var(--strata-border);
}
table.data-table th {
  background: var(--strata-tint);
  color: var(--strata-navy);
  font-family: var(--font-heading);
  font-weight: 600;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.form-field { margin-bottom: 1.1rem; }
.form-field label {
  display: block;
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--strata-navy);
  margin-bottom: 0.3rem;
}
.form-field input,
.form-field select,
.form-field textarea {
  width: 100%;
  padding: 0.55rem 0.75rem;
  border: 1px solid var(--strata-border);
  border-radius: var(--radius);
  font-family: var(--font-body);
  font-size: 0.95rem;
}
.form-field input:focus,
.form-field select:focus,
.form-field textarea:focus {
  outline: none;
  border-color: var(--strata-blue);
  box-shadow: 0 0 0 3px rgba(55, 171, 255, 0.25);
}

/* --- htmx loading indicators (AI draft / routing-suggestion buttons) ---
   htmx itself injects a default `.htmx-indicator { opacity: 0 }` /
   `.htmx-request .htmx-indicator { opacity: 1 }` stylesheet, but that default is only
   guaranteed while htmx.config.includeIndicatorStyles stays at its default (true) — pin
   it explicitly here so the "Thinking…" affordance doesn't silently disappear if that
   config is ever changed. */
.htmx-indicator { opacity: 0; transition: opacity 150ms ease-in; }
.htmx-request .htmx-indicator,
.htmx-request.htmx-indicator { opacity: 1; }

/* --- Admin "View As" banner (templates/partials/view_as_banner.html) --- */
.view-as-banner {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  flex-wrap: wrap;
  width: 100%;
  padding: 0.6rem 1.5rem;
  background: var(--strata-warning);
  color: var(--strata-navy-dark);
  font-weight: 600;
  font-size: 0.9rem;
  text-align: center;
}
.view-as-banner form { margin: 0; }
.view-as-banner-exit {
  padding: 0.3rem 0.8rem;
  font-size: 0.8rem;
  background: var(--strata-white);
  color: var(--strata-navy-dark);
  border: 1px solid var(--strata-navy-dark);
}
.view-as-banner-exit:hover {
  background: var(--strata-navy-dark);
  color: var(--strata-white);
}

/* --- QuickBooks reauth/refresh-expiry banner (templates/partials/qbo_banner.html) --- */
.qbo-banner {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  flex-wrap: wrap;
  width: 100%;
  padding: 0.6rem 1.5rem;
  font-weight: 600;
  font-size: 0.9rem;
  text-align: center;
}
.qbo-banner-urgent {
  background: var(--strata-danger);
  color: var(--strata-white);
}
.qbo-banner-warning {
  background: var(--strata-warning);
  color: var(--strata-navy-dark);
}
.qbo-banner-action {
  padding: 0.3rem 0.8rem;
  font-size: 0.8rem;
  background: var(--strata-white);
  color: var(--strata-navy-dark);
  border: 1px solid var(--strata-navy-dark);
}
.qbo-banner-action:hover {
  background: var(--strata-navy-dark);
  color: var(--strata-white);
}

/* --- PM console list/board polish (PM console polish spec) --- */

/* Sortable column header links (translation/services pm_list.html) */
.sort-link {
  color: var(--strata-navy);
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
}
.sort-link:hover { text-decoration: underline; }
.sort-indicator { font-size: 0.7rem; }

/* Reusable prev/next pagination control (templates/partials/pagination.html) */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  margin-top: 1.25rem;
}
.pagination-status {
  color: var(--strata-gray);
  font-size: 0.85rem;
}

/* Per-file line-item cards (translation/pm_detail.html) */
.file-card { padding: 1.25rem; }
.file-card + .file-card { margin-top: 1rem; }
.file-info-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}
.file-assignments-panel { margin-top: 0.85rem; }
.file-advance-row {
  margin-top: 0.85rem;
  padding-top: 0.85rem;
  border-top: 1px solid var(--strata-border);
}

/* --- Reporting (Phase 7): period selector, KPI stat cards, CSS-only bar charts ---
   No JS charting library — deliberate architecture decision to match this codebase's
   no-CDN, no-build-step CSP constraint. Bar widths are set via inline `style="width: NN%"`
   (CSP-safe since style-src already allows 'unsafe-inline'), with the percentage computed
   in-template via the built-in {% widthratio %} tag against each row-set's own max value —
   no new Python code, no custom template filter. */

.period-selector {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-bottom: 1.5rem;
}
.period-pill {
  padding: 0.4rem 0.9rem;
  border-radius: 999px;
  background: var(--strata-tint);
  color: var(--strata-navy);
  font-weight: 600;
  font-size: 0.85rem;
  border: 1px solid transparent;
}
.period-pill:hover { background: var(--strata-blue); color: var(--strata-navy-dark); text-decoration: none; }
.period-pill.active { background: var(--strata-navy); color: var(--strata-white); }

/* KPI stat cards (overview + section summaries) — a `.card` with a big number */
.stat-card .stat-label {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--strata-gray);
  font-weight: 700;
  margin-bottom: 0.4rem;
}
.stat-card .stat-value {
  font-family: var(--font-heading);
  font-size: 1.9rem;
  font-weight: 700;
  color: var(--strata-navy);
  line-height: 1.2;
}
.stat-card .stat-sub {
  font-size: 0.85rem;
  color: var(--strata-gray);
  margin-top: 0.3rem;
}

/* CSS-only bar charts */
.bar-chart {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}
.bar-chart-title {
  margin: 0 0 0.75rem;
}
.bar-row {
  display: grid;
  grid-template-columns: minmax(90px, 160px) 1fr auto;
  align-items: center;
  gap: 0.75rem;
}
.bar-row-label {
  font-size: 0.85rem;
  color: var(--strata-ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.bar-track {
  background: var(--strata-tint);
  border-radius: 999px;
  height: 14px;
  overflow: hidden;
  width: 100%;
}
.bar-fill {
  display: block;
  height: 100%;
  border-radius: 999px;
  max-width: 100%;
  background: var(--strata-blue);
}
.bar-fill-navy { background: var(--strata-navy); }
.bar-value {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--strata-navy);
  white-space: nowrap;
  min-width: 3.5rem;
  text-align: right;
}

/* Two-series bar groups (e.g. quoted vs. accepted per client) */
.bar-group + .bar-group {
  margin-top: 0.85rem;
  padding-top: 0.85rem;
  border-top: 1px solid var(--strata-border);
}
.bar-group-label {
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--strata-navy);
  margin-bottom: 0.4rem;
}
.bar-group .bar-row { grid-template-columns: minmax(70px, 110px) 1fr auto; margin-bottom: 0.3rem; }

.bar-legend {
  display: flex;
  gap: 1.25rem;
  font-size: 0.8rem;
  color: var(--strata-gray);
  margin-bottom: 0.75rem;
}
.bar-legend-swatch {
  display: inline-block;
  width: 0.7rem;
  height: 0.7rem;
  border-radius: 3px;
  margin-right: 0.35rem;
  vertical-align: middle;
}

@media (max-width: 600px) {
  .bar-row { grid-template-columns: 1fr; row-gap: 0.2rem; }
  .bar-value { text-align: left; }
}

/* --- Auth pages (allauth login/logout/password-reset — templates/allauth/) --- */
body.auth-page .app-main {
  max-width: 440px;
  margin: 3rem auto;
  background: var(--strata-white);
  border: 1px solid var(--strata-border);
  border-radius: var(--radius);
  padding: 2rem;
  box-shadow: var(--shadow-md);
}
body.auth-page form p { margin: 0 0 1.1rem; }
body.auth-page form label {
  display: block;
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--strata-navy);
  margin-bottom: 0.3rem;
}
body.auth-page form input {
  width: 100%;
  padding: 0.55rem 0.75rem;
  border: 1px solid var(--strata-border);
  border-radius: var(--radius);
  font-family: var(--font-body);
  font-size: 0.95rem;
}
body.auth-page form input:focus {
  outline: none;
  border-color: var(--strata-blue);
  box-shadow: 0 0 0 3px rgba(55, 171, 255, 0.25);
}
body.auth-page .btn { width: 100%; justify-content: center; margin-top: 0.25rem; }
body.auth-page .errorlist {
  list-style: none;
  padding: 0;
  margin: 0.25rem 0 0;
  color: var(--strata-danger);
  font-size: 0.85rem;
}
