:root {
  /* Base Colors - Dark Mode (Default) */
  --bg-main: #1a1a1a; /* Darker than slate for contrast */
  --card-bg: rgba(
    98,
    103,
    107,
    0.25
  ); /* Slate #62676B base with transparency */
  --text-main: #e5e3d6; /* Cream */
  --text-muted: #a5a5a5; /* Medium Grey */
  --border-glass: rgba(219, 201, 187, 0.15); /* Tan trace */
  --primary: #dbc9bb; /* Tan */
  --secondary: #62676b; /* Slate */
  --success: #22c55e;
  --danger: #ef4444;
  --warning: #f59e0b;
  --header-bg: rgba(26, 26, 26, 0.9);
  --input-bg: rgba(255, 255, 255, 0.05);
  --primary-hover: #d9cdbd; /* Light Tan */
  --glass-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.5);
}

body.light-mode {
  --bg-main: #e5e3d6; /* Cream */
  --card-bg: rgba(255, 255, 255, 0.5);
  --text-main: #62676b; /* Slate */
  --text-muted: #62676b; /* Slate for better visibility on cream */
  --border-glass: rgba(98, 103, 107, 0.1);
  --header-bg: rgba(229, 227, 214, 0.9);
  --input-bg: rgba(255, 255, 255, 0.4);
  --glass-shadow: 0 8px 32px 0 rgba(98, 103, 107, 0.1);
}

html {
  scroll-behavior: smooth;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: "Inter", sans-serif;
  background-color: var(--bg-main);
  color: var(--text-main);
  line-height: 1.5;
  transition:
    background-color 0.3s,
    color 0.3s;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Glassmorphism utility */
.glass {
  background: var(--card-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--border-glass);
  box-shadow: var(--glass-shadow);
}

/* Login Page */
/* Login Page */
.login-container {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: var(--bg-main); /* Fallback */
  background-image: url("../img/background.jpg");
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  position: relative;
  z-index: 1;
}

/* Overlay to darken background image for readability */
.login-container::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.6); /* Dark overlay */
  z-index: -1;
}

.login-card {
  width: 100%;
  max-width: 400px;
  padding: 2.5rem;
  border-radius: 1.5rem;
  background: var(--card-bg); /* Uses theme color with transparency */
  backdrop-filter: blur(20px); /* Stronger blur */
  border: 1px solid var(--border-glass);
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5); /* Stronger shadow */
}

/* Sidebar LOGO Constraint */
.sidebar-header img {
  max-width: 100%;
  height: auto;
  max-height: 80px;
  object-fit: contain;
  padding: 5px;
}

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

.login-header img {
  max-width: 150px;
  margin-bottom: 1rem;
}

.login-header h1 {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-main);
}

.form-group {
  margin-bottom: 1.5rem;
}

.form-group label {
  display: block;
  margin-bottom: 0.5rem;
  font-size: 0.875rem;
  color: var(--text-muted);
}

.form-input {
  width: 100%;
  padding: 0.75rem 1rem;
  background: var(--input-bg);
  border: 1px solid var(--border-glass);
  border-radius: 0.75rem;
  color: var(--text-main);
  font-size: 1rem;
  transition: all 0.2s;
}

.form-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.2);
}

/* Fix for Select Dropdowns in Dark Mode */
select.form-input option {
  background-color: var(--bg-main);
  color: var(--text-main);
}

.btn-primary {
  width: 100%;
  padding: 0.75rem;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: 0.75rem;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
}

.btn-primary:hover {
  background: var(--primary-hover);
}

/* Alerts */
.alert {
  padding: 1rem;
  border-radius: 0.75rem;
  margin-bottom: 1.5rem;
  font-size: 0.875rem;
}

.alert-danger {
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid var(--danger);
  color: var(--danger);
}

/* Animations */
@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.animate-fade-in {
  animation: fadeIn 0.5s ease-out forwards;
}

/* App Layout */
.app-layout {
  display: flex;
  min-height: 100vh;
  max-width: 100vw;
  overflow-x: hidden;
}

