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

/* ============================================
   DESIGN TOKENS
   ============================================ */
:root {
  --bg: #0a0b14;
  --bg2: #0d0f1a;
  --card: #111827;
  --card2: #1a2234;
  --border: rgba(255,255,255,0.08);
  --border2: rgba(255,255,255,0.04);
  --primary: #6366f1;
  --primary-hover: #5254cc;
  --primary-glow: rgba(99,102,241,0.25);
  --primary-glow2: rgba(99,102,241,0.12);
  --secondary: #8b5cf6;
  --secondary-glow: rgba(139,92,246,0.2);
  --success: #10b981;
  --success-bg: rgba(16,185,129,0.12);
  --warning: #f59e0b;
  --warning-bg: rgba(245,158,11,0.12);
  --danger: #ef4444;
  --danger-bg: rgba(239,68,68,0.12);
  --info: #3b82f6;
  --info-bg: rgba(59,130,246,0.12);
  --text: #f9fafb;
  --text2: #9ca3af;
  --text3: #6b7280;
  --text4: #4b5563;
  --sidebar-w: 240px;
  --radius: 12px;
  --radius-sm: 8px;
  --radius-xs: 6px;
  --radius-full: 9999px;
  --shadow: 0 4px 24px rgba(0,0,0,0.4);
  --shadow-sm: 0 2px 8px rgba(0,0,0,0.3);
  --shadow-lg: 0 8px 40px rgba(0,0,0,0.5);
  --shadow-primary: 0 0 20px rgba(99,102,241,0.3);
  --transition: all 0.2s ease;
  --transition-slow: all 0.35s ease;
}

/* ============================================
   RESET & BASE
   ============================================ */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
html { scroll-behavior: smooth; font-size: 16px; }
body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
a { text-decoration: none; color: inherit; }
button { cursor: pointer; font-family: inherit; }
input, textarea, select { font-family: inherit; }
img { max-width: 100%; display: block; }
ul, ol { list-style: none; }
h1,h2,h3,h4,h5,h6 { font-weight: 700; line-height: 1.3; }

/* ============================================
   SCROLLBAR
   ============================================ */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg2); }
::-webkit-scrollbar-thumb { background: var(--text4); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text3); }

/* ============================================
   LOADING SCREEN
   ============================================ */
#app-loading {
  position: fixed;
  inset: 0;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1.5rem;
  z-index: 9999;
}
.loading-logo {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  animation: fadeInDown 0.5s ease;
}
.loading-star {
  font-size: 2.5rem;
  animation: pulse-star 1.5s ease-in-out infinite;
}
.loading-name {
  font-size: 2rem;
  font-weight: 800;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.loading-bar-wrap {
  width: 200px;
  height: 3px;
  background: var(--border);
  border-radius: var(--radius-full);
  overflow: hidden;
}
.loading-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), var(--secondary));
  border-radius: var(--radius-full);
  animation: loading-slide 1.5s ease-in-out infinite;
}
.loading-text {
  color: var(--text3);
  font-size: 0.875rem;
  animation: pulse-opacity 1.5s ease-in-out infinite;
}
@keyframes loading-slide {
  0% { width: 0%; margin-left: 0; }
  50% { width: 70%; }
  100% { width: 0%; margin-left: 100%; }
}
@keyframes pulse-star {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.1); }
}
@keyframes pulse-opacity {
  0%, 100% { opacity: 0.5; }
  50% { opacity: 1; }
}

/* ============================================
   AUTH SCREENS
   ============================================ */
.auth-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  background: var(--bg);
  background-image: radial-gradient(ellipse at 20% 50%, rgba(99,102,241,0.08) 0%, transparent 60%),
                    radial-gradient(ellipse at 80% 20%, rgba(139,92,246,0.06) 0%, transparent 60%);
}
.auth-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 2.5rem;
  width: 100%;
  max-width: 420px;
  box-shadow: var(--shadow-lg);
  animation: fadeInUp 0.4s ease;
}
.auth-logo {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 1.5rem;
  font-weight: 800;
  margin-bottom: 1.5rem;
  color: var(--primary);
}
.auth-logo span {
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.auth-card h1 {
  font-size: 1.5rem;
  margin-bottom: 0.5rem;
  color: var(--text);
}
.auth-subtitle {
  color: var(--text2);
  font-size: 0.9rem;
  margin-bottom: 2rem;
  line-height: 1.6;
}

/* ============================================
   LAYOUT: SIDEBAR + MAIN
   ============================================ */
#admin-shell {
  display: flex;
  min-height: 100vh;
}

