/* Shell e componentes do sistema SellCore — adaptado do mockup
   documentacao/painel_sellcore.html para uma página real (sem o cartão
   de vitrine, navegação de verdade em vez de troca de painel via JS). */

*, *::before, *::after { box-sizing: border-box; }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-body);
  line-height: 1.5;
  font-size: 15.5px;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { font-family: var(--font-display); color: var(--ink); text-wrap: balance; margin: 0; }
p { margin: 0; }
ul { list-style: none; margin: 0; padding: 0; }
a { color: inherit; text-decoration: none; }
button { font-family: inherit; }
a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible {
  outline: 2px solid var(--gold); outline-offset: 2px; border-radius: 4px;
}
::selection { background: var(--gold-wash); }

/* ============ THEME TOGGLE ============ */
.theme-toggle {
  display: flex; gap: 2px; background: var(--paper-raised);
  border: 1px solid var(--line); border-radius: 999px; padding: 3px;
}
.theme-toggle button {
  appearance: none; border: none; background: transparent; color: var(--ink-faint);
  font-size: .72rem; font-weight: 600; padding: .4rem .7rem; border-radius: 999px; cursor: pointer;
  transition: background .15s ease, color .15s ease;
}
.theme-toggle button[aria-pressed="true"] { background: var(--gold); color: var(--gold-ink); }

/* Variante flutuante — só para páginas sem topbar própria (login). */
.theme-toggle.floating { position: fixed; top: 1rem; right: 1rem; z-index: 80; box-shadow: 0 2px 10px var(--shadow); }

/* ============ APP SHELL ============ */
.app-frame { display: grid; grid-template-columns: 15.5rem minmax(0, 1fr); min-height: 100vh; }

.app-side {
  background: var(--paper-sunk); border-right: 1px solid var(--line);
  display: flex; flex-direction: column; padding: 1.2rem 1rem;
}
.side-brand { display: flex; align-items: center; gap: .6rem; padding: .3rem .4rem 1rem; margin-bottom: .6rem; border-bottom: 1px solid var(--line); }
.side-brand .chip { width: 30px; height: 30px; border-radius: 8px; background: #fff; border: 1px solid var(--line); display: flex; align-items: center; justify-content: center; overflow: hidden; flex: none; }
.side-brand .chip img { width: 22px; height: 22px; object-fit: contain; }
.side-brand .word { font-family: var(--font-display); font-weight: 800; font-size: .95rem; }

.app-nav { display: flex; flex-direction: column; gap: .15rem; flex: 1; }
.app-nav a {
  display: flex; align-items: center; gap: .65rem; width: 100%; text-align: left;
  border-radius: 9px; padding: .58rem .7rem; font-size: .85rem; color: var(--ink-soft);
  transition: background .15s ease, color .15s ease;
}
.app-nav a svg { flex: none; width: 17px; height: 17px; color: var(--ink-faint); }
.app-nav a:hover { background: var(--paper-raised); }
.app-nav a.active { background: var(--gold-wash); color: var(--ink); font-weight: 700; }
.app-nav a.active svg { color: var(--gold); }
.app-nav a .lock { margin-left: auto; font-size: .62rem; color: var(--ink-faint); font-weight: 600; }
.app-nav .disabled { display: flex; align-items: center; gap: .65rem; padding: .58rem .7rem; font-size: .85rem; color: var(--ink-faint); cursor: default; }
.app-nav .disabled svg { flex: none; width: 17px; height: 17px; }
.nav-sep { height: 1px; background: var(--line); margin: .6rem .3rem; }

.side-foot { border-top: 1px solid var(--line); padding-top: .8rem; margin-top: .4rem; display: flex; align-items: center; gap: .55rem; }
.side-foot .av { width: 28px; height: 28px; border-radius: 50%; background: var(--gold); color: var(--gold-ink); display: flex; align-items: center; justify-content: center; font-family: var(--font-display); font-weight: 800; font-size: .7rem; flex: none; }
.side-foot .who b { display: block; font-size: .8rem; font-weight: 700; }
.side-foot .who span { font-size: .68rem; color: var(--ink-faint); }
.side-foot .logout { margin-left: auto; font-size: .72rem; color: var(--ink-faint); }
.side-foot .logout:hover { color: var(--ink); }

.app-main { display: flex; flex-direction: column; min-width: 0; }
.app-top { display: flex; align-items: center; justify-content: space-between; padding: 1rem 1.6rem; border-bottom: 1px solid var(--line); flex: none; }
.app-top h1 { font-size: 1.1rem; font-weight: 800; }
.top-actions { display: flex; align-items: center; gap: .9rem; position: relative; }

.bell-wrap { position: relative; }
.bell-btn {
  position: relative; width: 2.2rem; height: 2.2rem; border-radius: 50%;
  border: 1px solid var(--line); background: var(--paper-raised); color: var(--ink-soft);
  display: flex; align-items: center; justify-content: center; cursor: pointer;
}
.bell-btn:hover { color: var(--ink); }
.bell-btn .badge {
  position: absolute; top: -3px; right: -3px; min-width: 16px; height: 16px; padding: 0 3px;
  border-radius: 999px; background: var(--gold); color: var(--gold-ink);
  font-size: .6rem; font-weight: 800; display: flex; align-items: center; justify-content: center;
  border: 2px solid var(--paper-raised);
}
.notif-panel {
  position: absolute; top: calc(100% + .6rem); right: 0; width: 20rem;
  background: var(--paper-raised); border: 1px solid var(--line); border-radius: 12px;
  box-shadow: 0 16px 36px var(--shadow); z-index: 40;
  opacity: 0; visibility: hidden; transform: translateY(-6px);
  transition: opacity .15s ease, transform .15s ease, visibility .15s;
}
.notif-panel.open { opacity: 1; visibility: visible; transform: translateY(0); }
.notif-panel .np-head { display: flex; justify-content: space-between; align-items: center; padding: .8rem 1rem; border-bottom: 1px solid var(--line); }
.notif-panel .np-head h4 { font-size: .85rem; font-weight: 700; }
.np-empty { padding: 1.6rem 1rem; text-align: center; color: var(--ink-faint); font-size: .82rem; }
.np-group-lbl { font-size: .64rem; text-transform: uppercase; letter-spacing: .08em; color: var(--ink-faint); padding: .65rem 1rem .3rem; }
.np-item { display: flex; gap: .6rem; padding: .55rem 1rem; align-items: flex-start; }
.np-item:hover { background: var(--paper-sunk); }
.np-item .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--gold); margin-top: .4rem; flex: none; }
.np-item .tx b { display: block; font-size: .8rem; font-weight: 600; line-height: 1.35; }
.np-item .tx span { font-size: .7rem; color: var(--ink-faint); font-family: var(--font-mono); }