/* Sidebar */
.sidebar {
  width: 280px;
  height: 100vh;
  position: fixed;
  left: 0;
  top: 0;
  display: flex;
  flex-direction: column;
  z-index: 1000;
  transition: all 0.3s ease;
}

.sidebar-header {
  padding: 2rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

.logo-text {
  font-size: 1.5rem;
  font-weight: 800;
  letter-spacing: -0.5px;
  color: var(--text-main);
}

.logo-text span {
  color: var(--primary);
}

.sidebar-nav {
  flex: 1;
  padding: 1rem;
  overflow-y: auto;
}

.nav-label {
  padding: 1.5rem 0.75rem 0.5rem;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--text-muted);
  letter-spacing: 1px;
}

.sidebar-nav a {
  display: flex;
  align-items: center;
  padding: 0.875rem 1rem;
  margin-bottom: 0.25rem;
  border-radius: 0.75rem;
  color: var(--text-main);
  text-decoration: none;
  font-size: 0.9375rem;
  font-weight: 500;
  transition: all 0.2s;
}

.sidebar-nav a i {
  width: 24px;
  margin-right: 12px;
  font-size: 1.125rem;
  color: var(--text-muted);
  transition: all 0.2s;
}

.sidebar-nav a:hover {
  background: var(--border-glass);
}

.sidebar-nav a.active {
  background: var(--primary);
  color: white;
}

.sidebar-nav a.active i {
  color: white;
}

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

.user-info {
  display: flex;
  align-items: center;
  gap: 12px;
}

.user-avatar {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  color: white;
}

.user-details {
  display: flex;
  flex-direction: column;
}

.user-name {
  font-size: 0.875rem;
  font-weight: 600;
}

.user-role {
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* Main Content */
.main-content {
  flex: 1;
  margin-left: 280px;
  padding: 2rem;
  min-height: 100vh;
}

.top-header {
  height: 70px;
  margin-top: -2rem;
  margin-left: -2rem;
  margin-right: -2rem;
  margin-bottom: 2rem;
  padding: 0 2rem;
  background: var(--header-bg);
  backdrop-filter: blur(12px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 900;
  border-bottom: 1px solid var(--border-glass);
}

.page-title h2 {
  font-size: 1.25rem;
  font-weight: 700;
}

.mobile-only {
  display: none;
}

.search-box {
  position: relative;
}

.search-box i {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
}

.search-box input {
  background: var(--input-bg);
  border: 1px solid var(--border-glass);
  border-radius: 0.75rem;
  padding: 0.625rem 1rem 0.625rem 2.5rem;
  color: var(--text-main);
  width: 300px;
}

/* Dashboard Cards */
.dash-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(240px, 100%), 1fr));
  gap: 1.5rem;
  margin-bottom: 2rem;
}

.stat-card {
  padding: 1.5rem;
  border-radius: 1.25rem;
  display: flex;
  align-items: center;
  gap: 1.5rem;
}

.stat-icon {
  width: 60px;
  height: 60px;
  border-radius: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
}

.stat-icon.bg-primary {
  background: rgba(99, 102, 241, 0.15);
  color: var(--primary);
}
.stat-icon.bg-success {
  background: rgba(34, 197, 94, 0.15);
  color: var(--success);
}
.stat-icon.bg-warning {
  background: rgba(234, 179, 8, 0.15);
  color: var(--warning);
}
.stat-icon.bg-danger {
  background: rgba(239, 68, 68, 0.15);
  color: var(--danger);
}

.stat-info h3 {
  font-size: 0.875rem;
  color: var(--text-muted);
  font-weight: 500;
  margin-bottom: 0.25rem;
}

.stat-info .value {
  font-size: 1.5rem;
  font-weight: 700;
}

