/* ============================================================
   GESTÃO PRO - ESTILOS CUSTOMIZADOS
   ============================================================ */

:root {
  --primary: #6366f1;
  --primary-dark: #4f46e5;
  --bg-900: #0f172a;
  --bg-800: #1e293b;
  --bg-700: #334155;
  --bg-600: #475569;
  --text-primary: #f1f5f9;
  --text-secondary: #94a3b8;
  --border: #334155;
  --success: #22c55e;
  --warning: #f59e0b;
  --danger: #ef4444;
  --info: #3b82f6;
}

/* Light theme */
html:not(.dark) {
  --bg-900: #f8fafc;
  --bg-800: #ffffff;
  --bg-700: #f1f5f9;
  --bg-600: #e2e8f0;
  --text-primary: #0f172a;
  --text-secondary: #64748b;
  --border: #e2e8f0;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg-900);
  color: var(--text-primary);
  min-height: 100vh;
  overflow-x: hidden;
}

/* Scrollbar personalizada */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg-900); }
::-webkit-scrollbar-thumb { background: var(--bg-600); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--primary); }

/* ── Layout Principal ─────────────────────── */
.layout { display: flex; min-height: 100vh; }
.sidebar {
  width: 260px;
  min-height: 100vh;
  background: var(--bg-800);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  left: 0; top: 0; bottom: 0;
  z-index: 100;
  transition: transform 0.3s ease;
}
.sidebar.collapsed { transform: translateX(-260px); }
.main-content {
  margin-left: 260px;
  flex: 1;
  min-height: 100vh;
  transition: margin-left 0.3s ease;
}
.main-content.expanded { margin-left: 0; }

/* ── Sidebar ─────────────────────────────── */
.sidebar-logo {
  padding: 20px 20px 16px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 12px;
}
.logo-icon {
  width: 40px; height: 40px;
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; color: white;
  box-shadow: 0 4px 12px rgba(99,102,241,0.4);
}
.logo-text { font-size: 18px; font-weight: 700; color: var(--text-primary); }
.logo-sub { font-size: 11px; color: var(--text-secondary); }

.sidebar-nav { padding: 12px 10px; flex: 1; overflow-y: auto; }
.nav-group-label {
  font-size: 10px; font-weight: 600; letter-spacing: 0.08em;
  color: var(--text-secondary); text-transform: uppercase;
  padding: 8px 10px 4px;
}
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px; border-radius: 8px;
  cursor: pointer; margin-bottom: 2px;
  color: var(--text-secondary);
  font-size: 14px; font-weight: 500;
  transition: all 0.2s;
  text-decoration: none;
  border: none; background: none; width: 100%; text-align: left;
}
.nav-item:hover { background: var(--bg-700); color: var(--text-primary); }
.nav-item.active {
  background: rgba(99,102,241,0.15);
  color: #818cf8;
  font-weight: 600;
}
.nav-item .nav-icon { width: 18px; text-align: center; font-size: 15px; }
.nav-badge {
  margin-left: auto;
  background: #ef4444;
  color: white; font-size: 10px; font-weight: 700;
  padding: 1px 6px; border-radius: 10px;
}

.sidebar-footer {
  padding: 12px;
  border-top: 1px solid var(--border);
}

/* ── Topbar ──────────────────────────────── */
.topbar {
  height: 60px;
  background: var(--bg-800);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center;
  padding: 0 24px; gap: 16px;
  position: sticky; top: 0; z-index: 50;
}
.topbar-title { font-size: 18px; font-weight: 700; flex: 1; }
.topbar-actions { display: flex; align-items: center; gap: 12px; }

/* ── Cards ───────────────────────────────── */
.card {
  background: var(--bg-800);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
  transition: box-shadow 0.2s, transform 0.2s;
}
.card:hover { box-shadow: 0 4px 20px rgba(0,0,0,0.2); }
.card-glass {
  background: rgba(30,41,59,0.6);
  backdrop-filter: blur(12px);
  border: 1px solid rgba(51,65,85,0.6);
}

