/* ==========================================================================
   WMS RECEBIMENTO DE UNIDADES - SYSTEM DESIGN & STYLESHEET
   ========================================================================== */

:root {
  /* Color Palette - Sleek Modern Dark / Logistics Cyber Theme */
  --bg-main: #0b0f19;
  --bg-surface: #131b2e;
  --bg-card: rgba(23, 32, 54, 0.75);
  --bg-card-border: rgba(255, 255, 255, 0.08);
  --bg-glass-input: rgba(15, 23, 42, 0.6);
  
  --primary: #3b82f6;
  --primary-hover: #2563eb;
  --primary-glow: rgba(59, 130, 246, 0.35);
  
  --success: #10b981;
  --success-hover: #059669;
  --success-glow: rgba(16, 185, 129, 0.35);
  
  --warning: #f59e0b;
  --danger: #ef4444;
  --danger-glow: rgba(239, 68, 68, 0.4);
  
  --purple: #8b5cf6;
  --info: #06b6d4;

  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --text-dim: #64748b;

  --border-color: rgba(255, 255, 255, 0.12);
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  
  --font-family: 'Inter', system-ui, -apple-system, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
  
  --transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  --sidebar-width: 260px;
}

/* Light Theme Overrides */
body.light-theme {
  --bg-main: #f1f5f9;
  --bg-surface: #ffffff;
  --bg-card: rgba(255, 255, 255, 0.9);
  --bg-card-border: rgba(0, 0, 0, 0.08);
  --bg-glass-input: #f8fafc;
  
  --text-main: #0f172a;
  --text-muted: #475569;
  --text-dim: #94a3b8;
  --border-color: #cbd5e1;
}

/* Reset & Global */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-family);
  background-color: var(--bg-main);
  color: var(--text-main);
  min-height: 100vh;
  overflow-x: hidden;
  line-height: 1.5;
}

/* Utilities */
.hidden { display: none !important; }
.text-muted { color: var(--text-muted); }
.small { font-size: 0.85rem; }
.margin-top { margin-top: 1.5rem; }

/* Login Modal / Overlay */
.login-overlay {
  position: fixed;
  inset: 0;
  background: radial-gradient(circle at center, rgba(19, 27, 46, 0.95), rgba(7, 10, 18, 0.98));
  backdrop-filter: blur(12px);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}

.login-overlay:not(.active) {
  display: none !important;
}

.login-card {
  width: 100%;
  max-width: 440px;
  background: var(--bg-card);
  border: 1px solid var(--bg-card-border);
  border-radius: var(--radius-lg);
  padding: 2.5rem 2rem;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.5), 0 0 40px rgba(59, 130, 246, 0.15);
}

.login-header {
  text-align: center;
  margin-bottom: 2rem;
}

.login-header .brand-logo {
  font-size: 2.8rem;
  color: var(--primary);
  margin-bottom: 0.5rem;
}

.login-header h2 {
  font-weight: 800;
  letter-spacing: 0.5px;
  font-size: 1.4rem;
}

.login-header p {
  color: var(--text-muted);
  font-size: 0.9rem;
}



/* App Layout */
.app-layout {
  display: flex;
  min-height: 100vh;
}

/* Sidebar */
.sidebar {
  width: var(--sidebar-width);
  background: var(--bg-surface);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  z-index: 100;
  transition: width 0.28s cubic-bezier(0.4, 0, 0.2, 1), transform 0.28s cubic-bezier(0.4, 0, 0.2, 1);
}

.sidebar-brand {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.25rem 1rem;
  border-bottom: 1px solid var(--border-color);
}

.sidebar-brand .brand-logo-img {
  height: 36px;
  max-width: 85%;
  object-fit: contain;
}

.sidebar-brand .brand-text {
  display: flex;
  flex-direction: column;
}

.sidebar-brand .title {
  font-weight: 800;
  font-size: 1.05rem;
  letter-spacing: 0.5px;
  line-height: 1.2;
}

