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

:root {
  --primary: #0066cc;
  --primary-dark: #0052a3;
  --primary-light: #e6f0ff;
  --accent: #00d4ff;
  --success: #10b981;
  --danger: #ef4444;
  --warning: #f59e0b;
  --bg-primary: #ffffff;
  --bg-secondary: #f8fafc;
  --bg-tertiary: #f1f5f9;
  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-light: #94a3b8;
  --border: #e2e8f0;
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
  --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
  --radius-sm: 6px;
  --radius-md: 12px;
  --radius-lg: 16px;
}

/* Dark mode completo */
html.dark-mode {
  --primary: #3b82f6;
  --primary-dark: #1e40af;
  --primary-light: #1e3a8a;
  --accent: #06b6d4;
  --success: #10b981;
  --danger: #ef4444;
  --warning: #f59e0b;
  --bg-primary: #1a1a2e;
  --bg-secondary: #16213e;
  --bg-tertiary: #0f3460;
  --text-primary: #e8e8e8;
  --text-secondary: #b0b0b0;
  --text-light: #808080;
  --border: #2a2a3e;
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.5);
  --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.6);
}

html {
  scroll-behavior: smooth;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Helvetica Neue", sans-serif;
  background-color: var(--bg-secondary);
  color: var(--text-primary);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  transition: background-color 0.3s ease, color 0.3s ease;
  margin: 0;
  padding: 0;
}

.container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 20px;
}

/* Remover estilos de sidebar e ajustar layout -->
/* Navbar em cima sem bloquear conteúdo */
.navbar {
  background: var(--bg-primary);
  padding: 16px 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: var(--shadow-md);
  position: sticky;
  top: 0;
  z-index: 1000;
  border-bottom: 1px solid var(--border);
  transition: all 0.3s ease;
}

.navbar .container {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  gap: 20px;
}

.navbar-brand {
  font-size: 22px;
  font-weight: 800;
  background: linear-gradient(135deg, var(--primary) 0%, var(--accent) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  white-space: nowrap;
  letter-spacing: -0.5px;
  text-decoration: none;
}

.navbar-menu {
  display: flex;
  gap: 8px;
  flex: 1;
  justify-content: center;
  flex-wrap: wrap;
}

.nav-link {
  text-decoration: none;
  color: var(--text-secondary);
  font-weight: 500;
  transition: all 0.3s ease;
  font-size: 14px;
  padding: 8px 12px;
  border-radius: var(--radius-md);
  white-space: nowrap;
}

.nav-link:hover,
.nav-link.active {
  color: var(--primary);
  background-color: var(--primary-light);
}

.navbar-right {
  display: flex;
  gap: 12px;
  align-items: center;
  white-space: nowrap;
}

.user-name {
  font-size: 14px;
  color: var(--text-secondary);
  font-weight: 500;
}

/* Estilo para dark mode toggle */
.dark-mode-toggle {
  display: flex;
  align-items: center;
  cursor: pointer;
  gap: 6px;
  padding: 6px 10px;
  border-radius: var(--radius-md);
  transition: all 0.3s ease;
  background: none;
  border: none;
}

.dark-mode-toggle:hover {
  background-color: var(--primary-light);
}

.dark-mode-toggle input {
  display: none;
}

.toggle-icon {
  font-size: 18px;
  transition: transform 0.3s ease;
}

.dark-mode-toggle input:checked ~ .toggle-icon {
  transform: rotate(180deg);
}

/* ===== MAIN CONTENT ===== */
.main-content {
  background-color: var(--bg-secondary);
  padding: 40px 20px;
  min-height: calc(100vh - 70px);
  transition: all 0.3s ease;
}

.main-content h1 {
  font-size: 32px;
  font-weight: 800;
  margin-bottom: 30px;
  color: var(--text-primary);
  letter-spacing: -0.5px;
}

/* ===== BUTTONS ===== */
.btn {
  padding: 10px 20px;
  border: none;
  border-radius: var(--radius-md);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
  text-decoration: none;
  display: inline-block;
  white-space: nowrap;
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary) 0%, var(--accent) 100%);
  color: white;
  box-shadow: var(--shadow-md);
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}

