/* ============================================================
   BluePDV - Main Stylesheet
   ============================================================ */
:root {
  --blue-900: #0a1628;
  --blue-800: #0d2040;
  --blue-700: #1a3a6e;
  --blue-600: #1e4db7;
  --blue-500: #2563eb;
  --blue-400: #3b82f6;
  --blue-300: #60a5fa;
  --blue-100: #dbeafe;
  --blue-50:  #eff6ff;
  --accent:   #00d4aa;
  --accent2:  #f59e0b;
  --danger:   #ef4444;
  --success:  #10b981;
  --warning:  #f59e0b;
  --text-primary: #0f172a;
  --text-secondary: #64748b;
  --bg-light: #f8fafc;
  --bg-card: #ffffff;
  --border: #e2e8f0;
  --shadow: 0 1px 3px rgba(0,0,0,.08), 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);
  --shadow-lg: 0 10px 15px rgba(0,0,0,.1), 0 4px 6px rgba(0,0,0,.05);
  --sidebar-width: 260px;
  --topbar-height: 64px;
  --radius: 12px;
  --radius-sm: 8px;
  --font: 'Sora', sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
}

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

body {
  font-family: var(--font);
  background: var(--bg-light);
  color: var(--text-primary);
  margin: 0;
  padding: 0;
  overflow-x: hidden;
}

/* ── Sidebar ── */
.sidebar {
  position: fixed;
  left: 0; top: 0; bottom: 0;
  width: var(--sidebar-width);
  background: var(--blue-900);
  display: flex;
  flex-direction: column;
  z-index: 1000;
  transition: transform .3s ease, width .3s ease;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--blue-700) transparent;
}

.sidebar.collapsed { transform: translateX(calc(-1 * var(--sidebar-width))); }

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 20px 20px 16px;
  border-bottom: 1px solid rgba(255,255,255,.08);
}

.brand-logo {
  width: 42px; height: 42px;
  background: linear-gradient(135deg, var(--blue-500), var(--accent));
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 20px; color: white;
  box-shadow: 0 4px 12px rgba(37,99,235,.4);
  flex-shrink: 0;
}

.brand-name {
  font-size: 20px; font-weight: 700;
  color: white; letter-spacing: -0.5px;
}
.brand-name span { color: var(--accent); }
.brand-version { font-size: 10px; color: rgba(255,255,255,.4); display: block; font-family: var(--font-mono); }

.sidebar-empresa {
  margin: 8px 12px;
  background: rgba(255,255,255,.06);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  display: flex; align-items: center; gap: 8px;
  color: rgba(255,255,255,.7);
  font-size: 12px; font-weight: 500;
}

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

.nav-section {
  font-size: 9px; font-weight: 700;
  letter-spacing: 1.5px;
  color: rgba(255,255,255,.3);
  padding: 16px 20px 4px;
  text-transform: uppercase;
}

.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 16px;
  margin: 2px 8px;
  border-radius: var(--radius-sm);
  color: rgba(255,255,255,.65);
  text-decoration: none;
  font-size: 13.5px; font-weight: 500;
  transition: all .2s;
  position: relative;
}

.nav-item:hover {
  background: rgba(255,255,255,.07);
  color: white;
}

.nav-item.active {
  background: linear-gradient(135deg, var(--blue-600), var(--blue-500));
  color: white;
  box-shadow: 0 4px 12px rgba(37,99,235,.35);
}

.nav-item.nav-highlight:not(.active) {
  background: rgba(0,212,170,.12);
  color: var(--accent);
  border: 1px solid rgba(0,212,170,.25);
}

.nav-item i { font-size: 16px; width: 20px; flex-shrink: 0; }

.badge-new {
  margin-left: auto;
  background: var(--accent);
  color: var(--blue-900);
  font-size: 9px; font-weight: 700;
  padding: 2px 6px; border-radius: 20px;
  letter-spacing: .5px;
}

.sidebar-footer {
  padding: 12px;
  border-top: 1px solid rgba(255,255,255,.08);
}

