/* admin.css — Sistema de design completo do painel BOT SMS */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

/* ─── Variables ───────────────────────────────────────────────────────────── */
:root {
  --bg-base: #0d0d14;
  --bg-surface: #12121e;
  --bg-card: #1a1a2e;
  --bg-hover: #1e1e38;
  --border: rgba(255,255,255,0.07);
  --primary: #5b5bf9;
  --primary-dark: #4848e0;
  --accent: #14d778;
  --success: #14d778;
  --warning: #f59e0b;
  --danger: #ef4444;
  --info: #3b82f6;
  --text: #e8e8f0;
  --text-muted: #6b6b8c;
  --text-dim: #3a3a5a;
  --accent-soft: rgba(91,91,249,.12);
  --sidebar-w: 240px;
  --radius: 10px;
  --shadow: 0 4px 24px rgba(0,0,0,.4);
}

/* ─── Reset ───────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body { font-family: 'Inter', sans-serif; background: var(--bg-base); color: var(--text); font-size: 14px; overflow-x: hidden; }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font-family: inherit; font-size: inherit; }

input, select, textarea {
  width: 100%; background: var(--bg-surface); border: 1px solid var(--border);
  border-radius: 7px; color: var(--text); padding: 9px 12px; outline: none;
  transition: border-color .2s;
}
input:focus, select:focus, textarea:focus { border-color: var(--primary); }
textarea { resize: vertical; min-height: 80px; }
select option { background: var(--bg-card); }

table { width: 100%; border-collapse: collapse; }
th {
  text-align: left; font-size: 11px; font-weight: 600;
  text-transform: uppercase; letter-spacing: .05em;
  color: var(--text-muted); padding: 10px 14px;
  border-bottom: 1px solid var(--border); white-space: nowrap;
}
td { padding: 11px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: rgba(255,255,255,.02); }

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

.sidebar {
  width: var(--sidebar-w); flex-shrink: 0;
  background: var(--bg-surface); border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  position: fixed; top: 0; left: 0; height: 100vh;
  overflow-y: auto; overflow-x: hidden; z-index: 100;
}
.sidebar::-webkit-scrollbar { width: 4px; }
.sidebar::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

.main { margin-left: var(--sidebar-w); flex: 1; display: flex; flex-direction: column; min-height: 100vh; }
.content { padding: 22px 24px; flex: 1; max-width: 1400px; }

/* ─── Sidebar ─────────────────────────────────────────────────────────────── */
.sidebar-brand {
  display: flex; align-items: center; gap: 10px;
  padding: 18px 16px; border-bottom: 1px solid var(--border); flex-shrink: 0;
}
.sidebar-brand-icon {
  width: 34px; height: 34px; background: linear-gradient(135deg,#5b5bf9,#8b5cf6);
  border-radius: 8px; display: flex; align-items: center; justify-content: center;
  font-size: 17px; flex-shrink: 0;
}
.sidebar-brand-text { font-weight: 700; font-size: 14px; line-height: 1.3; }
.sidebar-brand-text small { display: block; font-size: 10px; color: var(--text-muted); font-weight: 400; }

.sidebar-nav { flex: 1; padding: 10px 8px; }
.sidebar-footer { padding: 10px 8px; border-top: 1px solid var(--border); flex-shrink: 0; }

.nav-section { margin-bottom: 18px; }
.nav-section-title {
  font-size: 9.5px; font-weight: 600; text-transform: uppercase;
  letter-spacing: .08em; color: var(--text-dim); padding: 0 10px; margin-bottom: 4px;
}
.nav-item {
  display: flex; align-items: center; gap: 9px; padding: 7px 10px;
  border-radius: 7px; color: var(--text-muted); font-size: 13px; font-weight: 500;
  cursor: pointer; transition: all .15s; margin-bottom: 1px; border: none; background: none; width: 100%;
}
.nav-item:hover { background: var(--bg-hover); color: var(--text); }
.nav-item.active { background: var(--accent-soft); color: var(--primary); }
.nav-item-icon {
  font-size: 17px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  width: 18px; /* garante alinhamento consistente */
}

/* ─── Topbar ──────────────────────────────────────────────────────────────── */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 24px; height: 56px; border-bottom: 1px solid var(--border);
  background: var(--bg-surface); position: sticky; top: 0; z-index: 50; flex-shrink: 0;
}
.topbar-title { font-size: 15px; font-weight: 600; }
.topbar-actions { display: flex; align-items: center; gap: 10px; }
.toolbar { display: flex; align-items: center; gap: 8px; margin-bottom: 14px; flex-wrap: wrap; }