/* SIDEBAR */
.sidebar {
  width: var(--sidebar-w);
  height: 100vh;
  position: fixed;
  left: 0;
  top: 0;
  background: var(--card);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  z-index: 1000;
  transition: transform 0.3s ease;
  overflow: hidden;
}
.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.25rem 1.25rem 1rem;
  border-bottom: 1px solid var(--border);
}
.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-weight: 800;
  font-size: 1.15rem;
}
.logo-icon { font-size: 1.3rem; }
.logo-text {
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.sidebar-close {
  display: none;
  background: none;
  border: none;
  color: var(--text2);
  padding: 0.25rem;
  border-radius: var(--radius-xs);
  transition: var(--transition);
}
.sidebar-close:hover { color: var(--text); background: var(--border); }

/* NAV */
.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 1rem 0.75rem;
}
.sidebar-nav ul { display: flex; flex-direction: column; gap: 0.25rem; }
.nav-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.7rem 0.9rem;
  border-radius: var(--radius-sm);
  color: var(--text2);
  font-size: 0.9rem;
  font-weight: 500;
  transition: var(--transition);
  position: relative;
  white-space: nowrap;
}
.nav-item:hover {
  color: var(--text);
  background: rgba(255,255,255,0.05);
}
.nav-item.active {
  color: var(--primary);
  background: var(--primary-glow2);
  font-weight: 600;
}
.nav-item.active .nav-icon { color: var(--primary); }
.nav-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  flex-shrink: 0;
  opacity: 0.7;
  transition: var(--transition);
}
.nav-item:hover .nav-icon, .nav-item.active .nav-icon { opacity: 1; }
.nav-label { flex: 1; }
.nav-badge {
  background: var(--danger);
  color: #fff;
  font-size: 0.7rem;
  font-weight: 700;
  padding: 0.1rem 0.45rem;
  border-radius: var(--radius-full);
  min-width: 20px;
  text-align: center;
  animation: pulse-badge 2s ease infinite;
}
@keyframes pulse-badge {
  0%, 100% { box-shadow: 0 0 0 0 rgba(239,68,68,0.4); }
  50% { box-shadow: 0 0 0 4px rgba(239,68,68,0); }
}

/* SIDEBAR FOOTER */
.sidebar-footer {
  padding: 1rem;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 0.75rem;
}
.sidebar-user {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex: 1;
  overflow: hidden;
}
.user-avatar {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-full);
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.9rem;
  flex-shrink: 0;
  color: #fff;
}
.user-info { overflow: hidden; }
.user-name {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.user-role {
  display: block;
  font-size: 0.72rem;
  color: var(--text3);
}
.btn-logout {
  background: none;
  border: none;
  color: var(--text3);
  padding: 0.4rem;
  border-radius: var(--radius-sm);
  transition: var(--transition);
  display: flex;
  align-items: center;
}
.btn-logout:hover { color: var(--danger); background: var(--danger-bg); }

/* SIDEBAR OVERLAY */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 999;
  backdrop-filter: blur(2px);
}

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

/* TOP BAR (mobile) */
.topbar {
  display: none;
  align-items: center;
  gap: 1rem;
  padding: 0.875rem 1.25rem;
  background: var(--card);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}
.topbar-menu {
  background: none;
  border: none;
  color: var(--text2);
  display: flex;
  align-items: center;
  padding: 0.2rem;
}
.topbar-logo {
  font-weight: 800;
  font-size: 1.1rem;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  flex: 1;
}
.topbar-right { display: flex; align-items: center; gap: 0.75rem; }
.topbar-time { font-size: 0.8rem; color: var(--text3); }

/* PAGE CONTAINER */
#page-container {
  flex: 1;
  padding: 1.75rem 2rem;
  animation: fadeIn 0.3s ease;
}

/* ============================================
   PAGE HEADER
   ============================================ */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.75rem;
  gap: 1rem;
  flex-wrap: wrap;
}
.page-title-wrap {}
.page-title {
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--text);
  margin-bottom: 0.25rem;
}
.page-subtitle {
  font-size: 0.875rem;
  color: var(--text2);
}
.page-actions { display: flex; align-items: center; gap: 0.75rem; flex-wrap: wrap; }

