/**
 * ERP SAAS - Layout Branco com Detalhes Coloridos
 * Versão: 2.0 - Layout Clean & Moderno
 */

/* === VARIÁVEIS CSS === */
:root {
  /* Cores primárias - azul moderno */
  --primary: #3b82f6;
  --primary-dark: #2563eb;
  --primary-light: #60a5fa;
  --primary-lighter: #dbeafe;
  
  /* Cores secundárias - verde sucesso */
  --secondary: #10b981;
  --secondary-dark: #059669;
  --secondary-light: #34d399;
  --secondary-lighter: #d1fae5;
  
  /* Cores de alerta */
  --warning: #f59e0b;
  --warning-light: #fbbf24;
  --warning-lighter: #fef3c7;
  
  --danger: #ef4444;
  --danger-light: #f87171;
  --danger-lighter: #fee2e2;
  
  --info: #06b6d4;
  --info-light: #22d3ee;
  --info-lighter: #cffafe;
  
  /* Tons de cinza para UI */
  --gray-50: #f9fafb;
  --gray-100: #f3f4f6;
  --gray-200: #e5e7eb;
  --gray-300: #d1d5db;
  --gray-400: #9ca3af;
  --gray-500: #6b7280;
  --gray-600: #4b5563;
  --gray-700: #374151;
  --gray-800: #1f2937;
  --gray-900: #111827;
  
  /* Fundo base branco */
  --bg-body: #ffffff;
  --bg-secondary: var(--gray-50);
  --bg-tertiary: var(--gray-100);
  
  /* Texto */
  --text-primary: var(--gray-900);
  --text-secondary: var(--gray-600);
  --text-muted: var(--gray-500);
  
  /* Bordas */
  --border-color: var(--gray-200);
  --border-light: var(--gray-100);
  
  /* Sombras elegantes */
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
  --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
  
  /* Gradientes coloridos para detalhes */
  --gradient-primary: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  --gradient-secondary: linear-gradient(135deg, var(--secondary) 0%, var(--secondary-dark) 100%);
  --gradient-rainbow: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 50%, var(--info) 100%);
}

/* === RESET E BASE === */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
  background-color: var(--bg-body);
  color: var(--text-primary);
  line-height: 1.6;
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* === LAYOUT PRINCIPAL === */
.layout-container {
  display: flex;
  min-height: 100vh;
  background-color: var(--bg-body);
}

/* === SIDEBAR === */
/* Estilos da sidebar foram movidos para includes/sidebar.php para evitar conflitos */

/* === CONTEÚDO PRINCIPAL === */
.main-content {
  flex: 1;
  margin-left: 280px;
  background-color: var(--bg-secondary);
  min-height: 100vh;
  transition: all 0.3s ease;
}

.main-content.sidebar-collapsed {
  margin-left: 80px;
}

/* Adaptações para nova sidebar */
body {
  margin-left: 280px;
}

@media (max-width: 768px) {
  body {
    margin-left: 0;
  }
}

/* === HEADER SUPERIOR === */
.top-header {
  background: var(--bg-body);
  border-bottom: 1px solid var(--border-color);
  padding: 1rem 2rem;
  display: flex;
  justify-content: between;
  align-items: center;
  box-shadow: var(--shadow-sm);
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.sidebar-toggle {
  background: none;
  border: none;
  font-size: 1.25rem;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 0.5rem;
  border-radius: 0.375rem;
  transition: all 0.2s ease;
}

.sidebar-toggle:hover {
  background-color: var(--bg-secondary);
  color: var(--primary);
}

.page-title {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-primary);
  margin: 0;
}

.breadcrumb {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.875rem;
  color: var(--text-muted);
}

.breadcrumb a {
  color: var(--primary);
  text-decoration: none;
}