.sidebar-brand .sub {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.user-badge-sidebar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1rem 1.25rem;
  background: rgba(255, 255, 255, 0.02);
  border-bottom: 1px solid var(--border-color);
}

.user-badge-sidebar .avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--purple));
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.9rem;
  color: white;
}

.user-badge-sidebar .user-name {
  font-size: 0.85rem;
  font-weight: 600;
  display: block;
}

.user-badge-sidebar .user-role {
  font-size: 0.65rem;
  padding: 0.1rem 0.5rem;
  border-radius: 20px;
  text-transform: uppercase;
  font-weight: 700;
  display: inline-block;
  background: rgba(59, 130, 246, 0.2);
  color: var(--primary);
}

/* Nav Menu */
.nav-menu {
  flex: 1;
  padding: 1rem 0.75rem;
  overflow-y: auto;
}

.nav-group-title {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-dim);
  padding: 1rem 0.75rem 0.4rem 0.75rem;
  font-weight: 700;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.7rem 0.85rem;
  color: var(--text-muted);
  text-decoration: none;
  border-radius: var(--radius-md);
  font-size: 0.9rem;
  font-weight: 500;
  transition: var(--transition);
  cursor: pointer;
  margin-bottom: 0.2rem;
}

.nav-item:hover {
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.05);
}

.nav-item.active {
  color: #ffffff;
  background: var(--primary);
  box-shadow: 0 4px 12px var(--primary-glow);
}

.nav-sub {
  padding-left: 2.2rem;
  font-size: 0.85rem;
}

.accordion-header {
  justify-content: space-between;
}

.accordion-header .accordion-icon {
  margin-left: auto;
  font-size: 0.75rem;
  transition: transform 0.3s;
}

.accordion-header.expanded .accordion-icon {
  transform: rotate(180deg);
}

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

/* Main Content Area */
.main-content {
  flex: 1;
  margin-left: var(--sidebar-width);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  transition: margin-left 0.28s cubic-bezier(0.4, 0, 0.2, 1);
  min-width: 0; /* Previne overflow de flexbox com tabelas */
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.75rem;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-color);
  position: sticky;
  top: 0;
  z-index: 90;
  gap: 1rem;
}

.btn-sidebar-toggle {
  background: var(--bg-glass-input);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  transition: var(--transition);
  flex-shrink: 0;
}

.btn-sidebar-toggle:hover {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}