/* ============================================
   CARDS
   ============================================ */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: var(--shadow-sm);
}
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.25rem;
  gap: 1rem;
}
.card-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
}
.card-subtitle { font-size: 0.8rem; color: var(--text3); margin-top: 0.2rem; }

/* STAT CARDS */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1.25rem;
  margin-bottom: 1.75rem;
}
.stat-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.4rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  position: relative;
  overflow: hidden;
  transition: var(--transition);
  box-shadow: var(--shadow-sm);
}
.stat-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  border-radius: var(--radius) var(--radius) 0 0;
}
.stat-card.primary::before { background: linear-gradient(90deg, var(--primary), var(--secondary)); }
.stat-card.success::before { background: var(--success); }
.stat-card.warning::before { background: var(--warning); }
.stat-card.info::before { background: var(--info); }
.stat-card:hover {
  border-color: rgba(255,255,255,0.15);
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}
.stat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.stat-icon {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
}
.stat-icon.primary { background: var(--primary-glow2); color: var(--primary); }
.stat-icon.success { background: var(--success-bg); color: var(--success); }
.stat-icon.warning { background: var(--warning-bg); color: var(--warning); }
.stat-icon.info { background: var(--info-bg); color: var(--info); }
.stat-trend {
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.2rem 0.5rem;
  border-radius: var(--radius-full);
}
.stat-trend.up { color: var(--success); background: var(--success-bg); }
.stat-trend.down { color: var(--danger); background: var(--danger-bg); }
.stat-trend.neutral { color: var(--text3); background: var(--border2); }
.stat-label { font-size: 0.8rem; color: var(--text3); font-weight: 500; }
.stat-value {
  font-size: 1.6rem;
  font-weight: 800;
  color: var(--text);
  line-height: 1.2;
}
.stat-sub {
  font-size: 0.78rem;
  color: var(--text3);
}

/* DASHBOARD GRID */
.dashboard-grid {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 1.25rem;
  margin-bottom: 1.25rem;
}

/* ============================================
   BUTTONS
   ============================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.6rem 1.25rem;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  font-family: inherit;
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  white-space: nowrap;
  text-decoration: none;
  line-height: 1.4;
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; pointer-events: none; }
.btn-primary {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}
.btn-primary:hover {
  background: var(--primary-hover);
  border-color: var(--primary-hover);
  box-shadow: var(--shadow-primary);
  transform: translateY(-1px);
}
.btn-secondary {
  background: rgba(255,255,255,0.06);
  color: var(--text);
  border-color: var(--border);
}
.btn-secondary:hover {
  background: rgba(255,255,255,0.1);
  border-color: rgba(255,255,255,0.15);
}
.btn-danger {
  background: var(--danger);
  color: #fff;
  border-color: var(--danger);
}
.btn-danger:hover {
  background: #dc2626;
  box-shadow: 0 0 15px rgba(239,68,68,0.3);
  transform: translateY(-1px);
}
.btn-success {
  background: var(--success);
  color: #fff;
  border-color: var(--success);
}
.btn-success:hover {
  background: #059669;
  box-shadow: 0 0 15px rgba(16,185,129,0.3);
  transform: translateY(-1px);
}
.btn-warning {
  background: var(--warning);
  color: #000;
  border-color: var(--warning);
}
.btn-warning:hover { background: #d97706; }
.btn-ghost {
  background: transparent;
  color: var(--text2);
  border-color: transparent;
}
.btn-ghost:hover { background: rgba(255,255,255,0.06); color: var(--text); }
.btn-sm {
  padding: 0.35rem 0.8rem;
  font-size: 0.8rem;
  border-radius: var(--radius-xs);
}
.btn-xs {
  padding: 0.2rem 0.55rem;
  font-size: 0.75rem;
  border-radius: 5px;
}
.btn-full { width: 100%; }
.btn-icon {
  padding: 0.5rem;
  border-radius: var(--radius-sm);
}

/* ============================================
   FORMS
   ============================================ */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  margin-bottom: 1rem;
}
.form-group:last-child { margin-bottom: 0; }
.form-group label {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text2);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.form-control {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  padding: 0.65rem 0.9rem;
  font-size: 0.9rem;
  transition: var(--transition);
  width: 100%;
  outline: none;
}
.form-control:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-glow2);
}
.form-control::placeholder { color: var(--text4); }
.form-control:disabled { opacity: 0.5; cursor: not-allowed; }
textarea.form-control { resize: vertical; min-height: 90px; }
select.form-control {
  cursor: pointer;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%239ca3af' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.9rem center;
  padding-right: 2.5rem;
}
.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}
.form-row-3 {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 1rem;
}
.form-hint { font-size: 0.76rem; color: var(--text3); }
.form-error { font-size: 0.76rem; color: var(--danger); }

