/* ===== FONDO ===== */
#loginScreen {
  background: linear-gradient(135deg, #e2e8f0, #ffffff);
  position: relative;
  overflow: hidden;
}

/* Efecto sutil de luces */
#loginScreen::before {
  content: "";
  position: absolute;
  width: 800px;
  height: 800px;
  top: -200px;
  left: -200px;
  background: radial-gradient(circle, rgba(255,255,255,0.7) 0%, transparent 70%);
  filter: blur(60px);
}

/* Tarjeta estilo Apple */
.login-card {
  width: 100%;
  max-width: 420px;
  min-height: 480px;
  padding: 50px 40px;
  border-radius: 22px;
  background: rgba(255,255,255,0.35);
  backdrop-filter: blur(22px);
  -webkit-backdrop-filter: blur(22px);
  border: 1px solid rgba(255,255,255,0.45);
  box-shadow: 0 25px 60px rgba(0,0,0,0.12);
  display: flex;
  flex-direction: column;
  justify-content: center;
  animation: fadeIn 0.6s ease;
}

/* Inputs Apple style */
.login-card input {
  background: rgba(255,255,255,0.6);
  border: none;
  border-radius: 10px;
  height: 45px;
  padding: 0 12px;
  font-size: 15px;
  transition: 0.3s;
}

.login-card input:focus {
  outline: none;
  background: rgba(255,255,255,0.9);
  box-shadow: 0px 0px 6px rgba(0,0,0,0.15);
}

/* Botón estilo Apple */
.btn-apple {
  background: #007aff;
  border: none;
  border-radius: 12px;
  color: white;
  font-size: 15px;
  font-weight: 500;
  padding: 12px;
  width: 100%;
  transition: 0.25s;
}

.btn-apple:hover {
  background: #0a6df0;
}

/* Animación inicial */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ===== ESTILOS BASE MACOS ===== */
body {
  background: #f5f5f7;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
}

/* SIDEBAR CON SCROLL MEJORADO */
.sidebar {
  background: #ffffff;
  border-right: 1px solid #e8e8ed;
  height: 100vh;
  position: fixed;
  left: 0;
  top: 0;
  width: 280px;
  z-index: 1000;
  transition: transform 0.3s ease;
  box-shadow: 2px 0 10px rgba(0, 0, 0, 0.1);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.sidebar.collapsed {
  transform: translateX(-280px);
}

.main-content {
  margin-left: 280px;
  transition: margin-left 0.3s ease;
  min-height: 100vh;
  padding-top: 70px;
}

.main-content.expanded {
  margin-left: 0;
}

.hamburger-btn {
  position: fixed;
  top: 20px;
  left: 20px;
  z-index: 1002;
  background: #ffffff;
  border: 1px solid #e8e8ed;
  border-radius: 8px;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  transition: all 0.3s ease;
}

.hamburger-btn:hover {
  background: #f5f5f7;
  transform: scale(1.05);
}

.hamburger-btn.collapsed {
  left: 15px;
}

/* HEADER FIJO */
.sidebar-header {
  padding: 80px 20px 20px 20px;
  border-bottom: 1px solid #e8e8ed;
  background: #ffffff;
  flex-shrink: 0;
}

/* ÁREA DE NAVEGACIÓN CON SCROLL */
.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 20px 0 80px 0;
}

/* Scroll suave estilo macOS para sidebar */
.sidebar-nav::-webkit-scrollbar {
  width: 6px;
}

.sidebar-nav::-webkit-scrollbar-track {
  background: transparent;
}

.sidebar-nav::-webkit-scrollbar-thumb {
  background: rgba(134, 134, 139, 0.2);
  border-radius: 10px;
}

.sidebar-nav::-webkit-scrollbar-thumb:hover {
  background: rgba(134, 134, 139, 0.4);
}

.nav-item {
  margin: 5px 20px;
}

.nav-link {
  color: #1d1d1f;
  padding: 12px 16px;
  border-radius: 8px;
  text-decoration: none;
  display: flex;
  align-items: center;
  transition: all 0.2s ease;
  font-weight: 500;
  font-size: 14px;
}

.nav-link:hover {
  background: #f5f5f7;
  color: #007aff;
  transform: translateX(5px);
}

.nav-link.active {
  background: #007aff;
  color: #ffffff;
}

.nav-link i {
  margin-right: 12px;
  font-size: 1.1em;
  flex-shrink: 0;
}

/* Módulos de contenido */
.module {
  display: none;
  padding: 20px 30px 30px;
}