/* Table Style */
.table-container {
  padding: 1.5rem;
  border-radius: 1.25rem;
  margin-top: 1.5rem;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th {
  text-align: left;
  padding: 1rem;
  font-size: 0.875rem;
  color: var(--text-muted);
  font-weight: 600;
  border-bottom: 1px solid var(--border-glass);
}

td {
  padding: 1rem;
  font-size: 0.9375rem;
  border-bottom: 1px solid var(--border-glass);
}

tr:last-child td {
  border-bottom: none;
}

.badge {
  padding: 0.25rem 0.75rem;
  border-radius: 0.5rem;
  font-size: 0.75rem;
  font-weight: 600;
}

.badge-success {
  background: rgba(34, 197, 94, 0.15);
  color: var(--success);
}
.badge-warning {
  background: rgba(234, 179, 8, 0.15);
  color: var(--warning);
}
.badge-danger {
  background: rgba(239, 68, 68, 0.15);
  color: var(--danger);
}

/* Responsive */
@media (max-width: 1024px) {
  .sidebar {
    transform: translateX(-100%);
    width: 250px;
  }
  .sidebar.open {
    transform: translateX(0);
  }
  .main-content {
    margin-left: 0;
  }
  .mobile-only {
    display: block;
    background: none;
    border: none;
    color: var(--text-main);
    font-size: 1.5rem;
    margin-right: 1rem;
  }
  .search-box input {
    width: 100%;
  }
}

/* Theme Toggle Button */
.btn-icon {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  cursor: pointer;
  border: 1px solid var(--border-glass);
  color: var(--text-main);
  background: var(--card-bg);
  transition: all 0.2s;
  margin-right: 1rem;
}

.btn-icon:hover {
  transform: scale(1.1);
  border-color: var(--primary);
  color: var(--primary);
}

/* Status Badges */
.status-badge {
  padding: 0.4rem 1rem;
  border-radius: 2rem;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  display: inline-block;
}

.status-pendente {
  background: rgba(99, 102, 241, 0.1);
  color: var(--primary);
}
.status-info {
  background: rgba(59, 130, 246, 0.1);
  color: #3b82f6;
}
.status-success {
  background: rgba(34, 197, 94, 0.1);
  color: var(--success);
}
.status-warning {
  background: rgba(245, 158, 11, 0.1);
  color: var(--warning);
}
.status-danger {
  background: rgba(239, 68, 68, 0.1);
  color: var(--danger);
}

/* Utility Classes */

/* Header Cart Badge */
.cart-badge-header {
  position: absolute;
  top: -5px;
  right: -5px;
  background: #ef4444;
  color: white;
  font-size: 0.65rem;
  font-weight: 700;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid var(--header-bg);
}

/* Cart Responsive Grid */
.cart-grid {
  grid-template-columns: 2fr 1fr;
  gap: 1.5rem;
}

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

  .table-container table {
    display: block;
    overflow-x: auto;
    white-space: nowrap;
  }

  .table-container th,
  .table-container td {
    min-width: 120px;
  }
}

@media print {
  /* Ocultar elementos desnecessários na impressão */
  .sidebar,
  .top-header,
  .top-actions,
  .btn-secondary,
  .btn-link,
  .btn-primary,
  .action-btn,
  #theme-toggle,
  .mobile-only {
    display: none !important;
  }

  .main-content {
    margin-left: 0 !important;
    padding: 0 !important;
    width: 100% !important;
  }

  .content-wrapper {
    padding: 0 !important;
    margin-top: 0 !important;
  }

  /* Melhorar legibilidade em papel */
  .glass {
    background: white !important;
    color: black !important;
    border: 1px solid #ddd !important;
    box-shadow: none !important;
    backdrop-filter: none !important;
    margin: 0 0 20px 0 !important;
    padding: 1.5rem !important;
  }

  body {
    background: white !important;
    color: black !important;
  }
  h2,
  h3,
  h4,
  span,
  div,
  p,
  strong,
  small {
    color: black !important;
    background: none !important;
  }

  table {
    width: 100% !important;
    border-collapse: collapse !important;
    border: 1px solid #ddd !important;
  }
  th {
    background: #f0f0f0 !important;
    color: black !important;
    border-bottom: 2px solid #ddd !important;
  }
  td {
    border-bottom: 1px solid #ddd !important;
    padding: 8px !important;
    color: black !important;
  }

  .badge {
    border: 1px solid #000 !important;
    color: black !important;
    background: none !important;
    text-transform: uppercase !important;
    font-size: 0.7rem !important;
  }

  /* Layout de Colunas para Impressão (Empilhado) */
  .dash-grid {
    display: block !important;
  }
  .dash-grid > div {
    width: 100% !important;
    margin-bottom: 20px !important;
    page-break-inside: avoid;
  }

  /* Reset de animações */
  .animate-fade-in {
    animation: none !important;
    opacity: 1 !important;
    transform: none !important;
  }
}