/* Input com ícone/botão interno */
.input-password-wrap { position: relative; }
.input-password-wrap .form-control { padding-right: 2.8rem; }
.password-eye {
  position: absolute;
  right: 0.7rem;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: var(--text3);
  cursor: pointer;
  padding: 0.2rem;
  transition: var(--transition);
  display: flex;
  align-items: center;
}
.password-eye:hover { color: var(--text); }
.input-with-btn { display: flex; gap: 0.5rem; }
.input-with-btn .form-control { flex: 1; }

/* Checkbox / Toggle */
.form-check {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  cursor: pointer;
}
.form-check input[type="checkbox"] {
  width: 16px;
  height: 16px;
  cursor: pointer;
  accent-color: var(--primary);
}
.form-check label { font-size: 0.875rem; color: var(--text); cursor: pointer; font-weight: 500; }

/* Image preview */
.img-preview {
  width: 100%;
  height: 160px;
  border: 2px dashed var(--border);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  cursor: pointer;
  transition: var(--transition);
  background: var(--bg2);
}
.img-preview:hover { border-color: var(--primary); }
.img-preview img { width: 100%; height: 100%; object-fit: contain; }
.img-placeholder { display: flex; flex-direction: column; align-items: center; gap: 0.5rem; color: var(--text3); font-size: 0.8rem; }

/* ============================================
   TABLES
   ============================================ */
.table-wrap {
  overflow-x: auto;
  border-radius: var(--radius);
  border: 1px solid var(--border);
}
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}
thead tr {
  background: var(--card2);
  border-bottom: 1px solid var(--border);
}
thead th {
  padding: 0.9rem 1rem;
  text-align: left;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text3);
  white-space: nowrap;
}
tbody tr {
  border-bottom: 1px solid var(--border2);
  transition: var(--transition);
}
tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: rgba(255,255,255,0.025); }
tbody td {
  padding: 0.85rem 1rem;
  vertical-align: middle;
  color: var(--text);
}
.td-muted { color: var(--text2); }
.td-bold { font-weight: 600; }
.td-actions { display: flex; gap: 0.4rem; flex-wrap: wrap; }
.table-clickable tbody tr { cursor: pointer; }

/* ============================================
   BADGES / CHIPS
   ============================================ */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.2rem 0.65rem;
  border-radius: var(--radius-full);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  white-space: nowrap;
}
.badge-success { background: var(--success-bg); color: var(--success); border: 1px solid rgba(16,185,129,0.2); }
.badge-warning { background: var(--warning-bg); color: var(--warning); border: 1px solid rgba(245,158,11,0.2); }
.badge-danger  { background: var(--danger-bg);  color: var(--danger);  border: 1px solid rgba(239,68,68,0.2); }
.badge-info    { background: var(--info-bg);    color: var(--info);    border: 1px solid rgba(59,130,246,0.2); }
.badge-secondary { background: var(--secondary-glow); color: var(--secondary); border: 1px solid rgba(139,92,246,0.2); }
.badge-neutral { background: rgba(255,255,255,0.06); color: var(--text2); border: 1px solid var(--border); }
.badge-primary { background: var(--primary-glow2); color: var(--primary); border: 1px solid var(--primary-glow); }

