/* responsive.css — mobile-first hardening for Trade Corridor.
   Loaded AFTER style.css (which stays byte-identical to the demo); this file
   only adds overrides so the app's panels, tables, forms and modals fit any
   screen with no horizontal overflow. */

/* 1) Never allow the page itself to scroll sideways. */
html, body { max-width: 100%; }
body { overflow-x: hidden; }

/* 2) Long unbreakable strings (URLs, LEI/VAT/passport/session codes, emails)
      must wrap instead of pushing the layout wider than the screen. */
.mono,
.kv dd,
.sec,
.note,
a.link,
.pill { overflow-wrap: anywhere; word-break: break-word; }

/* 3) Media and tables never exceed their container. */
img, svg, video, table { max-width: 100%; }

/* 4) Multi-field auth forms (company registration) need more room than the
      narrow login box: a comfortable centred card with even two-column pairs
      on larger screens. The ≤560px rule below still collapses it to one
      column on phones, where it already looked right. */
.auth .card.card-form { max-width: 560px; }
.auth .card.card-form .form-grid { gap: 0 18px; }

@media (max-width: 560px) {
  /* Modals fit the viewport regardless of any inline max-width. */
  .modal { max-width: calc(100vw - 32px) !important; }

  /* Table cells may wrap so action buttons stack rather than force a wide row. */
  .tbl td, .tbl th { white-space: normal !important; }
  .tbl td form { display: inline-block; margin: 2px 0; }

  /* Inline forms inside panels: inputs go full-width instead of fixed min-widths. */
  .panel-b form input,
  .panel-b form select,
  .panel-b form textarea { min-width: 0 !important; width: 100% !important; }
  .panel-b form { width: 100%; }

  /* Action groups and header actions wrap. */
  .panel-h { flex-wrap: wrap; }
  .panel-h .act { margin-left: 0; flex-wrap: wrap; }
  .page-head .ha { width: 100%; margin-left: 0; }

  /* Right-aligned action cells become left-aligned and wrap on phones. */
  .tbl td[style*="right"] { text-align: left !important; }

  /* Buttons comfortable to tap. */
  .btn.sm { height: 34px; }

  /* Data tables become stacked cards on phones (no cramped 5-column rows,
     no sideways scrolling). Each row is a card; cells flow top-to-bottom.
     Pills self-describe (e.g. "PEP: No match"), so hiding the header is fine. */
  .tbl, .tbl tbody, .tbl tr, .tbl td { display: block; width: 100%; }
  .tbl thead { display: none; }
  .tbl tr {
    border: 1px solid var(--line);
    border-radius: 10px;
    margin: 0 0 10px;
    padding: 10px 12px;
  }
  .tbl td {
    border: none !important;
    padding: 4px 0 !important;
    text-align: left !important;
  }
  .tbl td:empty { display: none; }
}

/* ─ Dashboard · new-registration review queue (v0.25) ─────────────────────
   A clear/flagged inbox of just-registered companies. Green rows are cleared;
   flagged rows reveal a translucent red block listing exactly what to review. */
