/* ============================================================================
   2Bee CRM — foglio di stile
   Palette derivata dal logo: giallo favo, blu notte del lettering "2bee",
   blu del lettering "innovation". Il blu è il colore d'azione (leggibile su
   bianco), il giallo l'accento, il blu notte il testo forte.
   ========================================================================== */

:root {
  --bee-yellow: #fabb18;
  --bee-yellow-soft: #fff6dd;
  --bee-yellow-dark: #d99a00;
  --navy: #22314f;
  --navy-soft: #33456a;
  --blue: #3e6db5;
  --blue-dark: #2f5691;
  --blue-soft: #eef3fb;

  --ink: #1a2438;
  --text: #3a4557;
  --muted: #77839a;
  --muted-2: #a8b1c2;
  --border: #e6e9f0;
  --border-2: #d3d9e4;
  --page: #f5f7fa;
  --surface: #ffffff;

  --success: #1f9254;
  --success-soft: #e7f5ed;
  --warning: #b8730b;
  --warning-soft: #fdf3e0;
  --danger: #c8362f;
  --danger-soft: #fdeceb;

  --shadow-xs: 0 1px 2px rgba(24, 39, 75, 0.05);
  --shadow-sm: 0 2px 8px rgba(24, 39, 75, 0.07);
  --shadow-md: 0 8px 24px rgba(24, 39, 75, 0.10);
  --shadow-lg: 0 18px 48px rgba(24, 39, 75, 0.16);
  --radius: 10px;
  --radius-lg: 14px;

  --topbar-h: 58px;
  --subbar-h: 44px;
  --font: Inter, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Arial, sans-serif;
  --font-brand: Poppins, 'Century Gothic', Futura, 'Segoe UI', Arial, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
html, body, #app { min-height: 100%; }

body {
  margin: 0;
  background: var(--page);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--blue); }
a:hover { color: var(--blue-dark); }

/* ── Marchio ─────────────────────────────────────────────────────────────── */