/* Status de estoque crítico — pisca */
.badge-critico {
  background: var(--danger-bg);
  color: var(--danger);
  border: 1px solid rgba(239,68,68,0.3);
  animation: blink-badge 1.5s ease-in-out infinite;
}
@keyframes blink-badge {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

/* ============================================
   MODALS
   ============================================ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.65);
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  backdrop-filter: blur(4px);
  animation: fadeIn 0.2s ease;
}
.modal {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  width: 100%;
  max-width: 600px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-lg);
  animation: slideInUp 0.25s ease;
}
.modal-sm { max-width: 440px; }
.modal-lg { max-width: 860px; }
.modal-xl { max-width: 1000px; }
.modal-header {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-shrink: 0;
}
.modal-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
}
.modal-close {
  background: none;
  border: none;
  color: var(--text3);
  cursor: pointer;
  padding: 0.25rem;
  border-radius: var(--radius-xs);
  transition: var(--transition);
  display: flex;
  align-items: center;
}
.modal-close:hover { color: var(--text); background: var(--border); }
.modal-body {
  padding: 1.5rem;
  overflow-y: auto;
  flex: 1;
}
.modal-footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.75rem;
  flex-shrink: 0;
}

/* ============================================
   ALERTS
   ============================================ */
.alert {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 0.9rem 1rem;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  line-height: 1.5;
  border: 1px solid transparent;
}
.alert-warning {
  background: var(--warning-bg);
  color: #fbbf24;
  border-color: rgba(245,158,11,0.2);
}
.alert-danger {
  background: var(--danger-bg);
  color: #f87171;
  border-color: rgba(239,68,68,0.2);
}
.alert-success {
  background: var(--success-bg);
  color: #34d399;
  border-color: rgba(16,185,129,0.2);
}
.alert-info {
  background: var(--info-bg);
  color: #60a5fa;
  border-color: rgba(59,130,246,0.2);
}

/* Alerta crítico piscante */
.alert-critico {
  background: rgba(239,68,68,0.08);
  border: 1px solid rgba(239,68,68,0.3);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  animation: pulse-alert 2s ease-in-out infinite;
}
@keyframes pulse-alert {
  0%, 100% { box-shadow: 0 0 0 0 rgba(239,68,68,0); }
  50% { box-shadow: 0 0 0 6px rgba(239,68,68,0.08); }
}

/* ============================================
   SEARCH / FILTERS
   ============================================ */
.search-bar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-bottom: 1.25rem;
}
.search-input-wrap {
  position: relative;
  flex: 1;
  min-width: 220px;
  max-width: 360px;
}
.search-input-wrap .search-icon {
  position: absolute;
  left: 0.8rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text3);
  display: flex;
  pointer-events: none;
}
.search-input-wrap .form-control {
  padding-left: 2.4rem;
}

/* ============================================
   PRODUCTS GRID
   ============================================ */
.products-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 1.25rem;
  margin-top: 1.25rem;
}
.product-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  transition: var(--transition);
  display: flex;
  flex-direction: column;
}
.product-card:hover {
  border-color: rgba(255,255,255,0.15);
  transform: translateY(-3px);
  box-shadow: var(--shadow);
}
.product-card.inactive { opacity: 0.5; }
.product-img {
  height: 160px;
  background: var(--card2);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  position: relative;
}
.product-img img { width: 100%; height: 100%; object-fit: cover; }
.product-img-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  color: var(--text4);
  font-size: 0.78rem;
}
.product-badge-pos {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  align-items: flex-end;
}
.product-info {
  padding: 1rem;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.product-name {
  font-weight: 600;
  font-size: 0.9rem;
  line-height: 1.4;
  color: var(--text);
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}
.product-price { font-size: 1.1rem; font-weight: 800; color: var(--success); }
.product-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: auto;
}
.product-stock { font-size: 0.78rem; color: var(--text3); }
.product-stock.low { color: var(--warning); }
.product-stock.zero { color: var(--danger); font-weight: 600; }
.product-actions {
  padding: 0.75rem 1rem;
  border-top: 1px solid var(--border2);
  display: flex;
  gap: 0.5rem;
}

/* ============================================
   EMPTY STATE
   ============================================ */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 4rem 2rem;
  text-align: center;
  gap: 1rem;
}
.empty-state-icon {
  font-size: 3rem;
  opacity: 0.3;
}
.empty-state h3 {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text2);
}
.empty-state p {
  font-size: 0.875rem;
  color: var(--text3);
  max-width: 320px;
  line-height: 1.6;
}