.top-user { display: flex; align-items: center; gap: .5rem; }
.top-user .av { width: 28px; height: 28px; border-radius: 50%; background: var(--gold); color: var(--gold-ink); display: flex; align-items: center; justify-content: center; font-family: var(--font-display); font-weight: 800; font-size: .7rem; }
.top-user .who { display: none; }
@media (min-width: 640px) { .top-user .who { display: block; } }
.top-user .who b { display: block; font-size: .78rem; font-weight: 700; }
.top-user .who span { font-size: .68rem; color: var(--ink-faint); }

.page { flex: 1; padding: 1.6rem 1.8rem 3rem; }

/* ============ FLASH MESSAGES ============ */
.flash { border-radius: 10px; padding: .7rem 1rem; margin-bottom: 1.2rem; font-size: .88rem; font-weight: 600; }
.flash.ok { background: var(--good-wash); color: var(--good); }
.flash.erro { background: var(--bad-wash); color: var(--bad); }

/* ============ STAT / DASHBOARD ============ */
.stat-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: .9rem; margin-bottom: 1.6rem; }
@media (max-width: 760px) { .stat-row { grid-template-columns: repeat(2, 1fr); } }
.stat-card { border: 1px solid var(--line); border-radius: 11px; padding: 1rem 1.1rem; background: var(--paper-raised); }
.stat-card .n { font-family: var(--font-display); font-weight: 900; font-size: 1.8rem; color: var(--gold); font-variant-numeric: tabular-nums; line-height: 1; }
.stat-card .l { font-size: .78rem; color: var(--ink-soft); margin-top: .45rem; }

.section h2 { font-size: 1rem; font-weight: 700; margin-bottom: .9rem; }
.attn-list { display: flex; flex-direction: column; gap: .5rem; }
.attn-item { display: flex; align-items: center; gap: .8rem; border: 1px solid var(--line); border-radius: 10px; padding: .75rem 1rem; background: var(--paper-raised); }
.attn-item .stripe { width: 4px; align-self: stretch; border-radius: 3px; flex: none; background: var(--gold); }
.attn-item .tx { flex: 1; min-width: 0; }
.attn-item .tx b { display: block; font-size: .85rem; font-weight: 600; }
.attn-item .tx span { font-size: .76rem; color: var(--ink-faint); }

