/* ============================================================================
   WHATSAPP GRUPOS APP - estilos consolidados
   Tema: verde WhatsApp (#25D366 / #128C7E), light, limpo, denso.
   A variavel --primaria e --primaria-escura vem do <style> inline no base
   (lido do empresa_config), entao o admin pode trocar a cor.
   ============================================================================ */

:root {
  --primaria:           #25D366;
  --primaria-escura:    #128C7E;
  --bg:                 #f6f7f8;
  --bg-card:            #ffffff;
  --texto:              #111827;
  --texto-secundario:   #4b5563;
  --texto-fraco:        #9ca3af;
  --borda:              #e5e7eb;
  --borda-forte:        #d1d5db;
  --sombra-card:        0 1px 2px rgba(0,0,0,.04), 0 1px 3px rgba(0,0,0,.06);
  --r:                  8px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 14px;
  color: var(--texto);
  background: var(--bg);
  line-height: 1.45;
}

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

h1, h2, h3, h4 { margin: 0 0 8px; line-height: 1.25; }
h1 { font-size: 22px; }
h2 { font-size: 18px; }
h3 { font-size: 16px; }
h4 { font-size: 14px; }

code { background: #f1f5f9; padding: 1px 5px; border-radius: 4px; font-size: 12.5px; }

/* ============================================================================
   APP SHELL (sidebar + main)
   ============================================================================ */
.app {
  display: grid;
  grid-template-columns: 240px 1fr;
  min-height: 100vh;
}

.sidebar {
  background: linear-gradient(180deg, #0f172a 0%, #1e293b 100%);
  color: #e2e8f0;
  display: flex;
  flex-direction: column;
  border-right: 1px solid #0b1224;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.sidebar-admin {
  background: linear-gradient(180deg, var(--primaria-escura) 0%, #0b6b5d 100%);
}

.sb-logo {
  padding: 18px 16px;
  border-bottom: 1px solid rgba(255,255,255,.08);
}
.sb-logo img { max-height: 38px; max-width: 100%; }
.sb-logo-fb {
  display: flex; align-items: center; gap: 8px;
  font-weight: 800; font-size: 16px; letter-spacing: .02em;
}
.sb-logo-fb i { font-size: 28px; color: var(--primaria); }

.sb-nav {
  flex: 1;
  padding: 8px 0;
}
.sb-grupo {
  padding: 14px 16px 6px;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: rgba(255,255,255,.55);
}
.sb-sub {
  padding: 8px 16px 4px;
  font-size: 11px;
  font-weight: 700;
  color: rgba(255,255,255,.7);
}
.sb-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 16px;
  color: #e2e8f0;
  font-size: 13.5px;
  font-weight: 500;
  border-left: 3px solid transparent;
  transition: background .15s;
}
.sb-item:hover { background: rgba(255,255,255,.06); text-decoration: none; }
.sb-item.on {
  background: rgba(37, 211, 102, .14);
  border-left-color: var(--primaria);
  color: #fff;
  font-weight: 700;
}
.sb-item i { font-size: 18px; opacity: .9; }

.sb-bottom {
  padding: 14px 16px;
  border-top: 1px solid rgba(255,255,255,.08);
  font-size: 13px;
}
.sb-user {
  display: flex; align-items: center; gap: 8px;
  margin-bottom: 6px;
  color: #fff;
  font-weight: 700;
}
.sb-user i { font-size: 22px; }
.sb-logout {
  display: inline-flex; align-items: center; gap: 6px;
  color: rgba(255,255,255,.75);
  font-size: 13px;
}
.sb-logout:hover { color: #fff; text-decoration: none; }

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

.topbar {
  display: flex; align-items: center; gap: 16px;
  padding: 14px 22px;
  background: #fff;
  border-bottom: 1px solid var(--borda);
}
.topbar-titulo {
  flex: 1; margin: 0;
  font-size: 18px; font-weight: 800;
}
.topbar-acoes { display: flex; gap: 8px; align-items: center; }

.conteudo {
  padding: 22px;
  flex: 1;
  min-width: 0;
}

/* ============================================================================
   CARDS, TABELAS, FORMS
   ============================================================================ */
.card {
  background: var(--bg-card);
  border: 1px solid var(--borda);
  border-radius: 12px;
  box-shadow: var(--sombra-card);
  margin-bottom: 16px;
  overflow: hidden;
}
.card-h {
  padding: 13px 16px;
  border-bottom: 1px solid var(--borda);
  font-weight: 800;
  font-size: 14px;
  display: flex; align-items: center; gap: 8px;
  background: #fafafa;
}
.card-b { padding: 16px; }

.flex-between { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 880px) { .grid-2 { grid-template-columns: 1fr; } }

.tabela {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  background: #fff;
  border: 1px solid var(--borda);
  border-radius: 10px;
  overflow: hidden;
  font-size: 13.5px;
}
.tabela thead th {
  text-align: left;
  padding: 11px 12px;
  background: #fafafa;
  font-weight: 800;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .03em;
  color: var(--texto-secundario);
  border-bottom: 1px solid var(--borda);
}
.tabela tbody td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--borda);
  vertical-align: middle;
}
.tabela tbody tr:last-child td { border-bottom: 0; }
.tabela tbody tr:hover { background: #fafafa; }
.tabela.tabela-compact thead th { padding: 8px 10px; }
.tabela.tabela-compact tbody td { padding: 7px 10px; }
.tabela .vazio { text-align: center; color: var(--texto-fraco); padding: 24px 0; }

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
}
.form-grid label { display: flex; flex-direction: column; gap: 4px; font-size: 12.5px; font-weight: 700; color: var(--texto-secundario); }
.form-grid-full { grid-column: 1 / -1; }

input[type=text], input[type=email], input[type=password], input[type=number],
input[type=date], input[type=time], input[type=color], select, textarea {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--borda-forte);
  border-radius: var(--r);
  font-size: 13.5px;
  font-family: inherit;
  background: #fff;
  color: var(--texto);
  font-weight: 400;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--primaria);
  box-shadow: 0 0 0 3px rgba(37, 211, 102, .15);
}
input[type=color] { height: 38px; padding: 2px 4px; cursor: pointer; }