/* ============================================
   PAGINATION
   ============================================ */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  margin-top: 1.5rem;
  flex-wrap: wrap;
}
.page-btn {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--card2);
  color: var(--text2);
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
}
.page-btn:hover { border-color: var(--primary); color: var(--primary); }
.page-btn.active { background: var(--primary); border-color: var(--primary); color: #fff; }
.page-btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* ============================================
   LOADING SKELETONS
   ============================================ */
.skeleton {
  background: linear-gradient(90deg, var(--card2) 25%, rgba(255,255,255,0.04) 50%, var(--card2) 75%);
  background-size: 200% 100%;
  animation: skeleton-wave 1.5s ease-in-out infinite;
  border-radius: var(--radius-sm);
}
@keyframes skeleton-wave {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}
.skeleton-text { height: 14px; border-radius: 4px; }
.skeleton-title { height: 24px; border-radius: 6px; }
.skeleton-card { height: 120px; border-radius: var(--radius); }
.skeleton-row { height: 52px; border-radius: 0; }

/* ============================================
   LOADING SPINNER
   ============================================ */
.spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
.spinner-sm {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading-center {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 3rem;
  gap: 1rem;
  color: var(--text3);
  font-size: 0.875rem;
}

/* ============================================
   CHART WRAPPERS
   ============================================ */
.chart-wrap {
  position: relative;
  width: 100%;
}
.chart-wrap canvas { border-radius: var(--radius-sm); }

/* ============================================
   STATUS STEPPER (Pedidos)
   ============================================ */
.status-stepper {
  display: flex;
  align-items: center;
  gap: 0;
  margin: 1.5rem 0;
  overflow-x: auto;
}
.step-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.4rem;
  flex: 1;
  min-width: 80px;
}
.step-circle {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--card2);
  border: 2px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  font-weight: 700;
  transition: var(--transition);
  z-index: 1;
  position: relative;
}
.step-item.done .step-circle { background: var(--success); border-color: var(--success); color: #fff; }
.step-item.active .step-circle { background: var(--primary); border-color: var(--primary); color: #fff; box-shadow: 0 0 12px rgba(99,102,241,0.4); }
.step-item.cancelled .step-circle { background: var(--danger-bg); border-color: var(--danger); color: var(--danger); }
.step-label { font-size: 0.7rem; color: var(--text3); text-align: center; }
.step-item.done .step-label { color: var(--success); }
.step-item.active .step-label { color: var(--primary); font-weight: 600; }
.step-connector {
  flex: 1;
  height: 2px;
  background: var(--border);
  margin: 0 -1px;
  margin-bottom: 22px;
}
.step-connector.done { background: var(--success); }

/* ============================================
   SECTION DIVIDERS
   ============================================ */
.section-title {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text3);
  margin-bottom: 0.75rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border2);
}

/* ============================================
   TABS
   ============================================ */
.tabs {
  display: flex;
  gap: 0.25rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 1.5rem;
}
.tab-btn {
  padding: 0.6rem 1rem;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  color: var(--text3);
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
}
.tab-btn:hover { color: var(--text); }
.tab-btn.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 600; }

/* ============================================
   FINANCEIRO / INFO BOXES
   ============================================ */
.info-box {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1rem;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin-bottom: 0.5rem;
}
.info-box-label { font-size: 0.8rem; color: var(--text3); }
.info-box-value { font-size: 0.95rem; font-weight: 700; color: var(--text); }
.info-box-value.positive { color: var(--success); }
.info-box-value.negative { color: var(--danger); }

/* ============================================
   TOOLTIP
   ============================================ */
[data-tooltip] {
  position: relative;
}
[data-tooltip]:hover::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--card2);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 0.75rem;
  padding: 0.3rem 0.65rem;
  border-radius: var(--radius-xs);
  white-space: nowrap;
  z-index: 100;
  pointer-events: none;
  box-shadow: var(--shadow-sm);
}

