/* ========================================= */
/* VARIABLES Y COLORES DE MARCA              */
/* ========================================= */
:root {
  --bg-dark: #0C0A18;
  --text-light: #F7F5FF;
  --accent-pink: #B95CFF;
  --accent-purple: #7C3AED;
  --accent-dark-purple: #4C1D95;
  --metal-grey: #D9DCE5;
}

/* ========================================= */
/* ESTILOS GENERALES                         */
/* ========================================= */
body {
  background-color: var(--bg-dark);
  color: var(--text-light);
  font-family: 'Chakra Petch', sans-serif;
  margin: 0;
}

h1, h2, h3, h4, h5, h6 {
  font-family: 'Michroma', sans-serif;
}

h1 { font-size: clamp(2rem, 4vw, 4rem); line-height: 1.1; }
h2 { font-size: clamp(1.4rem, 2.5vw, 2rem); color: var(--metal-grey); }

p, .body-text {
  font-family: 'Chakra Petch', sans-serif;
  font-size: 1rem;
  line-height: 1.6;
  color: var(--metal-grey);
}

.label, .btn {
  font-family: 'Chakra Petch', sans-serif;
  font-size: 12px;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  font-weight: 600;
}

/* ========================================= */
/* EFECTO DEGRADADO PARA TÍTULOS             */
/* ========================================= */
.gradient-text {
  background: linear-gradient(90deg, var(--accent-pink), var(--accent-purple));
  background-clip: text;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

/* ========================================= */
/* SIDEBAR                                   */
/* ========================================= */
.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  width: 250px;
  height: 100vh;      /* respaldo para navegadores viejos */
  height: 100dvh;     /* altura real visible en móviles */
  background: linear-gradient(180deg, #0C0A18 0%, #2e1065 100%);
  color: white;
  border-right: 1px solid rgba(185, 92, 255, 0.2);
  z-index: 1000;
  display: flex;
  flex-direction: column;
  overflow: hidden;   /* el scroll lo hace .nav, no el sidebar */
}

/* El logo se queda fijo arriba */
.sidebar .logo {
  flex: 0 0 auto;
  text-align: center;
  padding: 20px 15px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  margin-bottom: 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 100%;
  box-sizing: border-box;
}

.sidebar .logo img {
  max-width: 80px;
  margin-bottom: 10px;
  display: block;
}

.sidebar .logo h3 {
  color: var(--accent-pink);
  font-weight: bold;
  font-size: 18px;
  margin: 5px 0;
  text-align: center;
  width: 100%;
}

.sidebar .logo span {
  color: var(--metal-grey);
  font-size: 11px;
  font-family: 'Chakra Petch', sans-serif;
  letter-spacing: 1px;
  text-align: center;
  display: block;
  width: 100%;
}

/* EL NAV ES EL QUE HACE SCROLL */
.sidebar .nav {
  flex: 1 1 0;                 /* ocupa todo el espacio restante */
  min-height: 0;               /* CLAVE: permite que un hijo flex encoja y haga scroll */
  display: block;              /* anula el display:flex de Bootstrap (.nav) */
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain; /* evita que se mueva la página de atrás */
  -webkit-overflow-scrolling: touch;
  padding: 0 0 calc(20px + env(safe-area-inset-bottom)) 0;
  width: 100%;
  box-sizing: border-box;
  scrollbar-width: thin;
  scrollbar-color: rgba(185, 92, 255, 0.7) rgba(0, 0, 0, 0.3);
}

.sidebar .nav::-webkit-scrollbar {
  width: 8px;
}
.sidebar .nav::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.3);
  border-radius: 4px;
}
.sidebar .nav::-webkit-scrollbar-thumb {
  background: rgba(185, 92, 255, 0.7);
  border-radius: 4px;
}
.sidebar .nav::-webkit-scrollbar-thumb:hover {
  background: rgba(185, 92, 255, 1);
}