.breadcrumb a:hover {
  text-decoration: underline;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.cash-status {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  background: var(--secondary-lighter);
  color: var(--secondary-dark);
  border-radius: 0.5rem;
  font-weight: 600;
  font-size: 0.875rem;
}

.cash-status.closed {
  background: var(--danger-lighter);
  color: var(--danger);
}

.notifications {
  position: relative;
}

.notification-btn {
  background: none;
  border: none;
  font-size: 1.25rem;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 0.5rem;
  border-radius: 0.375rem;
  position: relative;
  transition: all 0.2s ease;
}

.notification-btn:hover {
  background-color: var(--bg-secondary);
  color: var(--primary);
}

.notification-badge {
  position: absolute;
  top: 0.25rem;
  right: 0.25rem;
  background: var(--danger);
  color: white;
  font-size: 0.75rem;
  padding: 0.125rem 0.375rem;
  border-radius: 1rem;
  font-weight: 600;
}

.user-dropdown {
  position: relative;
}

.user-btn {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  background: none;
  border: none;
  padding: 0.5rem;
  border-radius: 0.5rem;
  cursor: pointer;
  transition: all 0.2s ease;
}

.user-btn:hover {
  background-color: var(--bg-secondary);
}

.user-avatar {
  width: 40px;
  height: 40px;
  background: var(--gradient-primary);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: 600;
  font-size: 1rem;
}

.user-info {
  text-align: left;
}

.user-name {
  font-weight: 600;
  color: var(--text-primary);
  font-size: 0.875rem;
}

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

/* === CARDS === */
.card {
  background: var(--bg-body);
  border: 1px solid var(--border-color);
  border-radius: 0.75rem;
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  transition: all 0.2s ease;
}

.card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}

.card-header {
  padding: 1.5rem;
  border-bottom: 1px solid var(--border-light);
  background: var(--bg-secondary);
}

.card-title {
  font-size: 1.125rem;
  font-weight: 700;
  color: var(--text-primary);
  margin: 0;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.card-title i {
  color: var(--primary);
}

.card-body {
  padding: 1.5rem;
}

.card-footer {
  padding: 1rem 1.5rem;
  background: var(--bg-secondary);
  border-top: 1px solid var(--border-light);
}

/* === GRID DASHBOARD === */
.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1.5rem;
  padding: 2rem;
}

.stat-card {
  background: var(--bg-body);
  border: 1px solid var(--border-color);
  border-radius: 0.75rem;
  padding: 1.5rem;
  box-shadow: var(--shadow-sm);
  transition: all 0.2s ease;
  position: relative;
  overflow: hidden;
}

.stat-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: var(--gradient-primary);
}

.stat-card.secondary::before {
  background: var(--gradient-secondary);
}

.stat-card.warning::before {
  background: linear-gradient(135deg, var(--warning) 0%, var(--warning-light) 100%);
}

.stat-card.danger::before {
  background: linear-gradient(135deg, var(--danger) 0%, var(--danger-light) 100%);
}

.stat-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.stat-icon {
  width: 48px;
  height: 48px;
  border-radius: 0.75rem;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  color: white;
  background: var(--gradient-primary);
  margin-bottom: 1rem;
}

.stat-card.secondary .stat-icon {
  background: var(--gradient-secondary);
}

.stat-card.warning .stat-icon {
  background: linear-gradient(135deg, var(--warning) 0%, var(--warning-light) 100%);
}

.stat-card.danger .stat-icon {
  background: linear-gradient(135deg, var(--danger) 0%, var(--danger-light) 100%);
}

.stat-value {
  font-size: 2rem;
  font-weight: 800;
  color: var(--text-primary);
  margin-bottom: 0.25rem;
}

.stat-label {
  font-size: 0.875rem;
  color: var(--text-secondary);
  font-weight: 600;
}

.stat-change {
  font-size: 0.75rem;
  font-weight: 600;
  margin-top: 0.5rem;
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.stat-change.positive {
  color: var(--secondary);
}

.stat-change.negative {
  color: var(--danger);
}

/* === FORMULÁRIOS === */
.form-container {
  background: var(--bg-body);
  padding: 2rem;
  border-radius: 0.75rem;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border-color);
  margin: 1.5rem;
}

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

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

.form-label.required::after {
  content: ' *';
  color: var(--danger);
}

.form-control {
  width: 100%;
  padding: 0.75rem 1rem;
  border: 1px solid var(--border-color);
  border-radius: 0.5rem;
  font-size: 0.875rem;
  background: var(--bg-body);
  color: var(--text-primary);
  transition: all 0.2s ease;
}

.form-control:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.form-control:disabled {
  background-color: var(--bg-secondary);
  color: var(--text-muted);
  cursor: not-allowed;
}

.form-text {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 0.25rem;
}

.form-error {
  font-size: 0.75rem;
  color: var(--danger);
  margin-top: 0.25rem;
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

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

/* === BOTÕES === */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.75rem 1.5rem;
  font-size: 0.875rem;
  font-weight: 600;
  border-radius: 0.5rem;
  border: none;
  cursor: pointer;
  text-decoration: none;
  transition: all 0.2s ease;
  position: relative;
  overflow: hidden;
}

.btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--gradient-primary);
  color: white;
  box-shadow: var(--shadow-sm);
}

.btn-primary:hover:not(:disabled) {
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}

.btn-secondary {
  background: var(--gradient-secondary);
  color: white;
  box-shadow: var(--shadow-sm);
}

.btn-secondary:hover:not(:disabled) {
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}

.btn-outline {
  background: transparent;
  color: var(--primary);
  border: 1px solid var(--primary);
}

.btn-outline:hover:not(:disabled) {
  background: var(--primary);
  color: white;
}

.btn-danger {
  background: linear-gradient(135deg, var(--danger) 0%, var(--danger-light) 100%);
  color: white;
}

.btn-warning {
  background: linear-gradient(135deg, var(--warning) 0%, var(--warning-light) 100%);
  color: white;
}

.btn-sm {
  padding: 0.5rem 1rem;
  font-size: 0.75rem;
}

.btn-lg {
  padding: 1rem 2rem;
  font-size: 1rem;
}

.btn-block {
  width: 100%;
}

/* === TABELAS === */
.table-container {
  background: var(--bg-body);
  border-radius: 0.75rem;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border-color);
  overflow: hidden;
  margin: 1.5rem;
}

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

.table th {
  background: var(--bg-secondary);
  padding: 1rem;
  text-align: left;
  font-weight: 700;
  color: var(--text-primary);
  border-bottom: 1px solid var(--border-color);
  font-size: 0.875rem;
}

.table td {
  padding: 1rem;
  border-bottom: 1px solid var(--border-light);
  color: var(--text-primary);
  font-size: 0.875rem;
}

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

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

/* === BADGES === */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.25rem 0.75rem;
  font-size: 0.75rem;
  font-weight: 600;
  border-radius: 1rem;
  text-transform: uppercase;
  letter-spacing: 0.025em;
}

.badge-primary {
  background: var(--primary-lighter);
  color: var(--primary-dark);
}

.badge-secondary {
  background: var(--secondary-lighter);
  color: var(--secondary-dark);
}

.badge-success {
  background: var(--secondary-lighter);
  color: var(--secondary-dark);
}

.badge-warning {
  background: var(--warning-lighter);
  color: var(--warning);
}

.badge-danger {
  background: var(--danger-lighter);
  color: var(--danger);
}

.badge-info {
  background: var(--info-lighter);
  color: var(--info);
}

/* === ALERTAS === */
.alert {
  padding: 1rem 1.5rem;
  border-radius: 0.5rem;
  margin-bottom: 1rem;
  border-left: 4px solid;
  background: var(--bg-body);
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
}

.alert-success {
  border-left-color: var(--secondary);
  background: var(--secondary-lighter);
  color: var(--secondary-dark);
}

.alert-warning {
  border-left-color: var(--warning);
  background: var(--warning-lighter);
  color: var(--warning);
}

.alert-danger {
  border-left-color: var(--danger);
  background: var(--danger-lighter);
  color: var(--danger);
}

.alert-info {
  border-left-color: var(--info);
  background: var(--info-lighter);
  color: var(--info);
}

/* === MODAIS === */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.modal {
  background: var(--bg-body);
  border-radius: 0.75rem;
  box-shadow: var(--shadow-xl);
  max-width: 90vw;
  max-height: 90vh;
  overflow: auto;
  border: 1px solid var(--border-color);
}

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

.modal-title {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-primary);
  margin: 0;
}

.modal-close {
  background: none;
  border: none;
  font-size: 1.5rem;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0.25rem;
  border-radius: 0.25rem;
  transition: all 0.2s ease;
}

.modal-close:hover {
  background: var(--bg-tertiary);
  color: var(--text-primary);
}

.modal-body {
  padding: 1.5rem;
}

.modal-footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--border-light);
  background: var(--bg-secondary);
  display: flex;
  gap: 0.75rem;
  justify-content: flex-end;
}

/* === LOADING === */
.loading-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(2px);
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 1rem;
}