/* ============ EMPTY STATE ============ */
.ph-empty {
  border: 1.5px dashed var(--line); border-radius: 12px; padding: 3rem 1.5rem;
  text-align: center; color: var(--ink-faint); display: flex; flex-direction: column;
  align-items: center; gap: .6rem;
}
.ph-empty svg { width: 34px; height: 34px; color: var(--ink-faint); }
.ph-empty b { color: var(--ink-soft); font-size: .92rem; display: block; }
.ph-empty p { font-size: .82rem; max-width: 24rem; }

/* ============ CARDS / TABLES (CRUD) ============ */
.card { background: var(--paper-raised); border: 1px solid var(--line); border-radius: 12px; padding: 1.4rem 1.5rem; }
.toolbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1.2rem; gap: 1rem; flex-wrap: wrap; }
.btn {
  display: inline-flex; align-items: center; gap: .4rem; font-size: .85rem; font-weight: 700;
  padding: .55rem 1rem; border-radius: 8px; border: 1px solid var(--line);
  background: var(--paper-raised); color: var(--ink); cursor: pointer;
}
.btn.primary { background: var(--gold); color: var(--gold-ink); border-color: var(--gold); }
.btn:hover { filter: brightness(0.97); }

.tbl-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 12px; }
table.data { width: 100%; border-collapse: collapse; font-size: .87rem; min-width: 32rem; background: var(--paper-raised); }
table.data th, table.data td { text-align: left; padding: .75rem 1rem; border-bottom: 1px solid var(--line); }
table.data th { font-size: .7rem; text-transform: uppercase; letter-spacing: .05em; color: var(--ink-faint); background: var(--paper-sunk); font-weight: 600; }
table.data tr:last-child td { border-bottom: none; }
table.data tr:hover td { background: var(--paper-sunk); }
table.data td.num { font-variant-numeric: tabular-nums; font-family: var(--font-mono); font-size: .83rem; white-space: nowrap; }

.status-pill { display: inline-flex; font-size: .68rem; font-weight: 700; padding: .18rem .55rem; border-radius: 999px; }
.status-pill.ativa { background: var(--good-wash); color: var(--good); }
.status-pill.inativa { background: var(--bad-wash); color: var(--bad); }

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1.1rem; max-width: 40rem; }
@media (max-width: 640px) { .form-grid { grid-template-columns: 1fr; } }
.field { display: flex; flex-direction: column; gap: .35rem; }
.field.full { grid-column: 1 / -1; }
.field label { font-size: .78rem; font-weight: 600; color: var(--ink-soft); }
.field input, .field select, .field textarea {
  font-family: inherit; font-size: .88rem; padding: .55rem .7rem; border-radius: 8px;
  border: 1px solid var(--line); background: var(--paper); color: var(--ink);
}
.field textarea { font-family: inherit; }
.form-actions { display: flex; gap: .7rem; margin-top: 1.6rem; }

