/* Estilos institucionales para paneles y botoneras
   Diseñado para integrarse con Bootstrap 5
*/
:root {
  --si-primary: var(--bs-primary, #0d6efd);
  --si-accent: #0b5ed7;
  --si-muted: var(--bs-secondary-text-emphasis, #6c757d);

  /* Default Light Mode */
  --si-bg-card: #ffffff;
  --si-card-border: rgba(13, 110, 253, 0.08);
  --si-title: #0b2545;
  --si-subtitle: #6c757d;
  --si-icon-bg: rgba(13, 110, 253, 0.1);
  --si-radius: .6rem;
}

/* Modo Oscuro: Explicit Overrides */
[data-bs-theme="dark"] {
  --si-bg-card: #212529;
  /* Dark background */
  --si-card-border: #495057;
  /* Visible grey border */
  --si-title: #f8f9fa;
  /* Light text */
  --si-subtitle: #adb5bd;
  /* Muted light text */
  --si-icon-bg: rgba(13, 110, 253, 0.25);
  --si-primary: #3d8bfd;
  /* Lighter blue for better contrast */
}

/* Tile container */
.panel-tiles {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  /* Explicitly 3 columns requested */
  gap: 1.25rem;
}

/* Tablet Override */
@media (max-width: 992px) {
  .panel-tiles {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* Tile */
.panel-tile {
  background-color: var(--si-bg-card) !important;
  /* Force bg */
  border: 1px solid var(--si-card-border);
  border-radius: var(--si-radius);
  padding: 1rem 1.25rem;
  /* Compact padding */
  transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
  color: var(--si-title);
  /* Force text color */
  text-decoration: none;
  display: flex;
  flex-direction: column;
  justify-content: center !important;
  align-items: center;
  /* Center content horizontally */
  min-height: 115px;
  height: 100%;
  /* Reduced height to minimize empty space */
  text-align: center;
  /* Center text by default for uniformity */
}

.panel-tile:hover {
  transform: translateY(-4px);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.1);
  border-color: var(--si-primary);
  text-decoration: none;
  color: var(--si-title);
}

.panel-tile .icon {
  width: 50px;
  height: 50px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 12px;
  background: var(--si-icon-bg);
  color: var(--si-primary);
  font-size: 1.6rem;
  margin-bottom: 0.75rem;
  /* More space */
  margin-right: 0;
  /* Reset margin since we are centered */
}

.panel-tile .flex-grow-1 {
  text-align: center;
  /* Ensure text wrapper is centered */
  flex-grow: 0 !important;
}

.panel-tile .title {
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--si-title);
  margin-bottom: 0.2rem;
  line-height: 1.2;
}

.panel-tile .subtitle {
  font-size: 0.85rem;
  color: var(--si-subtitle);
  line-height: 1.3;
}

/* Ajustes responsivos */
@media (max-width: 576px) {
  .panel-tiles {
    grid-template-columns: 1fr;
    /* Stack on mobile */
  }

  @media (max-width: 576px) {
    .panel-tiles {
      grid-template-columns: 1fr;
      /* Stack on mobile */
    }

    .panel-tile {
      padding: 1rem;
      min-height: auto;
      flex-direction: row;
      /* Horizontal on mobile */
      align-items: center;
      justify-content: flex-start;
      /* Align left on mobile */
      text-align: left !important;
    }

    .panel-tile .icon {
      width: 42px;
      height: 42px;
      font-size: 1.4rem;
      margin-bottom: 0;
      margin-right: 1rem;
    }

    .panel-tile .flex-grow-1 {
      text-align: left;
      /* Reset alignment for wrapper */
    }
  }

  .panel-tile .flex-grow-1 {
    text-align: left;
  }
}

/* Dark mode hover specific */
[data-bs-theme="dark"] .panel-tile:hover {
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
  border-color: #3d8bfd;
  background-color: #2c3035 !important;
  /* Slightly lighter on hover */
}

/* Badge adjustments */
.badge-sample {
  padding: .45em .55em;
  border-radius: .45rem;
  font-weight: 600;
  background: rgba(0, 0, 0, 0.04);
  color: inherit;
}

[data-bs-theme="dark"] .badge-sample {
  background: rgba(255, 255, 255, 0.1);
}

/* Utilities */
.panel-tiles .col-actions {
  display: flex;
  gap: .5rem;
  justify-content: center;
}

/* Botón principal dentro del panel */
.panel-cta {
  border-radius: .5rem;
  padding: .55rem .9rem;
}

/* ==========================================================================
   FIX: Legacy app.css overrides
   app.css contains BS4 which forces .card background to white.
   We explicitly override it here for Dark Mode to work with BS5.
   ========================================================================== */
[data-bs-theme="dark"] .card {
  background-color: #212529;
  /* Dark card background */
  border-color: #495057;
  color: #dfdfdf;
}

[data-bs-theme="dark"] .card-header {
  background-color: rgba(255, 255, 255, 0.05);
  /* Slight highlight */
  border-bottom-color: #495057;
  color: #fff;
}

[data-bs-theme="dark"] .card-footer {
  background-color: rgba(0, 0, 0, 0.2);
  border-top-color: #495057;
}

/* Fix text muted in dark mode cards */
[data-bs-theme="dark"] .text-muted {
  color: #adb5bd !important;
}

/* ==========================================================================
   FIX: Navbar Border in Dark Mode
   Replace the hard white border with a subtle shadow to mimic light mode.
   ========================================================================== */
[data-bs-theme="dark"] .navbar.border-bottom {
  border-bottom: none !important;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.3), 0 2px 4px -1px rgba(0, 0, 0, 0.15);
  /* Soft dark shadow */
}