.topbar-title h1 {
  font-size: 1.35rem;
  font-weight: 700;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.status-indicator {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.8rem;
  color: var(--success);
  background: rgba(16, 185, 129, 0.1);
  padding: 0.3rem 0.75rem;
  border-radius: 20px;
  border: 1px solid rgba(16, 185, 129, 0.2);
}

.status-indicator .dot {
  width: 8px;
  height: 8px;
  background: var(--success);
  border-radius: 50%;
  box-shadow: 0 0 8px var(--success);
}

.theme-toggle {
  background: var(--bg-glass-input);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  width: 38px;
  height: 38px;
  border-radius: 50%;
  cursor: pointer;
  transition: var(--transition);
}

.theme-toggle:hover {
  background: var(--primary);
  color: white;
}

.content-body {
  padding: 2rem;
  flex: 1;
}

.page-view {
  display: none;
  animation: fadeIn 0.3s ease-in-out;
}

.page-view.active {
  display: block;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Cards & Grid Systems */
.grid-2col { display: grid; grid-template-columns: repeat(auto-fit, minmax(380px, 1fr)); gap: 1.5rem; }
.grid-3col { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 1.5rem; }
.grid-4col { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 1.25rem; }

.card {
  background: var(--bg-card);
  border: 1px solid var(--bg-card-border);
  border-radius: var(--radius-lg);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
  backdrop-filter: blur(10px);
  overflow: hidden;
}

.card-header {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.card-header h3 {
  font-size: 1.05rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.card-body {
  padding: 1.5rem;
}

.highlight-card {
  border: 1px solid rgba(59, 130, 246, 0.3);
  box-shadow: 0 0 30px rgba(59, 130, 246, 0.1);
}

/* Dashboard Metrics Cards */
.metrics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1.25rem;
  margin-bottom: 1.5rem;
}

.metric-card {
  background: var(--bg-card);
  border: 1px solid var(--bg-card-border);
  border-radius: var(--radius-md);
  padding: 1.25rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  transition: var(--transition);
}

.metric-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
}

.metric-icon {
  width: 50px;
  height: 50px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
}

.metric-card.primary .metric-icon { background: rgba(59, 130, 246, 0.15); color: var(--primary); }
.metric-card.info .metric-icon { background: rgba(6, 182, 212, 0.15); color: var(--info); }
.metric-card.warning .metric-icon { background: rgba(245, 158, 11, 0.15); color: var(--warning); }
.metric-card.success .metric-icon { background: rgba(16, 185, 129, 0.15); color: var(--success); }
.metric-card.purple .metric-icon { background: rgba(139, 92, 246, 0.15); color: var(--purple); }

.metric-data .label {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  display: block;
}

.metric-data .value {
  font-size: 1.7rem;
  font-weight: 800;
  font-family: var(--font-mono);
}

.charts-grid {
  display: grid;
  grid-template-columns: 3fr 2fr;
  gap: 1.5rem;
}

@media (max-width: 1024px) {
  .charts-grid { grid-template-columns: 1fr; }
}

/* Forms & Inputs */
.form-group {
  margin-bottom: 1.25rem;
}

.form-group label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 0.4rem;
  color: var(--text-main);
}

input[type="text"],
input[type="password"],
input[type="date"],
select,
textarea {
  width: 100%;
  padding: 0.75rem 1rem;
  background: var(--bg-glass-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  color: var(--text-main);
  font-family: var(--font-family);
  font-size: 0.9rem;
  transition: var(--transition);
}

input[type="text"]:focus,
input[type="password"]:focus,
input[type="date"]:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-glow);
}

.help-text {
  font-size: 0.75rem;
  color: var(--text-dim);
  margin-top: 0.25rem;
  display: block;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.75rem 1.5rem;
  border-radius: var(--radius-md);
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  border: none;
  transition: var(--transition);
  text-decoration: none;
}

.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-hover); box-shadow: 0 4px 15px var(--primary-glow); }

.btn-success { background: var(--success); color: white; }
.btn-success:hover { background: var(--success-hover); box-shadow: 0 4px 15px var(--success-glow); }

.btn-danger { background: var(--danger); color: white; }
.btn-danger:hover { background: #dc2626; box-shadow: 0 4px 15px var(--danger-glow); }

.btn-purple { background: var(--purple); color: white; }
.btn-purple:hover { background: #7c3aed; }

.btn-secondary { background: rgba(255, 255, 255, 0.1); color: var(--text-main); }
.btn-secondary:hover { background: rgba(255, 255, 255, 0.2); }

.btn-outline { background: transparent; border: 1px solid var(--border-color); color: var(--text-main); }
.btn-outline:hover { background: rgba(255, 255, 255, 0.05); border-color: var(--text-main); }

.btn-block { width: 100%; }
.btn-lg { padding: 1rem 2rem; font-size: 1.05rem; }
.btn-sm { padding: 0.4rem 0.8rem; font-size: 0.8rem; }

/* Tables */
.table-responsive {
  width: 100%;
  overflow-x: auto;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 0.88rem;
}

.data-table th,
.data-table td {
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--border-color);
}

.data-table th {
  background: rgba(255, 255, 255, 0.03);
  color: var(--text-muted);
  font-weight: 600;
  text-transform: uppercase;
  font-size: 0.75rem;
  letter-spacing: 0.5px;
}

.data-table tbody tr:hover {
  background: rgba(255, 255, 255, 0.02);
}

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.25rem 0.6rem;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
}