/* ============ AUTH ============ */
.auth-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 1.5rem; }
.auth-card { width: 100%; max-width: 22rem; background: var(--paper-raised); border: 1px solid var(--line); border-radius: 14px; padding: 2rem 1.8rem; box-shadow: 0 16px 40px var(--shadow); }
.auth-card .chip { width: 44px; height: 44px; border-radius: 10px; background: #fff; border: 1px solid var(--line); display: flex; align-items: center; justify-content: center; margin: 0 auto 1rem; overflow: hidden; }
.auth-card .chip img { width: 32px; height: 32px; object-fit: contain; }
.auth-card h1 { font-size: 1.15rem; text-align: center; margin-bottom: 1.4rem; }
.auth-card .field { margin-bottom: 1rem; }
.auth-card .btn { width: 100%; justify-content: center; margin-top: .4rem; }

/* ============ MÓDULO 1 — CENTRAL DE COMUNICAÇÃO ============ */
/* Mesmas classes do mockup documentacao/central_comunicacao.html —
   design já aprovado, só adaptado pra ocupar a altura real da página em
   vez do cartão de vitrine do mockup. */
.page.page-chat { padding: 0; display: flex; flex-direction: column; min-height: 0; flex: 1; }
.page.page-chat .flash { margin: 1rem 1.2rem 0; }
.com-wrap { flex: 1; min-height: 0; display: grid; grid-template-columns: 19rem minmax(0, 1fr); }

.conv-list { border-right: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; }
.conv-list .list-head { padding: 1rem 1.2rem .8rem; border-bottom: 1px solid var(--line); }
.conv-list .list-head h3 { font-size: .95rem; font-weight: 700; }
.filters { display: flex; gap: .4rem; flex-wrap: wrap; margin-top: .7rem; }
.chip-f { font-size: .68rem; font-weight: 600; padding: .28rem .6rem; border-radius: 999px; border: 1px solid var(--line); color: var(--ink-soft); background: var(--paper-raised); }
.chip-f.active { background: var(--gold); color: var(--gold-ink); border-color: var(--gold); }
.conv-items { overflow-y: auto; flex: 1; }
.conv-item { display: block; padding: .85rem 1.2rem; border-bottom: 1px solid var(--line); border-left: 3px solid transparent; }
.conv-item.selected { background: var(--gold-wash); border-left-color: var(--gold); }
.conv-item .row1 { display: flex; justify-content: space-between; align-items: baseline; gap: .5rem; }
.conv-item .cliente { font-weight: 700; font-size: .86rem; }
.conv-item .time { font-family: var(--font-mono); font-size: .68rem; color: var(--ink-faint); flex: none; }
.conv-item .assunto { font-size: .8rem; color: var(--ink-soft); margin-top: .15rem; }
.conv-item .snippet { font-size: .76rem; color: var(--ink-faint); margin-top: .35rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.status-pill.us { background: var(--gold-wash); color: var(--gold); }
.status-pill.client { background: var(--paper-sunk); color: var(--ink-soft); border: 1px solid var(--line); }
.status-pill.encerrada { background: var(--good-wash); color: var(--good); }

.thread { display: flex; flex-direction: column; min-height: 0; }
.thread-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: .9rem 1.3rem; border-bottom: 1px solid var(--line); }
.thread-head .who b { display: block; font-size: .95rem; font-weight: 700; }
.thread-head .who span { display: block; font-size: .78rem; color: var(--ink-soft); margin-top: .1rem; }
.thread-body { flex: 1; overflow-y: auto; padding: 1.2rem 1.3rem; display: flex; flex-direction: column; gap: .9rem; }
.bubble-row { display: flex; flex-direction: column; max-width: 74%; }
.bubble-row.out { align-self: flex-end; align-items: flex-end; }
.bubble-row.in { align-self: flex-start; align-items: flex-start; }
.bubble { padding: .62rem .85rem; border-radius: 12px; font-size: .87rem; line-height: 1.45; }
.bubble-row.out .bubble { background: var(--gold-wash); color: var(--ink); border-bottom-right-radius: 3px; }
.bubble-row.in .bubble { background: var(--paper-sunk); border: 1px solid var(--line); border-bottom-left-radius: 3px; }
.bubble-row .meta { font-family: var(--font-mono); font-size: .66rem; color: var(--ink-faint); margin-top: .3rem; }
.bubble-anexo img { max-width: 16rem; border-radius: 8px; display: block; }
.bubble-anexo audio { max-width: 16rem; }
.composer { display: flex; align-items: center; gap: .6rem; padding: .8rem 1.1rem; border-top: 1px solid var(--line); background: var(--paper-raised); }
.composer input[type="text"] { flex: 1; background: var(--paper-sunk); border: 1px solid var(--line); border-radius: 999px; padding: .6rem 1rem; color: var(--ink); font-size: .85rem; font-family: inherit; }
.icon-btn { width: 2.1rem; height: 2.1rem; border-radius: 50%; border: 1px solid var(--line); background: var(--paper-raised); color: var(--ink-soft); display: flex; align-items: center; justify-content: center; flex: none; cursor: pointer; }
.icon-btn svg { width: 15px; height: 15px; }
.icon-btn.send { background: var(--gold); color: var(--gold-ink); border-color: var(--gold); }
.anexo-preview { font-size: .74rem; color: var(--ink-soft); background: var(--paper-sunk); border: 1px solid var(--line); border-radius: 8px; padding: .3rem .6rem; display: none; }
.anexo-preview.tem-arquivo { display: block; }

/* ============ MÓDULO 9 — AGENDA ============ */
.cal-toolbar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1.1rem; flex-wrap: wrap; gap: .7rem; }
.cal-toolbar h2 { font-size: 1.05rem; font-weight: 800; text-transform: capitalize; }
.cal-nav { display: flex; gap: .5rem; }

