/* Glassmorphism Dark Blue Theme */
:root[data-bs-theme="dark"] {
  --tblr-body-bg: #0f172a;
  /* Deep Blue Slate */
  --tblr-body-color: #e2e8f0;
  --tblr-card-bg: rgba(30, 41, 59, 0.7);
  /* See-through dark blue */
  --tblr-card-border-color: rgba(255, 255, 255, 0.08);
  --tblr-border-color: rgba(255, 255, 255, 0.08);
  --tblr-bg-surface: rgba(15, 23, 42, 0.8);
}

[data-bs-theme="dark"] body {
  background: radial-gradient(circle at top left, #1e3a8a, #0f172a);
  min-height: 100vh;
}

[data-bs-theme="dark"] .card {
  background: rgba(30, 41, 59, 0.7) !important;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

[data-bs-theme="dark"] .navbar {
  background: rgba(15, 23, 42, 0.8) !important;
  backdrop-filter: blur(10px);
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

[data-bs-theme="dark"] .modal-content {
  background: rgba(30, 41, 59, 0.95) !important;
  backdrop-filter: blur(16px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: #fff;
}

[data-bs-theme="dark"] .modal-header,
[data-bs-theme="dark"] .modal-footer {
  border-color: rgba(255, 255, 255, 0.1);
}

[data-bs-theme="dark"] .modal-title {
  color: #fff;
}

[data-bs-theme="dark"] .btn-close {
  filter: invert(1) grayscale(100%) brightness(200%);
}

[data-bs-theme="dark"] .form-label {
  color: #e2e8f0;
}

[data-bs-theme="dark"] .table-responsive {
  border-radius: 4px;
}

/* STRONG TABLE OVERRIDES FOR GLASS EFFECT */
[data-bs-theme="dark"] .table,
[data-bs-theme="dark"] .table> :not(caption)>*>* {
  background-color: transparent !important;
  color: #fff !important;
  border-color: rgba(255, 255, 255, 0.08) !important;
}

[data-bs-theme="dark"] .table-striped>tbody>tr:nth-of-type(odd)>* {
  background-color: rgba(255, 255, 255, 0.03) !important;
  box-shadow: none !important;
  color: #fff !important;
}

[data-bs-theme="dark"] .table-striped>tbody>tr:nth-of-type(even)>* {
  background-color: transparent !important;
  box-shadow: none !important;
  color: #fff !important;
}

[data-bs-theme="dark"] .table-hover>tbody>tr:hover>* {
  background-color: rgba(255, 255, 255, 0.08) !important;
  color: #fff !important;
}

[data-bs-theme="dark"] .table thead th {
  background: rgba(15, 23, 42, 0.85) !important;
  backdrop-filter: blur(4px);
  color: #fff !important;
  border-bottom: 2px solid rgba(255, 255, 255, 0.1) !important;
}

[data-bs-theme="dark"] .dataTables_wrapper .dataTables_length,
[data-bs-theme="dark"] .dataTables_wrapper .dataTables_filter,
[data-bs-theme="dark"] .dataTables_wrapper .dataTables_info,
[data-bs-theme="dark"] .dataTables_wrapper .dataTables_processing,
[data-bs-theme="dark"] .dataTables_wrapper .dataTables_paginate {
  color: #cbd5e1 !important;
}

[data-bs-theme="dark"] .pagination .page-item .page-link {
  background: rgba(30, 41, 59, 0.6) !important;
  border-color: rgba(255, 255, 255, 0.1) !important;
  color: #e2e8f0 !important;
}

[data-bs-theme="dark"] .pagination .page-item.active .page-link {
  background: rgba(59, 130, 246, 0.6) !important;
  /* Blueish glass */
  border-color: rgba(59, 130, 246, 0.5) !important;
  color: #fff !important;
}

[data-bs-theme="dark"] .list-group-item {
  background: transparent;
  border-color: rgba(255, 255, 255, 0.08);
  color: inherit;
}

[data-bs-theme="dark"] .list-group-item-action:hover,
[data-bs-theme="dark"] .list-group-item-action:focus {
  background: rgba(255, 255, 255, 0.05);
  color: inherit;
}

/* Ensure Charts are visible on dark bg */
[data-bs-theme="dark"] .chart text {
  fill: #e2e8f0 !important;
}

[data-bs-theme="dark"] canvas {
  background: transparent !important;
}

/* Global Input Styling */
[data-bs-theme="dark"] .form-control,
[data-bs-theme="dark"] .form-select,
[data-bs-theme="dark"] .input-group-text {
  background-color: rgba(15, 23, 42, 0.6) !important;
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: #fff !important;
}

[data-bs-theme="dark"] .form-control:focus,
[data-bs-theme="dark"] .form-select:focus {
  background-color: rgba(15, 23, 42, 0.8) !important;
  border-color: rgba(59, 130, 246, 0.5);
  box-shadow: 0 0 0 0.25rem rgba(59, 130, 246, 0.25);
  color: #fff !important;
}

[data-bs-theme="dark"] .input-group-text {
  border-right: none;
  /* Blend with input if needed, or keep standard */
}

[data-bs-theme="dark"] .form-control::placeholder {
  color: rgba(255, 255, 255, 0.4);
}

[data-bs-theme="dark"] select option {
  background-color: #0f172a;
  /* Solid background for dropdown options */
  color: #fff;
}

/* Global Header Styling */
[data-bs-theme="dark"] .card-header,
[data-bs-theme="dark"] .modal-header {
  background-color: transparent !important;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

[data-bs-theme="dark"] .card-title,
[data-bs-theme="dark"] .modal-title {
  color: #ffffff !important;
}

/* Global Text Visibility - Force White */
[data-bs-theme="dark"] .card-body,
[data-bs-theme="dark"] .dataTables_wrapper,
[data-bs-theme="dark"] .dataTables_wrapper .dataTables_filter label,
[data-bs-theme="dark"] .dataTables_wrapper .dataTables_length label,
[data-bs-theme="dark"] .dataTables_wrapper .dataTables_info,
[data-bs-theme="dark"] .dataTables_wrapper .dataTables_paginate,
[data-bs-theme="dark"] .table {
  color: #ffffff !important;
}

[data-bs-theme="dark"] .table th,
[data-bs-theme="dark"] .table td,
[data-bs-theme="dark"] .table td span,
[data-bs-theme="dark"] .table td div,
[data-bs-theme="dark"] .table td a:not(.btn) {
  color: #ffffff !important;
}

/* Fix for DataTables Sorting Stripes */
[data-bs-theme="dark"] table.dataTable.display tbody tr.odd>.sorting_1,
[data-bs-theme="dark"] table.dataTable.order-column.stripe tbody tr.odd>.sorting_1,
[data-bs-theme="dark"] table.dataTable.display tbody tr.even>.sorting_1,
[data-bs-theme="dark"] table.dataTable.order-column.stripe tbody tr.even>.sorting_1 {
  background-color: transparent !important;
  /* Remove sorting stripe bg */
  color: #ffffff !important;
  box-shadow: none !important;
}

/* Sidebar Menu - Larger Text */
[data-bs-theme="dark"] .navbar-vertical .nav-link {
  font-size: 1.1rem;
  /* Increase from default 0.875rem/14px */
  padding-top: 0.75rem;
  padding-bottom: 0.75rem;
}

[data-bs-theme="dark"] .navbar-vertical .nav-link-title {
  font-weight: 500;
}

/* Mobile Menu Styling */
@media (max-width: 991.98px) {
  .navbar-collapse {
    background: rgba(15, 23, 42, 0.98) !important;
    backdrop-filter: blur(20px);
    position: absolute;
    top: 100%;
    left: 0;
    width: 100%;
    z-index: 1060;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
  }

  /* Reset navbar vertical positioning if any remnants exist */
  [data-bs-theme="dark"] .navbar-vertical {
    display: none !important;
  }
}

/* Fix Z-Index for Modals on Mobile to override .navbar-collapse z-index of 1050 and .navbar-vertical z-index of 1060 */
[data-bs-theme="dark"] .modal {
  z-index: 2000 !important;
}

[data-bs-theme="dark"] .modal-backdrop {
  z-index: 1090 !important;
  /* Above navbar (1060) */
}

/* =========================================
   SWEETALERT2 PRO STYLING
   ========================================= */
body.swal2-shown>[aria-hidden="true"] {
  transition: 0.1s filter;
  filter: blur(10px);
}

.swal2-popup {
  background: rgba(15, 23, 42, 0.85) !important;
  backdrop-filter: blur(20px) !important;
  -webkit-backdrop-filter: blur(20px) !important;
  border: 1px solid rgba(255, 255, 255, 0.1) !important;
  border-radius: 16px !important;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5) !important;
}

.swal2-title {
  color: #fff !important;
  font-weight: 600 !important;
}

.swal2-content,
.swal2-html-container {
  color: #cbd5e1 !important;
}

/* Success Icon Animation */
.swal2-icon.swal2-success {
  border-color: #10b981 !important;
  /* Emerald Green */
  box-shadow: 0 0 20px rgba(16, 185, 129, 0.4);
}

.swal2-icon.swal2-success .swal2-success-line-tip,
.swal2-icon.swal2-success .swal2-success-line-long {
  background-color: #10b981 !important;
}

.swal2-icon.swal2-success .swal2-success-ring {
  border: 4px solid rgba(16, 185, 129, 0.2) !important;
}

/* Error Icon Animation */
.swal2-icon.swal2-error {
  border-color: #ef4444 !important;
  /* Red 500 */
  box-shadow: 0 0 20px rgba(239, 68, 68, 0.4);
}

.swal2-icon.swal2-error .swal2-x-mark-line-left,
.swal2-icon.swal2-error .swal2-x-mark-line-right {
  background-color: #ef4444 !important;
}

/* Buttons */
.swal2-confirm.btn-primary {
  background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%) !important;
  box-shadow: 0 4px 6px -1px rgba(37, 99, 235, 0.5);
  border: none !important;
}

.swal2-cancel.btn-danger {
  background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%) !important;
  box-shadow: 0 4px 6px -1px rgba(220, 38, 38, 0.5);
  border: none !important;
}

/* =========================================
   STICKY NAVBAR STYLING
   ========================================= */
.navbar.sticky-top {
  position: sticky;
  top: 0;
  z-index: 1070 !important;
  /* Fixed: 1070 to override page-wrapper (1040) */
  width: 100%;
  background: rgba(15, 23, 42, 0.9) !important;
  backdrop-filter: blur(12px);
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

/* Ensure body has padding if needed, or rely on sticky positioning flow */
.page-wrapper {
  margin-left: 0 !important;
  /* Reset any sidebar margin */
}

/* Fix container width in horizontal mode */
@media (min-width: 992px) {
  .navbar-expand-md .navbar-nav {
    flex-direction: row;
    align-items: center;
  }

  .nav-item {
    margin-right: 1rem;
  }
}

/* Custom Fluid Container for 95% Width */
.custom-fluid-container {
  width: 95% !important;
  max-width: 95% !important;
  margin-left: auto;
  margin-right: auto;
  padding-left: 0.75rem;
  padding-right: 0.75rem;
}

/* =========================================
   HOME PAGE GLASS BUTTONS
   ========================================= */
/* =========================================
   HOME PAGE GLASS BUTTONS
   ========================================= */
.glass-button {
  background: rgba(255, 255, 255, 0.03);
  /* Ultra sheer */
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 50%;
  /* CIRCULAR SHAPE */
  transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 200px;
  /* Fixed Width */
  height: 200px;
  /* Fixed Height to match Width */
  margin: 0 auto;
  /* Center in column */
  color: #fff !important;
  text-decoration: none !important;
  position: relative;
  overflow: hidden;
  box-shadow: 0 4px 30px rgba(0, 0, 0, 0.1);
}

.glass-button::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg,
      transparent,
      rgba(255, 255, 255, 0.05),
      transparent);
  transition: 0.5s;
}

.glass-button:hover::before {
  left: 100%;
}

.glass-button:hover {
  background: rgba(255, 255, 255, 0.1);
  transform: translateY(-8px) scale(1.05);
  /* Slight scale up */
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
  border-color: rgba(255, 255, 255, 0.3);
}

.glass-button i {
  font-size: 3rem;
  /* Slightly adjusted size */
  margin-bottom: 0.8rem;
  transition: all 0.3s ease;
  filter: drop-shadow(0 0 10px rgba(255, 255, 255, 0.2));
}

.glass-button:hover i {
  transform: scale(1.1);
  filter: drop-shadow(0 0 15px rgba(255, 255, 255, 0.4));
}

.glass-button .card-title {
  font-size: 1rem;
  font-weight: 500;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  opacity: 0.95;
  text-align: center;
  line-height: 1.2;
  padding: 0 10px;
  /* Prevent text touching edges */
}

/* =========================================
   DASHBOARD MINI CARDS
   ========================================= */
.glass-mini-card {
  background: rgba(255, 255, 255, 0.03);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 20px;
  /* Slightly more rounded */
  padding: 1.5rem 1.8rem;
  /* Increased padding */
  position: relative;
  overflow: hidden;
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
  min-height: 150px;
  /* Increased height - "Mas largas" */
}

.glass-mini-card:hover {
  background: rgba(255, 255, 255, 0.08);
  transform: translateY(-5px);
  box-shadow: 0 10px 20px rgba(0, 0, 0, 0.2);
  border-color: rgba(255, 255, 255, 0.2);
}

.glass-mini-card .mini-content {
  z-index: 2;
}

.glass-mini-card .mini-title {
  font-size: 0.95rem;
  /* Slightly larger */
  text-transform: uppercase;
  letter-spacing: 0.5px;
  opacity: 0.8;
  margin-bottom: 0.4rem;
}

.glass-mini-card .mini-value {
  font-size: 1.8rem;
  /* Larger value */
  font-weight: 600;
  color: #fff;
  margin-bottom: 0px;
}

.glass-mini-card .mini-icon {
  font-size: 3rem;
  /* Larger icon */
  opacity: 0.3;
  transition: all 0.3s ease;
  z-index: 1;
}

.glass-mini-card:hover .mini-icon {
  opacity: 0.8;
  transform: scale(1.1) rotate(5deg);
  filter: drop-shadow(0 0 8px rgba(255, 255, 255, 0.4));
}

/* Specific colors for icons based on context */
.glass-mini-card.blue .mini-icon {
  color: #4299e1;
}

.glass-mini-card.green .mini-icon {
  color: #48bb78;
}

.glass-mini-card.yellow .mini-icon {
  color: #ecc94b;
}

.glass-mini-card.red .mini-icon {
  color: #f56565;
}

.glass-mini-card.purple .mini-icon {
  color: #9f7aea;
}

.glass-mini-card.azure .mini-icon {
  color: #63b3ed;
}

.glass-mini-card.orange .mini-icon {
  color: #ed8936;
}

.glass-mini-card.indigo .mini-icon {
  color: #667eea;
}

.glass-mini-card.pink .mini-icon {
  color: #d6336c;
}

.glass-mini-card.teal .mini-icon {
  color: #20c997;
}

.glass-mini-card.lime .mini-icon {
  color: #74b816;
}

.glass-mini-card .mini-link {
  font-size: 0.75rem;
  margin-top: 0.5rem;
  display: block;
  color: rgba(255, 255, 255, 0.6) !important;
  text-decoration: none;
  transition: color 0.2s;
}

.glass-mini-card .mini-link:hover {
  color: #fff !important;
}