/* ─── Cards ───────────────────────────────────────────────────────────────── */
.card {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 18px 20px;
}
.card-title {
  font-size: 11.5px; font-weight: 600; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: .07em; margin-bottom: 14px;
}

/* ─── Stat cards — CORRIGIDO: altura fixa, não cresce ────────────────────── */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px,1fr)); gap: 12px; }
.stat-card {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px 18px;
  position: relative; overflow: hidden;
  min-height: 88px; max-height: 110px; /* CRÍTICO: evita crescimento infinito */
}
.stat-card::before {
  content: attr(data-icon); position: absolute; right: -6px; top: -6px;
  font-size: 48px; opacity: .07; pointer-events: none; line-height: 1;
  user-select: none;
}
.stat-label { font-size: 10.5px; color: var(--text-muted); text-transform: uppercase; letter-spacing: .06em; margin-bottom: 6px; }
.stat-value { font-size: 22px; font-weight: 700; line-height: 1; }
.stat-subtext { font-size: 11px; color: var(--text-muted); margin-top: 4px; }
.stat-card.primary .stat-value { color: var(--primary); }
.stat-card.success .stat-value { color: var(--success); }
.stat-card.warning .stat-value { color: var(--warning); }
.stat-card.danger  .stat-value { color: var(--danger); }
.stat-card.accent  .stat-value { color: var(--accent); }
.stat-card.info    .stat-value { color: var(--info); }

/* ─── Chart wrapper — CORRIGIDO: altura fixa obrigatória ─────────────────── */
.chart-wrapper {
  position: relative;
  height: 240px;        /* CRÍTICO: altura fixa */
  max-height: 240px;    /* CRÍTICO: não deixa crescer */
  overflow: hidden;
}
.chart-wrapper canvas { display: block; }

/* ─── Buttons ─────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 5px;
  padding: 7px 14px; border-radius: 7px; border: none; cursor: pointer;
  font-size: 13px; font-weight: 500; transition: all .15s; line-height: 1;
  white-space: nowrap;
}
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--primary-dark); }
.btn-success { background: var(--success); color: #0a2010; font-weight: 600; }
.btn-success:hover:not(:disabled) { filter: brightness(1.1); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover:not(:disabled) { filter: brightness(1.1); }
.btn-warning { background: var(--warning); color: #1a0d00; font-weight: 600; }
.btn-warning:hover:not(:disabled) { filter: brightness(1.1); }
.btn-ghost { background: transparent; color: var(--text-muted); border: 1px solid var(--border); }
.btn-ghost:hover:not(:disabled) { background: var(--bg-hover); color: var(--text); border-color: rgba(255,255,255,.15); }
.btn-sm { padding: 5px 10px; font-size: 11.5px; border-radius: 6px; }
.btn-full { width: 100%; }
.btn-icon { padding: 7px; aspect-ratio: 1; }

/* ─── Badges ──────────────────────────────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center; gap: 3px;
  padding: 3px 8px; border-radius: 20px; font-size: 11px;
  font-weight: 600; white-space: nowrap;
}
.badge-success { background: rgba(20,215,120,.12); color: var(--success); }
.badge-danger  { background: rgba(239,68,68,.12);  color: var(--danger); }
.badge-warning { background: rgba(245,158,11,.12); color: var(--warning); }
.badge-accent  { background: var(--accent-soft);   color: var(--primary); }
.badge-muted   { background: rgba(255,255,255,.05); color: var(--text-muted); }
.badge-info    { background: rgba(59,130,246,.12);  color: var(--info); }
.badge-dot::before { content: '●'; font-size: 7px; }

/* ─── Forms ───────────────────────────────────────────────────────────────── */
.form-group { margin-bottom: 14px; }
.form-group label { display: block; font-size: 12px; font-weight: 500; color: var(--text-muted); margin-bottom: 5px; }
.form-group small { display: block; font-size: 11px; color: var(--text-dim); margin-top: 4px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; }

