/* Secretária IA - Estilos Globais */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --primary-light: #eff6ff;
  --success: #16a34a;
  --warning: #d97706;
  --danger: #dc2626;
  --info: #0891b2;
  --bg: #f8fafc;
  --surface: #ffffff;
  --border: #e2e8f0;
  --text: #0f172a;
  --text-muted: #64748b;
  --text-light: #94a3b8;
  --sidebar-w: 240px;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.04);
  --shadow-md: 0 4px 12px rgba(0,0,0,.08);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
}

/* ─── Layout ──────────────────────────────────────────────────────────────── */
.app-layout { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w);
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
  transition: transform .25s ease;
}

.sidebar-logo {
  padding: 1.25rem 1.25rem 1rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: .75rem;
}
.sidebar-logo .logo-icon {
  width: 36px; height: 36px;
  background: var(--primary);
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 1.1rem;
}
.sidebar-logo .logo-text { font-weight: 700; font-size: .9375rem; color: var(--text); }
.sidebar-logo .logo-sub  { font-size: .6875rem; color: var(--text-muted); }

.sidebar-nav { flex: 1; padding: .75rem .75rem; overflow-y: auto; }
.nav-section-label {
  font-size: .6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-light);
  padding: .5rem .5rem .25rem;
  margin-top: .5rem;
}
.nav-item {
  display: flex; align-items: center; gap: .625rem;
  padding: .5rem .75rem;
  border-radius: 8px;
  color: var(--text-muted);
  text-decoration: none;
  font-size: .875rem;
  font-weight: 500;
  transition: all .15s;
  margin-bottom: 2px;
  cursor: pointer;
}
.nav-item:hover { background: var(--bg); color: var(--text); }
.nav-item.active { background: var(--primary-light); color: var(--primary); }
.nav-item .icon { width: 18px; height: 18px; flex-shrink: 0; }
.nav-badge {
  margin-left: auto;
  background: var(--danger);
  color: #fff;
  font-size: .625rem;
  font-weight: 700;
  padding: .1rem .4rem;
  border-radius: 999px;
  min-width: 18px;
  text-align: center;
}

.sidebar-footer {
  padding: .75rem;
  border-top: 1px solid var(--border);
}
.user-info {
  display: flex; align-items: center; gap: .625rem;
  padding: .5rem .75rem;
  border-radius: 8px;
}
.user-avatar {
  width: 32px; height: 32px;
  background: var(--primary);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: .75rem; font-weight: 700;
  flex-shrink: 0;
}
.user-name  { font-size: .8125rem; font-weight: 600; color: var(--text); }
.user-role  { font-size: .6875rem; color: var(--text-muted); }
.btn-logout {
  display: flex; align-items: center; gap: .5rem;
  width: 100%; padding: .5rem .75rem;
  background: none; border: none; border-radius: 8px;
  color: var(--text-muted); font-size: .8125rem; cursor: pointer;
  transition: all .15s; margin-top: .25rem;
}
.btn-logout:hover { background: #fef2f2; color: var(--danger); }

.main-content {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: .875rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky; top: 0; z-index: 50;
}
.topbar-title { font-size: 1rem; font-weight: 700; color: var(--text); }
.topbar-sub   { font-size: .75rem; color: var(--text-muted); }
.topbar-actions { display: flex; align-items: center; gap: .625rem; }

.page-body { padding: 1.5rem; flex: 1; }

/* ─── Cards ───────────────────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}
.card-header {
  padding: 1rem 1.25rem .75rem;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
}
.card-title { font-size: .9375rem; font-weight: 700; color: var(--text); }
.card-body  { padding: 1.25rem; }

/* ─── Stats Grid ──────────────────────────────────────────────────────────── */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 1rem; margin-bottom: 1.5rem; }
.stat-card {
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  padding: 1.25rem;
  display: flex; align-items: flex-start; gap: 1rem;
  transition: box-shadow .15s;
}
.stat-card:hover { box-shadow: var(--shadow-md); }
.stat-icon {
  width: 44px; height: 44px;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.25rem; flex-shrink: 0;
}
.stat-value { font-size: 1.75rem; font-weight: 800; line-height: 1; color: var(--text); }
.stat-label { font-size: .75rem; color: var(--text-muted); margin-top: .2rem; }