.btn-primary:active {
  transform: translateY(0);
}

.btn-small {
  padding: 6px 12px;
  font-size: 12px;
}

.btn-danger {
  background: var(--danger);
  color: white;
  transition: all 0.3s ease;
}

.btn-danger:hover {
  background: #dc2626;
  transform: translateY(-2px);
}

.btn-success {
  background: var(--success);
  color: white;
  transition: all 0.3s ease;
}

.btn-success:hover {
  background: #059669;
  transform: translateY(-2px);
}

.btn-warning {
  background: var(--warning);
  color: white;
  transition: all 0.3s ease;
}

.btn-warning:hover {
  background: #d97706;
  transform: translateY(-2px);
}

.btn-block {
  width: 100%;
}

/* ===== ALERTS ===== */
.alert {
  padding: 14px 16px;
  border-radius: var(--radius-md);
  margin-bottom: 20px;
  font-size: 14px;
  font-weight: 500;
  border-left: 4px solid;
  animation: slideIn 0.3s ease;
  transition: all 0.3s ease;
}

@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.alert-error {
  background: #fee2e2;
  color: #991b1b;
  border-color: var(--danger);
}

html.dark-mode .alert-error {
  background: rgba(239, 68, 68, 0.1);
  color: #fca5a5;
}

.alert-success {
  background: #dcfce7;
  color: #166534;
  border-color: var(--success);
}

html.dark-mode .alert-success {
  background: rgba(16, 185, 129, 0.1);
  color: #86efac;
}

/* Ajustar main-content para não ficar bloqueado pela navbar */

.main-content {
  background-color: var(--bg-secondary);
  padding: 40px 20px;
  min-height: calc(100vh - 70px);
  transition: all 0.3s ease;
}

.main-content h1 {
  font-size: 32px;
  font-weight: 800;
  margin-bottom: 30px;
  color: var(--text-primary);
  letter-spacing: -0.5px;
}

/* ===== DASHBOARD ===== */
.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 20px;
  margin-bottom: 30px;
}

.dashboard-card {
  background: var(--bg-primary);
  padding: 24px;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  display: flex;
  gap: 16px;
  align-items: flex-start;
  transition: all 0.3s ease;
  border: 1px solid var(--border);
}

.dashboard-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-lg);
  border-color: var(--primary);
}

.card-icon {
  font-size: 36px;
  line-height: 1;
}

.card-content {
  flex: 1;
}

.card-content h3 {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 8px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.card-value {
  font-size: 28px;
  font-weight: 800;
  background: linear-gradient(135deg, var(--primary) 0%, var(--accent) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* ===== FORMS ===== */
.form-section {
  background: var(--bg-primary);
  padding: 32px;
  border-radius: var(--radius-lg);
  margin-bottom: 30px;
  box-shadow: var(--shadow-md);
  border: 1px solid var(--border);
  transition: all 0.3s ease;
}

.form-section h2 {
  font-size: 22px;
  font-weight: 700;
  margin-bottom: 24px;
  color: var(--text-primary);
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 20px;
}

.form-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 20px;
}

.venda-form {
  display: grid;
  gap: 24px;
}

.produtos-container {
  background: var(--bg-tertiary);
  padding: 24px;
  border-radius: var(--radius-md);
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 20px;
  border: 1px solid var(--border);
  transition: all 0.3s ease;
}

.produto-item {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 12px;
  background: var(--bg-primary);
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  transition: all 0.3s ease;
}

.produto-item:hover {
  border-color: var(--primary);
  box-shadow: var(--shadow-sm);
}

.produto-item label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
}

.produto-item input {
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  transition: all 0.3s ease;
  background-color: var(--bg-secondary);
  color: var(--text-primary);
}

.produto-item input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
}

/* ===== TABLES ===== */
.table-section {
  background: var(--bg-primary);
  padding: 32px;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  margin-bottom: 30px;
  border: 1px solid var(--border);
  overflow-x: auto;
  transition: all 0.3s ease;
}