.check {
  display: inline-flex !important;
  flex-direction: row !important;
  align-items: center; gap: 6px;
  font-weight: 600;
  cursor: pointer;
}
.check input { width: auto; }

.form-acoes {
  display: flex; gap: 8px; align-items: center; flex-wrap: wrap;
  margin-top: 14px;
}

/* ============================================================================
   BOTOES
   ============================================================================ */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: 6px;
  padding: 9px 14px;
  background: #fff;
  border: 1px solid var(--borda-forte);
  color: var(--texto);
  border-radius: var(--r);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  text-decoration: none;
  transition: background .12s, border-color .12s;
  white-space: nowrap;
  font-family: inherit;
}
.btn:hover { background: #f9fafb; text-decoration: none; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn i { font-size: 16px; }

.btn-primary {
  background: var(--primaria);
  border-color: var(--primaria);
  color: #fff;
}
.btn-primary:hover { background: var(--primaria-escura); border-color: var(--primaria-escura); }

.btn-danger {
  background: #fff;
  border-color: #ef4444;
  color: #b91c1c;
}
.btn-danger:hover { background: #fef2f2; }

.btn-sm { padding: 6px 10px; font-size: 12.5px; }
.btn-sm i { font-size: 14px; }

.btn-block { width: 100%; padding: 11px 14px; }

/* ============================================================================
   BADGES, FLASH, KPIs
   ============================================================================ */
.badge {
  display: inline-block;
  font-size: 10.5px; font-weight: 800;
  padding: 2px 8px;
  border-radius: 999px;
  text-transform: uppercase;
  letter-spacing: .03em;
}
.badge.ok   { background: #dcfce7; color: #166534; }
.badge.warn { background: #fef3c7; color: #92400e; }

.flash-area { margin-bottom: 16px; }
.flash {
  padding: 10px 14px;
  border-radius: 8px;
  border: 1px solid;
  margin-bottom: 8px;
  font-size: 13px;
  font-weight: 500;
}
.flash-success { background: #dcfce7; border-color: #86efac; color: #166534; }
.flash-info,
.flash-message { background: #dbeafe; border-color: #93c5fd; color: #1e40af; }
.flash-warning,
.flash-warn    { background: #fef3c7; border-color: #fcd34d; color: #92400e; }
.flash-danger,
.flash-error   { background: #fee2e2; border-color: #fca5a5; color: #991b1b; }

.kpis-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}
.kpi {
  background: #fff;
  border: 1px solid var(--borda);
  border-radius: 12px;
  padding: 14px 16px;
}
.kpi-rotulo {
  font-size: 11px; font-weight: 800;
  text-transform: uppercase; letter-spacing: .04em;
  color: var(--texto-secundario);
}
.kpi-valor {
  font-size: 28px; font-weight: 800;
  color: var(--primaria-escura);
  margin-top: 4px;
}

/* ============================================================================
   PAGINA DE LOGIN (operador + admin)
   ============================================================================ */
.login-page {
  display: flex; align-items: center; justify-content: center;
  min-height: 100vh;
  background: linear-gradient(135deg, var(--primaria) 0%, var(--primaria-escura) 100%);
  padding: 20px;
}
.login-card {
  width: 100%; max-width: 380px;
  background: #fff;
  border-radius: 14px;
  padding: 28px 26px;
  box-shadow: 0 12px 40px rgba(0,0,0,.18);
}
.login-card.login-admin .login-logo i { color: var(--primaria-escura); }
.login-logo { text-align: center; margin-bottom: 18px; }
.login-logo i { font-size: 52px; color: var(--primaria); }
.login-logo img { max-width: 200px; max-height: 80px; }
.login-logo h1 { margin: 8px 0 2px; font-size: 19px; }
.login-tagline { margin: 0; font-size: 12.5px; color: var(--texto-secundario); }
.login-form { display: flex; flex-direction: column; gap: 12px; }
.login-form label { display: flex; flex-direction: column; gap: 4px; font-size: 12.5px; font-weight: 700; color: var(--texto-secundario); }
.login-foot { margin-top: 14px; text-align: center; font-size: 13px; }
.login-foot a { color: var(--texto-secundario); }

/* ============================================================================
   ESPECIFICOS
   ============================================================================ */
.ip-form {
  display: flex; gap: 8px; flex-wrap: wrap; align-items: center;
}
.ip-form input[type=text] { flex: 1; min-width: 160px; }

.logos-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
}
.logo-box {
  border: 1px solid var(--borda);
  border-radius: 10px;
  padding: 12px;
  background: #fafafa;
}
.logo-rot {
  font-size: 12px; font-weight: 800;
  color: var(--texto-secundario);
  margin-bottom: 8px;
}
.logo-prev {
  height: 90px;
  background: #fff;
  border: 1px dashed var(--borda-forte);
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  margin-bottom: 8px;
}
.logo-prev img { max-height: 80px; max-width: 100%; }
.logo-prev .vazio { color: var(--texto-fraco); font-size: 12px; }
.logo-box input[type=file] { width: 100%; font-size: 12px; }

.bloco-sub {
  margin: 14px 0 8px;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--texto-secundario);
}

.inline-form { display: inline-flex; gap: 8px; align-items: center; }

.vazio { text-align: center; color: var(--texto-fraco); padding: 22px 12px; font-size: 13px; }

.erro-card {
  max-width: 420px;
  margin: 60px auto;
  text-align: center;
  background: #fff;
  border: 1px solid var(--borda);
  border-radius: 14px;
  padding: 32px 24px;
  box-shadow: var(--sombra-card);
}
.erro-codigo {
  font-size: 64px; font-weight: 800;
  color: var(--primaria);
  line-height: 1;
}
.erro-msg {
  font-size: 15px;
  color: var(--texto-secundario);
  margin: 12px 0 22px;
}

/* responsivo */
@media (max-width: 720px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: relative; height: auto; }
  .conteudo { padding: 14px; }
  .topbar { padding: 10px 14px; }
  .form-grid { grid-template-columns: 1fr; }
}