/* Estilos de los enlaces */
.sidebar .nav-link {
  color: rgba(255, 255, 255, 0.7);
  padding: 12px 25px;
  border-radius: 8px;
  margin: 3px 10px;
  transition: all 0.3s;
  font-size: 14px;
}

.sidebar .nav-link:hover,
.sidebar .nav-link.active {
  background: rgba(185, 92, 255, 0.2);
  color: white;
  box-shadow: 0 0 10px rgba(185, 92, 255, 0.3);
}

.sidebar .nav-link i {
  margin-right: 12px;
  color: var(--accent-purple);
  font-size: 16px;
}

/* ========================================= */
/* BOTÓN HAMBURGUESA (solo móvil)            */
/* ========================================= */
.menu-toggle {
  display: none;
  position: fixed;
  top: 15px;
  left: 15px;
  z-index: 1100;
  background: linear-gradient(90deg, var(--accent-pink), var(--accent-purple));
  color: white;
  border: none;
  border-radius: 8px;
  width: 45px;
  height: 45px;
  font-size: 20px;
  cursor: pointer;
  box-shadow: 0 2px 10px rgba(185, 92, 255, 0.4);
}

.menu-toggle:hover {
  opacity: 0.9;
}

/* Overlay para cerrar el menú en móvil */
.sidebar-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.6);
  z-index: 999;
}

.sidebar-overlay.active {
  display: block;
}

/* ========================================= */
/* CONTENIDO PRINCIPAL                       */
/* ========================================= */
.main-content {
  margin-left: 250px;
  padding: 30px;
  min-height: 100vh;
  overflow-x: hidden;
  transition: margin-left 0.3s ease;
}

/* ========================================= */
/* TARJETAS DEL DASHBOARD                    */
/* ========================================= */
.card-dashboard {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(185, 92, 255, 0.2);
  border-left: 4px solid var(--accent-pink);
  border-radius: 12px;
  padding: clamp(15px, 2vw, 25px);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
  transition: transform 0.2s, border-left-color 0.2s;
  color: var(--text-light);
  margin-bottom: 20px;
}

.card-dashboard:hover {
  transform: translateY(-5px);
  border-left-color: var(--accent-purple);
}

.card-dashboard .number {
  font-size: clamp(1.5rem, 3vw, 2.5rem);
  font-weight: bold;
  color: var(--accent-pink);
  font-family: 'Michroma', sans-serif;
  line-height: 1.1;
  word-break: keep-all;
}

.card-dashboard .label {
  color: var(--metal-grey);
  font-size: clamp(0.7rem, 1vw, 0.9rem);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-top: 8px;
  line-height: 1.2;
}

.card-dashboard h5 {
  color: var(--accent-pink) !important;
  font-family: 'Michroma', sans-serif;
  font-size: 16px;
  margin-bottom: 20px;
}

/* ========================================= */
/* TABLAS                                    */
/* ========================================= */
.tabla-apex {
  color: var(--text-light) !important;
  width: 100%;
  margin-top: 15px;
}

.tabla-apex thead th {
  color: var(--accent-pink) !important;
  font-family: 'Michroma', sans-serif;
  font-size: 12px;
  letter-spacing: 1px;
  text-transform: uppercase;
  border-bottom: 2px solid var(--accent-purple);
  background-color: transparent;
  padding: 12px 8px;
}

.tabla-apex tbody td {
  color: var(--text-light) !important;
  border-color: rgba(255, 255, 255, 0.08);
  background-color: transparent;
  padding: 12px 8px;
  vertical-align: middle;
}

.tabla-apex.table-hover tbody tr:hover td {
  background-color: rgba(185, 92, 255, 0.1) !important;
  color: var(--text-light) !important;
}

.tabla-vacia {
  color: var(--metal-grey);
  text-align: center;
  font-style: italic;
  padding: 25px;
}

/* ========================================= */
/* FORMULARIOS                               */
/* ========================================= */
.form-apex label {
  color: var(--metal-grey);
  font-weight: 500;
  display: block;
  margin-bottom: 5px;
  font-size: 0.9rem;
}

