/* Whatstoque - Design System */

:root {
  --green: #25D366;
  --green-dark: #128C7E;
  --green-light: #dcfce7;
  --bg: #f8fafc;
  --sidebar-bg: #1a1a2e;
  --sidebar-width: 220px;
  --topbar-h: 56px;
  --white: #ffffff;
  --text: #1e293b;
  --text-muted: #64748b;
  --border: #e2e8f0;
  --danger: #ef4444;
  --warning: #f59e0b;
  --warning-light: #fef9c3;
  --success: #22c55e;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(0,0,0,.07), 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);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; }
body { font-family: 'Segoe UI', system-ui, -apple-system, sans-serif; color: var(--text); background: var(--bg); }
a { color: var(--green-dark); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; }

/* ── App Layout ── */
.app-layout { background: var(--bg); }
.app-container { display: flex; padding-top: var(--topbar-h); min-height: 100vh; }
.main-content { flex: 1; min-width: 0; margin-left: var(--sidebar-width); padding: 24px; max-width: 1200px; }

/* ── Topbar ── */
.topbar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 100;
  height: var(--topbar-h); background: var(--white);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 20px; box-shadow: var(--shadow);
}
.topbar-left { display: flex; align-items: center; gap: 12px; }
.topbar-right { display: flex; align-items: center; gap: 16px; }
.topbar-logo { height: 36px; }
.topbar-company { font-size: .85rem; color: var(--text-muted); font-weight: 500; }
.sidebar-toggle { background: none; border: none; cursor: pointer; font-size: 1.2rem; padding: 4px 8px; color: var(--text-muted); }

/* ── Sidebar ── */
.sidebar {
  position: fixed; top: var(--topbar-h); left: 0; bottom: 0;
  width: var(--sidebar-width); background: var(--sidebar-bg);
  overflow-y: auto; padding: 16px 0; z-index: 95;
}
.sidebar-nav { list-style: none; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 11px 20px; color: rgba(255,255,255,.7); font-size: .9rem;
  transition: all .15s; text-decoration: none;
}
.nav-item:hover { background: rgba(255,255,255,.07); color: #fff; text-decoration: none; }
.nav-item.active { background: var(--green); color: #fff; }
.nav-icon { font-size: 1.1rem; width: 22px; text-align: center; }

/* Backdrop do off-canvas mobile: escurece o conteúdo atrás e fecha ao clicar.
   Só ativo no mobile (ver media query <768px); no desktop fica sempre oculto. */
.sidebar-backdrop {
  position: fixed; inset: 0; top: var(--topbar-h);
  background: rgba(0,0,0,.45); z-index: 90;
  opacity: 0; visibility: hidden; transition: opacity .2s, visibility .2s;
}
.sidebar-backdrop.open { opacity: 1; visibility: visible; }
/* Só faz sentido no off-canvas mobile; no desktop a sidebar é fixa e visível. */
@media (min-width: 769px) { .sidebar-backdrop { display: none; } }

/* Rodapé de ações do sidebar (logout/config) — só no mobile off-canvas */
.sidebar-mobile-footer { display: none; margin-top: 12px; padding-top: 12px; border-top: 1px solid rgba(255,255,255,.12); }
.sidebar-mobile-footer .nav-item { color: rgba(255,255,255,.7); }
.sidebar-mobile-footer .nav-item.text-danger { color: #fca5a5; }

/* ── Page Header ── */
.page-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 24px;
}
.page-header h1 { font-size: 1.5rem; font-weight: 700; }
.page-header p { color: var(--text-muted); font-size: .9rem; margin-top: 2px; }
.page-actions { display: flex; gap: 8px; }

/* ── Cards ── */
.card {
  background: var(--white); border-radius: var(--radius);
  box-shadow: var(--shadow); border: 1px solid var(--border);
}
.card-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px; border-bottom: 1px solid var(--border);
}
.card-header h2 { font-size: 1rem; font-weight: 600; }
.card-header-link { font-size: .85rem; color: var(--green-dark); }
.card-body { padding: 20px; }
.card-body.p-0 { padding: 0; }
.card-warning { border-left: 3px solid var(--warning); }
.mt-3 { margin-top: 16px; }
.mt-4 { margin-top: 24px; }

/* ── Stats ── */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px; margin-bottom: 24px; }
.stat-card {
  background: var(--white); border-radius: var(--radius); padding: 20px;
  box-shadow: var(--shadow); border: 1px solid var(--border);
  display: flex; align-items: center; gap: 16px;
}
.stat-card.stat-warning { border-left: 3px solid var(--warning); background: var(--warning-light); }
.stat-card.stat-success { border-left: 3px solid var(--success); }
.stat-icon { font-size: 2rem; }
.stat-number { font-size: 1.75rem; font-weight: 700; line-height: 1; }
.stat-label { font-size: .8rem; color: var(--text-muted); margin-top: 4px; }
.item-stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 16px; }