.brand { display: flex; align-items: center; gap: 10px; user-select: none; }
.brand-mark { width: 30px; height: 21px; flex: 0 0 auto; }
.brand-word {
  font-family: var(--font-brand);
  font-size: 18px;
  letter-spacing: -0.3px;
  white-space: nowrap;
  line-height: 1;
}
.brand-word b { color: var(--navy); font-weight: 600; }
.brand-word span { color: var(--blue); font-weight: 400; }
.brand-word.on-dark b, .brand-word.on-dark span { color: #fff; }
.brand-word.on-dark span { opacity: 0.72; }

/* ── Accesso ─────────────────────────────────────────────────────────────── */

.auth-page {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(320px, 46%) minmax(0, 1fr);
}

.auth-brand {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 52px 48px;
  background: linear-gradient(160deg, var(--navy) 0%, #16203a 100%);
  position: relative;
  overflow: hidden;
}
/* Favo decorativo, molto tenue: presenza di marchio senza rumore. */
.auth-brand::after {
  content: "";
  position: absolute;
  right: -90px;
  bottom: -70px;
  width: 420px;
  height: 291px;
  background: url("/assets/img/logo-mark.svg") no-repeat center / contain;
  opacity: 0.07;
}
.auth-brand h1 {
  margin: 46px 0 14px;
  font-size: 30px;
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: -0.6px;
  color: #fff;
}
.auth-brand p { margin: 0; color: rgba(255, 255, 255, 0.62); font-size: 15px; line-height: 1.7; max-width: 40ch; }
.auth-points { list-style: none; padding: 0; margin: 28px 0 0; display: flex; flex-direction: column; gap: 10px; }
.auth-points li {
  color: rgba(255, 255, 255, 0.78);
  font-size: 13.5px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.auth-points li::before {
  content: "";
  width: 7px; height: 7px;
  border-radius: 2px;
  background: var(--bee-yellow);
  flex: 0 0 auto;
}
.auth-foot { color: rgba(255, 255, 255, 0.35); font-size: 12px; position: relative; z-index: 1; }

.auth-panel-wrap { display: grid; place-items: center; padding: 32px; background: var(--surface); }
.auth-panel { width: min(400px, 100%); }
.auth-panel h2 { margin: 22px 0 4px; font-size: 21px; font-weight: 650; color: var(--ink); }
.auth-panel .auth-sub { color: var(--muted); font-size: 13.5px; margin-bottom: 24px; }

/* ── Barra di navigazione superiore ──────────────────────────────────────── */

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

.topbar {
  height: var(--topbar-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 0 20px;
  position: sticky;
  top: 0;
  z-index: 50;
}

.topnav { display: flex; align-items: center; gap: 2px; flex: 1; min-width: 0; overflow: hidden; }

.topnav-item {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 34px;
  padding: 0 12px;
  border-radius: 8px;
  color: var(--muted);
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  border: none;
  background: none;
  font-family: inherit;
  transition: background 0.14s ease, color 0.14s ease;
}
.topnav-item:hover { background: var(--page); color: var(--navy); }
.topnav-item.active { background: var(--navy); color: #fff; font-weight: 600; }
.topnav-item.active .nav-icon svg { stroke: var(--bee-yellow); }
.topnav-item .nav-icon { width: 16px; height: 16px; display: flex; flex: 0 0 auto; }
.topnav-item .nav-icon svg { width: 16px; height: 16px; stroke: currentColor; fill: none; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.topnav-count {
  font-size: 10.5px;
  font-weight: 700;
  background: var(--danger-soft);
  color: var(--danger);
  border-radius: 20px;
  padding: 0 5px;
  min-width: 17px;
  text-align: center;
}
.topnav-item.active .topnav-count { background: rgba(255,255,255,0.2); color: #fff; }

.topbar-right { display: flex; align-items: center; gap: 10px; margin-left: auto; flex: 0 0 auto; }

.user-avatar {
  width: 32px; height: 32px;
  border-radius: 9px;
  background: var(--navy);
  color: var(--bee-yellow);
  display: grid;
  place-items: center;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.3px;
  flex: 0 0 auto;
}
.assignee-avatar {
  width: 24px; height: 24px;
  border-radius: 7px;
  background: var(--blue-soft);
  color: var(--blue-dark);
  border: 1px solid #fff;
  display: grid;
  place-items: center;
  font-size: 10px;
  font-weight: 700;
}

.hamburger-btn {
  display: none;
  border: 1px solid var(--border-2);
  background: var(--surface);
  border-radius: 8px;
  width: 34px; height: 34px;
  font-size: 16px;
  cursor: pointer;
  color: var(--navy);
}

/* ── Pagina ──────────────────────────────────────────────────────────────── */

.app-content { flex: 1; min-height: 0; }
.page { padding: 22px 24px 40px; max-width: 1680px; margin: 0 auto; }

.page-header { display: flex; align-items: flex-start; gap: 16px; flex-wrap: wrap; margin-bottom: 18px; }
.page-header-title h1 { margin: 0; font-size: 22px; font-weight: 680; color: var(--ink); letter-spacing: -0.4px; }
.page-header-title p { margin: 3px 0 0; color: var(--muted); font-size: 13px; }
.page-header-right { margin-left: auto; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

/* ── Schede metrica ──────────────────────────────────────────────────────── */

.metrics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

.metric-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 15px 16px;
  position: relative;
  overflow: hidden;
  transition: box-shadow 0.16s ease, transform 0.16s ease;
}
.metric-card.clickable { cursor: pointer; }
.metric-card.clickable:hover { box-shadow: var(--shadow-sm); transform: translateY(-1px); }
.metric-accent { position: absolute; inset: 0 auto 0 0; width: 3px; }
.metric-label { font-size: 11.5px; font-weight: 600; letter-spacing: 0.4px; text-transform: uppercase; color: var(--muted); }
.metric-value { font-size: 26px; font-weight: 700; color: var(--ink); line-height: 1.15; margin: 6px 0 2px; letter-spacing: -0.8px; }
.metric-sub { font-size: 12px; color: var(--muted); }
.metric-sub.up { color: var(--success); }
.metric-sub.down { color: var(--danger); }

/* Pannello filtri: si apre sotto la barra di ricerca, non dentro la tabella. */
.filter-panel {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 12px 14px;
  margin-bottom: 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
}

/* Dati commerciali di testa nella scheda azienda: fatturato, addetti, priorità. */
.fact-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
  gap: 8px;
  margin-bottom: 14px;
}
.fact {
  background: var(--page);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px 10px;
  min-width: 0;
}
.fact-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.4px;
  text-transform: uppercase;
  color: var(--muted-2);
}
.fact-value {
  font-size: 13.5px;
  font-weight: 650;
  color: var(--ink);
  margin-top: 2px;
  overflow-wrap: anywhere;
}

.stat-row { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.stat-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 5px 13px 5px 10px;
  cursor: pointer;
  transition: border-color 0.14s ease, background 0.14s ease;
}
.stat-chip:hover { border-color: var(--border-2); }
.stat-chip.active { border-color: var(--navy); background: var(--navy); }
.stat-chip.active .stat-chip-value, .stat-chip.active .stat-chip-label { color: #fff; }
.stat-chip-dot { width: 8px; height: 8px; border-radius: 3px; flex: 0 0 auto; }
.stat-chip-value { font-size: 14px; font-weight: 700; color: var(--ink); }
.stat-chip-label { font-size: 12.5px; color: var(--muted); }

/* ── Contenitori dati ────────────────────────────────────────────────────── */

.data-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}
.data-card + .data-card { margin-top: 14px; }
.data-card-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 13px 18px;
  border-bottom: 1px solid var(--border);
}
.data-card-title { font-size: 13.5px; font-weight: 650; color: var(--ink); }
.data-card-body { padding: 14px 18px; }
.data-card-body.flush { padding: 0; }

.dash-grid { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 14px; align-items: start; }
.dash-col { display: flex; flex-direction: column; gap: 14px; min-width: 0; }

.list-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 18px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background 0.12s ease;
}
.list-row:last-child { border-bottom: none; }
.list-row:hover { background: var(--page); }
.list-row-main { min-width: 0; flex: 1; }
.list-row-title { font-size: 13px; font-weight: 600; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list-row-sub { font-size: 11.5px; color: var(--muted); margin-top: 1px; }
.list-row-side { flex: 0 0 auto; display: flex; align-items: center; gap: 6px; }

.date-badge {
  flex: 0 0 auto;
  width: 42px;
  text-align: center;
  border-radius: 9px;
  background: var(--blue-soft);
  padding: 4px 0 5px;
}
.date-badge-day { font-size: 16px; font-weight: 700; color: var(--navy); line-height: 1; }
.date-badge-mon { font-size: 10px; text-transform: uppercase; color: var(--blue-dark); letter-spacing: 0.5px; }

.empty-hint { padding: 26px 18px; text-align: center; color: var(--muted-2); font-size: 13px; }

/* ── Tabelle ─────────────────────────────────────────────────────────────── */

.table-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.table-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  padding: 11px 14px;
  border-bottom: 1px solid var(--border);
  background: #fbfcfe;
}
.table-toolbar .count { margin-left: auto; font-size: 12px; color: var(--muted); white-space: nowrap; }

.bulk-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  padding: 9px 14px;
  background: var(--navy);
  color: #fff;
  font-size: 12.5px;
}
.bulk-bar b { color: var(--bee-yellow); }

.ant-table-wrapper .ant-table { font-size: 13px; }
.ant-table-wrapper .ant-table-thead > tr > th {
  background: #fbfcfe !important;
  color: var(--muted) !important;
  font-size: 11.5px !important;
  font-weight: 650 !important;
  text-transform: uppercase;
  letter-spacing: 0.35px;
  border-bottom: 1px solid var(--border) !important;
}
.ant-table-wrapper .ant-table-tbody > tr > td { border-bottom: 1px solid var(--border) !important; }
.ant-table-wrapper .ant-table-tbody > tr:hover > td { background: #fbfcfe !important; }
tr.selected-row > td { background: var(--blue-soft) !important; }
tr.risk-row > td { box-shadow: inset 3px 0 0 var(--danger); }

.cell-title { font-weight: 600; font-size: 13px; color: var(--ink); }
.cell-sub { font-size: 11.5px; color: var(--muted); margin-top: 1px; }
.cell-muted { color: var(--muted-2); }
.cell-money { font-variant-numeric: tabular-nums; font-weight: 650; color: var(--ink); }

.table-actions { display: flex; gap: 6px; align-items: center; justify-content: flex-end; }

/* ── Pastiglie di stato ──────────────────────────────────────────────────── */

.pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 600;
  white-space: nowrap;
  line-height: 18px;
}
.pill-dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; flex: 0 0 auto; }

.rating-dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; flex: 0 0 auto; }