.table-section h2 {
  font-size: 22px;
  font-weight: 700;
  margin-bottom: 24px;
  color: var(--text-primary);
}

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

.table thead {
  background-color: var(--bg-tertiary);
  border-bottom: 2px solid var(--border);
}

.table th {
  padding: 14px 16px;
  text-align: left;
  font-weight: 700;
  color: var(--text-primary);
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.table td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  color: var(--text-secondary);
  font-size: 14px;
}

.table tbody tr {
  transition: all 0.2s ease;
}

.table tbody tr:hover {
  background-color: var(--bg-tertiary);
}

.product-thumbnail {
  max-width: 48px;
  max-height: 48px;
  border-radius: var(--radius-sm);
  object-fit: cover;
  border: 1px solid var(--border);
}

.no-image {
  font-size: 12px;
  color: var(--text-light);
  font-weight: 500;
}

/* ===== FILTERS ===== */
.filter-section {
  background: var(--bg-primary);
  padding: 24px;
  border-radius: var(--radius-lg);
  margin-bottom: 30px;
  box-shadow: var(--shadow-md);
  border: 1px solid var(--border);
  transition: all 0.3s ease;
}

.filter-form {
  display: flex;
  gap: 16px;
  align-items: flex-end;
  flex-wrap: wrap;
}

.filter-form .form-group {
  margin-bottom: 0;
}

.form-group {
  margin-bottom: 20px;
}

.form-group label {
  display: block;
  margin-bottom: 8px;
  font-weight: 600;
  color: var(--text-primary);
  font-size: 14px;
}

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 12px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-md);
  font-size: 14px;
  transition: all 0.3s ease;
  background-color: var(--bg-secondary);
  color: var(--text-primary);
}

.form-group input::placeholder {
  color: var(--text-light);
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--primary);
  background-color: var(--bg-primary);
  box-shadow: 0 0 0 3px var(--primary-light);
}

/* ===== AUTH ===== */
.auth-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: linear-gradient(135deg, #0066cc 0%, #00d4ff 100%);
}

.auth-container {
  width: 100%;
  max-width: 420px;
  padding: 20px;
}

.auth-card {
  background: var(--bg-primary);
  border-radius: var(--radius-lg);
  padding: 40px;
  box-shadow: var(--shadow-xl);
  backdrop-filter: blur(10px);
  transition: all 0.3s ease;
}

.logo {
  font-size: 32px;
  font-weight: 800;
  background: linear-gradient(135deg, var(--primary) 0%, var(--accent) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  text-align: center;
  margin-bottom: 8px;
  letter-spacing: -0.5px;
}

.tagline {
  text-align: center;
  color: var(--text-secondary);
  margin-bottom: 30px;
  font-size: 14px;
  font-weight: 500;
}

.auth-form {
  margin: 30px 0;
}

.auth-footer {
  text-align: center;
  margin-top: 20px;
  font-size: 14px;
  color: var(--text-secondary);
}

.auth-footer a {
  color: var(--primary);
  text-decoration: none;
  font-weight: 600;
  transition: color 0.3s ease;
}

.auth-footer a:hover {
  color: var(--primary-dark);
}

/* ===== RESPONSIVE ===== */
@media (max-width: 1024px) {
  .dashboard-grid {
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  }

  .navbar-menu {
    gap: 4px;
  }

  .nav-link {
    font-size: 13px;
    padding: 6px 10px;
  }
}

@media (max-width: 768px) {
  .navbar .container {
    flex-direction: column;
    gap: 12px;
  }

  .navbar-menu {
    width: 100%;
    justify-content: flex-start;
    gap: 4px;
    flex-wrap: wrap;
  }

  .nav-link {
    font-size: 12px;
    padding: 6px 8px;
  }

  .navbar-right {
    width: 100%;
    justify-content: space-between;
  }

  .user-name {
    display: none;
  }

  .dashboard-grid {
    grid-template-columns: 1fr;
  }

  .form-grid,
  .form-row {
    grid-template-columns: 1fr;
  }

  .produtos-container {
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 12px;
    padding: 16px;
  }

  .table {
    font-size: 12px;
  }

  .table th,
  .table td {
    padding: 10px 12px;
  }

  .main-content {
    padding: 24px 16px;
  }

  .form-section,
  .table-section,
  .filter-section {
    padding: 20px 16px;
  }

  .auth-card {
    padding: 28px 20px;
  }

  .logo {
    font-size: 28px;
  }

  .main-content h1 {
    font-size: 24px;
  }

  .filter-form {
    flex-direction: column;
  }

  .filter-form .form-group {
    width: 100%;
  }

  .btn {
    font-size: 13px;
    padding: 10px 16px;
  }
}

@media (max-width: 480px) {
  .navbar-brand {
    font-size: 18px;
  }

  .logo {
    font-size: 24px;
  }

  .main-content h1 {
    font-size: 22px;
    margin-bottom: 24px;
  }

  .dashboard-card {
    flex-direction: column;
    text-align: center;
  }

  .card-icon {
    font-size: 32px;
  }

  .card-value {
    font-size: 24px;
  }

  .form-section h2,
  .table-section h2 {
    font-size: 18px;
  }

  .table-section {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .table {
    min-width: 100%;
    width: max-content;
  }

  .auth-card {
    padding: 24px 16px;
  }

  .auth-form {
    margin: 20px 0;
  }

  .form-group {
    margin-bottom: 16px;
  }
}

/* ========== LOADER GLOBAL ========== */

#page-loader {
    position: fixed;
    inset: 0;
    z-index: 9999;
    display: none; /* escondido por padrão */
    align-items: center;
    justify-content: center;
    pointer-events: none;
}

#page-loader.active {
    display: flex;
    pointer-events: auto;
}

