/* ============================================================
   MEQ Vendas — Tema (sidebar escura fixa, ERP interno)
   ============================================================ */
:root {
  --meq-primary: #2563eb;       /* azul ação (blue-600) */
  --meq-primary-dark: #1d4ed8;
  --meq-sidebar-bg: #111827;    /* gray-900 */
  --meq-sidebar-border: #1f2937;/* gray-800 */
  --meq-sidebar-text: #d1d5db;  /* gray-300 */
  --meq-sidebar-muted: #6b7280; /* gray-500 */
  --meq-bg: #f8fafc;            /* slate-50 */
  --meq-card-border: #e5e7eb;
  --meq-text: #111827;
  --meq-text-muted: #6b7280;
  --meq-radius: 12px;
  --meq-sidebar-w: 256px;
}

* { box-sizing: border-box; }

body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background: var(--meq-bg);
  color: var(--meq-text);
  margin: 0;
  -webkit-font-smoothing: antialiased;
}

@keyframes meqToastIn { from { transform: translateX(20px); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* ============================================================
   SIDEBAR ESCURA FIXA
   ============================================================ */
#meq-sidebar {
  position: fixed;
  top: 0; left: 0;
  width: var(--meq-sidebar-w);
  height: 100vh;
  background: var(--meq-sidebar-bg);
  border-right: 1px solid var(--meq-sidebar-border);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  overflow-x: hidden;
  z-index: 1040;
  transition: transform .3s ease;
}
#meq-sidebar::-webkit-scrollbar { width: 6px; }
#meq-sidebar::-webkit-scrollbar-thumb { background: #374151; border-radius: 3px; }

.meq-sb-header {
  display: flex; align-items: center; gap: .75rem;
  height: 64px; padding: 0 1.25rem;
  border-bottom: 1px solid var(--meq-sidebar-border);
  flex-shrink: 0;
}
.meq-sb-logo-img { height: 32px; object-fit: contain; }
.meq-sb-logo-fallback {
  background: var(--meq-primary); width: 32px; height: 32px;
  border-radius: 8px; display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 1rem; flex-shrink: 0;
}
.meq-sb-title {
  color: #fff; font-weight: 700; font-size: 1rem; line-height: 1.15;
  word-break: break-word;
}

.meq-sb-nav { flex: 1; padding: 1rem .75rem; }

.meq-nav-heading {
  padding: 0 1rem; margin-top: 1rem; margin-bottom: .25rem;
  font-size: .7rem; font-weight: 600; letter-spacing: .05em;
  text-transform: uppercase; color: var(--meq-sidebar-muted);
}

.meq-nav-item {
  display: flex; align-items: center; gap: .75rem;
  padding: .7rem 1rem; margin-bottom: .15rem;
  font-size: .9rem; font-weight: 500;
  color: var(--meq-sidebar-text); text-decoration: none;
  border-radius: 8px; transition: background .15s, color .15s;
}
.meq-nav-item:hover { background: #1f2937; color: #fff; }
.meq-nav-item.active { background: var(--meq-primary); color: #fff; }
.meq-nav-item i { font-size: 1.05rem; width: 20px; text-align: center; }

.meq-nav-divider { border-top: 1px solid var(--meq-sidebar-border); margin: 1rem .5rem; }

.meq-sb-footer {
  border-top: 1px solid var(--meq-sidebar-border);
  padding: 1rem; display: flex; align-items: center; gap: .65rem;
  flex-shrink: 0;
}
.meq-sb-avatar {
  width: 36px; height: 36px; border-radius: 50%;
  background: rgba(37,99,235,.2); border: 1px solid #1e40af;
  color: #60a5fa; font-weight: 700; font-size: .9rem;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.meq-sb-user { display: flex; flex-direction: column; overflow: hidden; flex: 1; }
.meq-sb-user-name { color: #fff; font-size: .85rem; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.meq-sb-user-role { color: #9ca3af; font-size: .72rem; text-transform: capitalize; }
.meq-sb-logout {
  background: none; border: none; color: #9ca3af; font-size: 1.1rem;
  cursor: pointer; padding: .25rem; border-radius: 6px;
}
.meq-sb-logout:hover { color: #f87171; background: #1f2937; }

/* ============================================================
   ÁREA PRINCIPAL
   ============================================================ */
.meq-main {
  margin-left: var(--meq-sidebar-w);
  min-height: 100vh;
  display: flex; flex-direction: column;
}
.meq-content { flex: 1; padding: 1.75rem; }

/* Topbar (header) — visível em todas as telas, usuário à direita */
#meq-topbar {
  display: flex;
  align-items: center; gap: .75rem;
  height: 60px; padding: 0 1.5rem;
  background: #fff;
  border-bottom: 1px solid var(--meq-card-border);
  position: sticky; top: 0; z-index: 1030;
}
.meq-burger { background: none; border: none; color: var(--meq-text); font-size: 1.5rem; cursor: pointer; }
.meq-topbar-title { font-weight: 700; }
.meq-topbar-spacer { flex: 1; }

/* Menu de usuário (canto superior direito) */
.meq-user-menu { position: relative; }
.meq-user-btn {
  display: flex; align-items: center; gap: .6rem;
  background: none; border: 1px solid var(--meq-card-border);
  border-radius: 999px; padding: .3rem .7rem .3rem .35rem; cursor: pointer;
  transition: background .15s;
}
.meq-user-btn:hover { background: #f8fafc; }
.meq-user-avatar {
  width: 34px; height: 34px; border-radius: 50%;
  background: var(--meq-primary); color: #fff; font-weight: 700; font-size: .9rem;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.meq-user-info { flex-direction: column; align-items: flex-start; line-height: 1.1; }
.meq-user-name { font-size: .85rem; font-weight: 600; color: var(--meq-text); }
.meq-user-role { font-size: .72rem; color: var(--meq-text-muted); text-transform: capitalize; }
.meq-user-dropdown {
  position: absolute; right: 0; top: calc(100% + .5rem);
  background: #fff; border: 1px solid var(--meq-card-border); border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0,0,0,.12); min-width: 220px; padding: .4rem;
  opacity: 0; visibility: hidden; transform: translateY(-6px); transition: .15s; z-index: 1050;
}
.meq-user-dropdown.open { opacity: 1; visibility: visible; transform: translateY(0); }
.meq-user-dropdown-head { padding: .6rem .75rem; border-bottom: 1px solid var(--meq-card-border); margin-bottom: .3rem; }
.meq-user-dropdown-head .meq-user-name { font-size: .9rem; }
.meq-user-email { font-size: .75rem; color: var(--meq-text-muted); word-break: break-all; }
.meq-user-dropdown-item {
  display: flex; align-items: center; gap: .6rem; width: 100%;
  background: none; border: none; text-align: left; padding: .6rem .75rem;
  border-radius: 7px; cursor: pointer; font-size: .88rem; color: var(--meq-text);
}
.meq-user-dropdown-item:hover { background: #f1f5f9; }

/* Setinha do dashboard separada do link */
.meq-nav-toggle { display: flex; align-items: center; gap: .65rem; background: none; margin-bottom: .15rem; }
.meq-nav-toggle-link {
  display: flex; align-items: center; gap: .75rem; flex: 1;
  padding: .7rem 1rem; color: var(--meq-sidebar-text); text-decoration: none;
  font-size: .9rem; font-weight: 500; border-radius: 8px;
}
.meq-nav-toggle-link:hover { background: #1f2937; color: #fff; }
.meq-nav-toggle-link i { font-size: 1.05rem; width: 20px; text-align: center; }
.meq-nav-caret-btn {
  background: none; border: none; color: var(--meq-sidebar-muted); cursor: pointer;
  padding: .5rem .75rem; border-radius: 8px;
}
.meq-nav-caret-btn:hover { background: #1f2937; color: #fff; }

#meq-overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,.5); z-index: 1035;
}
#meq-overlay.show { display: block; }

/* ============================================================
   CABEÇALHO DE PÁGINA
   ============================================================ */
.meq-page-head {
  display: flex; justify-content: space-between; align-items: flex-start;
  flex-wrap: wrap; gap: 1rem; margin-bottom: 1.5rem;
}
.meq-page-title { font-size: 1.6rem; font-weight: 700; margin: 0; color: var(--meq-text); }
.meq-page-sub { color: var(--meq-text-muted); font-size: .9rem; margin: .15rem 0 0; }

/* ============================================================
   CARDS / STAT CARDS
   ============================================================ */
.meq-card {
  background: #fff; border: 1px solid var(--meq-card-border);
  border-radius: var(--meq-radius); box-shadow: 0 1px 3px rgba(0,0,0,.04);
}
.meq-card-body { padding: 1.25rem; }
.meq-card-head {
  padding: 1rem 1.25rem; border-bottom: 1px solid var(--meq-card-border);
  display: flex; justify-content: space-between; align-items: center;
}
.meq-card-title { font-size: 1rem; font-weight: 600; margin: 0; }

.stat-card {
  background: #fff; border: 1px solid var(--meq-card-border);
  border-radius: var(--meq-radius); padding: 1.1rem 1.25rem;
  display: flex; align-items: center; gap: 1rem; height: 100%;
  box-shadow: 0 1px 3px rgba(0,0,0,.04);
}
.stat-icon {
  width: 48px; height: 48px; border-radius: 10px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center; font-size: 1.4rem;
}
.stat-value { font-size: 1.5rem; font-weight: 700; line-height: 1.1; }
.stat-label { font-size: .8rem; color: var(--meq-text-muted); }
.stat-sub { font-size: .72rem; color: var(--meq-text-muted); margin-top: .15rem; }

/* ============================================================
   TABELAS
   ============================================================ */
.meq-table { width: 100%; border-collapse: collapse; font-size: .88rem; }
.meq-table thead th {
  text-align: left; padding: .7rem .85rem;
  font-size: .72rem; font-weight: 600; text-transform: uppercase; letter-spacing: .03em;
  color: var(--meq-text-muted); border-bottom: 2px solid var(--meq-card-border);
  white-space: nowrap; cursor: default; user-select: none;
}
.meq-table thead th.sortable { cursor: pointer; }
.meq-table thead th.sortable:hover { color: var(--meq-primary); }
.meq-table tbody td { padding: .7rem .85rem; border-bottom: 1px solid #f1f5f9; vertical-align: middle; }
.meq-table tbody tr:hover { background: #f8fafc; }
.meq-table .text-end { text-align: right; }
.meq-table .text-center { text-align: center; }

/* Tabelas centralizadas (clientes, vendas, orçamentos, vendedores) */
.meq-table-center thead th,
.meq-table-center tbody td { text-align: center; }

.meq-table-wrap { overflow-x: auto; }

/* Botões de ação em linha */
.meq-icon-btn {
  background: none; border: 1px solid transparent; cursor: pointer;
  padding: .3rem .45rem; border-radius: 6px; color: var(--meq-text-muted); font-size: .95rem;
}
.meq-icon-btn:hover { background: #f1f5f9; color: var(--meq-primary); }
.meq-icon-btn.danger:hover { color: #dc2626; }

/* ============================================================
   FORMULÁRIOS / BOTÕES
   ============================================================ */
.btn-meq { background: var(--meq-primary); border-color: var(--meq-primary); color: #fff; }
.btn-meq:hover { background: var(--meq-primary-dark); border-color: var(--meq-primary-dark); color: #fff; }

.meq-empty { text-align: center; padding: 3rem 1rem; color: var(--meq-text-muted); }
.meq-empty i { font-size: 2.5rem; display: block; margin-bottom: .5rem; opacity: .4; }

.meq-loading { text-align: center; padding: 3rem 1rem; color: var(--meq-text-muted); }

/* ============================================================
   RESPONSIVO
   ============================================================ */
@media (max-width: 991.98px) {
  #meq-sidebar { transform: translateX(-100%); }
  #meq-sidebar.open { transform: translateX(0); }
  .meq-main { margin-left: 0; }
  #meq-topbar { display: flex; }
  .meq-content { padding: 1rem; }
}

/* ============================================================
   MODAIS (próprios, sem depender do bootstrap.bundle.js)
   ============================================================ */
.meq-modal {
  display: none; position: fixed; inset: 0; z-index: 1060;
  background: rgba(15,23,42,.55); padding: 1rem;
  align-items: flex-start; justify-content: center; overflow-y: auto;
}
.meq-modal.show { display: flex; }
.meq-modal-dialog {
  background: #fff; border-radius: var(--meq-radius);
  width: 100%; max-width: 560px; margin: 2rem auto;
  box-shadow: 0 20px 60px rgba(0,0,0,.3); animation: meqToastIn .2s ease;
}
.meq-modal-dialog.lg { max-width: 760px; }
.meq-modal-dialog.xl { max-width: 980px; }
.meq-modal-head {
  display: flex; justify-content: space-between; align-items: center;
  padding: 1rem 1.25rem; border-bottom: 1px solid var(--meq-card-border);
}
.meq-modal-title { font-size: 1.05rem; font-weight: 700; margin: 0; }
.meq-modal-close { background: none; border: none; font-size: 1.3rem; color: var(--meq-text-muted); cursor: pointer; line-height: 1; }
.meq-modal-close:hover { color: var(--meq-text); }
.meq-modal-body { padding: 1.25rem; }
.meq-modal-foot { padding: 1rem 1.25rem; border-top: 1px solid var(--meq-card-border); display: flex; justify-content: flex-end; gap: .5rem; }

@media (max-width: 575.98px) {
  .hide-mobile { display: none !important; }
  .meq-modal { padding: 0; }
  .meq-modal-dialog,
  .meq-modal-dialog.lg,
  .meq-modal-dialog.xl {
    max-width: 100%; margin: 0; min-height: 100%; border-radius: 0;
  }
  .meq-modal-head { position: sticky; top: 0; background: #fff; z-index: 2; }
  .meq-modal-foot { position: sticky; bottom: 0; background: #fff; }
}

/* Mini-cards financeiros (detalhe de cliente/produto) */
.mini-stat { background: #f8fafc; border: 1px solid var(--meq-card-border); border-radius: 10px; padding: .75rem .9rem; }
.mini-stat-label { font-size: .68rem; text-transform: uppercase; letter-spacing: .03em; color: var(--meq-text-muted); }
.mini-stat-value { font-size: 1.15rem; font-weight: 700; margin-top: .15rem; }

/* Form labels compactas */
.meq-form-label { font-size: .8rem; font-weight: 600; color: #374151; margin-bottom: .25rem; }

/* ============================================================
   GRUPO DE NAVEGAÇÃO EXPANSÍVEL (dropdown de Dashboards)
   ============================================================ */
.meq-nav-group { margin-bottom: .15rem; }
.meq-nav-toggle { width: 100%; background: none; border: none; cursor: pointer; text-align: left; position: relative; }
.meq-nav-caret { margin-left: auto; font-size: .8rem !important; width: auto !important; transition: transform .2s; }
.meq-nav-toggle.open .meq-nav-caret { transform: rotate(180deg); }
.meq-nav-sub { max-height: 0; overflow: hidden; transition: max-height .25s ease; }
.meq-nav-sub.open { max-height: 800px; }
.meq-nav-subitem { padding-left: 2.5rem !important; font-size: .85rem !important; }
.meq-nav-subitem i { font-size: .95rem !important; }

/* ============================================================
   SININHO DE NOTIFICAÇÕES (header)
   ============================================================ */
.meq-notif-btn {
  position: relative; display: inline-flex; align-items: center; justify-content: center;
  width: 40px; height: 40px; border-radius: 50%; color: var(--meq-text);
  text-decoration: none; font-size: 1.2rem; transition: background .15s;
}
.meq-notif-btn:hover { background: #f1f5f9; color: var(--meq-primary); }
.meq-notif-badge {
  position: absolute; top: 2px; right: 2px; min-width: 18px; height: 18px;
  background: #dc2626; color: #fff; border-radius: 999px; font-size: .68rem;
  font-weight: 700; display: flex; align-items: center; justify-content: center;
  padding: 0 4px; border: 2px solid #fff;
}
/* Notificações — cartões */
.notif-card { display: flex; gap: .9rem; align-items: flex-start; padding: 1rem 1.1rem; border: 1px solid var(--meq-card-border); border-radius: 11px; margin-bottom: .7rem; background: #fff; }
.notif-card.pendente { border-left: 4px solid #dc2626; }
.notif-card.visualizada { border-left: 4px solid #f59e0b; }
.notif-card.feita { border-left: 4px solid #16a34a; opacity: .7; }
.notif-ic { width: 42px; height: 42px; border-radius: 10px; flex-shrink: 0; display: flex; align-items: center; justify-content: center; font-size: 1.2rem; }
.notif-body { flex: 1; }
.notif-title { font-weight: 600; font-size: .92rem; }
.notif-desc { font-size: .82rem; color: var(--meq-text-muted); margin-top: .15rem; }
.notif-meta { font-size: .72rem; color: var(--meq-text-muted); margin-top: .4rem; }