.form-apex input,
.form-apex select,
.form-apex textarea,
.main-content input,
.main-content select,
.main-content textarea {
  background-color: #2e2e4e !important;
  border: 1px solid var(--accent-dark-purple) !important;
  color: var(--text-light) !important;
  padding: 10px;
  border-radius: 5px;
  width: 100%;
  margin-bottom: 15px;
  font-family: 'Chakra Petch', sans-serif;
  box-sizing: border-box;
}

.form-apex input:focus,
.form-apex select:focus,
.form-apex textarea:focus,
.main-content input:focus,
.main-content select:focus,
.main-content textarea:focus {
  outline: none;
  border-color: var(--accent-pink) !important;
  box-shadow: 0 0 5px rgba(185, 92, 255, 0.5) !important;
}

.form-apex input::placeholder,
.main-content input::placeholder {
  color: var(--metal-grey);
  opacity: 0.5;
}

/* ========================================= */
/* BOTONES                                   */
/* ========================================= */
.btn-primary {
  background: linear-gradient(90deg, var(--accent-pink), var(--accent-purple)) !important;
  border: none !important;
  font-family: 'Michroma', sans-serif;
  letter-spacing: 1px;
  font-size: 13px;
  padding: 10px;
  color: white !important;
}

.btn-primary:hover {
  opacity: 0.9;
  color: white !important;
}

.btn-outline-primary {
  color: var(--accent-pink) !important;
  border-color: var(--accent-pink) !important;
  background: transparent !important;
}

.btn-outline-primary:hover {
  background: var(--accent-pink) !important;
  color: white !important;
}

.btn-outline-danger {
  color: #dc3545 !important;
  border-color: #dc3545 !important;
  background: transparent !important;
}

.btn-outline-danger:hover {
  background: #dc3545 !important;
  color: white !important;
}

.btn-secondary {
  background-color: #4a4a5e !important;
  border: none !important;
  color: white !important;
}

/* ========================================= */
/* BOTONES DE ACCIÓN                         */
/* ========================================= */
.acciones-doc {
  display: flex;
  gap: 5px;
  flex-wrap: nowrap;
}

.btn-accion {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 6px;
  text-decoration: none;
  transition: all 0.2s;
  border: 1px solid;
  font-size: 14px;
}

.btn-ver {
  background-color: rgba(185, 92, 255, 0.15);
  color: var(--accent-pink);
  border-color: var(--accent-pink);
}

.btn-ver:hover {
  background-color: var(--accent-pink);
  color: white;
}

.btn-descargar {
  background-color: rgba(58, 134, 255, 0.15);
  color: #3a86ff;
  border-color: #3a86ff;
}

.btn-descargar:hover {
  background-color: #3a86ff;
  color: white;
}

.btn-editar {
  background-color: rgba(255, 193, 7, 0.15);
  color: #ffc107;
  border: 1px solid #ffc107;
}

.btn-editar:hover {
  background-color: #ffc107;
  color: #000;
}

.btn-eliminar {
  background-color: rgba(220, 53, 69, 0.15);
  color: #dc3545;
  border: 1px solid #dc3545;
}

.btn-eliminar:hover {
  background-color: #dc3545;
  color: white;
}

/* ========================================= */
/* BARRAS DE PROGRESO                        */
/* ========================================= */
.progress-apex {
  background-color: rgba(255, 255, 255, 0.05);
  height: 10px;
  border-radius: 5px;
  overflow: hidden;
}

.progress-apex .progress-bar {
  background: linear-gradient(90deg, var(--accent-pink), var(--accent-purple));
  height: 100%;
}