.btn-logout {
  display: flex; align-items: center; gap: 8px;
  width: 100%; padding: 10px 12px;
  background: rgba(239,68,68,.12);
  color: #fca5a5;
  border: 1px solid rgba(239,68,68,.2);
  border-radius: var(--radius-sm);
  text-decoration: none;
  font-size: 13px; font-weight: 500;
  transition: all .2s;
}
.btn-logout:hover { background: rgba(239,68,68,.25); color: #fecaca; }

/* ── Main Wrapper ── */
.main-wrapper {
  margin-left: var(--sidebar-width);
  min-height: 100vh;
  transition: margin-left .3s;
  display: flex; flex-direction: column;
}
.main-wrapper.expanded { margin-left: 0; }

/* ── Topbar ── */
.topbar {
  height: var(--topbar-height);
  background: white;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center;
  padding: 0 20px;
  gap: 16px;
  position: sticky; top: 0; z-index: 100;
  box-shadow: var(--shadow);
}

.sidebar-toggle {
  background: none; border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  width: 36px; height: 36px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; color: var(--text-secondary);
  font-size: 18px; transition: all .2s;
}
.sidebar-toggle:hover { background: var(--blue-50); color: var(--blue-500); border-color: var(--blue-300); }

.topbar-breadcrumb {
  display: flex; align-items: center; gap: 6px;
  color: var(--text-secondary); font-size: 13px;
}

.topbar-right {
  margin-left: auto;
  display: flex; align-items: center; gap: 12px;
}

.topbar-clock {
  font-family: var(--font-mono);
  font-size: 13px; color: var(--text-secondary);
  background: var(--bg-light);
  padding: 4px 10px; border-radius: 6px;
  border: 1px solid var(--border);
}

.user-btn {
  display: flex; align-items: center; gap: 8px;
  background: none; border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 6px 10px; cursor: pointer;
  transition: all .2s;
}
.user-btn:hover { background: var(--blue-50); border-color: var(--blue-300); }

.user-avatar {
  width: 30px; height: 30px;
  background: linear-gradient(135deg, var(--blue-500), var(--blue-400));
  color: white; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 700;
}

.user-info { text-align: left; }
.user-name { display: block; font-size: 12px; font-weight: 600; color: var(--text-primary); }
.user-role { display: block; font-size: 10px; color: var(--text-secondary); }

/* ── Content Area ── */
.content-area {
  padding: 24px;
  flex: 1;
}

/* ── Page Header ── */
.page-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 24px; flex-wrap: wrap; gap: 12px;
}
.page-title {
  font-size: 22px; font-weight: 700;
  color: var(--text-primary); margin: 0;
}
.page-subtitle { color: var(--text-secondary); font-size: 13px; margin: 0; }

/* ── Cards ── */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  transition: box-shadow .2s;
}
.card:hover { box-shadow: var(--shadow-md); }
.card-header {
  background: none;
  border-bottom: 1px solid var(--border);
  padding: 16px 20px;
  font-weight: 600; font-size: 14px;
  display: flex; align-items: center; gap: 8px;
}
.card-body { padding: 20px; }

/* ── Stat Cards ── */
.stat-card {
  background: white;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  display: flex; align-items: flex-start; gap: 16px;
  transition: all .2s;
  position: relative; overflow: hidden;
}
.stat-card::before {
  content: '';
  position: absolute; top: 0; left: 0;
  width: 4px; height: 100%;
}
.stat-card.blue::before { background: var(--blue-500); }
.stat-card.green::before { background: var(--success); }
.stat-card.amber::before { background: var(--warning); }
.stat-card.red::before { background: var(--danger); }
.stat-card.teal::before { background: var(--accent); }

.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }

.stat-icon {
  width: 48px; height: 48px; border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px; flex-shrink: 0;
}
.stat-card.blue .stat-icon { background: var(--blue-50); color: var(--blue-500); }
.stat-card.green .stat-icon { background: #dcfce7; color: var(--success); }
.stat-card.amber .stat-icon { background: #fef3c7; color: var(--warning); }
.stat-card.red .stat-icon { background: #fee2e2; color: var(--danger); }
.stat-card.teal .stat-icon { background: #d0faf4; color: var(--accent); }

.stat-label { font-size: 12px; color: var(--text-secondary); font-weight: 500; margin-bottom: 4px; }
.stat-value { font-size: 22px; font-weight: 700; color: var(--text-primary); line-height: 1; }
.stat-value.mono { font-family: var(--font-mono); font-size: 18px; }
.stat-change { font-size: 11px; margin-top: 4px; font-weight: 500; }
.stat-change.up { color: var(--success); }
.stat-change.down { color: var(--danger); }

/* ── Tables ── */
.table { font-size: 13.5px; }
.table th { font-weight: 600; color: var(--text-secondary); font-size: 11px; text-transform: uppercase; letter-spacing: .5px; border-bottom: 2px solid var(--border) !important; }
.table td { vertical-align: middle; border-color: var(--border); }
.table tbody tr:hover { background: var(--blue-50); }

/* ── Buttons ── */
.btn { font-size: 13px; font-weight: 600; border-radius: var(--radius-sm); padding: 8px 16px; transition: all .2s; }
.btn-primary { background: var(--blue-500); border-color: var(--blue-500); }
.btn-primary:hover { background: var(--blue-600); border-color: var(--blue-600); box-shadow: 0 4px 12px rgba(37,99,235,.35); }
.btn-success { background: var(--success); border-color: var(--success); }
.btn-outline-primary { color: var(--blue-500); border-color: var(--blue-300); }
.btn-outline-primary:hover { background: var(--blue-500); color: white; }
.btn-sm { padding: 5px 10px; font-size: 12px; }

/* ── Forms ── */
.form-control, .form-select {
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  color: var(--text-primary);
  transition: all .2s;
}
.form-control:focus, .form-select:focus {
  border-color: var(--blue-400);
  box-shadow: 0 0 0 3px rgba(59,130,246,.15);
}
.form-label { font-size: 12px; font-weight: 600; color: var(--text-secondary); margin-bottom: 6px; }

/* ── Badges ── */
.badge { font-size: 11px; font-weight: 600; padding: 4px 8px; border-radius: 6px; }

/* ── Alerts ── */
.alert { border-radius: var(--radius-sm); border: none; font-size: 13.5px; }

/* ── PDV Specific ── */
.pdv-wrapper {
  display: grid;
  grid-template-columns: 1fr 400px;
  gap: 20px;
  height: calc(100vh - var(--topbar-height) - 48px);
}

.pdv-left, .pdv-right {
  background: white;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  display: flex; flex-direction: column;
  overflow: hidden;
}

.pdv-search-bar {
  padding: 16px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-light);
}

.pdv-cart {
  flex: 1; overflow-y: auto;
  padding: 0;
}

.cart-item {
  display: grid;
  grid-template-columns: 1fr auto auto auto;
  gap: 8px;
  align-items: center;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  transition: background .15s;
}
.cart-item:hover { background: var(--blue-50); }
.cart-item-name { font-weight: 500; }
.cart-item-price { color: var(--text-secondary); font-size: 11px; }

.cart-qty-btn {
  width: 26px; height: 26px; border-radius: 6px;
  border: 1px solid var(--border); background: white;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; font-weight: 700; transition: all .15s;
}
.cart-qty-btn:hover { background: var(--blue-500); color: white; border-color: var(--blue-500); }

.pdv-totals {
  padding: 16px;
  border-top: 1px solid var(--border);
  background: var(--bg-light);
}

.total-row {
  display: flex; justify-content: space-between;
  align-items: center; margin-bottom: 6px;
  font-size: 13px;
}
.total-row.grand {
  font-size: 20px; font-weight: 700;
  color: var(--blue-600);
  border-top: 2px solid var(--border);
  padding-top: 10px; margin-top: 10px;
}

.payment-grid {
  display: grid; grid-template-columns: 1fr 1fr;
  gap: 8px; margin: 12px 0;
}
.pay-btn {
  padding: 12px 8px;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  background: white; cursor: pointer;
  text-align: center; font-size: 12px; font-weight: 600;
  color: var(--text-secondary);
  transition: all .2s;
}
.pay-btn:hover, .pay-btn.active {
  border-color: var(--blue-500);
  background: var(--blue-50);
  color: var(--blue-600);
}
.pay-btn i { display: block; font-size: 20px; margin-bottom: 4px; }

/* ── Caixa Status ── */
.caixa-aberto { color: var(--success); }
.caixa-fechado { color: var(--danger); }

/* ── Responsive ── */
@media (max-width: 992px) {
  .sidebar { transform: translateX(calc(-1 * var(--sidebar-width))); }
  .sidebar.mobile-open { transform: translateX(0); }
  .main-wrapper { margin-left: 0; }
  .pdv-wrapper { grid-template-columns: 1fr; height: auto; }
}

@media (max-width: 576px) {
  .content-area { padding: 12px; }
  .stat-value { font-size: 18px; }
}

/* ── Animations ── */
@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
.fade-in { animation: fadeIn .3s ease forwards; }

@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: .6; } }
.pulse { animation: pulse 2s infinite; }

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--blue-300); }