.badge-info { background: rgba(6, 182, 212, 0.15); color: var(--info); }
.badge-success { background: rgba(16, 185, 129, 0.15); color: var(--success); }
.badge-danger { background: rgba(239, 68, 68, 0.15); color: var(--danger); }
.badge-warning { background: rgba(245, 158, 11, 0.15); color: var(--warning); }
.badge-purple { background: rgba(139, 92, 246, 0.15); color: var(--purple); }

/* Dynamic Scanning Area */
.scanner-banner {
  display: flex;
  align-items: center;
  gap: 1rem;
  background: rgba(59, 130, 246, 0.1);
  border: 1px solid rgba(59, 130, 246, 0.25);
  border-radius: var(--radius-md);
  padding: 1rem 1.25rem;
  margin-bottom: 1.5rem;
}

.scanner-banner i {
  font-size: 2rem;
  color: var(--primary);
}

.bip-inputs-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1.25rem;
  margin-bottom: 1.5rem;
}

.bip-field-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1.25rem;
  position: relative;
  transition: var(--transition);
}

.bip-field-card.valid {
  border-color: var(--success);
  box-shadow: 0 0 12px var(--success-glow);
}

.bip-field-card.invalid {
  border-color: var(--danger);
  box-shadow: 0 0 12px var(--danger-glow);
}

.bip-field-card input {
  font-family: var(--font-mono);
  font-size: 1.1rem;
  letter-spacing: 1px;
  font-weight: 600;
  text-transform: uppercase;
}

.rule-feedback {
  font-size: 0.75rem;
  margin-top: 0.4rem;
  display: flex;
  align-items: center;
  gap: 0.3rem;
}

.rule-feedback.valid { color: var(--success); }
.rule-feedback.invalid { color: var(--danger); }

/* Radio Cards & Toggles */
.radio-toggle {
  display: flex;
  gap: 1rem;
  margin-top: 0.5rem;
}

.radio-card {
  flex: 1;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1rem;
  cursor: pointer;
  text-align: center;
  transition: var(--transition);
}

.radio-card input { display: none; }

.radio-card span {
  font-weight: 700;
  font-size: 0.95rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
}

.radio-card.success:has(input:checked) {
  background: rgba(16, 185, 129, 0.2);
  border-color: var(--success);
  color: var(--success);
}

.radio-card.danger:has(input:checked) {
  background: rgba(239, 68, 68, 0.2);
  border-color: var(--danger);
  color: var(--danger);
}

.checkbox-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 0.75rem;
  margin-top: 0.5rem;
}

.checkbox-card {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.8rem 1rem;
  background: var(--bg-glass-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  cursor: pointer;
}

.select-multiple {
  height: 120px;
}

/* Modals */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.8);
  backdrop-filter: blur(8px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}

.modal-content {
  width: 100%;
  max-width: 500px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 2rem;
  box-shadow: 0 25px 50px rgba(0, 0, 0, 0.6);
}

.modal-content.lg {
  max-width: 750px;
}