.module.active {
  display: block;
}

/* Cards estilo macOS */
.card {
  background: #ffffff;
  color: #1d1d1f;
  border: 1px solid #e8e8ed;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
  border-radius: 12px;
  margin-bottom: 20px;
}

/* Tablas */
.table {
  --bs-table-bg: transparent;
  color: #1d1d1f;
}

.table thead {
  color: #007aff;
  font-weight: 600;
  border-bottom: 2px solid #e8e8ed;
}

/* Form controls estilo macOS */
.form-control,
.form-select {
  background: #ffffff;
  color: #1d1d1f;
  border: 1px solid #d2d2d7;
  border-radius: 8px;
  transition: all 0.2s ease;
  font-size: 14px;
}

.form-control:focus,
.form-select:focus {
  background: #ffffff;
  color: #1d1d1f;
  border-color: #007aff;
  box-shadow: 0 0 0 4px rgba(0, 122, 255, 0.15);
  outline: none;
}

.form-control:hover {
  border-color: #007aff;
}

/* Botones estilo macOS */
.btn-primary {
  background: #007aff;
  border-color: #007aff;
  border-radius: 8px;
  font-weight: 500;
  padding: 8px 16px;
  transition: all 0.2s ease;
}

.btn-primary:hover {
  background: #0056cc;
  border-color: #0056cc;
  transform: translateY(-1px);
}

.btn-outline-primary {
  border-color: #007aff;
  color: #007aff;
  border-radius: 8px;
}

.btn-outline-primary:hover {
  background: #007aff;
  border-color: #007aff;
}

/* Badge */
.badge {
  border-radius: 6px;
  font-weight: 500;
}

.badge.bg-muted {
  background: #e8e8ed !important;
  color: #86868b;
}

/* Modal estilo macOS */
.modal-content {
  background: #ffffff;
  color: #1d1d1f;
  border: 1px solid #e8e8ed;
  border-radius: 12px;
  backdrop-filter: blur(20px);
}

.modal-header {
  border-bottom: 1px solid #e8e8ed;
}

/* Texto auxiliar */
.text-muted-2 {
  color: #86868b;
}

/* Spinner overlay */
.spinner-overlay {
  position: fixed;
  inset: 0;
  background: rgba(245, 245, 247, 0.8);
  backdrop-filter: blur(20px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 2050;
}

/* Stats cards */
.stats-card {
  background: linear-gradient(135deg, #007aff 0%, #0056cc 100%);
  color: white;
  border-radius: 12px;
  padding: 20px;
  margin-bottom: 20px;
}

.stats-number {
  font-size: 2rem;
  font-weight: 700;
  margin: 0;
}

.stats-label {
  opacity: 0.9;
  font-size: 0.9rem;
}

/* Entity logo preview */
.entity-logo-preview {
  max-width: 100px;
  max-height: 60px;
  border-radius: 8px;
  border: 1px solid #e8e8ed;
}

/* Scrollbars estilo macOS */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: rgba(134, 134, 139, 0.3);
  border-radius: 10px;
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(134, 134, 139, 0.5);
}

/* User avatar button */
.user-avatar-btn {
  cursor: pointer;
  border-radius: 50%;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.user-avatar-btn:hover {
  transform: scale(1.08);
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.25);
}

.user-avatar-btn img,
.user-avatar-btn > div {
  pointer-events: none;
}

/* Dropdown estilo Apple iCloud */
.dropdown-menu-apple {
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(0, 0, 0, 0.08);
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12), 
              0 2px 8px rgba(0, 0, 0, 0.08);
  padding: 6px;
  margin-top: 8px;
}

.sidebar .dropdown-menu.dropdown-menu-apple {
  min-width: 241px !important;
}

.dropdown-menu-apple .dropdown-item-text {
  color: #86868b;
  font-size: 12px;
  font-weight: 500;
  padding: 8px 12px 4px;
}

.dropdown-menu-apple .dropdown-divider {
  border-color: rgba(0, 0, 0, 0.08);
  margin: 4px 0;
}

.dropdown-menu-apple .dropdown-item {
  color: #1d1d1f;
  font-size: 14px;
  font-weight: 400;
  padding: 10px 12px;
  border-radius: 8px;
  transition: background-color 0.15s ease;
}

.dropdown-menu-apple .dropdown-item:hover {
  background-color: rgba(0, 0, 0, 0.05);
  color: #1d1d1f;
}

.dropdown-menu-apple .dropdown-item:active {
  background-color: #007aff;
  color: white;
}