.loading-spinner {
  width: 48px;
  height: 48px;
  border: 4px solid var(--border-color);
  border-top: 4px solid var(--primary);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

.loading-text {
  color: var(--text-secondary);
  font-weight: 600;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* === TOOLTIPS === */
.tooltip {
  position: relative;
  display: inline-block;
}

.tooltip .tooltiptext {
  visibility: hidden;
  width: 200px;
  background-color: var(--gray-800);
  color: white;
  text-align: center;
  border-radius: 0.375rem;
  padding: 0.5rem;
  position: absolute;
  z-index: 1000;
  bottom: 125%;
  left: 50%;
  margin-left: -100px;
  opacity: 0;
  transition: opacity 0.3s;
  font-size: 0.75rem;
  font-weight: 500;
}

.tooltip:hover .tooltiptext {
  visibility: visible;
  opacity: 1;
}

/* === RESPONSIVO === */
@media (max-width: 768px) {
  /* Responsividade da sidebar movida para includes/sidebar.php */
  
  .main-content {
    margin-left: 0;
  }
  
  .top-header {
    padding: 1rem;
  }
  
  .dashboard-grid {
    grid-template-columns: 1fr;
    padding: 1rem;
  }
  
  .form-container,
  .table-container {
    margin: 1rem;
  }
  
  .modal {
    margin: 1rem;
    max-width: calc(100vw - 2rem);
  }
  
  .form-row {
    grid-template-columns: 1fr;
  }
  
  .user-info {
    display: none;
  }
  
  /* .sidebar-header h2 - movido para includes/sidebar.php */
  
  .page-title {
    font-size: 1.25rem;
  }
}

@media (max-width: 480px) {
  .top-header {
    flex-direction: column;
    gap: 1rem;
    align-items: stretch;
  }
  
  .header-right {
    justify-content: space-between;
  }
  
  .btn {
    padding: 0.625rem 1rem;
    font-size: 0.8rem;
  }
  
  .dashboard-grid {
    padding: 0.5rem;
    gap: 1rem;
  }
  
  .stat-card {
    padding: 1rem;
  }
  
  .table-container {
    overflow-x: auto;
  }
}

/* === DARK MODE (opcional) === */
@media (prefers-color-scheme: dark) {
  :root {
    --bg-body: #0f172a;
    --bg-secondary: #1e293b;
    --bg-tertiary: #334155;
    --text-primary: #f1f5f9;
    --text-secondary: #cbd5e1;
    --text-muted: #94a3b8;
    --border-color: #334155;
    --border-light: #475569;
  }
}

/* === ANIMAÇÕES === */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes slideIn {
  from { transform: translateX(-100%); }
  to { transform: translateX(0); }
}

@keyframes bounce {
  0%, 20%, 53%, 80%, 100% { transform: translate3d(0,0,0); }
  40%, 43% { transform: translate3d(0, -8px, 0); }
  70% { transform: translate3d(0, -4px, 0); }
  90% { transform: translate3d(0, -2px, 0); }
}

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

.animate-slide-in {
  animation: slideIn 0.3s ease-out;
}

.animate-bounce {
  animation: bounce 1s ease-in-out;
}

/* === UTILIDADES === */
.text-center { text-align: center; }
.text-left { text-align: left; }
.text-right { text-align: right; }

.mt-1 { margin-top: 0.25rem; }
.mt-2 { margin-top: 0.5rem; }
.mt-3 { margin-top: 1rem; }
.mt-4 { margin-top: 1.5rem; }

.mb-1 { margin-bottom: 0.25rem; }
.mb-2 { margin-bottom: 0.5rem; }
.mb-3 { margin-bottom: 1rem; }
.mb-4 { margin-bottom: 1.5rem; }

.p-1 { padding: 0.25rem; }
.p-2 { padding: 0.5rem; }
.p-3 { padding: 1rem; }
.p-4 { padding: 1.5rem; }

.d-none { display: none; }
.d-block { display: block; }
.d-flex { display: flex; }
.d-grid { display: grid; }

.justify-center { justify-content: center; }
.justify-between { justify-content: space-between; }
.align-center { align-items: center; }

.w-full { width: 100%; }
.h-full { height: 100%; }

.cursor-pointer { cursor: pointer; }

.rounded { border-radius: 0.375rem; }
.rounded-lg { border-radius: 0.5rem; }
.rounded-xl { border-radius: 0.75rem; }

.shadow-sm { box-shadow: var(--shadow-sm); }
.shadow { box-shadow: var(--shadow); }
.shadow-md { box-shadow: var(--shadow-md); }
.shadow-lg { box-shadow: var(--shadow-lg); } 