/* ── Vista con dettaglio affiancato ──────────────────────────────────────── */

.split-layout { display: grid; grid-template-columns: minmax(0, 1fr); gap: 14px; align-items: start; }
.split-layout.has-detail { grid-template-columns: minmax(0, 1fr) minmax(380px, 470px); }
.split-detail {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  position: sticky;
  top: calc(var(--topbar-h) + 16px);
  max-height: calc(100vh - var(--topbar-h) - 32px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.panel-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  background: #fbfcfe;
  flex: 0 0 auto;
}
.panel-inner { padding: 16px 18px 22px; overflow-y: auto; flex: 1; }
.split-close-btn {
  border: none;
  background: none;
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  color: var(--muted);
  padding: 0 4px;
}
.split-close-btn:hover { color: var(--ink); }

.detail-hero { display: flex; align-items: flex-start; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.detail-hero h2 { margin: 0; font-size: 18px; font-weight: 680; color: var(--ink); letter-spacing: -0.3px; }
.detail-hero-sub { font-size: 12.5px; color: var(--muted); margin-top: 3px; }

.detail-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 2px 16px; }
.detail-row { padding: 7px 0; border-bottom: 1px dashed var(--border); min-width: 0; }
.detail-row.full { grid-column: 1 / -1; }
.detail-label { font-size: 10.5px; font-weight: 650; text-transform: uppercase; letter-spacing: 0.4px; color: var(--muted-2); }
.detail-value { font-size: 13px; color: var(--text); margin-top: 2px; word-break: break-word; }

.section-title { font-size: 12.5px; font-weight: 650; color: var(--ink); display: flex; align-items: center; gap: 8px; }
.section-bar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.section-bar .spacer { flex: 1; }

/* Riquadro "prossima azione": il campo che tiene in vita il follow-up. */
.next-action-box {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius);
  background: var(--bee-yellow-soft);
  border: 1px solid #f5e2ac;
  margin-bottom: 14px;
}
.next-action-box.overdue { background: var(--danger-soft); border-color: #f6cdca; }
.next-action-box.empty { background: var(--page); border-color: var(--border); }
.next-action-text { font-size: 13px; color: var(--ink); font-weight: 550; }
.next-action-when { font-size: 11.5px; color: var(--muted); margin-top: 2px; }

/* ── Cronologia attività ─────────────────────────────────────────────────── */

.timeline { position: relative; padding-left: 20px; }
.timeline::before { content: ""; position: absolute; left: 5px; top: 4px; bottom: 4px; width: 2px; background: var(--border); }
.timeline-item { position: relative; padding: 0 0 16px; }
.timeline-dot {
  position: absolute;
  left: -20px;
  top: 3px;
  width: 12px; height: 12px;
  border-radius: 50%;
  background: var(--surface);
  border: 2px solid var(--border-2);
}
.timeline-dot.positive { border-color: var(--success); background: var(--success); }
.timeline-dot.negative { border-color: var(--danger); background: var(--danger); }
.timeline-dot.neutral { border-color: var(--blue); background: var(--blue); }
.timeline-head { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; }
.timeline-title { font-size: 13px; font-weight: 600; color: var(--ink); }
.timeline-time { font-size: 11.5px; color: var(--muted); margin-top: 2px; }
.timeline-note {
  font-size: 12.5px;
  color: var(--text);
  background: var(--page);
  border-radius: 8px;
  padding: 7px 10px;
  margin-top: 6px;
  white-space: pre-wrap;
}
.timeline-empty { padding: 22px 0; text-align: center; color: var(--muted-2); font-size: 13px; }

.contact-card {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 11px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 8px;
  background: var(--surface);
}
.contact-card-info { flex: 1; min-width: 0; }

.comment-list { display: flex; flex-direction: column; gap: 8px; }
.comment-item { background: var(--page); border-radius: var(--radius); padding: 9px 11px; }
.comment-head { display: flex; align-items: baseline; gap: 8px; }
.comment-author { font-size: 12.5px; font-weight: 650; color: var(--ink); }
.comment-time { font-size: 11px; color: var(--muted-2); }
.comment-body { font-size: 12.5px; color: var(--text); white-space: pre-wrap; margin-top: 3px; }

/* ── Editor riunioni a schermo intero ────────────────────────────────────── */

.meeting-fullscreen-modal .ant-modal { max-width: 100vw; top: 0; padding-bottom: 0; }
.meeting-editor { display: flex; flex-direction: column; height: 100%; background: var(--surface); }
.meeting-editor-topbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 18px;
  border-bottom: 1px solid var(--border);
  flex: 0 0 auto;
}
.meeting-editor-topbar-label { font-size: 13px; color: var(--muted); margin-right: auto; }
.meeting-editor-meta { display: flex; gap: 10px; flex-wrap: wrap; padding: 14px 18px 8px; }
.meeting-editor-title-input { font-size: 17px !important; font-weight: 650; flex: 1 1 320px; }
.meeting-format-bar {
  display: flex;
  gap: 4px;
  align-items: center;
  padding: 7px 18px;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}
