/* ============================================================
   AlfaSync - Estilos Globais
   Paleta: Verde #4CAF50 / Laranja #FF9800 / Preto #1a1a1a
   ============================================================ */

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

:root {
  --primary:       #4caf50;
  --primary-dark:  #388e3c;
  --primary-light: #e8f5e9;
  --secondary:     #FF9800;
  --secondary-dark:#e65100;
  --sidebar-bg:    #1a1a1a;
  --sidebar-text:  #c8c8c8;
  --sidebar-hover: #2d2d2d;
  --sidebar-active:#4caf50;
  --sidebar-width: 260px;
  --topbar-h:      64px;
  --bg:            #f4f6f9;
  --card-bg:       #ffffff;
  --text:          #2d3748;
  --text-muted:    #718096;
  --border:        #e2e8f0;
  --danger:        #e53e3e;
  --warning:       #d69e2e;
  --info:          #3182ce;
  --radius:        10px;
  --shadow:        0 2px 12px rgba(0,0,0,.07);
  --shadow-md:     0 4px 24px rgba(0,0,0,.10);
  --transition:    .2s ease;
}

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

body {
  font-family: 'Poppins', sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.6;
}

/* ---- Scrollbar ---- */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: #f1f1f1; }
::-webkit-scrollbar-thumb { background: #c1c1c1; border-radius: 3px; }

/* ============================================================
   LAYOUT ADMIN
   ============================================================ */

.app-wrapper {
  display: flex;
  min-height: 100vh;
}

/* ---- Sidebar ---- */
.sidebar {
  width: var(--sidebar-width);
  background: var(--sidebar-bg);
  position: fixed;
  top: 0; left: 0; bottom: 0;
  display: flex;
  flex-direction: column;
  z-index: 1000;
  transition: transform var(--transition);
  overflow-y: auto;
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 20px 22px;
  border-bottom: 1px solid rgba(255,255,255,.07);
  min-height: var(--topbar-h);
  text-decoration: none;
}

.sidebar-logo img {
  width: 38px;
  height: 38px;
  object-fit: contain;
}

.sidebar-logo-text {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
}

.sidebar-logo-text strong {
  color: #fff;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: .3px;
}

.sidebar-logo-text span {
  color: var(--primary);
  font-size: 10px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.sidebar-section {
  padding: 18px 22px 6px;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  color: rgba(255,255,255,.3);
}

.sidebar-nav {
  flex: 1;
  padding: 8px 12px;
}

.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 10px 12px;
  border-radius: 8px;
  color: var(--sidebar-text);
  text-decoration: none;
  font-size: 13.5px;
  font-weight: 400;
  transition: background var(--transition), color var(--transition);
  margin-bottom: 2px;
}

.sidebar-nav a:hover {
  background: var(--sidebar-hover);
  color: #fff;
}

.sidebar-nav a.active {
  background: rgba(76,175,80,.15);
  color: var(--primary);
  font-weight: 600;
}

.sidebar-nav a svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  stroke-width: 1.8;
}

.sidebar-footer {
  padding: 14px 16px;
  border-top: 1px solid rgba(255,255,255,.07);
}

.sidebar-footer a {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--sidebar-text);
  text-decoration: none;
  font-size: 13px;
  padding: 8px 10px;
  border-radius: 8px;
  transition: background var(--transition);
}

.sidebar-footer a:hover { background: var(--sidebar-hover); color: #fff; }

/* ---- Main Content ---- */
.main-content {
  margin-left: var(--sidebar-width);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* ---- Topbar ---- */
.topbar {
  height: var(--topbar-h);
  background: var(--card-bg);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
  position: sticky;
  top: 0;
  z-index: 100;
}

.topbar-title {
  font-size: 18px;
  font-weight: 600;
  color: var(--text);
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 14px;
}

.topbar-user {
  display: flex;
  align-items: center;
  gap: 10px;
}

.avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 700;
  font-size: 13px;
  flex-shrink: 0;
}

.topbar-user-info {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
}

.topbar-user-info strong { font-size: 13px; font-weight: 600; }
.topbar-user-info span { font-size: 11px; color: var(--text-muted); }

/* ---- Page Content ---- */
.page-content {
  padding: 28px;
  flex: 1;
}

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
  flex-wrap: wrap;
  gap: 12px;
}

.page-header h1 {
  font-size: 22px;
  font-weight: 700;
  color: var(--text);
}

.page-header p {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 2px;
}

/* ============================================================
   CARDS
   ============================================================ */

.card {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
}

.card-header {
  padding: 18px 22px 14px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.card-header h2 {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
}

.card-body { padding: 22px; }

/* ---- Stat Cards ---- */
.stat-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 18px;
  margin-bottom: 28px;
}