/* Quick Actions Dashboard */
.action-card {
  text-decoration: none;
  color: var(--text-main);
  padding: 1.5rem;
  border-radius: 1rem;
  display: flex;
  align-items: center;
  gap: 1.5rem;
  transition: all 0.3s ease;
  border: 1px solid var(--border-glass);
}

.action-card:hover {
  transform: translateY(-5px);
  background: rgba(255, 255, 255, 0.1);
  border-color: var(--primary);
  box-shadow: 0 10px 20px rgba(0, 0, 0, 0.1);
}

.action-card .icon-box {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  flex-shrink: 0;
}

.action-card .icon-box.new-order {
  background: rgba(99, 102, 241, 0.2);
  color: #6366f1;
}
.action-card .icon-box.customers {
  background: rgba(34, 197, 94, 0.2);
  color: #22c55e;
}
.action-card .icon-box.orders {
  background: rgba(245, 158, 11, 0.2);
  color: #f59e0b;
}

.action-card .action-info h3 {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 700;
  margin-bottom: 0.25rem;
}

.action-card .action-info p {
  margin: 0;
  font-size: 0.9rem;
  color: var(--text-muted);
}

/* Sidebar Toggle Button Styles */
.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.sidebar-toggle {
  background: none;
  border: none;
  color: var(--text-main);
  font-size: 1.2rem;
  padding: 0.5rem;
  border-radius: 0.5rem;
  cursor: pointer;
  transition: all 0.2s;
  flex-shrink: 0;
}

.sidebar-toggle:hover {
  background: rgba(99, 102, 241, 0.1);
  color: var(--primary);
}

/* Desktop: Sidebar Collapsed State (push content) */
@media (min-width: 1025px) {
  .app-layout.sidebar-collapsed .sidebar {
    width: 0;
    min-width: 0;
    padding: 0;
    overflow: hidden;
    border-right: none;
  }

  .app-layout.sidebar-collapsed .main-content {
    margin-left: 0;
  }
}

/* Mobile/Tablet: Sidebar as Overlay */
/* Mobile/Tablet: Sidebar as Overlay */
@media (max-width: 1024px) {
  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    height: 100vh;
    z-index: 1000;
    transform: translateX(-100%);
    transition: transform 0.3s ease;
    width: 250px; /* Ensure uniform width */
  }

  /* Show sidebar when 'sidebar-open' class is present */
  .app-layout.sidebar-open .sidebar {
    transform: translateX(0);
  }

  /* Overlay backdrop */
  .app-layout.sidebar-open::before {
    content: "";
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 999;
    animation: fadeIn 0.3s;
  }

  @keyframes fadeIn {
    from {
      opacity: 0;
    }
    to {
      opacity: 1;
    }
  }

  /* Main content never shifts on mobile */
  .main-content {
    margin-left: 0 !important;
    width: 100%;
  }
}

/* Smooth transitions */
.sidebar,
.main-content {
  transition: all 0.3s ease;
}

/* Main Sidebar Toggle Button (always visible in topbar) */
.sidebar-toggle-main {
  background: rgba(99, 102, 241, 0.1);
  border: 1px solid var(--primary);
  color: var(--primary);
  font-size: 1.2rem;
  padding: 0.5rem 0.75rem;
  border-radius: 0.5rem;
  cursor: pointer;
  transition: all 0.2s;
  margin-right: 1rem;
}

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

/* Page title alignment */
.page-title {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.page-title h2 {
  margin: 0;
}

/* Global Modal Styles */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  backdrop-filter: blur(8px);
}

.modal-content {
  background: var(--card-bg);
  padding: 2.5rem;
  border-radius: 1.5rem;
  position: relative;
  max-height: 90vh;
  overflow-y: auto;
  border: 1px solid var(--border-glass);
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
}

.btn-close-modal:hover {
  background: var(--danger) !important;
  border-color: var(--danger) !important;
  transform: rotate(90deg);
}