/* ── Modal ── */
.modal-content { border-radius: var(--radius); border: none; box-shadow: var(--shadow-lg); }
.modal-header { border-bottom: 1px solid var(--border); background: var(--bg-light); border-radius: var(--radius) var(--radius) 0 0; }

/* ── Toast ── */
.toast-container { z-index: 9999; }
.toast { border-radius: var(--radius-sm); font-size: 13px; }

/* ── Login Page ── */
.login-page {
  min-height: 100vh;
  background: linear-gradient(135deg, var(--blue-900) 0%, var(--blue-800) 50%, var(--blue-700) 100%);
  display: flex; align-items: center; justify-content: center;
  position: relative; overflow: hidden;
}
.login-page::before {
  content: '';
  position: absolute; inset: 0;
  background: radial-gradient(circle at 20% 80%, rgba(0,212,170,.15) 0%, transparent 50%),
              radial-gradient(circle at 80% 20%, rgba(37,99,235,.2) 0%, transparent 50%);
}
.login-card {
  background: rgba(255,255,255,.97);
  border-radius: 20px;
  padding: 40px;
  width: 100%; max-width: 420px;
  box-shadow: 0 25px 60px rgba(0,0,0,.3);
  position: relative;
}
.login-logo {
  width: 60px; height: 60px;
  background: linear-gradient(135deg, var(--blue-500), var(--accent));
  border-radius: 16px;
  display: flex; align-items: center; justify-content: center;
  font-size: 28px; color: white; margin: 0 auto 20px;
  box-shadow: 0 8px 24px rgba(37,99,235,.4);
}

/* ── Additional Utilities ── */
.fw-500 { font-weight: 500; }
.fw-600 { font-weight: 600; }
.fw-700 { font-weight: 700; }

/* ── Print styles ── */
@media print {
  .sidebar, .topbar, .page-header .btn, form.row, form.d-flex,
  .btn, button, .modal, .alert-dismissible .btn-close { display: none !important; }
  .main-wrapper { margin: 0 !important; }
  .content-area { padding: 10px !important; }
  .card { box-shadow: none !important; border: 1px solid #ddd !important; }
}

/* ── Dashboard specific ── */
.table-danger-subtle { background: rgba(239,68,68,.04); }

/* ── PDV fullscreen mode ── */
.pdv-wrapper {
  min-height: calc(100vh - var(--topbar-height) - 48px);
}

@media (max-width: 768px) {
  .pdv-wrapper {
    grid-template-columns: 1fr;
    height: auto;
  }
  .pdv-left, .pdv-right {
    height: auto;
  }
}

/* ── Mobile nav open ── */
@media (max-width: 992px) {
  .sidebar.mobile-open {
    transform: translateX(0);
    box-shadow: 4px 0 24px rgba(0,0,0,.4);
  }
}

/* ── Quick action buttons ── */
.quick-actions {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 12px;
}
.quick-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 16px;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  background: white;
  cursor: pointer;
  text-decoration: none;
  color: var(--text-primary);
  font-size: 13px;
  font-weight: 600;
  transition: all .2s;
}
.quick-btn:hover {
  border-color: var(--blue-400);
  background: var(--blue-50);
  color: var(--blue-600);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}
.quick-btn i { font-size: 24px; }

/* ── Status badges ── */
.status-ativo { color: var(--success); }
.status-inativo { color: var(--text-secondary); }
.status-bloqueado { color: var(--danger); }

/* ── Inventory alert ── */
.estoque-critico { 
  background: linear-gradient(135deg, rgba(239,68,68,.08), transparent);
  border-left: 3px solid var(--danger) !important;
}
.estoque-baixo {
  background: linear-gradient(135deg, rgba(245,158,11,.08), transparent);
  border-left: 3px solid var(--warning) !important;
}