.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; background: var(--line); gap: 1px; }
.cal-weekday { background: var(--paper-sunk); padding: .5rem; text-align: center; font-size: .68rem; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-faint); font-weight: 600; }
.cal-day { background: var(--paper-raised); min-height: 6rem; padding: .5rem; display: flex; flex-direction: column; gap: .3rem; text-decoration: none; color: inherit; }
.cal-day:hover { background: var(--paper-sunk); }
.cal-day .num { font-size: .78rem; font-weight: 700; color: var(--ink-soft); }
.cal-day.outro-mes { background: var(--paper); }
.cal-day.outro-mes .num { color: var(--ink-faint); }
.cal-day.hoje .num { display: inline-flex; align-items: center; justify-content: center; width: 1.4rem; height: 1.4rem; border-radius: 50%; background: var(--gold); color: var(--gold-ink); }
.cal-event-pill { font-size: .68rem; font-weight: 600; padding: .12rem .4rem; border-radius: 5px; background: var(--gold-wash); color: var(--gold); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cal-more { font-size: .66rem; color: var(--ink-faint); }

.cal-week-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: .8rem; }
@media (max-width: 900px) { .cal-week-grid { grid-template-columns: 1fr; } }
.cal-week-day { border: 1px solid var(--line); border-radius: 12px; padding: .8rem; background: var(--paper-raised); min-height: 8rem; }
.cal-week-day.hoje { border-color: var(--gold); }
.cal-week-day .lbl { font-size: .72rem; font-weight: 700; color: var(--ink-soft); margin-bottom: .5rem; text-transform: capitalize; }

.day-event { display: flex; gap: .7rem; border: 1px solid var(--line); border-radius: 10px; padding: .7rem .9rem; background: var(--paper-raised); align-items: flex-start; }
.day-event .hora { font-family: var(--font-mono); font-size: .78rem; color: var(--gold); flex: none; padding-top: .1rem; min-width: 4rem; }
.day-event .tx { flex: 1; }
.day-event .tx b { display: block; font-size: .88rem; font-weight: 700; }
.day-event .tx span { display: block; font-size: .78rem; color: var(--ink-faint); }
.day-event form { flex: none; }

.check-list { display: flex; flex-wrap: wrap; gap: .5rem; }
.check-item {
  display: flex; align-items: center; gap: .4rem; font-size: .82rem;
  border: 1px solid var(--line); border-radius: 999px; padding: .35rem .7rem .35rem .55rem;
  background: var(--paper-sunk); cursor: pointer;
}
.check-item input { margin: 0; }
.check-item-role { font-size: .68rem; color: var(--ink-faint); text-transform: capitalize; }

/* ============ MÓDULO 8 — CRM COMERCIAL ============ */
.crm-board { display: grid; grid-template-columns: repeat(6, minmax(13rem, 1fr)); gap: .9rem; align-items: start; overflow-x: auto; }
@media (max-width: 1100px) { .crm-board { grid-template-columns: repeat(3, minmax(13rem, 1fr)); } }
@media (max-width: 640px) { .crm-board { grid-template-columns: 1fr; } }
.crm-col { display: flex; flex-direction: column; gap: .6rem; min-width: 0; }
.crm-col-head { display: flex; align-items: center; justify-content: space-between; padding: 0 .1rem; }
.crm-col-head h3 { font-size: .76rem; font-weight: 700; color: var(--ink-soft); text-transform: uppercase; letter-spacing: .04em; }
.crm-col-head .n { font-size: .7rem; color: var(--ink-faint); font-family: var(--font-mono); }
.crm-card { display: block; border: 1px solid var(--line); border-radius: 10px; padding: .7rem .8rem; background: var(--paper-raised); text-decoration: none; color: inherit; display: flex; flex-direction: column; gap: .3rem; }
.crm-card:hover { background: var(--paper-sunk); }
.crm-card b { font-size: .85rem; font-weight: 700; }
.crm-card span { font-size: .74rem; color: var(--ink-faint); }
.crm-card span.atrasado { color: var(--bad); font-weight: 600; }

/* ============ RESPONSIVE ============ */
@media (max-width: 860px) {
  .app-frame { grid-template-columns: 1fr; }
  .app-side { flex-direction: row; overflow-x: auto; padding: .7rem; }
  .app-nav { flex-direction: row; }
  .side-brand, .side-foot, .nav-sep { display: none; }
  .app-nav a span.lbl, .app-nav .disabled span.lbl { display: none; }
  .page { padding: 1.2rem 1rem 2.5rem; }
  .app-top { flex-wrap: wrap; gap: .7rem; padding: .9rem 1rem; }
  .theme-toggle button { padding: .35rem .5rem; }
  .com-wrap { grid-template-columns: 1fr; }
  .conv-list { max-height: 12rem; border-right: none; border-bottom: 1px solid var(--line); }
}