.stat-card {
  background: var(--bg-800);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
  display: flex; align-items: center; gap: 16px;
}
.stat-icon {
  width: 52px; height: 52px; border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px; flex-shrink: 0;
}
.stat-info { flex: 1; }
.stat-value { font-size: 24px; font-weight: 700; line-height: 1.2; }
.stat-label { font-size: 13px; color: var(--text-secondary); margin-top: 2px; }
.stat-change { font-size: 12px; margin-top: 4px; }
.stat-change.up { color: var(--success); }
.stat-change.down { color: var(--danger); }

/* ── Buttons ─────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 8px 16px; border-radius: 8px;
  font-size: 14px; font-weight: 500; cursor: pointer;
  border: none; transition: all 0.2s;
  text-decoration: none; white-space: nowrap;
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover:not(:disabled) { background: var(--primary-dark); box-shadow: 0 4px 12px rgba(99,102,241,0.4); }
.btn-secondary { background: var(--bg-700); color: var(--text-primary); }
.btn-secondary:hover:not(:disabled) { background: var(--bg-600); }
.btn-success { background: #16a34a; color: white; }
.btn-success:hover:not(:disabled) { background: #15803d; }
.btn-danger { background: #dc2626; color: white; }
.btn-danger:hover:not(:disabled) { background: #b91c1c; }
.btn-ghost { background: transparent; color: var(--text-secondary); }
.btn-ghost:hover:not(:disabled) { background: var(--bg-700); color: var(--text-primary); }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-lg { padding: 12px 24px; font-size: 16px; }
.btn-icon { padding: 8px; border-radius: 8px; }
.btn-outline {
  background: transparent; border: 1px solid var(--border);
  color: var(--text-primary);
}
.btn-outline:hover:not(:disabled) { background: var(--bg-700); }

/* ── Forms ───────────────────────────────── */
.form-group { margin-bottom: 16px; }
.form-label {
  display: block; font-size: 13px; font-weight: 500;
  color: var(--text-secondary); margin-bottom: 6px;
}
.form-label .required { color: #ef4444; margin-left: 3px; }
.form-input, .form-select, .form-textarea {
  width: 100%; padding: 9px 12px;
  background: var(--bg-700); border: 1px solid var(--border);
  border-radius: 8px; color: var(--text-primary);
  font-size: 14px; transition: border-color 0.2s, box-shadow 0.2s;
  appearance: none;
}
.form-input:focus, .form-select:focus, .form-textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(99,102,241,0.15);
}
.form-input::placeholder { color: var(--text-secondary); }
.form-textarea { resize: vertical; min-height: 80px; }
.form-select option { background: var(--bg-800); }
.input-group { display: flex; gap: 8px; align-items: flex-end; }
.input-group .form-input { flex: 1; }
.form-error { font-size: 12px; color: var(--danger); margin-top: 4px; }
.form-hint { font-size: 12px; color: var(--text-secondary); 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; }

/* ── Tables ──────────────────────────────── */
.table-wrapper { overflow-x: auto; border-radius: 12px; }
.data-table { width: 100%; border-collapse: collapse; }
.data-table thead th {
  background: var(--bg-700); padding: 10px 14px;
  text-align: left; font-size: 12px; font-weight: 600;
  color: var(--text-secondary); text-transform: uppercase;
  letter-spacing: 0.05em; white-space: nowrap;
  border-bottom: 1px solid var(--border);
}
.data-table thead th:first-child { border-radius: 12px 0 0 0; }
.data-table thead th:last-child { border-radius: 0 12px 0 0; }
.data-table tbody tr {
  border-bottom: 1px solid var(--border);
  transition: background 0.15s;
}
.data-table tbody tr:hover { background: var(--bg-700); }
.data-table tbody td { padding: 10px 14px; font-size: 14px; }