.newregs .panel-b { display: flex; flex-direction: column; gap: 10px; }
.reg-item {
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  overflow: hidden;
  background: var(--surface-2);
}
.reg-item.flagged { border-color: rgba(244, 67, 54, .38); }
.reg-head {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 12px 14px; text-decoration: none; color: var(--fg);
}
.reg-head:hover { background: rgba(120, 165, 210, .06); }
.reg-name { font-weight: 600; }
.reg-when { margin-right: auto; }
.reg-flags {
  display: flex; flex-direction: column; gap: 6px;
  padding: 10px 14px;
  background: rgba(244, 67, 54, .10);
  border-top: 1px solid rgba(244, 67, 54, .28);
}
.reg-flag { display: flex; align-items: center; gap: 8px; font-size: 13px; color: #ffb0ab; }
.reg-flag::before { content: "•"; color: var(--crit); font-weight: 700; }

@media (max-width: 640px) {
  .reg-when { width: 100%; margin-right: 0; order: 3; }
}

/* ─ Support / help centre (Corridor AI) — v0.29 ─────────────────────────── */
.doc-card { border: 1px solid var(--line); border-radius: var(--r-sm); padding: 12px 14px; background: var(--surface-2); }
.doc-card-h { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.ai-sources { margin-top: 12px; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.ai-sources .chip {
  display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 12px;
  text-decoration: none; color: var(--fg); background: var(--surface);
  border: 1px solid var(--line-2);
}
.ai-sources .chip:hover { border-color: var(--accent); }

/* ─ Topbar: collapse account actions into a dropdown on small screens (v0.30) ─ */
.acct { display: contents; }               /* desktop: items flow inline as before */
.acct-menu { display: contents; }
.acct-toggle { border: 0; padding: 0; font: inherit; cursor: pointer; }

@media (max-width: 900px) {
  .topbar { gap: 10px; }
  .brand { width: auto; min-width: 0; }     /* don't reserve the sidebar width */
  .brand .tag { display: none; }            /* tagline off — keeps the bar short */
  .top-actions { gap: 8px; }
  .acct { display: inline-flex; position: relative; align-items: center; }
  .acct-menu {
    position: absolute; top: calc(100% + 12px); inset-inline-end: 0; z-index: 60;
    display: none; flex-direction: column; align-items: stretch; gap: 10px;
    min-width: 220px; padding: 12px;
    background: var(--surface-2); border: 1px solid var(--line-2);
    border-radius: var(--r-sm); box-shadow: 0 16px 40px rgba(0,0,0,.5);
  }
  .acct.open .acct-menu { display: flex; }
  .acct-menu .note { padding: 2px 4px 8px; border-bottom: 1px solid var(--line); }
  .acct-menu .rowbtn { width: 100%; text-align: start; padding: 9px 11px; }
  .acct-menu form, .acct-menu .langsw { width: 100%; }
  .acct-menu .langsw select { width: 100%; }
}

/* ─ Corridor AI — floating help bubble + chat drawer ─────────────────────── */
.ai-fab {
  position: fixed; inset-inline-end: 18px; bottom: 18px; z-index: 70;
  width: 54px; height: 54px; border-radius: 50%; border: 0; cursor: pointer;
  display: grid; place-items: center; color: var(--accent-ink, #081120);
  background: linear-gradient(145deg, var(--accent), var(--violet));
  box-shadow: 0 12px 28px rgba(0,0,0,.45);
}
.ai-fab:hover { filter: brightness(1.05); }
.ai-drawer {
  position: fixed; inset-inline-end: 18px; bottom: 84px; z-index: 71;
  width: 380px; max-width: calc(100vw - 36px); height: 70vh; max-height: 560px;
  display: none; flex-direction: column; overflow: hidden;
  background: var(--surface); border: 1px solid var(--line-2);
  border-radius: 16px; box-shadow: 0 22px 60px rgba(0,0,0,.55);
}
.ai-drawer.open { display: flex; }
.ai-drawer-h { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.ai-close { border: 0; background: transparent; color: var(--muted); font-size: 18px; cursor: pointer; line-height: 1; }
.ai-close:hover { color: var(--fg); }
.ai-msgs { flex: 1; overflow-y: auto; padding: 14px 16px; display: flex; flex-direction: column; gap: 10px; }
.ai-msg { max-width: 85%; padding: 10px 13px; border-radius: 14px; line-height: 1.55; font-size: 14px; }
.ai-msg.bot { align-self: flex-start; background: var(--surface-2); border: 1px solid var(--line); border-bottom-left-radius: 5px; }
.ai-msg.user { align-self: flex-end; background: linear-gradient(145deg, var(--accent), var(--violet)); color: var(--accent-ink, #081120); border-bottom-right-radius: 5px; }
.ai-msg.thinking { opacity: .7; font-style: italic; }
.ai-input { display: flex; gap: 8px; padding: 12px; border-top: 1px solid var(--line); }
.ai-input input { flex: 1; height: 40px; padding: 0 12px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 9px; color: var(--fg); font-family: inherit; font-size: 14px; }
.ai-boundary { padding: 0 12px 12px; font-size: 11.5px; }

@media (max-width: 560px) {
  .ai-drawer { inset-inline: 0; bottom: 0; width: 100%; max-width: 100%; height: 82vh; max-height: none; border-radius: 16px 16px 0 0; }
  .ai-fab { inset-inline-end: 14px; bottom: 14px; }
}

/* ─ QR codes (passport share links + public verify) — v0.32 ──────────────── */
.qr { display: inline-block; background: #fff; padding: 8px; border-radius: 10px; line-height: 0; }
.qr img, .qr canvas { display: block; }
.qr-wrap { display: flex; flex-direction: column; align-items: center; gap: 8px; }
.qr-wrap .sec { text-align: center; }

/* Public passport block: link + actions beside the QR; stacks on mobile. */
.pub-pass { display: flex; align-items: center; justify-content: space-between; gap: 18px; flex-wrap: wrap; }
.pub-pass-main { flex: 1 1 260px; min-width: 0; }
.pub-pass-main .sec a { word-break: break-all; }
.btn.ok { border-color: var(--ok, #1f8a4c); color: var(--ok, #1f8a4c); }
@media (max-width: 560px) { .pub-pass { justify-content: center; text-align: center; } .pub-pass-main .row { justify-content: center; } }

/* ─ Print-ready document (self-service DPA) — v0.34 ───────────────────────── */
.doc-body { background: #0a0f1a; margin: 0; }
.doc-toolbar { display: flex; gap: 10px; justify-content: flex-end; align-items: center; max-width: 820px; margin: 0 auto; padding: 16px; }
.doc { max-width: 820px; margin: 0 auto 40px; padding: 0 16px; }
.doc-sheet { background: #fff; color: #111; border-radius: 12px; padding: 48px 52px; box-shadow: 0 10px 40px rgba(0,0,0,.35); line-height: 1.6; }
.doc-sheet h1 { font-size: 24px; margin: 0 0 6px; color: #081120; }
.doc-sheet h2 { font-size: 15px; margin: 22px 0 6px; color: #081120; }
.doc-sheet p { margin: 0 0 10px; }
.doc-kicker { font-size: 12px; letter-spacing: .08em; text-transform: uppercase; color: #6b7686; }
.doc-head { border-bottom: 2px solid #eef1f5; padding-bottom: 14px; margin-bottom: 18px; }
.doc-meta { color: #44505f; font-size: 13.5px; margin-top: 6px; }
.doc-tbl { width: 100%; border-collapse: collapse; margin: 8px 0 4px; font-size: 13.5px; }
.doc-tbl th, .doc-tbl td { text-align: left; border: 1px solid #e3e8ef; padding: 8px 10px; vertical-align: top; color: #111; }
.doc-tbl th { background: #f6f8fb; color: #44505f; font-weight: 600; }
.doc-sign { display: flex; gap: 40px; margin-top: 34px; flex-wrap: wrap; }
.doc-sign-col { flex: 1 1 240px; }
.doc-sign-role { font-size: 12px; letter-spacing: .06em; text-transform: uppercase; color: #6b7686; margin-bottom: 26px; }
.doc-sign-line { border-top: 1px solid #111; padding-top: 6px; min-height: 1px; }
.doc-sign-line.doc-sign-filled { font-family: "Georgia", serif; font-style: italic; font-size: 18px; border-top-color: #111; }
.doc-sheet .sec { color: #6b7686; font-size: 12.5px; }
.doc-foot { margin-top: 28px; border-top: 1px solid #eef1f5; padding-top: 12px; font-size: 11.5px; color: #8a93a0; }
@media print {
  .no-print { display: none !important; }
  .doc-body { background: #fff; }
  .doc { max-width: none; margin: 0; padding: 0; }
  .doc-sheet { box-shadow: none; border-radius: 0; padding: 0; }
}