.alert-modal-content {
  text-align: center;
  border-color: var(--danger);
  animation: modalBounce 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes modalBounce {
  from { transform: scale(0.8); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

.modal-icon.danger {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background: rgba(239, 68, 68, 0.2);
  color: var(--danger);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.8rem;
  margin: 0 auto 1.25rem auto;
  box-shadow: 0 0 30px var(--danger-glow);
}

.alert-details {
  background: rgba(239, 68, 68, 0.1);
  border: 1px dashed var(--danger);
  border-radius: var(--radius-md);
  padding: 1rem;
  margin-top: 1rem;
  font-family: var(--font-mono);
  font-size: 0.9rem;
  color: #fca5a5;
  text-align: left;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 1rem;
}

.modal-close-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.8rem;
  cursor: pointer;
}

.modal-close-btn:hover { color: white; }

/* Timeline Styles */
.timeline {
  position: relative;
  padding-left: 2rem;
  margin-top: 1rem;
}

.timeline::before {
  content: '';
  position: absolute;
  left: 8px;
  top: 5px;
  bottom: 5px;
  width: 2px;
  background: var(--border-color);
}

.timeline-item {
  position: relative;
  margin-bottom: 1.5rem;
}

.timeline-dot {
  position: absolute;
  left: -2rem;
  top: 2px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--primary);
  border: 3px solid var(--bg-surface);
}

.timeline-item.success .timeline-dot { background: var(--success); }
.timeline-item.danger .timeline-dot { background: var(--danger); }
.timeline-item.warning .timeline-dot { background: #f59e0b; }
.timeline-item.info .timeline-dot { background: #3b82f6; }
.timeline-item.purple .timeline-dot { background: #8b5cf6; }

.timeline-content {
  background: var(--bg-glass-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 0.85rem 1rem;
}

.timeline-header {
  display: flex;
  justify-content: space-between;
  font-weight: 700;
  font-size: 0.85rem;
  margin-bottom: 0.3rem;
}

/* Packaging Box Styles */
.box-status-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1.25rem;
}

.box-stat-item {
  display: flex;
  justify-content: space-between;
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--border-color);
}

.box-unit-list {
  max-height: 200px;
  overflow-y: auto;
  margin-top: 1rem;
  padding-right: 0.5rem;
}

.box-unit-chip {
  display: flex;
  justify-content: space-between;
  background: var(--bg-glass-input);
  padding: 0.4rem 0.75rem;
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-size: 0.8rem;
  margin-bottom: 0.4rem;
}

/* Toast Notification System */
.toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 10000;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.toast-message {
  min-width: 300px;
  background: rgba(16, 185, 129, 0.95); /* Success green */
  color: #fff;
  padding: 1rem 1.25rem;
  border-radius: var(--radius-md);
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.3);
  display: flex;
  align-items: center;
  gap: 12px;
  font-family: var(--font-sans);
  font-size: 0.9rem;
  font-weight: 500;
  transform: translateX(120%);
  transition: transform 0.35s cubic-bezier(0.16, 1, 0.3, 1);
  border-left: 5px solid #064e3b;
}

.toast-message.show {
  transform: translateX(0);
}

.toast-message.error {
  background: rgba(239, 68, 68, 0.95); /* Danger red */
  border-left-color: #7f1d1d;
}

.toast-message i {
  font-size: 1.2rem;
}

/* ==========================================================================
   ESTILOS DE SIDEBAR RECOLHIDA (COLLAPSED)
   ========================================================================== */
body.sidebar-collapsed {
  --sidebar-width: 68px;
}

body.sidebar-collapsed .sidebar-brand {
  padding: 0.85rem 0.35rem;
}

body.sidebar-collapsed .sidebar-brand .brand-logo-img {
  height: 26px;
  max-width: 90%;
}

body.sidebar-collapsed .user-badge-sidebar {
  justify-content: center;
  padding: 0.75rem 0.25rem;
}

body.sidebar-collapsed .user-badge-sidebar .user-info {
  display: none !important;
}

body.sidebar-collapsed .nav-group-title {
  display: none !important;
}

body.sidebar-collapsed .nav-item {
  justify-content: center;
  padding: 0.65rem 0;
  gap: 0;
}

body.sidebar-collapsed .nav-item span,
body.sidebar-collapsed .nav-item .accordion-icon {
  display: none !important;
}

body.sidebar-collapsed .nav-sub {
  padding-left: 0 !important;
}

body.sidebar-collapsed .sidebar-footer button {
  justify-content: center;
  padding: 0.6rem 0;
}

body.sidebar-collapsed .sidebar-footer button span {
  display: none !important;
}

/* Sidebar Backdrop para Telas Menores */
.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(4px);
  z-index: 95;
}

/* Tabelas com Cabeçalho Fixo e Scroll Suave */
.table-responsive {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.table-responsive table th {
  position: sticky;
  top: 0;
  z-index: 5;
}

/* Scrollbars Modernos e Discretos */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.15);
}

