/* ============================================================
   SuaLojaPDV — Admin CSS v2.0
   Sidebar recolhível + Mobile/Tablet slide-over
   © 2026 SuaLojaPDV Soluções e Automação
   ============================================================ */

/* ---- VARIÁVEIS ---- */
:root {
  --sb-width:260px;
  --sb-collapsed-width:68px;
  --sb-bg:linear-gradient(180deg,#0f172a 0%,#1e3a8a 100%);
  --sb-transition:all .28s cubic-bezier(.4,0,.2,1);
  --topbar-h:60px;
}

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

/* ================================================================
   SIDEBAR PRINCIPAL (nova versão recolhível)
   ================================================================ */
.adm-sidebar {
  width:var(--sb-width);
  min-width:var(--sb-width);
  background:var(--sb-bg);
  color:#fff;
  display:flex;
  flex-direction:column;
  position:fixed;
  top:0; left:0;
  height:100vh;
  z-index:500;
  transition:var(--sb-transition);
  box-shadow:4px 0 24px rgba(0,0,0,.18);
  overflow:hidden;
}
.adm-sidebar::-webkit-scrollbar { width:0; }

/* --- Header da sidebar --- */
.adm-sb-head {
  display:flex;
  align-items:center;
  gap:10px;
  padding:0 14px;
  height:60px;
  border-bottom:1px solid rgba(255,255,255,.1);
  flex-shrink:0;
}
.adm-sb-brand { display:flex; align-items:center; gap:10px; flex:1; min-width:0; }
.adm-sb-logo {
  width:36px; height:36px; border-radius:10px;
  background:rgba(255,255,255,.15);
  display:flex; align-items:center; justify-content:center;
  font-size:16px; flex-shrink:0;
}
.adm-sb-name {
  font-size:15px; font-weight:700;
  white-space:nowrap; overflow:hidden; text-overflow:ellipsis;
  transition:var(--sb-transition);
}

/* Botão recolher (apenas desktop) */
.adm-sb-collapse-btn {
  background:rgba(255,255,255,.1);
  border:none; color:#fff;
  width:28px; height:28px; border-radius:7px;
  display:flex; align-items:center; justify-content:center;
  cursor:pointer; transition:.2s; font-size:11px;
  flex-shrink:0;
}
.adm-sb-collapse-btn:hover { background:rgba(255,255,255,.25); }

/* Botão fechar (apenas mobile/tablet) */
.adm-sb-close-btn {
  display:none;
  background:rgba(255,255,255,.1);
  border:none; color:#fff;
  width:28px; height:28px; border-radius:7px;
  align-items:center; justify-content:center;
  cursor:pointer; transition:.2s; font-size:15px;
  flex-shrink:0;
}
.adm-sb-close-btn:hover { background:rgba(255,255,255,.25); }

/* --- Área de scroll --- */
.adm-sb-scroll {
  flex:1; overflow-y:auto; overflow-x:hidden;
  padding:8px 0;
}
.adm-sb-scroll::-webkit-scrollbar { width:3px; }
.adm-sb-scroll::-webkit-scrollbar-thumb { background:rgba(255,255,255,.15); border-radius:3px; }

/* --- Grupos de navegação --- */
.adm-nav-group { padding:10px 10px 4px; }
.adm-nav-label {
  font-size:10px; font-weight:700; text-transform:uppercase;
  letter-spacing:1.5px; color:rgba(255,255,255,.38);
  padding:0 8px; margin-bottom:6px;
  white-space:nowrap; overflow:hidden;
  transition:opacity .2s, height .2s;
}
.adm-nav-link {
  display:flex; align-items:center; gap:10px;
  padding:9px 10px; border-radius:9px;
  font-size:13.5px; font-weight:500;
  color:rgba(255,255,255,.75);
  text-decoration:none; margin-bottom:2px;
  position:relative; transition:.18s;
  white-space:nowrap; overflow:hidden;
}
.adm-nav-link:hover { background:rgba(255,255,255,.12); color:#fff; }
.adm-nav-link.active { background:rgba(59,130,246,.38); color:#fff; font-weight:600; }
.adm-nav-link i { width:20px; text-align:center; font-size:15px; flex-shrink:0; }
.adm-nav-link span { transition:opacity .15s; }
.adm-nav-exit { color:rgba(255,130,130,.9) !important; }
.adm-nav-exit:hover { background:rgba(239,68,68,.15) !important; color:#fca5a5 !important; }

/* Badge de notificação */
.adm-badge {
  margin-left:auto;
  background:#ef4444; color:#fff;
  font-size:10px; font-weight:700; font-style:normal;
  padding:2px 6px; border-radius:50px;
  white-space:nowrap; flex-shrink:0;
  transition:opacity .15s;
}

/* Tooltip no estado collapsed */
.adm-nav-link::after {
  content: attr(data-tip);
  position:absolute; left:calc(var(--sb-collapsed-width) + 4px); top:50%;
  transform:translateY(-50%);
  background:#1e293b; color:#fff; font-size:12px; font-weight:600;
  padding:5px 10px; border-radius:7px; white-space:nowrap;
  opacity:0; pointer-events:none;
  transition:opacity .15s; z-index:999;
  box-shadow:0 4px 12px rgba(0,0,0,.3);
}

/* --- Rodapé com usuário --- */
.adm-sb-foot {
  display:flex; align-items:center; gap:10px;
  padding:12px 14px;
  border-top:1px solid rgba(255,255,255,.1);
  flex-shrink:0; overflow:hidden;
}
.adm-sb-foot-avatar {
  width:34px; height:34px; border-radius:50%;
  background:rgba(59,130,246,.5);
  display:flex; align-items:center; justify-content:center;
  font-size:14px; font-weight:700; flex-shrink:0;
}
.adm-sb-foot-info { min-width:0; transition:opacity .15s; }
.adm-sb-foot-name { font-size:13px; font-weight:600; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.adm-sb-foot-role { font-size:11px; color:rgba(255,255,255,.5); }
.adm-readonly-tag {
  font-size:9px; background:rgba(251,191,36,.3);
  padding:1px 5px; border-radius:4px; margin-left:4px; color:#fde68a;
}

/* ================================================================
   ESTADO RECOLHIDO — Desktop
   ================================================================ */
.adm-sidebar.sb-collapsed {
  width:var(--sb-collapsed-width);
  min-width:var(--sb-collapsed-width);
}
/* Esconder textos */
.adm-sidebar.sb-collapsed .adm-sb-name,
.adm-sidebar.sb-collapsed .adm-nav-label,
.adm-sidebar.sb-collapsed .adm-nav-link span,
.adm-sidebar.sb-collapsed .adm-badge,
.adm-sidebar.sb-collapsed .adm-sb-foot-info { opacity:0; width:0; overflow:hidden; }
/* Centralizar ícones */
.adm-sidebar.sb-collapsed .adm-nav-link { justify-content:center; padding:10px 0; gap:0; }
.adm-sidebar.sb-collapsed .adm-sb-foot { justify-content:center; }
/* Tooltip visível */
.adm-sidebar.sb-collapsed .adm-nav-link:hover::after { opacity:1; }
/* Brand centralizada */
.adm-sidebar.sb-collapsed .adm-sb-brand { justify-content:center; }
.adm-sidebar.sb-collapsed .adm-sb-collapse-btn i { transform:rotate(180deg); }

/* ---- CONTEÚDO PRINCIPAL ---- */
.admin-main {
  flex:1;
  margin-left:var(--sb-width);
  background:#f0f4ff;
  min-height:100vh;
  transition:var(--sb-transition);
}
.admin-main.sb-main-collapsed { margin-left:var(--sb-collapsed-width); }
/* compatibilidade com classe antiga */
.admin-main.collapsed { margin-left:var(--sb-collapsed-width); }

/* ================================================================
   OVERLAY ESCURO — Mobile/Tablet
   ================================================================ */
.sb-overlay {
  display:none;
  position:fixed; inset:0;
  background:rgba(0,0,0,.58);
  z-index:498;
  backdrop-filter:blur(2px);
  -webkit-backdrop-filter:blur(2px);
  transition:opacity .25s;
  cursor:pointer;
}
.sb-overlay.active { display:block; }

/* ================================================================
   HAMBURGER TOPBAR — visível em todos os tamanhos
   ================================================================ */
.adm-hamburger {
  display:flex !important;
  flex-direction:column;
  justify-content:center;
  align-items:center;
  gap:5px;
  width:38px; height:38px;
  padding:6px;
  background:none;
  border:none;
  cursor:pointer;
  border-radius:8px;
  transition:.2s;
  flex-shrink:0;
}
.adm-hamburger:hover { background:#f1f5f9; }
.adm-hamburger span {
  display:block;
  width:20px; height:2px;
  background:#1e293b;
  border-radius:2px;
  transition:.25s;
  pointer-events:none;
}

/* ---- TOPBAR ---- */
.admin-topbar {
  background:#fff;
  border-bottom:1px solid #e2e8f0;
  padding:0 20px;
  height:var(--topbar-h);
  display:flex;
  align-items:center;
  justify-content:space-between;
  position:sticky; top:0; z-index:50;
  box-shadow:0 1px 4px rgba(0,0,0,.06);
}
.admin-topbar h1 { font-size:20px; font-weight:700; color:#1e293b; }
.admin-breadcrumb { font-size:13px; color:#64748b; }
.adm-topbar-date { font-size:12px; color:#94a3b8; white-space:nowrap; }

/* ---- BODY ---- */
.admin-body { padding:28px; }

/* ---- STAT CARDS ---- */
.admin-stats-grid {
  display:grid;
  grid-template-columns:repeat(auto-fill, minmax(220px,1fr));
  gap:20px; margin-bottom:28px;
}
.admin-stat-card {
  background:#fff; border-radius:14px; padding:20px 24px;
  border:1px solid #e2e8f0; box-shadow:0 1px 3px rgba(0,0,0,.08);
  display:flex; align-items:center; gap:16px;
  transition:all .25s cubic-bezier(.4,0,.2,1);
}
.admin-stat-card:hover { box-shadow:0 4px 24px rgba(30,64,175,.10); transform:translateY(-2px); }
.admin-stat-icon {
  width:48px; height:48px; border-radius:12px;
  display:flex; align-items:center; justify-content:center;
  font-size:20px; flex-shrink:0;
}
.admin-stat-value { font-size:22px; font-weight:800; color:#1e293b; line-height:1; }
.admin-stat-label { font-size:12px; color:#64748b; margin-top:4px; font-weight:500; }

/* ---- TABLE ---- */
.table-container {
  background:#fff; border-radius:14px;
  border:1px solid #e2e8f0;
  overflow:hidden; margin-bottom:24px;
}
.table-filters {
  display:flex; align-items:center; gap:12px;
  padding:16px 20px; border-bottom:1px solid #e2e8f0; flex-wrap:wrap;
}
.data-table { width:100%; border-collapse:collapse; }
.data-table th {
  padding:10px 14px; background:#f8fafc;
  font-size:12px; font-weight:700; text-transform:uppercase;
  letter-spacing:.5px; color:#64748b; text-align:left;
  border-bottom:1px solid #e2e8f0; white-space:nowrap;
}
.data-table td {
  padding:12px 14px; font-size:14px; color:#374151;
  border-bottom:1px solid #f1f5f9; vertical-align:middle;
}
.data-table tr:last-child td { border-bottom:none; }
.data-table tr:hover td { background:#fafbff; }

/* ---- MODAL ---- */
.modal-overlay {
  position:fixed; inset:0;
  background:rgba(0,0,0,.5);
  z-index:1000; display:none;
  align-items:center; justify-content:center;
  padding:16px;
  backdrop-filter:blur(2px);
}
.modal-overlay.open { display:flex; }
.modal {
  background:#fff; border-radius:16px;
  padding:32px; max-width:600px; width:100%;
  max-height:90vh; overflow-y:auto;
  box-shadow:0 24px 64px rgba(0,0,0,.25);
}
.modal-header { display:flex; align-items:center; justify-content:space-between; margin-bottom:24px; }
.modal-header h3 { font-size:18px; font-weight:700; }
.modal-close { background:none; border:none; font-size:20px; color:#64748b; cursor:pointer; padding:4px; }
.modal-footer { display:flex; gap:12px; justify-content:flex-end; margin-top:24px; }

/* ---- SETTINGS ---- */
.settings-section { margin-bottom:32px; }
.settings-section h3 { font-size:15px; font-weight:700; color:#1e293b; margin-bottom:16px; padding-bottom:12px; border-bottom:1px solid #e2e8f0; display:flex; align-items:center; gap:8px; }

/* ---- ORDER DETAIL ---- */
.order-detail-grid { display:grid; grid-template-columns:2fr 1fr; gap:24px; }
.order-info-card { background:#fff; border-radius:14px; border:1px solid #e2e8f0; padding:24px; margin-bottom:20px; }
.order-info-card h4 { font-size:14px; font-weight:700; color:#475569; margin-bottom:16px; text-transform:uppercase; letter-spacing:.5px; }
.order-info-row { display:flex; justify-content:space-between; padding:8px 0; border-bottom:1px solid #f1f5f9; font-size:14px; }
.order-info-row:last-child { border-bottom:none; }
.order-timeline { margin-top:16px; }
.timeline-item { display:flex; gap:12px; margin-bottom:16px; }
.timeline-dot { width:32px; height:32px; border-radius:50%; display:flex; align-items:center; justify-content:center; font-size:12px; flex-shrink:0; }

/* ---- PRINT VIEW ---- */
@media print {
  .adm-sidebar, .admin-topbar, .no-print, .btn { display:none !important; }
  .admin-main { margin:0 !important; }
  body { background:#fff; }
}

/* ================================================================
   RESPONSIVO — Tablet e Mobile (<=1024px)
   Sidebar se torna drawer slide-over — começa FORA da tela
   ================================================================ */
@media (max-width:1024px) {
  /* Sidebar: posição fixa, fora da tela à esquerda */
  .adm-sidebar {
    transform:translateX(-100%);
    box-shadow:none;
    /* Sempre exibe na largura completa quando aberta no mobile */
    width:var(--sb-width) !important;
    min-width:var(--sb-width) !important;
    /* Resetar collapsed no mobile */
    z-index:502;
  }
  /* Slide para dentro */
  .adm-sidebar.sb-mobile-open {
    transform:translateX(0);
    box-shadow:6px 0 32px rgba(0,0,0,.30);
  }
  /* Anular collapsed no mobile — não faz sentido */
  .adm-sidebar.sb-collapsed {
    width:var(--sb-width) !important;
    min-width:var(--sb-width) !important;
  }
  .adm-sidebar.sb-collapsed .adm-sb-name,
  .adm-sidebar.sb-collapsed .adm-nav-label,
  .adm-sidebar.sb-collapsed .adm-nav-link span,
  .adm-sidebar.sb-collapsed .adm-badge,
  .adm-sidebar.sb-collapsed .adm-sb-foot-info {
    opacity:1 !important; width:auto !important; overflow:visible !important;
  }
  .adm-sidebar.sb-collapsed .adm-nav-link {
    justify-content:flex-start !important; padding:9px 10px !important; gap:10px !important;
  }
  .adm-sidebar.sb-collapsed .adm-sb-foot { justify-content:flex-start !important; }
  /* Mostrar botão fechar (X), esconder botão collapse */
  .adm-sb-close-btn { display:flex !important; }
  .adm-sb-collapse-btn { display:none !important; }
  /* Conteúdo ocupa 100% */
  .admin-main {
    margin-left:0 !important;
  }
  /* Layout */
  .order-detail-grid { grid-template-columns:1fr; }
  .form-row-3 { grid-template-columns:1fr 1fr; }
  /* Modais */
  .modal { max-width:calc(100vw - 32px) !important; padding:24px 18px; }
}

/* ================================================================
   RESPONSIVO — Mobile (<=768px)
   ================================================================ */
/* ================================================================
   RESPONSIVO — Tablet e Mobile (<=900px)
   1 coluna · 1 bloco por linha em TODO o painel admin
   ================================================================ */
@media (max-width:900px) {
  .admin-body          { padding:12px; }
  .admin-topbar        { padding:0 12px; }
  .adm-topbar-date     { display:none; }

  /* Stats: 2 colunas em tablet */
  .admin-stats-grid    { grid-template-columns:repeat(2,1fr); gap:10px; margin-bottom:16px; }

  /* Todas as classes de form-row → 1 coluna */
  .form-row,
  .form-row-3,
  .order-detail-grid   { grid-template-columns:1fr !important; gap:0 !important; }

  /* Grids inline por atributo style → 1 coluna */
  [style*="grid-template-columns:2fr 1fr"],
  [style*="grid-template-columns:1fr 2fr"],
  [style*="grid-template-columns:1fr 1fr"],
  [style*="grid-template-columns:1fr 1fr 1fr"],
  [style*="grid-template-columns:repeat(2,"],
  [style*="grid-template-columns:repeat(3,"],
  [style*="grid-template-columns:repeat(4,"],
  [style*="grid-template-columns:repeat(auto"] {
    grid-template-columns:1fr !important;
  }

  /* Produto / formulário: coluna lateral desce para baixo */
  .prod-form-grid      { grid-template-columns:1fr !important; }

  /* Cards de formulário: 1 bloco por linha */
  .checkout-card       { margin-bottom:14px !important; }

  /* Tabela com scroll horizontal */
  .table-container     { overflow-x:auto; -webkit-overflow-scrolling:touch; }
  .table-filters       { flex-direction:column; align-items:stretch; gap:8px; }
  .data-table          { min-width:520px; }

  /* Modais */
  .modal { max-width:calc(100vw - 20px) !important; padding:20px 14px !important; border-radius:14px; }

  /* Botões em grupo */
  .btn-group           { flex-wrap:wrap; gap:6px; }

  /* Rows de flex inline */
  [style*="display:flex"][style*="gap"] { flex-wrap:wrap; }

  /* Settings: grids internos → 1 coluna */
  .settings-section [style*="display:grid"]       { display:flex !important; flex-direction:column !important; }
  .settings-section [style*="grid-template-columns"] { display:flex !important; flex-direction:column !important; }

  /* Esconder colunas opcionais de tabelas */
  .hide-mobile         { display:none !important; }
}

/* ================================================================
   RESPONSIVO — Mobile (<=768px)
   ================================================================ */
@media (max-width:768px) {
  .admin-body          { padding:10px; }
  .admin-topbar        { padding:0 10px; }
  .admin-stats-grid    { grid-template-columns:1fr 1fr; gap:8px; }
  .form-row, .form-row-3, .order-detail-grid { grid-template-columns:1fr !important; }
  [style*="grid-template-columns"] { grid-template-columns:1fr !important; }
  [style*="display:grid"]          { grid-template-columns:1fr !important; }
}

/* ================================================================
   RESPONSIVO — Mobile pequeno (<=480px)
   ================================================================ */
@media (max-width:480px) {
  .admin-body             { padding:8px !important; }
  .admin-topbar           { padding:0 8px !important; }
  .admin-stats-grid       { grid-template-columns:1fr !important; gap:8px; }
  .data-table th,
  .data-table td          { padding:8px 6px; font-size:12px; }
  h2[style*="font-size:22px"] { font-size:17px !important; }
  .adm-hamburger          { width:34px; height:34px; }
  .modal                  { padding:16px 10px !important; }
  [style*="grid-template-columns"] { grid-template-columns:1fr !important; }
  [style*="display:grid"]          { grid-template-columns:1fr !important; }
}

/* Footer admin global */
.admin-footer-global {
  text-align:center; padding:14px 20px; font-size:12px;
  color:#94a3b8; border-top:1px solid #e2e8f0;
  margin-top:auto; background:#f8fafc;
}