/* ─── Toggle switch ───────────────────────────────────────────────────────── */
.toggle { position: relative; display: inline-flex; align-items: center; flex-shrink: 0; }
.toggle input { position: absolute; opacity: 0; width: 0; height: 0; }
.toggle-slider {
  display: block; width: 36px; height: 20px; cursor: pointer;
  background: var(--bg-surface); border: 1px solid var(--border);
  border-radius: 20px; transition: .2s; position: relative;
}
.toggle-slider::before {
  content: ''; position: absolute; width: 14px; height: 14px;
  left: 2px; top: 2px; background: var(--text-muted);
  border-radius: 50%; transition: .2s;
}
.toggle input:checked + .toggle-slider { background: var(--primary); border-color: var(--primary); }
.toggle input:checked + .toggle-slider::before { transform: translateX(16px); background: #fff; }

/* ─── Table container ─────────────────────────────────────────────────────── */
.table-container {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); overflow: hidden;
}
.table-container table { min-width: 600px; }
.table-scroll { overflow-x: auto; }

/* ─── Pagination ──────────────────────────────────────────────────────────── */
.pagination { display: flex; align-items: center; gap: 4px; margin-top: 14px; justify-content: center; flex-wrap: wrap; }
.page-btn {
  background: var(--bg-card); border: 1px solid var(--border);
  color: var(--text-muted); padding: 5px 11px; border-radius: 6px;
  cursor: pointer; font-size: 12px; transition: all .15s; font-family: inherit;
}
.page-btn:hover { background: var(--bg-hover); color: var(--text); }
.page-btn.active { background: var(--primary); border-color: var(--primary); color: #fff; font-weight: 600; }
.page-ellipsis { color: var(--text-dim); padding: 0 2px; }

/* ─── Modal ───────────────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.7);
  z-index: 300; display: none; align-items: center;
  justify-content: center; padding: 20px;
}
.modal-overlay.open { display: flex; animation: fadeIn .15s; }
@keyframes fadeIn { from { opacity: 0 } to { opacity: 1 } }

.modal {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: 12px; width: 100%; max-width: 480px;
  max-height: 90vh; display: flex; flex-direction: column;
  box-shadow: 0 24px 80px rgba(0,0,0,.6);
  animation: slideUp .18s ease;
}
.modal-wide { max-width: 680px; }
@keyframes slideUp { from { transform: translateY(16px); opacity: 0 } to { transform: translateY(0); opacity: 1 } }
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px; border-bottom: 1px solid var(--border); flex-shrink: 0;
}
.modal-header h3 { font-size: 15px; font-weight: 600; }
.modal-close { background: none; border: none; color: var(--text-muted); font-size: 18px; cursor: pointer; padding: 4px 6px; border-radius: 4px; line-height: 1; }
.modal-close:hover { background: var(--bg-hover); color: var(--text); }
.modal-body { padding: 20px; overflow-y: auto; flex: 1; }
.modal-footer { padding: 14px 20px; border-top: 1px solid var(--border); display: flex; gap: 8px; justify-content: flex-end; flex-shrink: 0; }

/* ─── Toast ───────────────────────────────────────────────────────────────── */
#toast {
  position: fixed; bottom: 24px; right: 24px; z-index: 999;
  padding: 11px 18px; border-radius: 8px; font-size: 13px; font-weight: 500;
  max-width: 380px; opacity: 0; transform: translateY(10px);
  transition: all .22s; pointer-events: none; box-shadow: var(--shadow);
  display: flex; align-items: center; gap: 8px;
}
#toast.toast-show { opacity: 1; transform: translateY(0); }
#toast.toast-success { background: #0f2e1a; color: var(--success); border: 1px solid rgba(20,215,120,.25); }
#toast.toast-error   { background: #2a0a0a; color: var(--danger);  border: 1px solid rgba(239,68,68,.25); }
#toast.toast-info    { background: #111530; color: var(--primary);  border: 1px solid rgba(91,91,249,.25); }
#toast.toast-warning { background: #261700; color: var(--warning);  border: 1px solid rgba(245,158,11,.25); }

