/* ==========================================================================
   Suporte Komfort House — folha de estilo do portal
   Sem dependência de build (Vite/npm): CSS puro servido estaticamente.
   ========================================================================== */

:root {
  --brand:        #1f4e79;
  --brand-dark:   #163a5a;
  --brand-light:  #e8f0f8;
  --accent:       #e8590c;

  --bg:           #f4f6f9;
  --surface:      #ffffff;
  --border:       #dfe3e8;
  --text:         #1c2733;
  --text-muted:   #667382;

  --success:      #2f9e44;
  --danger:       #c92a2a;
  --warning:      #f08c00;
  --info:         #1971c2;

  --radius:       10px;
  --radius-sm:    6px;
  --shadow:       0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .1);
  --shadow-lg:    0 4px 6px -1px rgba(16, 24, 40, .1), 0 2px 4px -2px rgba(16, 24, 40, .06);

  --sidebar-w:    246px;
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 14px;
  line-height: 1.55;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3, h4 { margin: 0 0 .5rem; line-height: 1.25; font-weight: 650; }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.2rem; }
h3 { font-size: 1.02rem; }

p { margin: 0 0 .75rem; }

.muted     { color: var(--text-muted); }
.small     { font-size: .82rem; }
.tiny      { font-size: .75rem; }
.strong    { font-weight: 600; }
.mono      { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.nowrap    { white-space: nowrap; }
.text-right{ text-align: right; }
.text-center{ text-align: center; }

/* ---------- Layout ---------- */

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

.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--brand);
  color: #dce6f1;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.sidebar-brand {
  padding: 1.1rem 1.15rem;
  border-bottom: 1px solid rgba(255,255,255,.12);
}
.sidebar-brand strong { color: #fff; font-size: 1rem; display: block; letter-spacing: .01em; }
.sidebar-brand span   { font-size: .74rem; color: #9db8d4; text-transform: uppercase; letter-spacing: .08em; }

.sidebar-nav { padding: .7rem 0; flex: 1; }
.sidebar-section {
  padding: .9rem 1.15rem .3rem;
  font-size: .68rem;
  text-transform: uppercase;
  letter-spacing: .09em;
  color: #82a3c4;
  font-weight: 600;
}
.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: .55rem;
  padding: .5rem 1.15rem;
  color: #dce6f1;
  font-size: .875rem;
  border-left: 3px solid transparent;
}
.sidebar-nav a:hover { background: rgba(255,255,255,.07); text-decoration: none; color: #fff; }
.sidebar-nav a.active { background: rgba(255,255,255,.13); border-left-color: var(--accent); color: #fff; font-weight: 550; }
.sidebar-nav .count {
  margin-left: auto;
  background: rgba(255,255,255,.18);
  border-radius: 20px;
  padding: 0 .45rem;
  font-size: .72rem;
}

.sidebar-footer {
  padding: .85rem 1.15rem;
  border-top: 1px solid rgba(255,255,255,.12);
  font-size: .8rem;
}
.sidebar-footer a { color: #b9cde2; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

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

.content { padding: 1.5rem; flex: 1; }
.content-narrow { max-width: 880px; }

.page-head {
  display: flex;
  align-items: flex-start;
  gap: 1rem;
  margin-bottom: 1.15rem;
  flex-wrap: wrap;
}
.page-head .spacer { flex: 1; }
.page-head p { margin: 0; }

/* ---------- Cartões ---------- */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 1.15rem;
}
.card-head {
  padding: .8rem 1.1rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: .75rem;
  font-weight: 600;
}
.card-head .spacer { flex: 1; }
.card-body { padding: 1.1rem; }
.card-body.tight { padding: .75rem 1.1rem; }
.card-foot {
  padding: .75rem 1.1rem;
  border-top: 1px solid var(--border);
  background: #fafbfc;
  border-radius: 0 0 var(--radius) var(--radius);
}

/* ---------- Grid ---------- */

.grid { display: grid; gap: 1.15rem; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-6 { grid-template-columns: repeat(6, minmax(0, 1fr)); }
.grid-sidebar { grid-template-columns: minmax(0, 1fr) 320px; }

@media (max-width: 1100px) {
  .grid-6 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-sidebar { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 760px) {
  .grid-2, .grid-3, .grid-4, .grid-6 { grid-template-columns: minmax(0, 1fr); }
  .sidebar { display: none; }
  .content { padding: 1rem; }
}

/* ---------- KPI ---------- */

.kpi {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: .95rem 1rem;
  box-shadow: var(--shadow);
  display: block;
  color: inherit;
}
a.kpi:hover { text-decoration: none; border-color: var(--brand); box-shadow: var(--shadow-lg); }
.kpi .label { font-size: .74rem; text-transform: uppercase; letter-spacing: .06em; color: var(--text-muted); font-weight: 600; }
.kpi .value { font-size: 1.75rem; font-weight: 700; line-height: 1.15; margin-top: .2rem; }
.kpi .hint  { font-size: .76rem; color: var(--text-muted); }
.kpi.accent-blue   .value { color: var(--info); }
.kpi.accent-green  .value { color: var(--success); }
.kpi.accent-orange .value { color: var(--warning); }
.kpi.accent-red    .value { color: var(--danger); }

/* ---------- Tabelas ---------- */

.table-wrap { overflow-x: auto; }

table.table { width: 100%; border-collapse: collapse; font-size: .875rem; }
table.table th, table.table td { padding: .6rem .7rem; text-align: left; border-bottom: 1px solid var(--border); vertical-align: middle; }
table.table th {
  font-size: .72rem;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--text-muted);
  font-weight: 650;
  background: #fafbfc;
  white-space: nowrap;
}
table.table tbody tr:hover { background: #f8fafc; }
table.table th a { color: var(--text-muted); }
table.table td.actions { white-space: nowrap; text-align: right; }

.empty {
  padding: 2.5rem 1rem;
  text-align: center;
  color: var(--text-muted);
}

/* ---------- Badges ---------- */

.badge {
  display: inline-block;
  padding: .13rem .5rem;
  border-radius: 20px;
  font-size: .74rem;
  font-weight: 600;
  line-height: 1.5;
  color: #fff;
  white-space: nowrap;
}
.badge-soft {
  background: #eef1f5;
  color: var(--text-muted);
  border: 1px solid var(--border);
}
.badge-overdue { background: var(--danger); }

/* ---------- Formulários ---------- */

.field { margin-bottom: .95rem; }
.field label, .label {
  display: block;
  font-size: .8rem;
  font-weight: 600;
  margin-bottom: .3rem;
  color: #364152;
}
.field .help { font-size: .78rem; color: var(--text-muted); margin-top: .25rem; }

input[type=text], input[type=email], input[type=password], input[type=number],
input[type=date], input[type=time], input[type=search], input[type=tel],
select, textarea {
  width: 100%;
  padding: .5rem .6rem;
  font: inherit;
  font-size: .875rem;
  color: var(--text);
  background: #fff;
  border: 1px solid #ccd3db;
  border-radius: var(--radius-sm);
  outline: none;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(31, 78, 121, .12);
}
input[type=color] { width: 46px; height: 34px; padding: 2px; border: 1px solid #ccd3db; border-radius: var(--radius-sm); background: #fff; }
textarea { min-height: 110px; resize: vertical; }
select[multiple] { min-height: 160px; }

.checkbox {
  display: flex;
  gap: .5rem;
  align-items: flex-start;
  font-size: .87rem;
  margin-bottom: .5rem;
  cursor: pointer;
}
.checkbox input { margin-top: .18rem; flex-shrink: 0; }

fieldset.consent {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: .85rem 1rem;
  background: #fbfcfd;
  margin-bottom: 1rem;
}
fieldset.consent legend { font-size: .78rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--text-muted); padding: 0 .35rem; }

.form-row { display: flex; gap: .9rem; flex-wrap: wrap; }
.form-row > * { flex: 1; min-width: 190px; }

/* ---------- Botões ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  padding: .48rem .9rem;
  font: inherit;
  font-size: .875rem;
  font-weight: 550;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  cursor: pointer;
  background: #eef1f5;
  color: #364152;
  line-height: 1.4;
}
.btn:hover { text-decoration: none; filter: brightness(.97); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--brand); color: #fff; }
.btn-accent  { background: var(--accent); color: #fff; }
.btn-success { background: var(--success); color: #fff; }
.btn-danger  { background: var(--danger); color: #fff; }
.btn-outline { background: #fff; border-color: #ccd3db; color: #364152; }
.btn-link    { background: none; padding: .2rem .3rem; color: var(--brand); }
.btn-sm      { padding: .28rem .55rem; font-size: .8rem; }
.btn-block   { width: 100%; justify-content: center; }

.btn-group { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }

/* ---------- Alertas ---------- */

.alert {
  padding: .7rem .95rem;
  border-radius: var(--radius-sm);
  margin-bottom: 1rem;
  border: 1px solid transparent;
  font-size: .875rem;
}
.alert-success { background: #e9f7ec; border-color: #b7e4c2; color: #1e6b2e; }
.alert-danger  { background: #fdecec; border-color: #f5c2c2; color: #9c2020; }
.alert-warning { background: #fff6e5; border-color: #ffe0a3; color: #8a5300; }
.alert-info    { background: var(--brand-light); border-color: #c3d8ec; color: var(--brand-dark); }
.alert ul { margin: .35rem 0 0; padding-left: 1.15rem; }

/* ---------- Thread do ticket ---------- */

.thread { display: flex; flex-direction: column; gap: .9rem; }

.msg {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  overflow: hidden;
}
.msg-head {
  display: flex;
  align-items: center;
  gap: .6rem;
  padding: .55rem .9rem;
  background: #fafbfc;
  border-bottom: 1px solid var(--border);
  font-size: .82rem;
}
.msg-head .spacer { flex: 1; }
.msg-body { padding: .9rem; white-space: pre-wrap; word-break: break-word; }
.msg.internal { border-color: #f3d9a4; }
.msg.internal .msg-head { background: #fff8e6; color: #8a5300; }
.msg.staff .msg-head { background: var(--brand-light); }

.avatar {
  width: 30px; height: 30px;
  border-radius: 50%;
  background: var(--brand);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: .74rem;
  font-weight: 700;
  flex-shrink: 0;
}
.avatar.client { background: #7048e8; }

.attachments { display: flex; flex-wrap: wrap; gap: .45rem; padding: 0 .9rem .8rem; }
.attachment {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: .25rem .5rem;
  font-size: .8rem;
  background: #fafbfc;
}

/* ---------- Timeline de status ---------- */

.timeline { list-style: none; margin: 0; padding: 0; font-size: .82rem; }
.timeline li { padding: .35rem 0 .35rem .9rem; border-left: 2px solid var(--border); position: relative; }
.timeline li::before {
  content: '';
  position: absolute;
  left: -5px; top: .7rem;
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--brand);
}

/* ---------- Definições (detalhe do ticket) ---------- */

.dl { display: grid; grid-template-columns: 108px minmax(0,1fr); gap: .35rem .7rem; font-size: .85rem; }
.dl dt { color: var(--text-muted); }
.dl dd { margin: 0; }

/* ---------- Paginação ---------- */

.pagination { display: flex; gap: .3rem; flex-wrap: wrap; align-items: center; margin-top: 1rem; font-size: .85rem; }
.pagination a, .pagination span {
  padding: .32rem .6rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: #fff;
  color: var(--text);
}
.pagination .active span { background: var(--brand); color: #fff; border-color: var(--brand); }
.pagination .disabled span { color: #aeb6c0; }
.pagination svg { width: 14px; height: 14px; }

/* ---------- Abas ---------- */

.tabs {
  display: flex;
  gap: .25rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 1.15rem;
  flex-wrap: wrap;
}
.tabs a {
  padding: .5rem .85rem;
  font-size: .875rem;
  color: var(--text-muted);
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  font-weight: 550;
}
.tabs a:hover { color: var(--text); text-decoration: none; }
.tabs a.active { color: var(--brand); border-bottom-color: var(--brand); }

/* ---------- Filtros ---------- */

.filters { display: grid; grid-template-columns: repeat(auto-fit, minmax(165px, 1fr)); gap: .7rem; align-items: end; }
.filters .field { margin: 0; }

/* ---------- Barra de progresso ---------- */

.bar { height: 7px; background: #eef1f5; border-radius: 20px; overflow: hidden; }
.bar > span { display: block; height: 100%; background: var(--brand); }

/* ---------- Sugestões da base de conhecimento ---------- */

.kb-suggest {
  border: 1px solid #c3d8ec;
  background: var(--brand-light);
  border-radius: var(--radius-sm);
  padding: .75rem .9rem;
  margin-bottom: 1rem;
}
.kb-suggest h4 { margin: 0 0 .4rem; font-size: .85rem; color: var(--brand-dark); }
.kb-suggest ul { margin: 0; padding-left: 1.1rem; font-size: .85rem; }
.kb-suggest li { margin-bottom: .2rem; }

.kb-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 1rem;
  box-shadow: var(--shadow);
  height: 100%;
}
.kb-card h3 { font-size: .97rem; margin-bottom: .3rem; }

/* ---------- Guest / público ---------- */

.guest-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem 1rem;
  background: linear-gradient(160deg, var(--brand) 0%, var(--brand-dark) 100%);
}
.guest-card {
  width: 100%;
  max-width: 430px;
  background: var(--surface);
  border-radius: 12px;
  box-shadow: 0 12px 32px rgba(10, 25, 45, .25);
  padding: 1.9rem;
}
.guest-card h1 { font-size: 1.25rem; text-align: center; }
.guest-card .brand-mark { text-align: center; margin-bottom: 1.3rem; }
.guest-card .brand-mark strong { display: block; color: var(--brand); font-size: 1.05rem; }
.guest-card .brand-mark span { font-size: .74rem; text-transform: uppercase; letter-spacing: .1em; color: var(--text-muted); }

.public-header {
  background: var(--brand);
  color: #fff;
  padding: .85rem 1.5rem;
  display: flex;
  align-items: center;
  gap: 1rem;
}
.public-header a { color: #dce6f1; }
.public-header .spacer { flex: 1; }
.public-wrap { max-width: 1000px; margin: 0 auto; padding: 1.75rem 1.25rem; }

.hero {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2rem;
  text-align: center;
  box-shadow: var(--shadow);
  margin-bottom: 1.5rem;
}
.hero h1 { font-size: 1.6rem; }

.dept-tile {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 1rem;
  box-shadow: var(--shadow);
  border-top: 3px solid var(--brand);
  display: block;
  color: inherit;
}
.dept-tile:hover { text-decoration: none; box-shadow: var(--shadow-lg); }
.dept-tile strong { display: block; margin-bottom: .2rem; }

/* ---------- Utilitários ---------- */

.stack > * + * { margin-top: .9rem; }
.flex { display: flex; gap: .6rem; align-items: center; }
.flex-between { display: flex; gap: .6rem; align-items: center; justify-content: space-between; }
.flex-wrap { flex-wrap: wrap; }
.mt-0 { margin-top: 0; } .mt-1 { margin-top: .5rem; } .mt-2 { margin-top: 1rem; } .mt-3 { margin-top: 1.5rem; }
.mb-0 { margin-bottom: 0; } .mb-1 { margin-bottom: .5rem; } .mb-2 { margin-bottom: 1rem; } .mb-3 { margin-bottom: 1.5rem; }
.hidden { display: none !important; }

@media print {
  .sidebar, .topbar, .btn, form.inline-form { display: none !important; }
  .content { padding: 0; }
}