.dropdown-menu-apple .dropdown-item i {
  color: #86868b;
  font-size: 14px;
}

.dropdown-menu-apple .dropdown-item:active i {
  color: white;
}

.dropdown-menu-apple .dropdown-label {
  display: block;
  color: #86868b;
  font-size: 11px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  margin-bottom: 2px;
}

.dropdown-menu-apple .dropdown-item-text span:not(.dropdown-label) {
  display: block;
  color: #1d1d1f;
  font-size: 13px;
  font-weight: 400;
  word-break: break-all;
}

/* Iconos de navegación con colores */
.nav-link[data-module="dashboard"] i {
  color: #007aff;
}

.nav-link[data-module="users"] i {
  color: #5856d6;
}

.nav-link[data-module="entities"] i {
  color: #34c759;
}

.nav-link[data-module="fincas"] i {
  color: #ff9500;
}

.nav-link[data-module="zones"] i {
  color: #5ac8fa;
}

.nav-link[data-module="production"] i {
  color: #30d158;
}

.nav-link[data-module="transactions"] i {
  color: #ff9500;
}

.nav-link[data-module="reports"] i {
  color: #ff2d55;
}

.nav-link[data-module="console"] i {
  color: #af52de;
}

/* Cuando está activo, el icono se vuelve blanco */
.nav-link.active i {
  color: #ffffff !important;
}

/* CRÉDITOS FIJOS EN LA PARTE INFERIOR */
.sidebar-credits {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 15px 20px;
  text-align: center;
  background: linear-gradient(to top, #ffffff 70%, transparent);
  border-top: 1px solid #e8e8ed;
  flex-shrink: 0;
}

.sidebar-credits a {
  color: #86868b;
  font-size: 11px;
  text-decoration: none;
  transition: color 0.2s ease;
}

.sidebar-credits a:hover {
  color: #25d366;
}

.sidebar-credits i {
  font-size: 12px;
}

/* ===== ESTILOS PARA MÓDULO PRODUCCIÓN ===== */

.nav-link[data-module="production"] i {
  color: #30d158;
}

.nav-link.active[data-module="production"] i {
  color: #ffffff !important;
}

.stats-card {
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.stats-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.15);
}

#productionTable tbody tr {
  transition: background-color 0.2s ease;
}

#productionTable tbody tr:hover {
  background-color: #f5f5f7;
}

#productionChart {
  max-height: 400px;
}

.form-select:disabled {
  background-color: #f5f5f7;
  color: #86868b;
  cursor: not-allowed;
  opacity: 0.6;
}

input[type="date"].form-control-sm {
  background: #ffffff;
  border: 1px solid #d2d2d7;
  border-radius: 8px;
  padding: 6px 12px;
  font-size: 13px;
  color: #1d1d1f;
  transition: all 0.2s ease;
}

input[type="date"].form-control-sm:focus {
  border-color: #007aff;
  box-shadow: 0 0 0 4px rgba(0, 122, 255, 0.15);
  outline: none;
}

input[type="date"].form-control-sm:hover {
  border-color: #007aff;
}

#btnApplyDateFilter {
  border-radius: 8px;
  font-size: 13px;
  padding: 6px 16px;
  font-weight: 500;
}

#btnClearDateFilter {
  border-radius: 8px;
  font-size: 13px;
  padding: 6px 16px;
  font-weight: 500;
  border-color: #d2d2d7;
  color: #1d1d1f;
}

#btnClearDateFilter:hover {
  background: #f5f5f7;
  border-color: #007aff;
  color: #007aff;
}

/* ===== ESTILOS PARA MÓDULO TRANSACCIONES ===== */

.nav-link[data-module="transactions"] i {
  color: #ff9500;
}

.nav-link.active[data-module="transactions"] i {
  color: #ffffff !important;
}

#transactionTable tbody tr {
  transition: background-color 0.2s ease;
}

#transactionTable tbody tr:hover {
  background-color: #f5f5f7;
}

#transactionTable .badge {
  font-size: 12px;
  padding: 4px 10px;
  border-radius: 6px;
  font-weight: 500;
}

#transactionChartComparison,
#transactionChartBreakdown {
  max-height: 350px;
}

#totalTransactionBalance {
  transition: color 0.3s ease;
}

.stats-card {
  transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.3s ease;
}