/* ========================================= */
/* BADGES DE ESTADO                          */
/* ========================================= */
.badge-vencido { background: #dc3545; color: white; }
.badge-por-vencer { background: #ffc107; color: #000; }
.badge-vigente { background: #28a745; color: white; }

/* ========================================= */
/* LISTAS (CHECKLIST)                        */
/* ========================================= */
.list-group-item {
  border-radius: 8px !important;
  margin-bottom: 5px;
  transition: all 0.2s;
  background-color: transparent !important;
  color: var(--text-light) !important;
  border-color: rgba(255, 255, 255, 0.08) !important;
}

.list-group-item:hover {
  background-color: rgba(185, 92, 255, 0.08) !important;
}

.list-group-item i {
  font-size: 1.1rem;
}

/* ========================================= */
/* CLASES PROPIAS DE TEXTO                   */
/* ========================================= */
.texto-principal {
  color: var(--text-light);
  font-family: 'Chakra Petch', sans-serif;
}

.texto-secundario {
  color: var(--metal-grey);
  font-family: 'Chakra Petch', sans-serif;
  font-size: 0.95rem;
}

.texto-pequeno {
  color: var(--metal-grey);
  font-family: 'Chakra Petch', sans-serif;
  font-size: 0.85rem;
}

.titulo-tarjeta {
  color: var(--accent-pink);
  font-family: 'Michroma', sans-serif;
  font-size: 16px;
  letter-spacing: 0.5px;
  margin-bottom: 20px;
}

.subtitulo-seccion {
  color: var(--accent-pink);
  font-family: 'Michroma', sans-serif;
  font-size: 13px;
  letter-spacing: 1px;
  text-transform: uppercase;
  margin: 20px 0 10px 0;
  padding-bottom: 8px;
  border-bottom: 1px solid rgba(185, 92, 255, 0.2);
}

/* ========================================= */
/* ANULAR BOOTSTRAP                          */
/* ========================================= */
.main-content .text-muted,
.main-content small.text-muted,
.main-content p.text-muted {
  color: var(--metal-grey) !important;
  opacity: 1 !important;
}

.main-content .text-dark {
  color: var(--text-light) !important;
}

.main-content hr {
  border-color: rgba(255, 255, 255, 0.1) !important;
}

.main-content label {
  color: var(--metal-grey) !important;
  font-weight: 500;
  margin-bottom: 5px;
  display: block;
}

/* ========================================= */
/* TABLAS RESPONSIVE                         */
/* ========================================= */
.table-responsive {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.table-responsive::-webkit-scrollbar {
  height: 6px;
}

.table-responsive::-webkit-scrollbar-thumb {
  background: var(--accent-purple);
  border-radius: 3px;
}

/* ========================================= */
/* MODAL                                     */
/* ========================================= */
.modal-content {
  background-color: #1a1a2e !important;
  border: 2px solid var(--accent-purple) !important;
  border-radius: 15px;
}

.modal-header {
  border-bottom: 1px solid rgba(185, 92, 255, 0.3) !important;
}

.modal-footer {
  border-top: 1px solid rgba(185, 92, 255, 0.3) !important;
}

.modal-body .form-label {
  color: var(--metal-grey);
  font-size: 0.9rem;
  margin-bottom: 5px;
}

.modal-body input,
.modal-body textarea,
.modal-body select {
  background-color: #2e2e4e !important;
  border: 1px solid var(--accent-dark-purple) !important;
  color: var(--text-light) !important;
  padding: 10px;
  border-radius: 5px;
  width: 100%;
}

.modal-body input:focus,
.modal-body textarea:focus,
.modal-body select:focus {
  border-color: var(--accent-pink) !important;
  box-shadow: 0 0 5px rgba(185, 92, 255, 0.5) !important;
  outline: none;
}

/* ========================================= */
/* LOGIN                                     */
/* ========================================= */
.logo-login {
  width: 180px;
  margin-bottom: 20px;
}

/* ========================================= */
/* SCROLLBAR PERSONALIZADO                   */
/* ========================================= */
.main-content::-webkit-scrollbar {
  width: 8px;
}

.main-content::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.05);
}

.main-content::-webkit-scrollbar-thumb {
  background: var(--accent-purple);
  border-radius: 4px;
}

/* ========================================= */
/* SIDEBAR - GRUPOS DESPLEGABLES             */
/* ========================================= */

/* Botón de grupo (título del acordeón) */
.sidebar .nav-group-toggle {
    display: flex !important;
    align-items: center !important;
    cursor: pointer !important;
    color: rgba(255, 255, 255, 0.9) !important;
    font-weight: 500 !important;
    padding: 12px 20px !important;
    border-radius: 8px !important;
    margin: 3px 10px !important;
    transition: all 0.3s !important;
    text-decoration: none !important;
    width: calc(100% - 20px) !important;
    box-sizing: border-box !important;
    background: transparent !important;
}

.sidebar .nav-group-toggle:hover {
    background: rgba(185, 92, 255, 0.15) !important;
    color: white !important;
}

.sidebar .nav-group-toggle > i:first-child {
    margin-right: 12px !important;
    color: var(--accent-purple) !important;
    font-size: 16px !important;
    flex-shrink: 0 !important;
    width: 20px !important;
    text-align: center !important;
}

.sidebar .nav-group-toggle > span {
    flex: 1 !important;
    text-align: left !important;
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
}

.sidebar .nav-chevron {
    flex-shrink: 0 !important;
    margin-left: auto !important;
    transition: transform 0.3s ease !important;
    font-size: 12px !important;
    color: rgba(185, 92, 255, 0.8) !important;
    width: auto !important;
    text-align: right !important;
}

.sidebar .nav-group-toggle[aria-expanded="true"] .nav-chevron {
    transform: rotate(180deg) !important;
}

/* Subitems */
.sidebar .nav-subitem {
    display: flex !important;
    align-items: center !important;
    padding: 10px 20px 10px 45px !important;
    font-size: 13px !important;
    color: rgba(255, 255, 255, 0.65) !important;
    border-radius: 8px !important;
    margin: 2px 10px !important;
    transition: all 0.3s !important;
    width: calc(100% - 20px) !important;
    box-sizing: border-box !important;
    text-decoration: none !important;
    overflow: hidden !important;
}

.sidebar .nav-subitem:hover,
.sidebar .nav-subitem.active {
    background: rgba(185, 92, 255, 0.2) !important;
    color: white !important;
}

.sidebar .nav-subitem i {
    margin-right: 10px !important;
    font-size: 13px !important;
    color: rgba(185, 92, 255, 0.7) !important;
    flex-shrink: 0 !important;
    width: 16px !important;
    text-align: center !important;
}

.sidebar .nav-subitem.active i {
    color: var(--accent-purple) !important;
}

/* ========================================= */
/* CONTENIDO DE GRUPOS (ACORDEÓN)            */
/* ========================================= */
.sidebar .nav-group-content {
    display: none;
}

.sidebar .nav-group-content.show {
    display: block;
}

/* ========================================= */
/* PLACEHOLDERS GLOBALES                     */
/* ========================================= */
input::placeholder,
textarea::placeholder,
select::placeholder {
  color: #888 !important;
  opacity: 1 !important;
}

input::-moz-placeholder,
textarea::-moz-placeholder {
  color: #888 !important;
  opacity: 1 !important;
}

input::-webkit-input-placeholder,
textarea::-webkit-input-placeholder {
  color: #888 !important;
  opacity: 1 !important;
}

input:-ms-input-placeholder,
textarea:-ms-input-placeholder {
  color: #888 !important;
}

input:focus::placeholder,
textarea:focus::placeholder {
  color: #999 !important;
}

/* ========================================= */
/* CHECKBOXES PERSONALIZADOS                 */
/* ========================================= */
.form-check-input-custom {
    width: 20px !important;
    height: 20px !important;
    margin: 0 !important;
    cursor: pointer;
    accent-color: #B95CFF;
    flex-shrink: 0;
}

.form-check {
    display: flex !important;
    align-items: center !important;
    gap: 8px !important;
    padding-left: 0 !important;
    margin-bottom: 0.5rem;
}

.form-check .form-check-input-custom {
    margin-left: 0 !important;
}

.form-check-label {
    margin: 0 !important;
    white-space: nowrap;
}

@media (max-width: 768px) {
    .form-check-label {
        white-space: normal !important;
        line-height: 1.2;
    }
}

/* ========================================= */
/* CATEGORÍAS JERÁRQUICAS                    */
/* ========================================= */
.categoria-item {
    margin-bottom: 10px;
    border: 1px solid rgba(185, 92, 255, 0.2);
    border-radius: 8px;
    overflow: hidden;
}

.categoria-header {
    background: rgba(185, 92, 255, 0.1);
    padding: 15px;
    cursor: pointer;
    transition: all 0.2s;
}

.categoria-header:hover {
    background: rgba(185, 92, 255, 0.2);
}

.categoria-body {
    padding: 15px;
    background: rgba(255, 255, 255, 0.02);
}

.categoria-body .tabla-apex {
    margin-top: 0;
}

.categoria-header .bi-chevron-down {
    transition: transform 0.3s;
}

.categoria-header[aria-expanded="true"] .bi-chevron-down {
    transform: rotate(180deg);
}

/* ========================================= */
/* INDICADORES - RESPONSIVE                  */
/* ========================================= */
@media (max-width: 1200px) {
    .row > [class*="col-md-2"] {
        flex: 0 0 auto;
        width: 33.333%;
    }
}

@media (max-width: 768px) {
    h5[style*="font-size: 2rem"],
    h5[style*="font-size: 2.5rem"],
    h3[style*="font-size: 2.5rem"] {
        font-size: 1.5rem !important;
    }
    
    .row > [class*="col-md-2"],
    .row > [class*="col-md-3"] {
        flex: 0 0 auto;
        width: 50%;
    }
    
    h2[style*="color: #B95CFF"] {
        font-size: 1.5rem !important;
    }
}

@media (max-width: 576px) {
    .row > [class*="col-md-2"],
    .row > [class*="col-md-3"] {
        flex: 0 0 auto;
        width: 100%;
    }
    
    h5[style*="font-size: 2rem"],
    h5[style*="font-size: 2.5rem"],
    h3[style*="font-size: 2.5rem"] {
        font-size: 1.2rem !important;
    }
    
    .d-flex.gap-2 {
        flex-wrap: wrap !important;
    }
}

/* ========================================= */
/* RESPONSIVE - TABLETS (768px - 1024px)     */
/* ========================================= */
@media (max-width: 1024px) {
  .sidebar {
    width: 220px;
  }

  .main-content {
    margin-left: 220px;
    padding: 20px;
  }

  .sidebar .logo h3 {
    font-size: 16px;
  }

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

/* ========================================= */
/* RESPONSIVE - MÓVILES (menos de 768px)     */
/* ========================================= */
@media (max-width: 768px) {
  .sidebar {
    width: 260px;
    transform: translateX(-100%);
    transition: transform 0.3s ease;
  }

  .sidebar.active {
    transform: translateX(0);
  }

  .main-content {
    margin-left: 0;
    padding: 70px 15px 15px 15px;
  }

  .menu-toggle {
    display: block;
  }

  .sidebar .logo img {
    max-width: 70px;
  }
  
  .sidebar .logo h3 {
    font-size: 20px;
  }
  
  .sidebar .logo span {
    font-size: 11px;
  }
  
  .btn-accion {
    width: 28px;
    height: 28px;
    font-size: 12px;
  }
  
  .card-dashboard {
    border-radius: 10px;
  }
}

/* ========================================= */
/* RESPONSIVE - MÓVILES MUY PEQUEÑOS         */
/* ========================================= */
@media (max-width: 480px) {
  .sidebar {
    width: 240px;
  }
}

/* ========================================= */
/* PANTALLAS GRANDES                         */
/* ========================================= */
@media (min-width: 1200px) {
  .card-dashboard .number {
    font-size: 2.5rem;
  }
  
  .col-xl-8 .card-dashboard {
    min-height: 400px;
  }
}