:root {
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --primary-light: #dbeafe;
  --bg: #f8fafc;
  --bg-card: #ffffff;
  --text: #1e293b;
  --text-muted: #64748b;
  --border: #e2e8f0;
  --success: #16a34a;
  --danger: #dc2626;
  --warning: #d97706;
  --info: #0284c7;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(0,0,0,.1), 0 1px 2px rgba(0,0,0,.06);
  --shadow-md: 0 4px 6px rgba(0,0,0,.07), 0 2px 4px rgba(0,0,0,.06);
}

[data-theme="dark"] {
  --bg: #0f172a;
  --bg-card: #1e293b;
  --text: #f1f5f9;
  --text-muted: #94a3b8;
  --border: #334155;
  --primary-light: #1e3a5f;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

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

/* ── Utilitários ─────────────────────────────────────────── */
.hidden   { display: none !important; }
.flex     { display: flex; }
.flex-col { flex-direction: column; }
.gap-1    { gap: 8px; }
.gap-2    { gap: 16px; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.text-center { text-align: center; }
.text-muted { color: var(--text-muted); font-size: 13px; }
.text-sm  { font-size: 13px; }
.fw-600   { font-weight: 600; }
.mt-1     { margin-top: 8px; }
.mt-2     { margin-top: 16px; }
.w-full   { width: 100%; }

/* ── Toast ───────────────────────────────────────────────── */
#toast-container {
  position: fixed; top: 16px; right: 16px; z-index: 9999;
  display: flex; flex-direction: column; gap: 8px;
}
.toast {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 12px 16px;
  box-shadow: var(--shadow-md); font-size: 14px;
  max-width: 320px; animation: slideIn .2s ease;
}
.toast.success { border-left: 4px solid var(--success); }
.toast.error   { border-left: 4px solid var(--danger); }
.toast.info    { border-left: 4px solid var(--info); }
@keyframes slideIn { from { opacity: 0; transform: translateX(20px); } to { opacity: 1; transform: translateX(0); } }

/* ── Botões ──────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: 6px; padding: 10px 18px; border: none; border-radius: 8px;
  font-size: 14px; font-weight: 600; cursor: pointer;
  transition: opacity .15s, transform .1s; text-decoration: none;
}
.btn:active { transform: scale(.97); }
.btn-primary  { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-danger   { background: var(--danger); color: #fff; }
.btn-success  { background: var(--success); color: #fff; }
.btn-outline  { background: transparent; border: 1.5px solid var(--border); color: var(--text); }
.btn-ghost    { background: transparent; color: var(--primary); }
.btn-sm       { padding: 6px 12px; font-size: 13px; }
.btn-lg       { padding: 14px 24px; font-size: 16px; }
.btn-icon     { padding: 8px; border-radius: 8px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-block    { width: 100%; }

/* ── Card ────────────────────────────────────────────────── */
.card {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px;
  box-shadow: var(--shadow);
}

/* ── Form ────────────────────────────────────────────────── */
.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-group label { font-size: 13px; font-weight: 600; color: var(--text-muted); }
.form-control {
  padding: 10px 14px; border: 1.5px solid var(--border);
  border-radius: 8px; font-size: 15px; background: var(--bg-card);
  color: var(--text); transition: border-color .15s;
  width: 100%;
}
.form-control:focus { outline: none; border-color: var(--primary); }
select.form-control { appearance: none; cursor: pointer; }

/* ── Badge ───────────────────────────────────────────────── */
.badge {
  display: inline-block; padding: 3px 8px; border-radius: 20px;
  font-size: 12px; font-weight: 600;
}
.badge-blue    { background: var(--primary-light); color: var(--primary); }
.badge-green   { background: #dcfce7; color: #15803d; }
.badge-red     { background: #fee2e2; color: #b91c1c; }
.badge-yellow  { background: #fef9c3; color: #a16207; }
.badge-gray    { background: var(--border); color: var(--text-muted); }
.badge-purple  { background: #f3e8ff; color: #7c3aed; }

/* ── Login ───────────────────────────────────────────────── */
.login-wrap {
  min-height: 100dvh; display: flex; align-items: center;
  justify-content: center; padding: 24px;
  background: linear-gradient(135deg, #1e3a8a 0%, #2563eb 100%);
}
.login-card {
  background: #fff; border-radius: 20px;
  padding: 40px 32px; width: 100%; max-width: 380px;
  box-shadow: 0 20px 40px rgba(0,0,0,.2);
}
.login-logo { font-size: 48px; text-align: center; }
.login-title { font-size: 22px; font-weight: 700; text-align: center; margin-top: 8px; }
.login-sub   { color: #64748b; text-align: center; font-size: 14px; }

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

.sidebar {
  width: 240px; background: var(--bg-card);
  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;
}
.sidebar-logo {
  padding: 20px 16px; font-size: 18px; font-weight: 700;
  border-bottom: 1px solid var(--border); display: flex;
  align-items: center; gap: 10px; color: var(--primary);
}
.sidebar-nav { flex: 1; overflow-y: auto; padding: 12px 8px; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 11px 14px; border-radius: 8px; cursor: pointer;
  font-size: 14px; font-weight: 500; color: var(--text-muted);
  transition: all .15s; text-decoration: none; border: none;
  background: transparent; width: 100%; text-align: left;
}
.nav-item:hover { background: var(--bg); color: var(--text); }
.nav-item.active { background: var(--primary-light); color: var(--primary); font-weight: 600; }
.nav-item .icon { font-size: 18px; width: 22px; }

.main-content {
  flex: 1; margin-left: 240px; display: flex; flex-direction: column; min-height: 100dvh;
  overflow-x: hidden;
}
.topbar {
  background: var(--bg-card); border-bottom: 1px solid var(--border);
  padding: 14px 24px; display: flex; align-items: center;
  justify-content: space-between; position: sticky; top: 0; z-index: 50;
}
.topbar-title { font-size: 18px; font-weight: 700; }
.page-content { padding: 24px; flex: 1; }

/* Hambúrguer mobile */
.hamburger { display: none; background: transparent; border: none; font-size: 24px; cursor: pointer; color: var(--text); }
.sidebar-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 99; }

@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .sidebar-overlay.open { display: block; }
  .main-content { margin-left: 0; }
  .hamburger { display: block; }
  .page-content { padding: 16px; }
}

/* ── Stats Grid ──────────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 16px;
}
.stat-card {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 20px;
  display: flex; flex-direction: column; gap: 6px;
}
.stat-card .stat-icon { font-size: 28px; }
.stat-card .stat-value { font-size: 26px; font-weight: 700; color: var(--primary); }
.stat-card .stat-label { font-size: 13px; color: var(--text-muted); }

/* ── Appointment Cards ───────────────────────────────────── */
.apt-card {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 14px 16px;
  display: flex; align-items: flex-start; gap: 14px;
}
.apt-time { font-size: 20px; font-weight: 700; color: var(--primary); min-width: 54px; }
.apt-info { flex: 1; }
.apt-name { font-weight: 600; font-size: 15px; }
.apt-service { color: var(--text-muted); font-size: 13px; }
.apt-actions { display: flex; flex-direction: column; gap: 6px; align-items: flex-end; }

/* ── Table ───────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 12px 14px; border-bottom: 1px solid var(--border); }
th { font-size: 12px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--bg); }

/* ── Modal ───────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.5);
  display: flex; align-items: center; justify-content: center;
  z-index: 999; padding: 16px;
}
.modal {
  background: var(--bg-card); border-radius: var(--radius);
  padding: 24px; width: 100%; max-width: 480px;
  max-height: 90dvh; overflow-y: auto;
  box-shadow: 0 20px 40px rgba(0,0,0,.2);
}
.modal-title { font-size: 18px; font-weight: 700; margin-bottom: 16px; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 20px; }

/* ── Tabs ────────────────────────────────────────────────── */
.tabs { display: flex; gap: 4px; border-bottom: 2px solid var(--border); margin-bottom: 20px; }
.tab {
  padding: 10px 16px; font-size: 14px; font-weight: 500;
  color: var(--text-muted); cursor: pointer; border-bottom: 2px solid transparent;
  margin-bottom: -2px; background: transparent; border-top: none;
  border-left: none; border-right: none;
}
.tab.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 600; }

/* ── Agendar (público) ───────────────────────────────────── */
.agendar-wrap {
  min-height: 100dvh; background: var(--bg); padding: 0;
  display: flex; flex-direction: column;
}
.agendar-header {
  background: linear-gradient(135deg, #1e3a8a 0%, #2563eb 100%);
  color: #fff; padding: 24px 20px 20px;
  display: flex; align-items: center; gap: 12px;
}
.agendar-header h1 { font-size: 20px; font-weight: 700; }
.agendar-body { flex: 1; padding: 20px 16px; max-width: 540px; margin: 0 auto; width: 100%; }

.step-indicator {
  display: flex; align-items: center; margin-bottom: 24px;
}
.step-dot {
  width: 32px; height: 32px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 700;
  background: var(--border); color: var(--text-muted);
  flex-shrink: 0;
}
.step-dot.active { background: var(--primary); color: #fff; }
.step-dot.done   { background: var(--success); color: #fff; }
.step-line { flex: 1; height: 2px; background: var(--border); }
.step-line.done { background: var(--success); }

.service-card {
  background: var(--bg-card); border: 2px solid var(--border);
  border-radius: var(--radius); padding: 16px; cursor: pointer;
  transition: border-color .15s;
}
.service-card.selected { border-color: var(--primary); background: var(--primary-light); }
.service-card:hover { border-color: var(--primary); }
.service-name { font-weight: 600; font-size: 15px; }
.service-meta { color: var(--text-muted); font-size: 13px; display: flex; gap: 12px; margin-top: 4px; }

.date-picker { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.date-btn {
  aspect-ratio: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center; border-radius: 8px;
  font-size: 12px; cursor: pointer; border: 1.5px solid var(--border);
  background: var(--bg-card); font-weight: 500;
}
.date-btn .day-num { font-size: 15px; font-weight: 700; }
.date-btn.selected { background: var(--primary); border-color: var(--primary); color: #fff; }
.date-btn.today    { border-color: var(--primary); color: var(--primary); }
.date-btn:disabled { opacity: .35; cursor: not-allowed; }

.slot-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(72px, 1fr)); gap: 8px; }
.slot-btn {
  padding: 10px 0; text-align: center; border-radius: 8px;
  border: 1.5px solid var(--border); background: var(--bg-card);
  font-size: 14px; font-weight: 600; cursor: pointer;
}
.slot-btn.selected { background: var(--primary); border-color: var(--primary); color: #fff; }
.slot-btn:hover    { border-color: var(--primary); }

/* ── Fiado / Finance colors ──────────────────────────────── */
.method-dinheiro { color: #16a34a; }
.method-pix      { color: #7c3aed; }
.method-debito   { color: #0284c7; }
.method-credito  { color: #d97706; }
.method-fiado    { color: #dc2626; }

/* ── Apt Card v2 ────────────────────────────────────────── */
.apt-card-v2 {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  transition: box-shadow .15s;
}
.apt-card-v2:hover { box-shadow: var(--shadow-md); }
.apt-card-v2 .apt-header {
  display: flex; align-items: center; gap: 14px;
  padding: 14px 16px 10px;
}
.apt-card-v2 .apt-hora {
  font-size: 22px; font-weight: 800; color: var(--primary);
  min-width: 58px; letter-spacing: -.5px;
}
.apt-card-v2 .apt-body { flex: 1; }
.apt-card-v2 .apt-cliente { font-weight: 700; font-size: 15px; }
.apt-card-v2 .apt-meta { color: var(--text-muted); font-size: 13px; margin-top: 2px; }
.apt-card-v2 .apt-footer {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 16px 12px;
  border-top: 1px solid var(--border);
  background: var(--bg);
  flex-wrap: wrap;
}
.apt-card-v2 .apt-footer .badge { margin-right: auto; font-size: 12px; }
.btn-wpp {
  background: #25d366; color: #fff;
  border: none; border-radius: 8px;
  padding: 7px 12px; font-size: 13px;
  font-weight: 600; cursor: pointer;
  display: inline-flex; align-items: center; gap: 5px;
}
.btn-wpp:hover { background: #1da851; }

/* ── Empty state ─────────────────────────────────────────── */
.empty-state {
  text-align: center; padding: 48px 16px;
  color: var(--text-muted);
}
.empty-state .empty-icon { font-size: 48px; margin-bottom: 12px; }
.empty-state p { font-size: 15px; }

/* ── Rodapé ──────────────────────────────────────────────── */
.site-footer {
  text-align: center;
  padding: 18px 16px;
  font-size: 12px;
  color: var(--text-muted);
  border-top: 1px solid var(--border);
  margin-top: 40px;
}
.site-footer strong { color: var(--text); }
.site-footer a { color: var(--primary); text-decoration: none; }
.site-footer a:hover { text-decoration: underline; }

/* ── Scrollbar ───────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

/* ═══════════════════════════════════════════════════════════
   RESPONSIVIDADE MOBILE
   ═══════════════════════════════════════════════════════════ */
@media (max-width: 480px) {
  /* Topbar: evita overflow dos botões */
  .topbar { padding: 10px 14px; gap: 8px; flex-wrap: nowrap; }
  .topbar-title { font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 120px; }
  .topbar .btn-sm { padding: 6px 8px; font-size: 12px; }
  /* Esconde texto longo do botão + Novo Agendamento no mobile */
  .topbar .btn-novo-apt { font-size: 0; padding: 7px 10px; }
  .topbar .btn-novo-apt::before { content: '+'; font-size: 18px; font-weight: 700; }

  /* Page content mais compacto */
  .page-content { padding: 12px; }

  /* Stats: 2 colunas no celular */
  .stats-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .stat-card { padding: 14px 12px; }
  .stat-card .stat-value { font-size: 20px; }
  .stat-card .stat-icon  { font-size: 22px; }

  /* Cards de agendamento v2 */
  .apt-card-v2 .apt-hora { font-size: 18px; min-width: 48px; }
  .apt-card-v2 .apt-cliente { font-size: 14px; }
  .apt-card-v2 .apt-footer { gap: 6px; padding: 8px 12px 10px; }
  .apt-card-v2 .apt-footer .btn-sm { padding: 5px 8px; font-size: 11px; }
  .btn-wpp { padding: 6px 10px; font-size: 12px; }

  /* Tabelas: fonte menor e scroll horizontal já existe */
  table { font-size: 13px; }
  th, td { padding: 9px 10px; }
  /* Esconde colunas menos importantes em telas muito pequenas */
  .hide-mobile { display: none !important; }

  /* Modal: tela cheia no mobile */
  .modal { padding: 18px; max-height: 95dvh; }
  .modal-actions { flex-direction: column; }
  .modal-actions .btn { width: 100%; }

  /* Cards de configuração: full width */
  .card { padding: 14px; }

  /* Agendar: header mais compacto */
  .agendar-header { padding: 16px 14px; }
  .agendar-header h1 { font-size: 17px; }
  .agendar-body { padding: 14px 12px; }

  /* Slot grid: mais colunas no mobile */
  .slot-grid { grid-template-columns: repeat(auto-fill, minmax(60px, 1fr)); gap: 6px; }
  .slot-btn { padding: 8px 0; font-size: 13px; }

  /* Date picker: cell menor */
  .date-btn .day-num { font-size: 13px; }
  .date-btn { font-size: 11px; border-radius: 6px; }

  /* Login */
  .login-card { padding: 28px 20px; }

  /* Tabs: scroll horizontal */
  .tabs { overflow-x: auto; flex-wrap: nowrap; padding-bottom: 2px; }
  .tab { white-space: nowrap; padding: 10px 12px; font-size: 13px; }

  /* Sidebar logo: evita texto longo transbordar */
  .sidebar-logo { font-size: 15px; padding: 16px 12px; }
}