/* ===== 📱 RESPONSIVE MOBILE OPTIMIZADO ===== */
@media (max-width: 768px) {
  /* ✅ SIDEBAR MOBILE MEJORADO */
  .sidebar {
    width: 85%;
    max-width: 320px;
    transform: translateX(-100%);
    box-shadow: none;
  }

  /* ✅ Cuando está visible en mobile */
  .sidebar.show {
    transform: translateX(0) !important;
    box-shadow: 2px 0 20px rgba(0, 0, 0, 0.3);
  }

  /* ✅ NO aplicar collapsed en mobile */
  .sidebar.collapsed {
    transform: translateX(-100%);
  }

  /* Main content sin margen en mobile */
  .main-content {
    margin-left: 0 !important;
    padding-top: 70px;
  }

  .main-content.expanded {
    margin-left: 0;
  }

  /* Header del sidebar más compacto en mobile */
  .sidebar-header {
    padding: 70px 15px 15px 15px;
  }

  .sidebar-header h4 {
    font-size: 1.1rem;
  }

  .sidebar-header small {
    font-size: 0.75rem;
  }

  /* Avatar más pequeño en mobile */
  .user-avatar-btn,
  .user-avatar-btn img,
  .user-avatar-btn > div {
    width: 32px !important;
    height: 32px !important;
    font-size: 13px !important;
  }

  /* Nombre de usuario más pequeño */
  #userName {
    font-size: 13px;
  }

  /* Nav items más espaciados y con mejor padding en mobile */
  .sidebar-nav {
    padding: 15px 0 100px 0;
  }

  .nav-item {
    margin: 3px 15px;
  }

  .nav-link {
    padding: 14px 16px;
    font-size: 15px;
    border-radius: 10px;
  }

  .nav-link i {
    font-size: 1.2em;
    margin-right: 14px;
  }

  /* Créditos más compactos en mobile */
  .sidebar-credits {
    padding: 12px 15px;
  }

  .sidebar-credits a {
    font-size: 10px;
  }

  /* Hamburger button ajustado para mobile */
  .hamburger-btn {
    width: 44px;
    height: 44px;
    top: 15px;
    left: 15px;
  }

  .hamburger-btn i {
    font-size: 1.3rem;
  }

  /* Módulos con menos padding en mobile */
  .module {
    padding: 15px 15px 30px;
  }

  /* Cards más compactas en mobile */
  .card {
    margin-bottom: 15px;
  }

  /* Stats cards en columna en mobile */
  .stats-card {
    margin-bottom: 15px;
  }

  .stats-number {
    font-size: 1.75rem;
  }

  .stats-label {
    font-size: 0.85rem;
  }

  /* Filtros de fecha responsive */
  .card-body .d-flex.flex-wrap {
    flex-direction: column;
    align-items: stretch !important;
  }
  
  .card-body .d-flex.flex-wrap > div {
    width: 100%;
    margin-bottom: 10px;
  }
  
  input[type="date"].form-control-sm {
    width: 100%;
    min-width: 100%;
  }
  
  #btnApplyDateFilter,
  #btnClearDateFilter,
  #btnApplyTransactionDateFilter,
  #btnClearTransactionDateFilter {
    width: 100%;
    margin-top: 8px;
  }

  /* Tablas responsive */
  .table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .table {
    font-size: 13px;
  }

  .table th,
  .table td {
    padding: 10px 8px;
    white-space: nowrap;
  }

  /* Dropdown más grande en mobile para mejor tap */
  .dropdown-menu-apple {
    min-width: 280px !important;
  }

  .dropdown-menu-apple .dropdown-item {
    padding: 12px 14px;
    font-size: 15px;
  }

  /* Form controls más grandes en mobile */
  .form-control,
  .form-select {
    font-size: 16px;
    padding: 10px 12px;
    min-height: 44px;
  }

  /* Botones más grandes en mobile */
  .btn {
    padding: 10px 16px;
    font-size: 15px;
    min-height: 44px;
  }

  .btn-sm {
    padding: 8px 12px;
    font-size: 14px;
    min-height: 38px;
  }
}

/* ===== 📱 EXTRA SMALL DEVICES (< 576px) ===== */
@media (max-width: 576px) {
  .sidebar {
    width: 90%;
  }

  .sidebar-header h4 {
    font-size: 1rem;
  }

  .nav-link {
    padding: 12px 14px;
    font-size: 14px;
  }

  .stats-number {
    font-size: 1.5rem;
  }

  .stats-label {
    font-size: 0.8rem;
  }

  .table {
    font-size: 12px;
  }

  .table th,
  .table td {
    padding: 8px 6px;
  }
}