.stat-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 22px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 16px;
}

.stat-icon {
  width: 52px;
  height: 52px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.stat-icon.green  { background: var(--primary-light); color: var(--primary); }
.stat-icon.orange { background: #fff3e0; color: var(--secondary); }
.stat-icon.blue   { background: #e3f2fd; color: #1976d2; }
.stat-icon.red    { background: #fce4e4; color: var(--danger); }

.stat-icon svg { width: 26px; height: 26px; stroke-width: 1.8; }

.stat-info { flex: 1; }
.stat-value { font-size: 26px; font-weight: 700; line-height: 1.1; }
.stat-label { font-size: 12px; color: var(--text-muted); font-weight: 500; margin-top: 3px; }

/* ============================================================
   BOTÕES
   ============================================================ */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 9px 18px;
  border-radius: 8px;
  font-family: 'Poppins', sans-serif;
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid transparent;
  text-decoration: none;
  transition: all var(--transition);
  white-space: nowrap;
  line-height: 1;
}

.btn svg { width: 16px; height: 16px; stroke-width: 2; flex-shrink: 0; }

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

.btn-secondary {
  background: #fff;
  color: var(--text);
  border-color: var(--border);
}
.btn-secondary:hover { background: var(--bg); border-color: #b0bec5; }

.btn-danger {
  background: var(--danger);
  color: #fff;
  border-color: var(--danger);
}
.btn-danger:hover { background: #c53030; }

.btn-warning {
  background: var(--secondary);
  color: #fff;
  border-color: var(--secondary);
}
.btn-warning:hover { background: var(--secondary-dark); }

.btn-info {
  background: var(--info);
  color: #fff;
  border-color: var(--info);
}
.btn-info:hover { background: #2b6cb0; }

.btn-sm { padding: 6px 12px; font-size: 12px; }
.btn-lg { padding: 13px 28px; font-size: 15px; }
.btn-icon { padding: 5px; border-radius: 6px; line-height: 1; }
.btn-icon svg { width: 14px; height: 14px; margin: 0; display: block; }

/* ============================================================
   TABELAS
   ============================================================ */

.table-wrapper {
  overflow-x: auto;
  border-radius: var(--radius);
}

table.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.data-table thead th {
  background: var(--bg);
  color: var(--text-muted);
  font-weight: 600;
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: .6px;
  padding: 11px 16px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.data-table tbody tr { border-bottom: 1px solid var(--border); transition: background var(--transition); }
.data-table tbody tr:hover { background: #fafbfc; }
.data-table tbody td { padding: 10px 10px; vertical-align: middle; }
.data-table tbody td.col-acoes { white-space: nowrap; width: 1%; }
.data-table tbody tr:last-child { border-bottom: none; }

.table-actions {
  display: flex;
  gap: 3px;
  flex-wrap: nowrap;
  align-items: center;
  white-space: nowrap;
}

/* Coluna de ações — nunca quebra, largura automática */
.col-acoes {
  width: 1%;
  white-space: nowrap;
}

/* Ocultar colunas em telas menores */
@media (max-width: 900px) {
  .hide-md { display: none !important; }
}
@media (max-width: 600px) {
  .hide-sm { display: none !important; }
}

/* ============================================================
   FORMULÁRIOS
   ============================================================ */

.form-group { margin-bottom: 18px; }

.form-label {
  display: block;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 6px;
}

.form-label .req { color: var(--danger); margin-left: 3px; }

.form-control,
.form-select {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-family: 'Poppins', sans-serif;
  font-size: 13.5px;
  color: var(--text);
  background: #fff;
  transition: border-color var(--transition), box-shadow var(--transition);
  outline: none;
}

.form-control:focus,
.form-select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(76,175,80,.15);
}

.form-control.is-invalid { border-color: var(--danger); }
.form-text { font-size: 11.5px; color: var(--text-muted); margin-top: 4px; }
.invalid-feedback { font-size: 11.5px; color: var(--danger); margin-top: 4px; }

.form-row {
  display: grid;
  gap: 16px;
}

.form-row.cols-2 { grid-template-columns: 1fr 1fr; }
.form-row.cols-3 { grid-template-columns: 1fr 1fr 1fr; }
.form-row.cols-4 { grid-template-columns: 1fr 1fr 1fr 1fr; }

/* ============================================================
   BADGES / STATUS
   ============================================================ */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .4px;
}

.badge-success  { background: #e8f5e9; color: #2e7d32; }
.badge-warning  { background: #fff3e0; color: #e65100; }
.badge-danger   { background: #fce4e4; color: #c62828; }
.badge-info     { background: #e3f2fd; color: #1565c0; }
.badge-secondary{ background: #f5f5f5; color: #616161; }

/* ============================================================
   ALERTS
   ============================================================ */

.alert {
  padding: 13px 16px;
  border-radius: 8px;
  font-size: 13.5px;
  margin-bottom: 18px;
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.alert-success { background: #e8f5e9; color: #2e7d32; border: 1px solid #a5d6a7; }
.alert-danger  { background: #fce4e4; color: #c62828; border: 1px solid #ef9a9a; }
.alert-warning { background: #fff3e0; color: #e65100; border: 1px solid #ffcc80; }
.alert-info    { background: #e3f2fd; color: #1565c0; border: 1px solid #90caf9; }

/* ============================================================
   FILTROS
   ============================================================ */

.filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 18px;
  align-items: flex-end;
}

.filter-bar .form-control,
.filter-bar .form-select {
  max-width: 200px;
  flex: 1;
  min-width: 120px;
}

/* ============================================================
   MODAL
   ============================================================ */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition);
}

.modal-overlay.show { opacity: 1; pointer-events: all; }

.modal-box {
  background: #fff;
  border-radius: 12px;
  max-width: 500px;
  width: 100%;
  padding: 28px;
  box-shadow: var(--shadow-md);
  transform: translateY(-10px);
  transition: transform var(--transition);
}

.modal-overlay.show .modal-box { transform: translateY(0); }
.modal-title { font-size: 17px; font-weight: 700; margin-bottom: 12px; }
.modal-body  { font-size: 14px; color: var(--text); margin-bottom: 22px; line-height: 1.7; }
.modal-footer { display: flex; gap: 10px; justify-content: flex-end; }

/* ============================================================
   CHECKLIST
   ============================================================ */

.checklist-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.checklist-table th, .checklist-table td { padding: 9px 12px; border: 1px solid var(--border); text-align: center; }
.checklist-table th { background: var(--sidebar-bg); color: #fff; font-weight: 600; font-size: 12px; }
.checklist-table td:first-child { width: 38px; font-weight: 700; color: var(--text-muted); }
.checklist-table td:nth-child(2) { text-align: left; }
.checklist-table tr:nth-child(even) td { background: #fafbfc; }

.checklist-checkbox {
  width: 20px;
  height: 20px;
  cursor: pointer;
  accent-color: var(--primary);
}

/* ============================================================
   PÚBLICO (checklist/subordem sem login)
   ============================================================ */

.public-wrapper {
  max-width: 720px;
  margin: 0 auto;
  padding: 20px 16px;
}

.public-header {
  text-align: center;
  padding: 20px 0 16px;
  margin-bottom: 20px;
  border-bottom: 2px solid var(--primary);
}

.public-header img { width: 60px; margin-bottom: 8px; }
.public-header h1  { font-size: 18px; font-weight: 700; color: var(--text); }
.public-header p   { font-size: 13px; color: var(--text-muted); }

/* ============================================================
   LOGIN / CADASTRO (área pública)
   ============================================================ */

.auth-wrapper {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--sidebar-bg);
  padding: 20px;
}

.auth-card {
  background: #fff;
  border-radius: 16px;
  padding: 40px;
  width: 100%;
  max-width: 440px;
  box-shadow: 0 8px 40px rgba(0,0,0,.25);
}

.auth-logo {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 28px;
}

.auth-logo img { width: 46px; }

.auth-logo-text strong { display: block; font-size: 17px; font-weight: 700; }
.auth-logo-text span   { font-size: 11px; color: var(--text-muted); }

.auth-title {
  font-size: 20px;
  font-weight: 700;
  margin-bottom: 6px;
}

.auth-subtitle {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 28px;
}

/* ============================================================
   RESPONSIVO
   ============================================================ */

/* Impedir zoom indesejado no iOS ao focar inputs */
@media screen and (max-width: 768px) {
  input[type="text"], input[type="email"], input[type="password"],
  input[type="number"], input[type="tel"], input[type="date"],
  select, textarea {
    font-size: 16px !important;
  }
}

@media (max-width: 900px) {
  .form-row.cols-3,
  .form-row.cols-4 { grid-template-columns: 1fr 1fr; }
  .charts-tempo { grid-template-columns: 1fr !important; }
}

@media (max-width: 768px) {
  /* Layout base */
  .sidebar { transform: translateX(-100%); transition: transform .25s ease; }
  .sidebar.open { transform: translateX(0); }
  .main-content { margin-left: 0 !important; }
  .topbar { padding: 0 14px; }
  .page-content { padding: 14px; }

  /* Formulários */
  .form-row.cols-2,
  .form-row.cols-3,
  .form-row.cols-4 { grid-template-columns: 1fr; }

  /* Cards de estatística */
  .stat-cards { grid-template-columns: 1fr 1fr; }

  /* Auth */
  .auth-card { padding: 24px 18px; }

  /* Tabelas: scroll horizontal */
  .table-wrapper { overflow-x: auto; -webkit-overflow-scrolling: touch; }

  /* Filtros em coluna */
  .filter-bar { flex-direction: column; align-items: stretch; }
  .filter-bar .form-control,
  .filter-bar .form-select,
  .filter-bar .btn { width: 100%; max-width: 100%; }

  /* Page header */
  .page-header { flex-direction: column; align-items: flex-start; gap: 10px; }
  .page-header > div:last-child { width: 100%; }
  .page-header .btn { width: 100%; justify-content: center; }

  /* Cards gráfico */
  .charts-tempo { grid-template-columns: 1fr !important; }

  /* Topbar empresa tag */
  .empresa-ativa-tag .empresa-cnpj { display: none; }
  /* Ocultar nome/função do usuário na topbar — manter só o avatar */
  .topbar-user-info { display: none; }
  /* Ocultar botão "Trocar" estabelecimento — acesso via menu */
  .btn-trocar-emp { display: none; }
  /* Garantir que topbar não transborde */
  .topbar { overflow: hidden; }
  .topbar-right { min-width: 0; overflow: hidden; }
  .empresa-ativa-tag { max-width: 180px; flex-shrink: 1; min-width: 0; }
  .empresa-ativa-tag strong { max-width: 120px; }

  /* Modais */
  .modal-box { width: 95vw !important; max-width: 95vw !important; padding: 20px 16px; }
}

@media (max-width: 480px) {
  /* Em telas muito pequenas ocultar tag de empresa (só avatar visível) */
  .empresa-ativa-tag { display: none; }
  .stat-cards { grid-template-columns: 1fr 1fr; }
  .page-content { padding: 10px; }

  /* Botões de ação em tabelas — ícones menores */
  .btn-icon { padding: 4px 5px; }
  .btn-icon svg { width: 13px; height: 13px; }

  /* Ocultar colunas extras em telas muito pequenas */
  .hide-xs { display: none !important; }
}

/* ============================================================
   PÚBLICO (checklist / subordem) — mobile
   ============================================================ */

.public-wrapper { max-width: 600px; margin: 0 auto; padding: 16px; }

@media (max-width: 480px) {
  .public-wrapper { padding: 10px; }
  .public-header { padding: 16px 10px; }
  .public-header h1 { font-size: 16px; }
  .checklist-table { font-size: 11px; }
  .checklist-table .item-desc { font-size: 11px; }
  .item-col label { font-size: 11px; }
  .item-col { gap: 6px; }
}

/* ============================================================
   HAMBURGUER (mobile)
   ============================================================ */

.btn-hamburger {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  padding: 6px;
  color: var(--text);
}

.btn-hamburger svg { width: 24px; height: 24px; }

@media (max-width: 768px) {
  .btn-hamburger { display: flex; }
  .sidebar-overlay {
    position: fixed; inset: 0;
    background: rgba(0,0,0,.5);
    z-index: 999;
    display: none;
  }
  .sidebar-overlay.show { display: block; }
}

/* ============================================================
   MISC
   ============================================================ */

.text-muted  { color: var(--text-muted); }
.text-danger { color: var(--danger); }
.text-success{ color: var(--primary); }
.fw-600      { font-weight: 600; }
.mb-0 { margin-bottom: 0; }
.mt-4 { margin-top: 16px; }
.gap-2{ gap: 8px; }
.d-flex { display: flex; }
.align-items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.w-100 { width: 100%; }

/* ── Empresa ativa no topbar ─────────────────────────────── */
.empresa-ativa-tag {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(255,255,255,.08);
  border: 1px solid rgba(255,255,255,.12);
  border-radius: 8px;
  padding: 6px 12px;
  font-size: 12px;
  color: var(--text-main);
  max-width: 260px;
}
.empresa-ativa-tag svg { flex-shrink: 0; color: var(--primary); }
.empresa-ativa-tag div { overflow: hidden; }
.empresa-ativa-tag strong { display: block; font-weight: 600; font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.empresa-ativa-tag span  { display: block; font-size: 11px; color: var(--text-muted); }
.btn-trocar-emp {
  display: flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
  font-size: 11px;
  font-weight: 600;
  color: var(--primary);
  text-decoration: none;
  padding: 4px 8px;
  border-radius: 6px;
  border: 1px solid var(--primary);
  margin-left: 4px;
  flex-shrink: 0;
}
.btn-trocar-emp:hover { background: var(--primary); color: #fff; }