/* ── Tables ── */
.table-responsive { width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.table th { padding: 10px 16px; text-align: left; font-size: .75rem; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; color: var(--text-muted); border-bottom: 1px solid var(--border); background: var(--bg); }
.table td { padding: 12px 16px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tr:last-child td { border-bottom: none; }
.table-hover tbody tr:hover { background: var(--bg); }
.sort-link { color: inherit; text-decoration: none; display: inline-flex; align-items: center; gap: 3px; white-space: nowrap; cursor: pointer; }
.sort-link:hover { color: var(--text); text-decoration: none; }
.sort-link.active { color: var(--text); }
/* Seta neutra (⇅) nas colunas inativas: apagada, ganha cor no hover pra
   deixar claro que a coluna é ordenável. Na ativa (▲/▼) fica em cor plena. */
.sort-arrow { font-size: .7rem; opacity: .35; transition: opacity .15s, color .15s; }
.sort-link:hover .sort-arrow { opacity: .8; color: var(--green-dark); }
.sort-link.active .sort-arrow { opacity: 1; color: var(--green-dark); }
.row-warning { background: #fffbeb !important; }
.item-link { font-weight: 600; color: var(--text); }
.item-link:hover { color: var(--green-dark); }

/* ── Badges ── */
.badge {
  display: inline-block; padding: 3px 10px; border-radius: 20px;
  font-size: .75rem; font-weight: 600;
}
.badge-in { background: #dcfce7; color: #166534; }
.badge-out { background: #fee2e2; color: #991b1b; }
.badge-adjustment { background: #e0f2fe; color: #0369a1; }
.badge-warning { background: var(--warning-light); color: #92400e; }
.badge-source-web { background: #e0f2fe; color: #0369a1; }
.badge-source-whatsapp { background: #dcfce7; color: #166534; }
.badge-role-operator { background: #f1f5f9; color: #475569; }
.badge-role-manager { background: #e0f2fe; color: #0369a1; }
.badge-role-admin { background: #fdf4ff; color: #7e22ce; }

/* ── Buttons ── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 9px 18px; border-radius: 8px; font-size: .9rem; font-weight: 600;
  cursor: pointer; border: none; text-decoration: none; transition: all .15s;
}
.btn:hover { text-decoration: none; filter: brightness(0.95); }
.btn-primary { background: var(--green); color: white; }
.btn-secondary { background: var(--bg); color: var(--text); border: 1px solid var(--border); }
.btn-success { background: #22c55e; color: white; }
.btn-danger { background: var(--danger); color: white; }
.btn-outline { background: transparent; color: var(--text); border: 1px solid var(--border); }
.btn-outline-danger { background: transparent; color: var(--danger); border: 1px solid var(--danger); }
.btn-link { background: none; color: var(--green-dark); padding: 9px 4px; }
.btn-sm { padding: 5px 12px; font-size: .8rem; }
.btn-lg { padding: 13px 28px; font-size: 1rem; }
.btn-block { width: 100%; }
.btn-green { background: var(--green); color: white; }
.btn-ghost { background: transparent; color: white; border: 1px solid rgba(255,255,255,.4); }

/* ── Forms ── */
.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-size: .85rem; font-weight: 600; margin-bottom: 5px; color: var(--text); }
.form-control {
  width: 100%; padding: 9px 13px; border: 1px solid var(--border);
  border-radius: 8px; font-size: .9rem; color: var(--text);
  background: white; transition: border-color .15s;
}
.form-control:focus { outline: none; border-color: var(--green); box-shadow: 0 0 0 3px rgba(37,211,102,.1); }
.form-text { font-size: .78rem; color: var(--text-muted); margin-top: 3px; display: block; }
.form-row { display: flex; gap: 16px; }
.form-row .form-group { flex: 1; }
.form-row .col-3 { flex: 0 0 25%; }
.form-row .col-4 { flex: 0 0 33.33%; }
.form-row .col-6 { flex: 0 0 50%; }
.form-row .col-8 { flex: 0 0 66.66%; }
.form-actions { display: flex; gap: 10px; align-items: center; margin-top: 24px; }
.form-check-row { display: flex; align-items: center; gap: 8px; margin-bottom: 16px; }
.form-check-input { width: auto; margin: 0; }
.form-check-label { font-size: .85rem; color: var(--text); font-weight: normal; }
.search-form .search-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.search-input { max-width: 300px; }
.filter-form .filter-row { display: flex; align-items: flex-end; gap: 16px; flex-wrap: wrap; }
.filter-form .form-group { margin-bottom: 0; }
fieldset { border: 1px solid var(--border); border-radius: 8px; padding: 16px; }
fieldset legend { font-size: .85rem; font-weight: 600; color: var(--text-muted); padding: 0 6px; }

/* ── Alerts ── */
.alert {
  display: flex; align-items: flex-start; justify-content: space-between;
  padding: 12px 16px; border-radius: 8px; margin-bottom: 16px; font-size: .9rem;
}
.alert-success { background: var(--green-light); color: #166534; border: 1px solid #bbf7d0; }
.alert-danger { background: #fee2e2; color: #991b1b; border: 1px solid #fecaca; }
.alert-info { background: #e0f2fe; color: #0369a1; border: 1px solid #bae6fd; }
.alert-warning { background: var(--warning-light); color: #92400e; border: 1px solid #fde68a; }
.alert-close { background: none; border: none; cursor: pointer; font-size: .8rem; opacity: .7; padding: 0 4px; }

/* ── Dropdown ── */
.dropdown { position: relative; }
.avatar-btn {
  width: 36px; height: 36px; border-radius: 50%; background: var(--green);
  color: white; font-weight: 700; font-size: 1rem; border: none; cursor: pointer;
}
.dropdown-menu {
  position: absolute; right: 0; top: 44px; background: white; border-radius: 10px;
  box-shadow: var(--shadow-md); border: 1px solid var(--border);
  min-width: 200px; display: none; z-index: 200;
}
.dropdown-menu.open { display: block; }
.dropdown-header { padding: 12px 16px; }
.dropdown-header strong { display: block; font-size: .9rem; }
.dropdown-header small { color: var(--text-muted); font-size: .8rem; }
.dropdown-item { display: block; padding: 9px 16px; font-size: .9rem; color: var(--text); }
.dropdown-item:hover { background: var(--bg); text-decoration: none; }
.dropdown-item.text-danger { color: var(--danger); }

/* ── Dashboard grid ── */
.dashboard-grid { display: grid; grid-template-columns: 1fr 360px; gap: 20px; }
@media (max-width: 900px) { .dashboard-grid { grid-template-columns: 1fr; } }

/* ── Misc ── */
.text-muted { color: var(--text-muted) !important; font-size: .85rem; }
.text-danger { color: var(--danger) !important; }
.text-green { color: var(--green); }
.ms-1 { margin-left: 4px; }
.ms-2 { margin-left: 8px; }
.mb-0 { margin-bottom: 0; }
.mb-3 { margin-bottom: 16px; }
.empty-state { text-align: center; padding: 48px 24px; color: var(--text-muted); }
.empty-icon { font-size: 3rem; margin-bottom: 12px; }
.actions { white-space: nowrap; display: flex; gap: 4px; }
.whatsapp-link { color: var(--green-dark); }
.forgot-link { margin-left: auto; font-size: .85rem; color: var(--text-muted); }

/* ── Auth pages ── */
.auth-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: var(--bg); padding: 24px; }
.auth-card { background: white; border-radius: 16px; padding: 40px; width: 100%; max-width: 420px; box-shadow: var(--shadow-md); border: 1px solid var(--border); }
.auth-logo { text-align: center; margin-bottom: 24px; }
.auth-title { font-size: 1.3rem; font-weight: 700; text-align: center; margin-bottom: 24px; }
.auth-subtitle { text-align: center; color: var(--text-muted); font-size: .9rem; margin-bottom: 20px; }
.auth-footer { text-align: center; margin-top: 20px; font-size: .85rem; color: var(--text-muted); }

/* ── Landing page ── */
.public-layout { background: white; }
.landing { font-family: 'Segoe UI', system-ui, sans-serif; }
.container { max-width: 1100px; margin: 0 auto; padding: 0 24px; }

.landing-nav {
  background: rgba(26,26,46,.95); backdrop-filter: blur(10px);
  position: sticky; top: 0; z-index: 100; padding: 14px 0; border-bottom: 1px solid rgba(255,255,255,.1);
}
.landing-nav .container { display: flex; align-items: center; justify-content: space-between; }
.nav-links { display: flex; align-items: center; gap: 28px; }
.nav-links a { color: rgba(255,255,255,.8); font-size: .9rem; text-decoration: none; }
.nav-links a:hover { color: white; }
.btn-outline-white { border: 1px solid rgba(255,255,255,.5); color: white; padding: 7px 18px; border-radius: 8px; font-size: .85rem; }

.hero {
  background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
  color: white; padding: 80px 0;
}
.hero .container { display: flex; gap: 60px; align-items: center; }
.hero-content { flex: 1; }
.hero-badge { display: inline-block; background: rgba(37,211,102,.15); color: var(--green); border: 1px solid rgba(37,211,102,.3); padding: 5px 14px; border-radius: 20px; font-size: .82rem; font-weight: 600; margin-bottom: 20px; }
.hero h1 { font-size: 2.5rem; font-weight: 800; line-height: 1.2; margin-bottom: 18px; }
.hero-subtitle { font-size: 1rem; color: rgba(255,255,255,.75); line-height: 1.6; margin-bottom: 28px; }
.hero-actions { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.hero-footnote { font-size: .8rem; color: rgba(255,255,255,.5); }

.hero-phone { flex: 0 0 320px; }
.phone-mockup {
  background: white; border-radius: 20px; padding: 20px;
  box-shadow: 0 20px 60px rgba(0,0,0,.4);
}
.chat-bubble { padding: 10px 14px; border-radius: 12px; margin-bottom: 10px; font-size: .85rem; line-height: 1.4; max-width: 85%; }
.chat-bubble.incoming { background: #f1f0f0; color: #333; align-self: flex-start; border-radius: 12px 12px 12px 2px; }
.chat-bubble.outgoing { background: #dcf8c6; color: #333; margin-left: auto; border-radius: 12px 12px 2px 12px; }

.features { padding: 80px 0; background: var(--bg); }
.section-title { text-align: center; font-size: 1.8rem; font-weight: 700; margin-bottom: 8px; }
.section-subtitle { text-align: center; color: var(--text-muted); margin-bottom: 48px; }
.features-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 24px; margin-top: 48px; }
.feature-card { background: white; border-radius: 14px; padding: 28px; box-shadow: var(--shadow); border: 1px solid var(--border); }
.feature-icon { font-size: 2.2rem; margin-bottom: 14px; }
.feature-card h3 { font-size: 1rem; font-weight: 700; margin-bottom: 8px; }
.feature-card p { font-size: .88rem; color: var(--text-muted); line-height: 1.6; }

.pricing { padding: 80px 0; }
.plans-grid { display: flex; gap: 24px; justify-content: center; flex-wrap: wrap; margin-top: 48px; }
.plan-card { background: white; border-radius: 16px; padding: 32px; width: 320px; box-shadow: var(--shadow); border: 1px solid var(--border); position: relative; }
.plan-featured { border: 2px solid var(--green); box-shadow: 0 8px 30px rgba(37,211,102,.2); }
.plan-badge { position: absolute; top: -12px; left: 50%; transform: translateX(-50%); background: var(--green); color: white; padding: 4px 16px; border-radius: 20px; font-size: .8rem; font-weight: 700; white-space: nowrap; }
.plan-header { margin-bottom: 20px; }
.plan-header h3 { font-size: 1.2rem; font-weight: 700; margin-bottom: 8px; }
.price-value { font-size: 2.2rem; font-weight: 800; color: var(--text); }
.price-period { font-size: .9rem; color: var(--text-muted); }
.plan-features { list-style: none; margin-bottom: 28px; }
.plan-features li { padding: 6px 0; font-size: .9rem; border-bottom: 1px solid var(--border); }
.plan-features li:last-child { border-bottom: none; }

.landing-footer { background: var(--sidebar-bg); color: rgba(255,255,255,.7); padding: 40px 0; text-align: center; }
.footer-links { margin-top: 12px; display: flex; gap: 20px; justify-content: center; }
.footer-links a { color: rgba(255,255,255,.6); font-size: .85rem; }

/* ── Checkout ── */
.checkout-page { min-height: 100vh; background: var(--bg); padding: 24px; }
.checkout-header { text-align: center; margin-bottom: 32px; }
.checkout-grid { display: grid; grid-template-columns: 320px 1fr; gap: 32px; max-width: 900px; margin: 0 auto; }
.checkout-summary { background: var(--sidebar-bg); color: white; border-radius: 16px; padding: 28px; height: fit-content; }
.checkout-summary h2 { font-size: 1rem; color: rgba(255,255,255,.7); margin-bottom: 20px; text-transform: uppercase; letter-spacing: .08em; }
.summary-plan { margin-bottom: 20px; }
.summary-plan-name { font-size: 1.1rem; font-weight: 700; }
.summary-plan-price { font-size: 1.6rem; font-weight: 800; color: var(--green); }
.summary-features { list-style: none; margin-bottom: 20px; }
.summary-features li { padding: 5px 0; font-size: .88rem; color: rgba(255,255,255,.8); }
.summary-guarantee { font-size: .82rem; color: rgba(255,255,255,.6); line-height: 1.7; }
.checkout-form-card { background: white; border-radius: 16px; padding: 32px; box-shadow: var(--shadow); }
.checkout-form-card h2 { font-size: 1.2rem; font-weight: 700; margin-bottom: 24px; }
.checkout-footnote { font-size: .78rem; color: var(--text-muted); text-align: center; margin-top: 12px; }

/* ── Pagy ── */
.pagy { display: flex; gap: 4px; justify-content: center; padding: 16px; flex-wrap: wrap; }
.pagy a, .pagy span { padding: 6px 12px; border-radius: 6px; font-size: .85rem; border: 1px solid var(--border); color: var(--text); }
.pagy a:hover { background: var(--bg); text-decoration: none; }
.pagy .current { background: var(--green); color: white; border-color: var(--green); }

@media (max-width: 768px) {
  .main-content { margin-left: 0; }
  .sidebar { transform: translateX(-100%); transition: transform .2s; }
  .sidebar.open { transform: translateX(0); }
  .form-row { flex-direction: column; }
  .dashboard-grid { grid-template-columns: 1fr; }
  .checkout-grid { grid-template-columns: 1fr; }
  .hero .container { flex-direction: column; }
  .hero-phone { display: none; }
  .hero h1 { font-size: 1.8rem; }
  .plans-grid { flex-direction: column; align-items: center; }

  /* #3 — topbar não deve estourar no mobile: some o nome da empresa */
  .topbar-company { display: none; }

  /* #10 — page-header empilha no mobile pra não quebrar o título */
  .page-header { flex-direction: column; align-items: flex-start; gap: 12px; }
  .page-header h1 { font-size: 1.25rem; }
  .page-actions { flex-wrap: wrap; }

  /* #3 — logout/config acessíveis no rodapé do sidebar off-canvas */
  .sidebar-mobile-footer { display: block; }
}

/* Alvo de toque: em dispositivos sem cursor fino (touch), garante ~44px de
   altura nos botões de ação compactos das tabelas (WCAG 2.5.5). */
@media (hover: none) and (pointer: coarse) {
  .actions .btn-sm { min-height: 44px; }
}