/* ─── Empty state ─────────────────────────────────────────────────────────── */
.empty-state { text-align: center; padding: 48px 20px; color: var(--text-muted); }
.empty-state-icon { font-size: 38px; margin-bottom: 10px; opacity: .4; }
.empty-state p { font-size: 13px; }

/* ─── Spinner ─────────────────────────────────────────────────────────────── */
.spinner {
  display: inline-block; width: 22px; height: 22px;
  border: 2px solid rgba(255,255,255,.08); border-top-color: var(--primary);
  border-radius: 50%; animation: spin .65s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ─── Code / QR ───────────────────────────────────────────────────────────── */
.code-block {
  background: var(--bg-surface); border: 1px solid var(--border);
  border-radius: 8px; padding: 12px 14px; font-family: 'Courier New', monospace;
  font-size: 13px; word-break: break-all; color: var(--accent); line-height: 1.6;
}
.qr-container {
  display: flex; align-items: center; justify-content: center;
  background: #fff; border-radius: 10px; padding: 16px;
  width: 200px; height: 200px; margin: 0 auto;
}
.qr-container img { width: 100%; height: 100%; object-fit: contain; }

/* ─── Status dot ──────────────────────────────────────────────────────────── */
.status-dot {
  display: inline-block; width: 8px; height: 8px;
  border-radius: 50%; flex-shrink: 0;
}
.status-dot.connected   { background: var(--success); box-shadow: 0 0 6px var(--success); }
.status-dot.scanning    { background: var(--warning); animation: pulse 1s infinite; }
.status-dot.disconnected { background: var(--text-dim); }
@keyframes pulse { 0%,100% { opacity: 1 } 50% { opacity: .4 } }

/* ─── Bot card ────────────────────────────────────────────────────────────── */
.bot-card { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; }
.bot-card.connected   { border-color: rgba(20,215,120,.2); }
.bot-card.scanning    { border-color: rgba(245,158,11,.2); }
.bot-card.disconnected { border-color: var(--border); }

/* ─── Login page ──────────────────────────────────────────────────────────── */
.login-page {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: radial-gradient(ellipse at 25% 25%, rgba(91,91,249,.18) 0%, transparent 55%),
              radial-gradient(ellipse at 75% 75%, rgba(20,215,120,.1) 0%, transparent 55%),
              var(--bg-base);
}
.login-box {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: 14px; padding: 40px; width: 100%; max-width: 380px;
  box-shadow: 0 24px 80px rgba(0,0,0,.5);
}
.login-logo { text-align: center; margin-bottom: 28px; }
.login-logo-icon { font-size: 44px; display: block; margin-bottom: 10px; }
.login-logo h1 { font-size: 20px; font-weight: 700; }
.login-logo p { font-size: 12px; color: var(--text-muted); margin-top: 4px; }
.login-error {
  background: rgba(239,68,68,.1); border: 1px solid rgba(239,68,68,.25);
  color: var(--danger); padding: 10px 14px; border-radius: 7px;
  margin-bottom: 16px; font-size: 13px;
}

/* ─── Scrollbar global ────────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,.15); }

/* ─── Misc utils ──────────────────────────────────────────────────────────── */
.text-muted { color: var(--text-muted); }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.text-warning { color: var(--warning); }
.mono { font-family: 'Courier New', monospace; }
.flex { display: flex; align-items: center; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.mb-0 { margin-bottom: 0; }
.mt-16 { margin-top: 16px; }
.w-full { width: 100%; }
hr.divider { border: none; border-top: 1px solid var(--border); margin: 16px 0; }
