/* ============================================================
   FRANQUIA LEGAL — screen patterns
   Page-level building blocks used across the client, admin and
   public screens. Loaded after fl-theme.css.
   ============================================================ */

/* ---------- shared text bits ---------- */
.page-sub { color: var(--text-muted); }
.mel-link { color: var(--color-primary-text); font-weight: 700; text-decoration: none; }
.mel-link:hover { text-decoration: underline; }

/* ---------- mobile burger (admin shell) ---------- */
.fl-mobile-burger { display: none; }
@media (max-width: 900px) {
  .fl-mobile-burger {
    display: inline-grid;
    position: fixed; top: 14px; left: 14px; z-index: 40;
  }
}
.fl-sidebar-backdrop {
  position: fixed; inset: 0; z-index: 55;
  background: color-mix(in srgb, var(--slate-900), transparent 45%);
  opacity: 0; pointer-events: none; transition: opacity .2s ease;
  display: none;
}
@media (max-width: 900px) {
  .fl-sidebar-backdrop { display: block; }
  .fl-shell.is-open .fl-sidebar-backdrop { opacity: 1; pointer-events: auto; }
}

/* ============================================================
   PUBLIC / AUTH — split hero screen
   ============================================================ */
.fl-auth-split { display: grid; grid-template-columns: 1.05fr .95fr; min-height: 100vh; }
.fl-auth-hero {
  position: relative; overflow: hidden;
  background: radial-gradient(120% 100% at 28% 18%, #17345f 0%, #0c2142 45%, #081628 100%);
  color: #fff; padding: 48px 58px; display: flex; flex-direction: column;
}
/* the Franquia Legal lockup is two-line, so it needs a little more height
   than a single-line wordmark would */
.fl-auth-hero .hero-logo { position: relative; z-index: 2; }
.fl-auth-hero .hero-logo img { height: 68px; }
/* auto margins top AND bottom centre the copy in the space left over below the
   logo, instead of pinning it to the bottom of the panel */
.fl-auth-hero .hero-copy {
  margin-top: auto; margin-bottom: auto;
  max-width: 420px; position: relative; z-index: 2;
}
.fl-auth-hero h2 {
  font-size: 2.7rem; font-weight: 800; line-height: 1.08;
  letter-spacing: -.022em; margin: 0 0 18px; color: #fff;
}
.fl-auth-hero p { color: #aabdd8; font-size: 1.06rem; line-height: 1.6; margin: 0; }
.fl-auth-hero .hero-bullet {
  display: inline-flex; align-items: center; gap: 10px;
  margin-top: 22px; font-weight: 700; color: #e3ebf6;
}
.fl-auth-hero .hero-bullet svg { width: 18px; height: 18px; color: #5fd08a; }
/* the brand "F" sits fully inside the panel so the mark stays readable —
   scaling it past the edges turns it into stray diagonal lines */
.fl-fmotif {
  position: absolute; right: 24px; top: 50%; transform: translateY(-50%);
  height: min(68%, 600px); width: auto; max-width: none;
  opacity: .55; z-index: 0; pointer-events: none; user-select: none;
}
.fl-auth-form {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 40px 24px; background: var(--bg-base);
}
.auth-card {
  width: 100%; max-width: 410px; background: #fff;
  border: 1px solid var(--slate-200); border-radius: 16px;
  box-shadow: var(--shadow-md); padding: 34px 32px;
}
.auth-card-wide { max-width: 560px; }
.auth-card h1 { font-size: 1.7rem; margin-bottom: 4px; }
.auth-card .field { margin-bottom: 14px; }
.pw-wrap { position: relative; }
.pw-wrap .input { padding-right: 42px; }
.pw-eye {
  position: absolute; right: 8px; top: 50%; transform: translateY(-50%);
  background: none; border: 0; color: var(--slate-400); cursor: pointer;
  padding: 6px; display: grid; place-items: center;
}
.pw-eye:hover { color: var(--slate-600); }
.pw-eye svg { width: 18px; height: 18px; }
.auth-foot { margin-top: 22px; color: var(--slate-400); font-size: 13px; text-align: center; }
@media (max-width: 880px) {
  .fl-auth-split { grid-template-columns: 1fr; }
  .fl-auth-hero { display: none; }
}

/* ---------- simple public page (terms, faq) ---------- */
.fl-public-main { padding: 32px; }
.fl-public-inner { max-width: 900px; margin: 0 auto; }
.fl-public-bar {
  display: flex; align-items: center; gap: 16px;
  padding: 0 32px; height: 70px; background: #fff;
  border-bottom: 1px solid var(--slate-200);
}
.fl-public-bar img { height: 30px; display: block; }
.fl-public-bar .spacer { flex: 1; }

/* ============================================================
   CLIENT — dashboard
   ============================================================ */
.fl-chat-fab {
  position: fixed; right: 24px; bottom: 24px;
  width: 56px; height: 56px; border-radius: 50%;
  background: var(--fl-blue); color: #fff; border: 0;
  display: grid; place-items: center;
  box-shadow: var(--shadow-lg); cursor: pointer; z-index: 40;
}
.fl-chat-fab svg { width: 24px; height: 24px; }

.pts-hero {
  position: relative; overflow: hidden;
  border: 1px solid var(--slate-200); border-radius: 16px;
  background: linear-gradient(110deg, var(--fl-blue-050), #fff 68%);
  box-shadow: var(--shadow-sm);
}
.pts-hero .big {
  font-size: 3rem; font-weight: 800; letter-spacing: -.035em;
  line-height: 1; color: var(--fl-blue);
}
.pts-hero-glow {
  position: absolute; right: -50px; top: -50px;
  width: 200px; height: 200px; border-radius: 50%;
  background: var(--fl-grad-soft); opacity: .65;
}
.pts-hero-row {
  position: relative; padding: 28px 30px;
  display: flex; justify-content: space-between; align-items: center;
  gap: 24px; flex-wrap: wrap;
}
.pts-hero-actions {
  display: flex; flex-direction: column; gap: 10px;
  align-items: stretch; min-width: 220px;
}

.qa-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
.qa {
  display: flex; flex-direction: column; gap: 10px; padding: 18px;
  border: 1px solid var(--slate-200); border-radius: 14px; background: #fff;
  text-decoration: none; color: var(--text-main); font-weight: 700;
  transition: .15s; box-shadow: var(--shadow-xs);
}
.qa:hover { border-color: var(--fl-blue); transform: translateY(-3px); box-shadow: var(--shadow-sm); }
.qa-ic {
  width: 42px; height: 42px; border-radius: 11px;
  background: var(--fl-blue-050); color: var(--fl-blue);
  display: grid; place-items: center;
}
.qa-ic svg { width: 21px; height: 21px; }
@media (max-width: 760px) { .qa-grid { grid-template-columns: 1fr 1fr; } }

/* ============================================================
   ADMIN — dashboard band + KPI tiles
   ============================================================ */
.admin-band {
  position: relative; overflow: hidden; border-radius: 18px;
  padding: 28px 30px;
  background: radial-gradient(130% 160% at 12% 0%, #17345f 0%, #0b1d38 60%);
  color: #fff; margin-bottom: 26px;
}
.admin-band-glow {
  position: absolute; right: -50px; top: -60px;
  width: 240px; height: 240px; border-radius: 50%;
  background: var(--fl-grad); opacity: .2; filter: blur(8px);
}
.admin-band-row {
  display: flex; justify-content: space-between; align-items: flex-start;
  gap: 16px; position: relative; flex-wrap: wrap;
}
.admin-band-eyebrow {
  font-size: 11px; letter-spacing: .09em; text-transform: uppercase;
  font-weight: 800; color: #9fb3d0;
}
.admin-band-title { color: #fff; margin: 6px 0 4px; font-size: 1.9rem; }
.admin-band-sub { color: #aabdd8; margin: 0; max-width: 52ch; }
.admin-band-cta { background: #fff; color: var(--fl-blue-700); border: 0; }
.admin-band-cta:hover:not(:disabled) { background: #eef4fb; color: var(--fl-blue-700); }
.admin-band-kpis {
  display: flex; gap: 14px; margin-top: 24px;
  position: relative; flex-wrap: wrap;
}
.admin-band-kpis > * {
  flex: 1; min-width: 118px;
  background: rgba(255, 255, 255, .06);
  border: 1px solid rgba(255, 255, 255, .08);
  border-radius: 12px; padding: 14px 16px;
  text-decoration: none; transition: background .15s; display: block;
}
.admin-band-kpis a:hover { background: rgba(255, 255, 255, .12); }
.admin-band-kpis .bk-n {
  font-size: 1.9rem; font-weight: 800; letter-spacing: -.03em;
  line-height: 1; color: #fff;
}
.admin-band-kpis .bk-l { font-size: 12.5px; color: #9fb3d0; font-weight: 700; margin-top: 5px; }
.admin-band-kpis .bk-warn { color: #ffbf6b; }

.kpi-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; }
.kpi-tile { position: relative; overflow: hidden; }
.kpi-tile .kpi-top { display: flex; align-items: center; justify-content: space-between; }
.kpi-tile .kpi-num {
  font-size: 2.4rem; font-weight: 800; letter-spacing: -0.03em;
  line-height: 1.05; margin-top: 14px; color: var(--text-main);
}
.kpi-tile .kpi-lbl { color: var(--text-muted); font-weight: 700; font-size: 14px; margin-top: 4px; }
.kpi-tile .kpi-foot {
  margin-top: 12px; font-size: 12.5px; color: var(--slate-400);
  font-weight: 700; display: flex; align-items: center; gap: 6px;
}
@media (max-width: 760px) { .kpi-grid { grid-template-columns: 1fr; } }

/* ============================================================
   TICKET / CHAT THREAD
   ============================================================ */
.tk-split { display: grid; grid-template-columns: 320px 1fr; gap: 24px; align-items: start; }
@media (max-width: 780px) { .tk-split { grid-template-columns: 1fr; } }

.tk-thread { display: flex; flex-direction: column; gap: 16px; }
.msg { display: flex; gap: 12px; max-width: 80%; }
.msg-in { align-self: flex-start; }
.msg-out { align-self: flex-end; flex-direction: row-reverse; }
.msg-bubble {
  background: #fff; border: 1px solid var(--slate-200); border-radius: 14px;
  box-shadow: var(--shadow-xs); padding: 14px 16px; min-width: 0;
}
.msg-out .msg-bubble { background: var(--fl-blue-050); border-color: var(--fl-blue-100); }
.msg-meta { display: flex; align-items: baseline; gap: 8px; margin-bottom: 7px; }
.msg-out .msg-meta { flex-direction: row-reverse; }
.msg-name { font-weight: 800; font-size: 14px; }
.msg-out .msg-name { color: var(--fl-blue-700); }
.msg-time { font-size: 12px; color: var(--slate-400); font-weight: 700; font-family: var(--font-mono); }
.msg-text { margin: 0; line-height: 1.6; white-space: pre-wrap; overflow-wrap: break-word; }
.msg-out .msg-text { text-align: right; }
.msg-files { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 12px; }
.msg-out .msg-files { justify-content: flex-end; }

.doc-chip {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 8px 14px; border: 1px solid var(--slate-200); border-radius: 10px;
  font-weight: 700; font-size: 13.5px; color: var(--fl-blue-700);
  text-decoration: none; background: var(--slate-50);
}
.doc-chip:hover { background: var(--fl-blue-050); }
.doc-chip svg { width: 16px; height: 16px; color: var(--slate-400); }
.msg-out .doc-chip { background: #fff; }

.kv-line { display: flex; flex-direction: column; gap: 4px; }

.composer {
  background: #fff; border: 1px solid var(--slate-200);
  border-radius: 14px; box-shadow: var(--shadow-sm);
  padding: 16px; margin-top: 18px;
}
.composer-foot {
  display: flex; align-items: center; justify-content: space-between;
  flex-wrap: wrap; gap: 12px; margin-top: 12px;
}
.btn-approve { background: #1e8e4e; color: #fff; border-color: transparent; }
.btn-approve:hover:not(:disabled) { background: #187a43; color: #fff; }

/* ============================================================
   SUBSCRIPTION / PLANS
   ============================================================ */
.plan-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 18px; }
.plan-card {
  position: relative; background: #fff; border: 1px solid var(--slate-200);
  border-radius: 16px; padding: 24px; box-shadow: var(--shadow-sm);
  display: flex; flex-direction: column; gap: 14px;
  transition: transform .15s, box-shadow .15s, border-color .15s;
}
.plan-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-md); border-color: var(--fl-blue); }
.plan-card.is-featured { border-color: var(--fl-blue); box-shadow: var(--shadow-md); }
.plan-badge {
  position: absolute; top: -11px; right: 18px;
  background: var(--fl-grad); color: #fff;
  font-size: 11px; font-weight: 800; letter-spacing: .05em; text-transform: uppercase;
  padding: 4px 10px; border-radius: 999px;
}
.plan-name { font-size: var(--text-lg); font-weight: 800; }
.plan-price { display: flex; align-items: baseline; gap: 6px; }
.plan-price .amount { font-size: 2.2rem; font-weight: 800; letter-spacing: -.03em; color: var(--text-main); }
.plan-price .per { color: var(--text-muted); font-weight: 700; font-size: 14px; }
.plan-feats { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 9px; }
.plan-feats li { display: flex; align-items: flex-start; gap: 9px; font-size: 14.5px; }
.plan-feats svg { width: 17px; height: 17px; color: var(--color-success); flex-shrink: 0; margin-top: 2px; }

/* ---------- settings nav ---------- */
.settings-nav { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 22px; }
.settings-nav a {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 9px 14px; border-radius: 10px;
  color: var(--slate-600); font-weight: 700; font-size: 14.5px; text-decoration: none;
  border: 1px solid transparent; transition: background .15s, color .15s;
}
.settings-nav a svg { width: 17px; height: 17px; color: var(--slate-400); }
.settings-nav a:hover { background: var(--slate-100); color: var(--slate-800); }
.settings-nav a.is-active { background: var(--fl-blue-050); color: var(--fl-blue-700); }
.settings-nav a.is-active svg { color: var(--fl-blue); }
.settings-nav a.is-danger { color: var(--color-error); }
.settings-nav a.is-danger svg { color: var(--color-error); }

/* ---------- FAQ accordion ---------- */
.faq-list { display: flex; flex-direction: column; gap: 10px; }
.faq-item {
  background: #fff; border: 1px solid var(--slate-200);
  border-radius: 12px; overflow: hidden;
}
.faq-item summary {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 16px 18px; cursor: pointer; font-weight: 800; list-style: none;
}
.faq-item summary::-webkit-details-marker { display: none; }
.faq-item summary::after {
  content: ""; width: .5rem; height: .5rem; flex-shrink: 0;
  border-right: 2px solid var(--slate-400); border-bottom: 2px solid var(--slate-400);
  transform: rotate(45deg); transition: transform .2s ease;
}
.faq-item[open] summary::after { transform: rotate(-135deg); }
.faq-item .faq-body {
  padding: 0 18px 18px; color: var(--text-muted); line-height: 1.7;
}

/* ---------- misc ---------- */
.stack { display: flex; flex-direction: column; gap: var(--spacing-md); }
.stack-lg { display: flex; flex-direction: column; gap: var(--spacing-lg); }
.row-gap { display: flex; gap: var(--spacing-sm); align-items: center; flex-wrap: wrap; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: var(--spacing-md); }
@media (max-width: 900px) { .grid-4 { grid-template-columns: 1fr 1fr; } }
@media (max-width: 560px) { .grid-4 { grid-template-columns: 1fr; } }

/* ---------- shell stacking (client / public) ---------- */
.fl-app-stack { flex: 1; display: flex; flex-direction: column; min-height: 100vh; }
.fl-app-stack > main { flex: 1; }

/* the two-line lockup needs a little more height than a single-line wordmark */
.fl-topbar-logo img { height: 38px; }
.fl-sidebar-logo img { height: 40px; }

/* ---------- client dashboard: welcome card (no active plan) ---------- */
.welcome { position: relative; overflow: hidden; }
.welcome::after {
  content: ""; position: absolute; right: -60px; top: -60px;
  width: 240px; height: 240px; border-radius: 50%;
  background: var(--fl-grad-soft); opacity: .7; z-index: 0;
}
.welcome > * { position: relative; z-index: 1; }
.welcome-row {
  display: flex; justify-content: space-between; align-items: center;
  gap: 24px; flex-wrap: wrap;
}
.pts-pill {
  display: inline-flex; align-items: baseline; gap: 8px;
  padding: 8px 16px; border-radius: 999px;
  background: var(--fl-blue-050); color: var(--fl-blue-700); font-weight: 800;
}
.pts-pill .n { font-size: 1.5rem; letter-spacing: -.02em; }

/* ---------- buy extra points ---------- */
/* quantity, running total and the buy button on one line; the total column is
   sized so the amount can grow without shifting the button around */
.buy-pts {
  display: grid;
  grid-template-columns: minmax(120px, 180px) minmax(140px, auto) auto;
  align-items: end; gap: 18px;
}
.buy-pts .input { text-align: right; font-weight: 800; font-size: 16px; }
.buy-pts-total { display: flex; flex-direction: column; gap: 6px; }
.buy-pts-amount {
  font-size: 1.5rem; font-weight: 800;
  color: var(--fl-blue); letter-spacing: -.02em; line-height: 1.2;
}

@media (max-width: 620px) {
  .buy-pts { grid-template-columns: 1fr; align-items: stretch; }
  .buy-pts .input { text-align: left; }
}

/* ---------- payment method picker (subscribe modal) ---------- */
.pay-opts { display: flex; flex-direction: column; gap: 10px; margin-top: 18px; }
.pay-opt {
  display: flex; align-items: flex-start; gap: 14px; width: 100%;
  padding: 16px; text-align: left; cursor: pointer;
  background: #fff; border: 1px solid var(--slate-200); border-radius: 14px;
  font: inherit; color: inherit;
  transition: border-color .15s, background-color .15s;
}
.pay-opt:hover, .pay-opt:focus-visible {
  border-color: var(--fl-blue); background: var(--fl-blue-050);
}
.pay-opt svg { width: 22px; height: 22px; flex-shrink: 0; margin-top: 2px; color: var(--fl-blue); }
.pay-opt span { display: flex; flex-direction: column; gap: 3px; }
.pay-opt strong { font-weight: 800; }
.pay-opt small { font-size: 13px; line-height: 1.4; color: var(--text-muted); }

/* ---------- checkbox tint ---------- */
.fl-app .checkbox { width: 18px; height: 18px; border-radius: 5px; accent-color: var(--fl-blue); }

/* ---------- sortable table headers ---------- */
.th-sort {
  display: inline-flex; align-items: center; gap: 6px;
  color: inherit; text-decoration: none; font: inherit;
}
.th-sort svg { width: 14px; height: 14px; opacity: .4; }
.th-sort:hover svg { opacity: .8; }
.th-sort.is-on svg { opacity: 1; color: var(--fl-blue); }

/* ---------- settings: sidebar menu + panel ---------- */
.settings-split { display: grid; grid-template-columns: 240px 1fr; gap: 24px; align-items: start; }
@media (max-width: 760px) { .settings-split { grid-template-columns: 1fr; } }

/* ---------- lightweight modal (Alpine-driven) ---------- */
.fl-modal-backdrop {
  position: fixed; inset: 0; z-index: 80;
  background: color-mix(in srgb, var(--slate-900), transparent 45%);
  backdrop-filter: blur(3px);
  display: flex; align-items: center; justify-content: center; padding: 20px;
}
/* The class sets display:flex, which outranks the user-agent rule for the
   hidden attribute, so hiding has to be spelled out for a modal driven by
   plain JS rather than by a framework directive. */
.fl-modal-backdrop[hidden] { display: none; }
.fl-modal {
  background: #fff; border-radius: var(--radius-lg);
  box-shadow: var(--shadow-modal); padding: 28px;
  width: 100%; max-width: 460px;
}

/* ============================================================
   AI ANSWER — flowing border + glow (admin ticket composer)
   ============================================================ */
@keyframes spin-slow {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}
.ai-wrap { position: relative; width: 100%; border-radius: var(--radius-lg); }
.ai-flow-border {
  position: absolute; inset: -3px;
  border-radius: var(--radius-lg); overflow: hidden;
  opacity: 0; transition: opacity .3s ease; pointer-events: none; z-index: 0;
}
.ai-flow-border.is-on { opacity: 1; }
.ai-flow-border .siri-gradient {
  position: absolute; left: 50%; top: 50%;
  width: 250%; aspect-ratio: 1; margin-left: -125%; margin-top: -125%;
  background: conic-gradient(from 0deg, #3b82f6, #8b5cf6, #efaaaa, #06b6d4, #3b82f6);
  animation: spin-slow 3s linear infinite;
}
.ai-wrap .textarea { position: relative; z-index: 1; }

@keyframes siri-inset-loop {
  0%   { box-shadow: inset 0 0 10px rgba(59, 130, 246, 0.4); }
  25%  { box-shadow: inset 0 0 20px rgba(139, 92, 246, 0.4); }
  50%  { box-shadow: inset 0 0 20px rgba(239, 168, 168, 0.4); }
  75%  { box-shadow: inset 0 0 10px rgba(6, 182, 212, 0.4); }
  100% { box-shadow: inset 0 0 10px rgba(59, 130, 246, 0.4); }
}
.ai-glow-pulse {
  animation: siri-inset-loop 3s infinite linear;
  background-color: var(--slate-50);
}
.btn-ai { background: #5b53d6; color: #fff; border-color: transparent; }
.btn-ai:hover:not(:disabled) { background: #4b44bb; color: #fff; }

/* The driver.js tour is skinned in its own fl-tour.css, which is loaded
   after the library's stylesheet so it can win on cascade order rather than
   on !important. */

/* keep identity + action cells on one line */
/* Capped on purpose: a long client or company name would otherwise stretch
   the row until .table-scroll starts scrolling sideways, which buries the
   status and action columns. The full value stays reachable through the
   cell's title attribute. */
.id-name {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  /* 16ch measured, not guessed: it is the widest cap that keeps the whole
     row inside the admin content column, so a long company name no longer
     pushes the status and action cells out of view. */
  max-width: 16ch;
}
.row-actions { flex-wrap: nowrap; }

/* Tighter side padding for a table that has more columns than the admin
   content width comfortably fits. Nine columns at 20px a side spend 360px on
   padding alone, which is what pushed the ticket rows into a sideways scroll
   on a 1366px screen. Vertical padding is left alone so the rows keep their
   height. The .data-card variant is spelled out because mel-app.css targets
   that context specifically and would otherwise win on specificity. */
.table-compact td, .table-compact th,
.data-card table.table-compact td, .data-card table.table-compact th {
  padding-left: 9px;
  padding-right: 9px;
}

/* One line, clipped, for a value of unbounded length in a generic list cell.
   Without the inline-block the ellipsis never kicks in, since a plain inline
   span has no width of its own to overflow. */
.cell-clamp {
  display: inline-block;
  max-width: 34ch;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  vertical-align: middle;
}
/* A list with many columns has to clamp harder than a three-column one, so
   the generic template picks this variant by column count instead of every
   list paying for the widest one. */
.table-clamp-sm .cell-clamp { max-width: 18ch; }

/* ---------- service ↔ category matrix row ---------- */
.cat-row {
  display: grid; grid-template-columns: 180px 1fr auto;
  align-items: center; gap: 16px;
  padding: 10px 12px; border-radius: 10px; background: var(--slate-50);
}
.cat-row .input { max-width: 120px; }
@media (max-width: 700px) {
  .cat-row { grid-template-columns: 1fr; gap: 8px; }
  .cat-row .input { max-width: 100%; }
}

/* ============================================================
   ADMIN CHAT PANEL
   ============================================================ */
.chat-panel { display: flex; flex-direction: column; height: 750px; }
.chat-history {
  flex: 1; overflow-y: auto;
  padding: 24px; display: flex; flex-direction: column; gap: 20px;
}
.chat-row { display: flex; flex-direction: column; }
.chat-row.is-user { align-items: flex-end; }
.chat-row.is-bot { align-items: flex-start; }
.chat-bubble {
  max-width: 80%; border-radius: 14px; padding: 14px 16px;
  font-size: var(--text-sm); line-height: 1.6; white-space: pre-wrap;
  background: var(--slate-100); color: var(--text-main);
  border: 1px solid var(--slate-200);
}
.chat-row.is-user .chat-bubble {
  background: var(--fl-blue-050); border-color: var(--fl-blue-100);
  color: var(--fl-blue-700); border-top-right-radius: 4px;
}
.chat-row.is-bot .chat-bubble { border-top-left-radius: 4px; }
.chat-meta {
  margin-top: 6px; display: flex; align-items: center; gap: 8px;
  font-size: 12px; color: var(--slate-400); font-weight: 600;
}
.chat-moderation {
  margin-top: 10px; width: 100%; max-width: 80%;
  background: var(--honey-50); border: 1px solid color-mix(in srgb, var(--color-warning), white 65%);
  border-radius: 12px; padding: 16px;
}
.chat-composer { padding: 16px 20px; border-top: 1px solid var(--slate-200); background: var(--slate-50); }
@media (max-width: 760px) { .chat-panel { height: 70vh; } .chat-bubble, .chat-moderation { max-width: 100%; } }

/* ---------- simple column layout (public pages) ---------- */
.fl-cols { display: grid; gap: 48px; align-items: center; padding: 48px 16px; margin: 0 auto; }
.fl-cols-2 { grid-template-columns: 1fr; }
@media (min-width: 1024px) { .fl-cols-2 { grid-template-columns: 1fr 1fr; } }

/* ============================================================
   CLIENT CHAT WIDGET (Fran)
   ============================================================ */
.fl-chat-fab.is-hidden { opacity: 0; pointer-events: none; transform: scale(.9); }
.fl-chat-fab { transition: opacity .2s, transform .2s; }

.fl-chat-window {
  position: fixed; right: 24px; bottom: 92px; z-index: 50;
  width: 380px; max-width: calc(100vw - 32px);
  height: 520px; max-height: calc(100vh - 130px);
  background: #fff; border: 1px solid var(--slate-200);
  border-radius: 16px; box-shadow: var(--shadow-lg);
  display: flex; flex-direction: column; overflow: hidden;
  transform-origin: bottom right; transform: scale(.95);
  opacity: 0; pointer-events: none; transition: all .2s ease;
}
.fl-chat-window.is-open { transform: scale(1); opacity: 1; pointer-events: auto; }

.fl-chat-head {
  background: var(--fl-blue); color: #fff;
  padding: 14px 16px; display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.fl-chat-avatar {
  width: 40px; height: 40px; border-radius: 50%;
  background: rgba(255, 255, 255, .2); display: grid; place-items: center; flex-shrink: 0;
}
.fl-chat-avatar svg { width: 21px; height: 21px; }
.fl-chat-icon {
  background: transparent; border: 0; color: #cfe4fa; cursor: pointer;
  padding: 6px; border-radius: 8px; display: grid; place-items: center;
}
.fl-chat-icon:hover { background: rgba(255, 255, 255, .14); color: #fff; }
.fl-chat-icon svg { width: 18px; height: 18px; }

.fl-chat-body {
  flex: 1; overflow-y: auto; padding: 16px;
  background: var(--bg-base); display: flex; flex-direction: column; gap: 12px;
}
.fl-chat-row { display: flex; width: 100%; }
.fl-chat-row.is-user { justify-content: flex-end; }
.fl-chat-row.is-bot { justify-content: flex-start; }
.fl-chat-bubble {
  max-width: 85%; border-radius: 16px; padding: 11px 14px;
  font-size: var(--text-sm); line-height: 1.55; box-shadow: var(--shadow-xs);
  background: #fff; color: var(--text-main); border: 1px solid var(--slate-200);
  border-bottom-left-radius: 4px;
}
.fl-chat-row.is-user .fl-chat-bubble {
  background: var(--fl-blue); color: #fff; border-color: transparent;
  border-bottom-left-radius: 16px; border-bottom-right-radius: 4px;
}
.fl-chat-foot { padding: 14px 16px; background: #fff; border-top: 1px solid var(--slate-200); }
.fl-chat-send {
  position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
  background: transparent; border: 0; color: var(--fl-blue);
  cursor: pointer; padding: 7px; border-radius: 8px; display: grid; place-items: center;
}
.fl-chat-send:hover { background: var(--fl-blue-050); }
.fl-chat-send svg { width: 18px; height: 18px; }

@media (max-width: 480px) {
  .fl-chat-window { right: 12px; left: 12px; width: auto; bottom: 84px; }
}

/* Nectar computes --menu-item-active-bg from the :root (honey) primary, so the
   settings menu would stay amber while every other active nav is blue. */
.fl-app .menu-item.is-active { background: var(--fl-blue-050); color: var(--fl-blue-700); }
.fl-app .menu-item.is-danger.is-active { background: var(--color-error-bg); color: var(--color-error); }

/* the drawer close button needs an explicit icon size */
.fl-sidebar-burger svg { width: 20px; height: 20px; }

/* ---------- generic (Alpine-directive) modal shell ---------- */
.fl-modal-shell { display: none; position: fixed; inset: 0; z-index: 80; align-items: center; justify-content: center; padding: 20px; }
.fl-modal-shell.is-active { display: flex; }
.fl-modal-backdrop-layer {
  position: absolute; inset: 0;
  background: color-mix(in srgb, var(--slate-900), transparent 45%);
  backdrop-filter: blur(3px);
}
.fl-modal-shell .fl-modal { position: relative; z-index: 1; }

/* ============================================================
   OVERRIDES / REFINEMENTS (round 2)
   Nectar's reset makes every <svg> display:block, so icons inside
   a text-align:center block sit flush left. These rules give the
   affected patterns real centring instead.
   ============================================================ */

/* ---------- empty states ---------- */
.empty {
  display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 14px;
  text-align: center; padding: 64px 24px; color: var(--text-muted);
}
.empty svg { margin: 0; }
.empty-ic {
  width: 66px; height: 66px; border-radius: 18px;
  background: var(--slate-100); color: var(--slate-400);
  display: grid; place-items: center; flex-shrink: 0;
}
.empty-ic svg { width: 28px; height: 28px; }
.empty-title { font-weight: 700; font-size: 15.5px; color: var(--text-main); margin: 0; }
.empty-text { margin: 0; max-width: 46ch; font-size: 14px; line-height: 1.6; }
.empty .btn { margin-top: 4px; }

/* ---------- points balance in the client topbar ---------- */
/* Sits inside .fl-topnav so it rides the right-hand cluster, but reads as a
   readout rather than another nav destination. */
.fl-topnav .fl-balance {
  gap: 6px;
  margin-right: 10px;
  padding: 7px 13px;
  border-radius: 999px;
  background: var(--fl-blue-050);
  color: var(--fl-blue-700);
  border: 1px solid color-mix(in srgb, var(--fl-blue) 18%, transparent);
}
.fl-topnav .fl-balance:hover {
  background: color-mix(in srgb, var(--fl-blue) 12%, #fff);
  color: var(--fl-blue-700);
}
.fl-topnav .fl-balance svg { width: 15px; height: 15px; color: var(--fl-blue); }
.fl-balance-n { font-weight: 800; font-size: 15px; font-variant-numeric: tabular-nums; }
.fl-balance-l { font-weight: 700; color: var(--text-muted); }

@media (max-width: 700px) {
  /* the number is the point; the word "pontos" is the first thing to go */
  .fl-balance-l { display: none; }
  .fl-topnav .fl-balance { margin-right: 4px; padding: 6px 10px; }
}

/* ---------- back link (replaces the old "Voltar" button) ---------- */
.back-link {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 13.5px; font-weight: 700; color: var(--text-muted);
  text-decoration: none; margin-bottom: 8px;
  transition: color .15s;
}
.back-link:hover { color: var(--fl-blue-700); }
.back-link svg { width: 15px; height: 15px; }

/* ---------- ticket detail: give the screen (and the detail rail) room ---------- */
.tk-split { grid-template-columns: minmax(340px, 380px) minmax(0, 1fr); gap: 28px; }
.fl-main-inner:has(> .tk-split) { max-width: 1440px; }
.fl-client-inner:has(> .tk-split) { max-width: 1320px; }
@media (max-width: 1000px) { .tk-split { grid-template-columns: 1fr; } }

/* the detail rail sticks while the thread scrolls */
.tk-aside { position: sticky; top: 24px; }
.tk-aside .card-body { display: flex; flex-direction: column; gap: 18px; }
.tk-aside .field { margin-bottom: 0; }
/* the service field stacks its approval badge underneath instead of squeezing
   the select into half the rail */
.tk-service-badge { margin-top: 8px; display: inline-flex; }

/* ---------- FAQ accordion ---------- */
.faq-list { display: flex; flex-direction: column; gap: 12px; }
.faq-item {
  background: #fff; border: 1px solid var(--slate-200);
  border-radius: 14px; box-shadow: var(--shadow-xs);
  overflow: hidden; transition: border-color .15s, box-shadow .15s;
}
.faq-item:hover { border-color: var(--slate-300); }
.faq-item[open] { border-color: var(--fl-blue-100); box-shadow: var(--shadow-sm); }
/* Nectar styles bare <summary> with a slate header fill — the card supplies
   its own surface, so reset it back to transparent */
.faq-item summary {
  display: flex; align-items: center; gap: 16px;
  padding: 18px 20px; cursor: pointer; list-style: none;
  background: transparent;
  font-weight: 700; font-size: 15.5px; color: var(--text-main);
  transition: color .15s;
}
.faq-item[open] summary { border-bottom: 1px solid var(--slate-100); }
.faq-item summary::-webkit-details-marker { display: none; }
.faq-item summary::after { content: none; }
.faq-item summary:hover { color: var(--fl-blue-700); }
.faq-q { flex: 1; min-width: 0; }
.faq-chev {
  width: 32px; height: 32px; border-radius: 50%; flex-shrink: 0;
  background: var(--slate-100); color: var(--slate-500);
  display: grid; place-items: center;
  transition: transform .22s ease, background .15s, color .15s;
}
.faq-chev svg { width: 16px; height: 16px; }
.faq-item[open] .faq-chev {
  background: var(--fl-blue-050); color: var(--fl-blue); transform: rotate(180deg);
}
.faq-body {
  padding: 18px 20px 20px; color: var(--text-muted);
  line-height: 1.75; font-size: 14.5px;
}
.faq-body > :last-child { margin-bottom: 0; }

/* an empty-state row is not a real record — don't give it the row hover tint */
.empty-title:empty, .empty-text:empty { display: none; }
.table-hover tbody tr:has(.empty):hover,
table:not([class]) tbody tr:has(.empty):hover { background-color: transparent; }

/* read-only facts sit in a tinted panel so they read as status, not as inputs */
/* one per row: SLA strings like "Atrasado em 12d 5h" wrap badly in two columns */
.tk-facts {
  display: grid; grid-template-columns: 1fr; gap: 14px;
  background: var(--slate-50); border: 1px solid var(--slate-200);
  border-radius: 12px; padding: 14px 16px; margin-bottom: 4px;
}
.tk-aside form { display: flex; flex-direction: column; gap: 16px; }
.tk-aside form > .field { margin-bottom: 0; }

/* Q&A reads better on a narrower measure than a full-width dashboard page */
.fl-client-inner:has(> .faq-list) { max-width: 860px; }

/* Pill tone for a flag whose *true* side is the exceptional one. mel-app.css
   ships yn-yes (green) and yn-no (grey), which assume true is the good state.
   A column like "deleted" inverts that: the value worth catching the eye is
   the one that says the record is gone. */
.yn-alert {
  background: var(--color-error-bg);
  color: var(--color-error);
}

/* Approval history on a ticket. Shown to the client and to the firm from the
   same component, so it has to sit comfortably in either sidebar. */
.approval-log { display: flex; flex-direction: column; gap: 8px; }
.approval-log ul { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.approval-log li {
  border-left: 2px solid var(--color-success);
  padding: 2px 0 2px 10px;
}
.approval-head { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; }
/* Clamped for the same reason the table cells are: this sits in a narrow
   sidebar, and a long company name would otherwise stack three lines tall and
   push the buttons below it out of reach. min-width:0 is what lets a flex item
   shrink below its content at all. */
.approval-who {
  font-weight: 700;
  font-size: 14px;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.approval-when { color: var(--text-muted); font-size: 12px; white-space: nowrap; }
.approval-what { color: var(--text-muted); font-size: 13px; }

/* Label with an action on the right — used where a field can be added to from
   the field itself, so the trigger has to sit on the label line rather than
   stealing a row of its own in a narrow sidebar. */
.fl-label-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
}
.btn-inline-add {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
  font: inherit;
  font-size: 12px;
  font-weight: 700;
  color: var(--fl-blue);
}
.btn-inline-add:hover { text-decoration: underline; }
.btn-inline-add svg { width: 13px; height: 13px; }

/* Two fields side by side inside a modal that is too narrow for four rows. */
.qs-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