/* ── Badges/Tags ─────────────────────────── */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 8px; border-radius: 20px;
  font-size: 11px; font-weight: 600; white-space: nowrap;
}
.badge-success { background: rgba(34,197,94,0.15); color: #22c55e; }
.badge-warning { background: rgba(245,158,11,0.15); color: #f59e0b; }
.badge-danger { background: rgba(239,68,68,0.15); color: #ef4444; }
.badge-info { background: rgba(59,130,246,0.15); color: #3b82f6; }
.badge-gray { background: rgba(100,116,139,0.15); color: #94a3b8; }
.badge-purple { background: rgba(139,92,246,0.15); color: #8b5cf6; }

/* ── Modal ───────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.7); backdrop-filter: blur(4px);
  z-index: 1000; display: flex; align-items: center; justify-content: center;
  padding: 20px; animation: fadeIn 0.2s ease;
}
.modal {
  background: var(--bg-800); border: 1px solid var(--border);
  border-radius: 16px; width: 100%; max-height: 90vh;
  display: flex; flex-direction: column; overflow: hidden;
  animation: slideUp 0.3s ease;
}
.modal-sm { max-width: 400px; }
.modal-md { max-width: 600px; }
.modal-lg { max-width: 800px; }
.modal-xl { max-width: 1100px; }
.modal-header {
  padding: 20px 24px 16px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between; flex-shrink: 0;
}
.modal-title { font-size: 18px; font-weight: 700; }
.modal-body { padding: 24px; overflow-y: auto; flex: 1; }
.modal-footer {
  padding: 16px 24px; border-top: 1px solid var(--border);
  display: flex; align-items: center; justify-content: flex-end; gap: 10px; flex-shrink: 0;
}

/* ── Search & Filters ────────────────────── */
.search-bar {
  position: relative; flex: 1; max-width: 400px;
}
.search-bar input { padding-left: 38px; }
.search-bar .search-icon {
  position: absolute; left: 12px; top: 50%;
  transform: translateY(-50%); color: var(--text-secondary);
  pointer-events: none;
}
.filter-bar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }

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

/* ── Grid ────────────────────────────────── */
.grid { display: grid; gap: 20px; }
.grid-cols-2 { grid-template-columns: repeat(2, 1fr); }
.grid-cols-3 { grid-template-columns: repeat(3, 1fr); }
.grid-cols-4 { grid-template-columns: repeat(4, 1fr); }
.grid-cols-2-1 { grid-template-columns: 2fr 1fr; }

/* ── PDV / Venda ─────────────────────────── */
.pdv-layout { display: grid; grid-template-columns: 1fr 380px; gap: 20px; height: calc(100vh - 130px); }
.pdv-products { overflow-y: auto; }
.pdv-cart {
  background: var(--bg-800); border: 1px solid var(--border);
  border-radius: 12px; display: flex; flex-direction: column;
  overflow: hidden;
}
.pdv-cart-header { padding: 16px; border-bottom: 1px solid var(--border); }
.pdv-cart-items { flex: 1; overflow-y: auto; padding: 12px; }
.pdv-cart-footer { padding: 16px; border-top: 1px solid var(--border); background: var(--bg-700); }
.cart-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px; background: var(--bg-700); border-radius: 8px;
  margin-bottom: 8px;
}
.cart-item-name { flex: 1; font-size: 13px; font-weight: 500; }
.cart-item-qty {
  display: flex; align-items: center; gap: 6px;
}
.qty-btn {
  width: 26px; height: 26px; border-radius: 6px;
  border: 1px solid var(--border); background: var(--bg-800);
  color: var(--text-primary); cursor: pointer; font-size: 14px;
  display: flex; align-items: center; justify-content: center;
  transition: all 0.15s;
}
.qty-btn:hover { background: var(--primary); border-color: var(--primary); }
.cart-item-price { font-size: 13px; font-weight: 600; color: var(--primary); min-width: 70px; text-align: right; }

/* ── Product Card ────────────────────────── */
.product-card {
  background: var(--bg-800); border: 1px solid var(--border);
  border-radius: 12px; overflow: hidden; cursor: pointer;
  transition: all 0.2s; position: relative;
}
.product-card:hover { border-color: var(--primary); transform: translateY(-2px); box-shadow: 0 8px 24px rgba(0,0,0,0.2); }
.product-img {
  height: 140px; background: var(--bg-700);
  display: flex; align-items: center; justify-content: center;
  font-size: 40px; color: var(--text-secondary);
}
.product-info { padding: 14px; }
.product-name { font-size: 14px; font-weight: 600; margin-bottom: 4px; line-height: 1.3; }
.product-meta { font-size: 12px; color: var(--text-secondary); margin-bottom: 8px; }
.product-price { font-size: 18px; font-weight: 700; color: var(--primary); }
.product-stock { font-size: 11px; color: var(--text-secondary); margin-top: 4px; }

/* ── Animations ──────────────────────────── */
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp { from { transform: translateY(20px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
@keyframes slideIn { from { transform: translateX(-20px); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pulse { 0%,100%{opacity:1} 50%{opacity:0.5} }

.fade-in { animation: fadeIn 0.3s ease; }
.slide-in { animation: slideIn 0.3s ease; }
.loading-spin { animation: spin 1s linear infinite; }
.pulse { animation: pulse 2s infinite; }

/* ── Toast ───────────────────────────────── */
.toast-container { position: fixed; bottom: 24px; right: 24px; z-index: 9999; display: flex; flex-direction: column; gap: 8px; }
.toast {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 16px; border-radius: 10px; min-width: 280px;
  background: var(--bg-800); border: 1px solid var(--border);
  box-shadow: 0 8px 24px rgba(0,0,0,0.3);
  animation: slideUp 0.3s ease; font-size: 14px;
}
.toast.success { border-left: 4px solid var(--success); }
.toast.error { border-left: 4px solid var(--danger); }
.toast.warning { border-left: 4px solid var(--warning); }
.toast.info { border-left: 4px solid var(--info); }

/* ── Login ───────────────────────────────── */
.login-bg {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: radial-gradient(ellipse at 20% 50%, rgba(99,102,241,0.15) 0%, transparent 50%),
              radial-gradient(ellipse at 80% 20%, rgba(139,92,246,0.1) 0%, transparent 50%),
              var(--bg-900);
}
.login-card {
  width: 100%; max-width: 420px;
  background: var(--bg-800); border: 1px solid var(--border);
  border-radius: 20px; padding: 40px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.5);
}

/* ── Tooltip ─────────────────────────────── */
.tooltip { position: relative; }
.tooltip-text {
  position: absolute; bottom: calc(100% + 6px); left: 50%;
  transform: translateX(-50%); background: var(--bg-600);
  color: var(--text-primary); font-size: 12px; padding: 4px 8px;
  border-radius: 6px; white-space: nowrap; pointer-events: none;
  opacity: 0; transition: opacity 0.2s; z-index: 100;
}
.tooltip:hover .tooltip-text { opacity: 1; }

/* ── Pagination ──────────────────────────── */
.pagination { display: flex; align-items: center; gap: 6px; justify-content: center; margin-top: 20px; }
.page-btn {
  width: 34px; height: 34px; border-radius: 8px; border: 1px solid var(--border);
  background: var(--bg-800); color: var(--text-primary); cursor: pointer;
  display: flex; align-items: center; justify-content: center; font-size: 13px;
  transition: all 0.15s;
}
.page-btn:hover { background: var(--bg-700); }
.page-btn.active { background: var(--primary); border-color: var(--primary); color: white; }
.page-btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* ── Skeleton Loading ────────────────────── */
.skeleton {
  background: linear-gradient(90deg, var(--bg-700) 25%, var(--bg-600) 50%, var(--bg-700) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: 6px;
}
@keyframes shimmer { to { background-position: -200% 0; } }

/* ── Chart container ─────────────────────── */
.chart-container { position: relative; height: 260px; }

/* ── Notification dot ────────────────────── */
.notif-dot {
  width: 8px; height: 8px; border-radius: 50%; background: #ef4444;
  position: absolute; top: 3px; right: 3px;
  animation: pulse 2s infinite;
}

/* ── Mobile sidebar overlay ──────────────── */
.sidebar-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.5); z-index: 99;
}

/* ── Responsive ──────────────────────────── */
@media (max-width: 1024px) {
  .pdv-layout { grid-template-columns: 1fr; height: auto; }
  .grid-cols-4 { grid-template-columns: repeat(2, 1fr); }
  .grid-cols-3 { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 768px) {
  .sidebar { transform: translateX(-260px); }
  .sidebar.mobile-open { transform: translateX(0); }
  .sidebar-overlay { display: block; }
  .sidebar-overlay.active { display: block; }
  .main-content { margin-left: 0; }
  .grid-cols-2 { grid-template-columns: 1fr; }
  .grid-cols-3 { grid-template-columns: 1fr; }
  .grid-cols-4 { grid-template-columns: 1fr 1fr; }
  .form-row.cols-2, .form-row.cols-3 { grid-template-columns: 1fr; }
  .page-header { flex-direction: column; align-items: flex-start; }
  .filter-bar { flex-direction: column; align-items: stretch; }
  .topbar { padding: 0 16px; }
  .pdv-layout { grid-template-columns: 1fr; }
  .modal { margin: 0; border-radius: 0; max-height: 100vh; }
  .modal-overlay { padding: 0; align-items: flex-end; }
}

/* ── Empty state ─────────────────────────── */
.empty-state {
  text-align: center; padding: 60px 20px;
  color: var(--text-secondary);
}
.empty-icon { font-size: 48px; margin-bottom: 16px; opacity: 0.4; }
.empty-title { font-size: 18px; font-weight: 600; color: var(--text-primary); margin-bottom: 8px; }
.empty-desc { font-size: 14px; margin-bottom: 24px; }

/* ── Avatar ──────────────────────────────── */
.avatar {
  width: 36px; height: 36px; border-radius: 50%;
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; font-weight: 700; color: white;
  flex-shrink: 0;
}

/* ── Divider ─────────────────────────────── */
.divider { height: 1px; background: var(--border); margin: 16px 0; }

/* ── Tabs ────────────────────────────────── */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 20px; }
.tab-btn {
  padding: 8px 16px; font-size: 14px; font-weight: 500;
  border: none; background: none; color: var(--text-secondary);
  cursor: pointer; border-bottom: 2px solid transparent;
  transition: all 0.2s; margin-bottom: -1px;
}
.tab-btn:hover { color: var(--text-primary); }
.tab-btn.active { color: var(--primary); border-bottom-color: var(--primary); }

/* ── Input Toggle / Switch ───────────────── */
.switch { position: relative; display: inline-block; width: 44px; height: 24px; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider {
  position: absolute; cursor: pointer; inset: 0;
  background: var(--bg-700); border-radius: 24px;
  border: 1px solid var(--border); transition: .3s;
}
.slider:before {
  content: ""; position: absolute;
  width: 18px; height: 18px; border-radius: 50%;
  background: white; bottom: 2px; left: 2px; transition: .3s;
}
input:checked + .slider { background: var(--primary); border-color: var(--primary); }
input:checked + .slider:before { transform: translateX(20px); }

/* ── Progress bar ────────────────────────── */
.progress { background: var(--bg-700); border-radius: 10px; overflow: hidden; height: 8px; }
.progress-bar { height: 100%; border-radius: 10px; transition: width 0.5s ease; }

/* ── Color chips for categories ──────────── */
.color-dot { width: 12px; height: 12px; border-radius: 50%; flex-shrink: 0; }

/* ── Numeric highlight ───────────────────── */
.highlight-green { color: var(--success); font-weight: 600; }
.highlight-red { color: var(--danger); font-weight: 600; }
.highlight-yellow { color: var(--warning); font-weight: 600; }
.highlight-blue { color: var(--info); font-weight: 600; }
.highlight-purple { color: #8b5cf6; font-weight: 600; }