::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.2);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.35);
}

/* ==========================================================================
   ADAPTAÇÃO AUTOMÁTICA DE RESOLUÇÃO POR MONITOR (BREAKPOINTS)
   ========================================================================== */

/* 1. Monitores Ultra-Wide / 2K / 4K (Resolução >= 1920px) */
@media (min-width: 1920px) {
  html {
    font-size: 15.5px;
  }
  :root {
    --sidebar-width: 280px;
  }
  .content-body {
    padding: 2rem 2.5rem;
  }
  .grid-2col {
    grid-template-columns: repeat(auto-fit, minmax(460px, 1fr));
    gap: 1.5rem;
  }
  .grid-3col {
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 1.5rem;
  }
  .grid-4col {
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1.25rem;
  }
  .metrics-grid {
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1.25rem;
  }
}

/* 2. Monitores Standard HD / Notebooks (1280px a 1440px ou Altura <= 820px) */
@media (max-width: 1440px), (max-height: 820px) {
  html {
    font-size: 13.5px;
  }
  :root {
    --sidebar-width: 235px;
  }
  .content-body {
    padding: 1.25rem 1.5rem;
  }
  .topbar {
    padding: 0.75rem 1.5rem;
  }
  .card-body {
    padding: 1.15rem 1.25rem;
  }
  .grid-2col {
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 1rem;
  }
  .grid-3col {
    grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
    gap: 1rem;
  }
  .grid-4col {
    grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
    gap: 0.75rem;
  }
  .metrics-grid {
    grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
    gap: 0.85rem;
  }
  .metric-card {
    padding: 0.85rem 1rem;
  }
  .metric-icon {
    width: 42px;
    height: 42px;
    font-size: 1.2rem;
  }
  .metric-data .value {
    font-size: 1.45rem;
  }
  .modal-content {
    max-height: 90vh;
    overflow-y: auto;
    padding: 1.35rem;
  }
}

/* 3. Monitores Compactos e Bancadas de Teste (1025px a 1200px) */
@media (max-width: 1200px) {
  html {
    font-size: 13px;
  }
  :root {
    --sidebar-width: 220px;
  }
  .content-body {
    padding: 1rem;
  }
  .topbar {
    padding: 0.65rem 1rem;
  }
  .grid-2col {
    grid-template-columns: 1fr;
  }
  .charts-grid {
    grid-template-columns: 1fr;
  }
}

/* 4. Tablets e Terminais Touch de Operação (769px a 1024px) */
@media (max-width: 1024px) {
  :root {
    --sidebar-width: 260px;
  }
  .sidebar {
    transform: translateX(-100%);
    box-shadow: 0 0 40px rgba(0, 0, 0, 0.7);
  }
  .main-content {
    margin-left: 0 !important;
  }
  body.sidebar-open .sidebar {
    transform: translateX(0);
  }
  body.sidebar-open .sidebar-backdrop {
    display: block;
  }
}

/* 5. Telas Pequenas e Smartphones (<= 768px) */
@media (max-width: 768px) {
  html {
    font-size: 12.5px;
  }
  .topbar {
    padding: 0.65rem 0.85rem;
    flex-wrap: wrap;
    gap: 0.5rem;
  }
  .topbar-actions {
    margin-left: auto;
  }
  .content-body {
    padding: 0.75rem;
  }
  .grid-2col, .grid-3col, .grid-4col {
    grid-template-columns: 1fr;
    gap: 0.75rem;
  }
  .metrics-grid {
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem;
  }
  .modal-overlay {
    padding: 0.5rem;
  }
  .modal-content {
    padding: 1rem;
    max-height: 95vh;
  }
  .scanner-banner {
    flex-direction: column;
    text-align: center;
  }
}