/* ─── Buttons ─────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: .4rem;
  padding: .5rem 1rem; border-radius: 8px;
  font-size: .8125rem; font-weight: 600;
  cursor: pointer; border: none;
  transition: all .15s; text-decoration: none;
  white-space: nowrap;
}
.btn:active { transform: scale(.97); }
.btn-primary   { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-success   { background: var(--success); color: #fff; }
.btn-danger    { background: var(--danger); color: #fff; }
.btn-outline   { background: transparent; border: 1.5px solid var(--border); color: var(--text-muted); }
.btn-outline:hover { border-color: var(--primary); color: var(--primary); background: var(--primary-light); }
.btn-ghost     { background: transparent; color: var(--text-muted); }
.btn-ghost:hover { background: var(--bg); color: var(--text); }
.btn-sm { padding: .35rem .75rem; font-size: .75rem; }
.btn-icon { padding: .4rem; border-radius: 7px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ─── Badges ──────────────────────────────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center; gap: .25rem;
  padding: .2rem .6rem; border-radius: 999px;
  font-size: .6875rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em;
}
.badge-baixa   { background: #f0fdf4; color: #15803d; }
.badge-media   { background: #eff6ff; color: #1d4ed8; }
.badge-alta    { background: #fff7ed; color: #c2410c; }
.badge-urgente { background: #fef2f2; color: #b91c1c; }
.badge-pendente    { background: #fef9c3; color: #854d0e; }
.badge-em_andamento { background: #eff6ff; color: #1d4ed8; }
.badge-concluida   { background: #f0fdf4; color: #15803d; }
.badge-cancelada   { background: #f8fafc; color: #94a3b8; }
.badge-inbound  { background: #f0fdf4; color: #15803d; }
.badge-outbound { background: #eff6ff; color: #1d4ed8; }
.badge-manual      { background: #f8fafc; color: #64748b; }
.badge-ia_inbound  { background: #faf5ff; color: #7c3aed; }
.badge-ia_outbound { background: #fff7ed; color: #c2410c; }

/* ─── Table ───────────────────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
thead th {
  padding: .625rem 1rem;
  text-align: left;
  font-size: .6875rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: .06em;
  color: var(--text-muted);
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
tbody tr { border-bottom: 1px solid var(--border); transition: background .1s; }
tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: var(--bg); }
tbody td { padding: .75rem 1rem; font-size: .8125rem; vertical-align: middle; }

/* ─── Forms ───────────────────────────────────────────────────────────────── */
.form-group { margin-bottom: 1rem; }
label { display: block; font-size: .8125rem; font-weight: 600; color: var(--text); margin-bottom: .375rem; }
input[type=text], input[type=email], input[type=password], input[type=number],
input[type=date], input[type=datetime-local], textarea, select {
  width: 100%; padding: .5625rem .875rem;
  border: 1.5px solid var(--border); border-radius: 8px;
  font-size: .875rem; color: var(--text); background: var(--surface);
  transition: border-color .15s, box-shadow .15s;
  font-family: inherit;
}
input:focus, textarea:focus, select:focus {
  outline: none; border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37,99,235,.12);
}
textarea { resize: vertical; min-height: 80px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.form-hint { font-size: .75rem; color: var(--text-muted); margin-top: .25rem; }

/* ─── Filters ─────────────────────────────────────────────────────────────── */
.filters-bar {
  display: flex; align-items: center; gap: .75rem;
  flex-wrap: wrap; margin-bottom: 1rem;
}
.filter-select {
  padding: .4375rem .75rem;
  border: 1.5px solid var(--border); border-radius: 8px;
  font-size: .8125rem; color: var(--text); background: var(--surface);
  cursor: pointer;
}
.search-input {
  padding: .4375rem .75rem;
  border: 1.5px solid var(--border); border-radius: 8px;
  font-size: .8125rem; min-width: 200px;
}
.search-input:focus { outline: none; border-color: var(--primary); }

/* ─── Modal ───────────────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.4);
  display: flex; align-items: center; justify-content: center;
  z-index: 1000; padding: 1rem;
  opacity: 0; pointer-events: none;
  transition: opacity .2s;
}
.modal-overlay.open { opacity: 1; pointer-events: all; }
.modal {
  background: var(--surface);
  border-radius: 14px;
  box-shadow: 0 20px 60px rgba(0,0,0,.15);
  width: 100%; max-width: 560px;
  max-height: 90vh; overflow-y: auto;
  transform: scale(.95) translateY(8px);
  transition: transform .2s;
}
.modal-overlay.open .modal { transform: scale(1) translateY(0); }
.modal-header {
  padding: 1.25rem 1.5rem 1rem;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
}
.modal-title { font-size: 1rem; font-weight: 700; }
.modal-close {
  width: 30px; height: 30px; border-radius: 7px;
  background: none; border: none; cursor: pointer;
  color: var(--text-muted); font-size: 1.1rem;
  display: flex; align-items: center; justify-content: center;
  transition: all .15s;
}
.modal-close:hover { background: var(--bg); color: var(--text); }
.modal-body   { padding: 1.25rem 1.5rem; }
.modal-footer { padding: .875rem 1.5rem; border-top: 1px solid var(--border); display: flex; gap: .625rem; justify-content: flex-end; }

/* ─── Toast ───────────────────────────────────────────────────────────────── */
#toast-container {
  position: fixed; top: 1rem; right: 1rem;
  z-index: 9999; display: flex; flex-direction: column; gap: .5rem;
}
.toast {
  display: flex; align-items: center; gap: .75rem;
  padding: .75rem 1rem; border-radius: 10px;
  background: var(--surface); border: 1px solid var(--border);
  box-shadow: var(--shadow-md);
  font-size: .875rem; min-width: 280px; max-width: 360px;
  animation: slideIn .25s ease;
}
.toast.success { border-left: 4px solid var(--success); }
.toast.error   { border-left: 4px solid var(--danger); }
.toast.info    { border-left: 4px solid var(--primary); }
@keyframes slideIn { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* ─── Empty state ─────────────────────────────────────────────────────────── */
.empty-state { text-align: center; padding: 3rem 1rem; }
.empty-state .empty-icon { font-size: 2.5rem; margin-bottom: .75rem; opacity: .4; }
.empty-state p { color: var(--text-muted); font-size: .875rem; }

/* ─── Chat bubbles ────────────────────────────────────────────────────────── */
.chat-wrap { display: flex; flex-direction: column; gap: .5rem; padding: 1rem; }
.bubble-row { display: flex; }
.bubble-row.outbound { justify-content: flex-end; }
.bubble {
  max-width: 70%; padding: .625rem .875rem;
  border-radius: 12px; font-size: .875rem; line-height: 1.4;
  position: relative;
}
.bubble.inbound  { background: var(--bg); border: 1px solid var(--border); border-bottom-left-radius: 4px; }
.bubble.outbound { background: var(--primary); color: #fff; border-bottom-right-radius: 4px; }
.bubble-meta { font-size: .6875rem; opacity: .6; margin-top: .25rem; }
.bubble.outbound .bubble-meta { color: rgba(255,255,255,.75); }

/* ─── Sidebar mobile toggle ───────────────────────────────────────────────── */
.menu-toggle {
  display: none; background: none; border: none;
  cursor: pointer; padding: .25rem; color: var(--text);
}

/* ─── Misc ────────────────────────────────────────────────────────────────── */
.text-muted   { color: var(--text-muted); }
.text-danger  { color: var(--danger); }
.text-success { color: var(--success); }
.text-primary { color: var(--primary); }
.fw-bold { font-weight: 700; }
.d-flex { display: flex; }
.align-center { align-items: center; }
.gap-1 { gap: .25rem; } .gap-2 { gap: .5rem; } .gap-3 { gap: .75rem; }
.mt-1 { margin-top: .25rem; } .mt-2 { margin-top: .5rem; } .mt-3 { margin-top: .75rem; }
.mb-1 { margin-bottom: .25rem; } .mb-2 { margin-bottom: .5rem; } .mb-3 { margin-bottom: .75rem; }
.ml-auto { margin-left: auto; }
.w-100 { width: 100%; }
.spinner {
  width: 20px; height: 20px;
  border: 2.5px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading-overlay {
  display: flex; align-items: center; justify-content: center;
  padding: 3rem; color: var(--text-muted);
  gap: .75rem;
}
.contact-card {
  display: flex; align-items: center; gap: .875rem;
  padding: .875rem 1rem; border-radius: 10px;
  border: 1px solid var(--border); background: var(--surface);
  cursor: pointer; transition: all .15s; text-decoration: none; color: inherit;
}
.contact-card:hover { border-color: var(--primary); box-shadow: var(--shadow-md); }
.contact-card.active { border-color: var(--primary); background: var(--primary-light); }
.contact-avatar {
  width: 40px; height: 40px; border-radius: 50%;
  background: var(--primary); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: .875rem; flex-shrink: 0;
}
.awaiting-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--warning); flex-shrink: 0;
}
.info-box {
  background: var(--primary-light);
  border: 1px solid #bfdbfe;
  border-radius: 8px; padding: .875rem 1rem;
  font-size: .8125rem; color: #1e40af;
}
.info-box code {
  background: #dbeafe; padding: .1rem .35rem;
  border-radius: 4px; font-family: monospace; font-size: .8rem;
}
.divider { height: 1px; background: var(--border); margin: 1rem 0; }
.switch-wrap { display: flex; align-items: center; justify-content: space-between; padding: .75rem 1rem; background: var(--bg); border-radius: 8px; }
.switch { position: relative; display: inline-block; width: 42px; height: 24px; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider {
  position: absolute; cursor: pointer; inset: 0;
  background: var(--border); border-radius: 999px;
  transition: .2s;
}
.slider::before {
  content: ''; position: absolute;
  height: 18px; width: 18px; left: 3px; bottom: 3px;
  background: #fff; border-radius: 50%; transition: .2s;
}
input:checked + .slider { background: var(--primary); }
input:checked + .slider::before { transform: translateX(18px); }

/* ─── Responsive ──────────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .main-content { margin-left: 0; }
  .menu-toggle { display: block; }
  .form-row { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .page-body { padding: 1rem; }
}