/* ============================================
   ANIMATIONS
   ============================================ */
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes fadeInDown {
  from { opacity: 0; transform: translateY(-20px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes slideInUp {
  from { opacity: 0; transform: translateY(30px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes slideIn {
  from { opacity: 0; transform: translateX(-20px); }
  to { opacity: 1; transform: translateX(0); }
}

/* ============================================
   RESPONSIVE — 1200px
   ============================================ */
@media (max-width: 1200px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .dashboard-grid { grid-template-columns: 1fr; }
}

/* ============================================
   RESPONSIVE — 768px (Tablet)
   ============================================ */
@media (max-width: 768px) {
  :root { --sidebar-w: 0px; }

  .topbar { display: flex; }

  .sidebar {
    transform: translateX(-100%);
    width: 260px;
  }
  .sidebar.open { transform: translateX(0); }
  .sidebar-close { display: flex; }
  .sidebar-overlay.active { display: block; }

  .main-content { margin-left: 0; }

  #page-container { padding: 1.25rem; }

  .stats-grid { grid-template-columns: repeat(2, 1fr); gap: 1rem; }
  .stat-value { font-size: 1.3rem; }

  /* Formulários empilhados em 1 coluna para celular e tablet */
  .form-row, .form-row-3 { grid-template-columns: 1fr; gap: 0.75rem; }

  .page-header { flex-direction: column; align-items: flex-start; gap: 0.75rem; }
  .page-actions { width: 100%; display: flex; flex-direction: column; gap: 0.5rem; }
  .page-actions .btn { width: 100%; }

  .modal { max-width: 100%; margin: 0; border-radius: 16px 16px 0 0; max-height: 85vh; }
  .modal-overlay { align-items: flex-end; padding: 0; }

  /* Forçar scroll horizontal fluido nas tabelas para evitar encolhimento de colunas e encavalamento de textos */
  .table-wrap table { font-size: 0.825rem; min-width: 850px; }
  thead th, tbody td { padding: 0.75rem 0.85rem; }
}

/* ============================================
   RESPONSIVE — 480px (Mobile)
   ============================================ */
@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr; }
  .products-grid { grid-template-columns: 1fr; } /* Apenas 1 coluna de produtos no celular para caber botões e dados */
  .auth-card { padding: 1.75rem 1.25rem; }
  .search-bar { flex-direction: column; align-items: stretch; }
  .search-input-wrap { max-width: 100%; width: 100%; }
  .dashboard-grid { grid-template-columns: 1fr; }
}

/* ============================================
   PRINT HIDE
   ============================================ */
@media print {
  .sidebar, .topbar, .btn, .page-actions { display: none !important; }
  .main-content { margin-left: 0; }
}

/* ============================================
   SAAS LANDING PAGE STYLES
   ============================================ */
.landing-container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 1.5rem;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}
.landing-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.5rem 0;
  border-bottom: 1px solid var(--border);
}
.landing-logo {
  font-size: 1.5rem;
  font-weight: 800;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--text);
}
.landing-logo span {
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}
.landing-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 4rem;
  padding: 4rem 0;
}
.landing-hero {
  text-align: center;
  max-width: 800px;
  margin: 0 auto;
}
.hero-badge {
  display: inline-block;
  background: rgba(99, 102, 241, 0.1);
  color: var(--primary);
  border: 1px solid rgba(99, 102, 241, 0.2);
  border-radius: 9999px;
  padding: 0.35rem 1rem;
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 1.5rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.landing-hero h1 {
  font-size: 3rem;
  font-weight: 800;
  line-height: 1.15;
  margin-bottom: 1.5rem;
  background: linear-gradient(135deg, var(--text) 30%, var(--text2));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}
.hero-desc {
  font-size: 1.125rem;
  color: var(--text2);
  line-height: 1.6;
  margin-bottom: 2.5rem;
}
.hero-actions {
  display: flex;
  justify-content: center;
  gap: 1rem;
}
.landing-features {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 2rem;
  margin-top: 2rem;
}
.feature-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 2rem;
  transition: var(--transition);
}
.feature-card:hover {
  transform: translateY(-5px);
  border-color: rgba(99, 102, 241, 0.3);
  box-shadow: 0 10px 30px rgba(0,0,0,0.2);
}
.feature-icon {
  font-size: 2.5rem;
  display: block;
  margin-bottom: 1rem;
}
.feature-card h3 {
  font-size: 1.2rem;
  font-weight: 700;
  margin-bottom: 0.75rem;
  color: var(--text1);
}
.feature-card p {
  color: var(--text2);
  font-size: 0.925rem;
  line-height: 1.5;
}

@media (max-width: 768px) {
  .landing-hero h1 { font-size: 2.25rem; }
  .landing-main { padding: 2rem 0; gap: 2.5rem; }
  .hero-desc { font-size: 1rem; }
}