#page-loader .loader-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, 0.65); /* fundo escuro */
    backdrop-filter: blur(3px);
}

#page-loader .loader-content {
    position: relative;
    z-index: 1;
    padding: 24px 28px;
    border-radius: 16px;
    background: #ffffff;
    box-shadow: 0 18px 40px rgba(15, 23, 42, 0.35);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
}

html.dark-mode #page-loader .loader-content {
    background: #0f172a;
    box-shadow: 0 18px 40px rgba(15, 23, 42, 0.8);
}

.loader-spinner {
    width: 42px;
    height: 42px;
    border-radius: 999px;
    border: 4px solid #e5e7eb;
    border-top-color: #2563eb;
    animation: loader-spin 0.8s linear infinite;
}

html.dark-mode .loader-spinner {
    border-color: #1e293b;
    border-top-color: #60a5fa;
}

.loader-text {
    font-size: 14px;
    font-weight: 500;
    color: #374151;
}

html.dark-mode .loader-text {
    color: #e5e7eb;
}

@keyframes loader-spin {
    to {
        transform: rotate(360deg);
    }
}

/* ===================== LOADER GLOBAL ===================== */

#page-loader {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex; /* visível por padrão */
  align-items: center;
  justify-content: center;
  pointer-events: auto;
}

#page-loader.hidden {
  display: none; /* some quando JS adicionar .hidden */
}

#page-loader .loader-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.65);
  backdrop-filter: blur(3px);
}

#page-loader .loader-content {
  position: relative;
  z-index: 1;
  padding: 24px 28px;
  border-radius: 16px;
  background: #ffffff;
  box-shadow: 0 18px 40px rgba(15, 23, 42, 0.35);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

html.dark-mode #page-loader .loader-content {
  background: #0f172a;
  box-shadow: 0 18px 40px rgba(15, 23, 42, 0.8);
}

.loader-spinner {
  width: 42px;
  height: 42px;
  border-radius: 999px;
  border: 4px solid #e5e7eb;
  border-top-color: #2563eb;
  animation: loader-spin 0.8s linear infinite;
}

html.dark-mode .loader-spinner {
  border-color: #1e293b;
  border-top-color: #60a5fa;
}

.loader-text {
  font-size: 14px;
  font-weight: 500;
  color: #374151;
}

html.dark-mode .loader-text {
  color: #e5e7eb;
}

@keyframes loader-spin {
  to {
      transform: rotate(360deg);
  }
}