.format-sep { width: 1px; height: 18px; background: var(--border-2); margin: 0 4px; }
.meeting-editor-body { flex: 1; overflow-y: auto; padding: 20px 18px; min-height: 0; }
.meeting-editor-content {
  max-width: 860px;
  margin: 0 auto;
  min-height: 100%;
  outline: none;
  font-size: 14.5px;
  line-height: 1.75;
  color: var(--text);
}
.meeting-editor-content h1 { font-size: 24px; }
.meeting-editor-content h2 { font-size: 19px; }
.meeting-editor-content h3 { font-size: 16px; }
.meeting-editor-footer {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 18px;
  border-top: 1px solid var(--border);
  flex: 0 0 auto;
}
.meeting-wordcount { font-size: 12px; color: var(--muted); margin-right: auto; }

/* ── Ricerca globale ─────────────────────────────────────────────────────── */

.search-result { padding: 9px 12px; border-radius: 8px; cursor: pointer; display: flex; gap: 10px; align-items: center; }
.search-result:hover { background: var(--page); }
.search-kind {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  font-weight: 700;
  color: var(--muted-2);
  flex: 0 0 62px;
}

/* ── Adattamento a schermi stretti ───────────────────────────────────────── */

@media (max-width: 1180px) {
  .split-layout.has-detail { grid-template-columns: minmax(0, 1fr); }
  .split-detail { position: static; max-height: none; }
  .dash-grid { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 900px) {
  .auth-page { grid-template-columns: minmax(0, 1fr); }
  .auth-brand { display: none; }
}

@media (max-width: 860px) {
  .page { padding: 16px 14px 32px; }
  .hamburger-btn { display: inline-flex; align-items: center; justify-content: center; }
  .topnav {
    position: fixed;
    top: var(--topbar-h);
    left: 0;
    right: 0;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    box-shadow: var(--shadow-md);
    flex-direction: column;
    align-items: stretch;
    padding: 8px;
    gap: 2px;
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.2s ease, padding 0.2s ease;
    z-index: 49;
  }
  .topnav.open { max-height: 70vh; overflow-y: auto; padding: 8px; }
  .topnav-item { height: 40px; }
  .brand-word { font-size: 16px; }
}
