/* =============================================
   VARIABLES
   ============================================= */
:root {
  --sidebar-bg:          #1a1f2e;
  --topbar-bg:           #1a1f2e;
  --sidebar-text:        rgba(255,255,255,0.65);
  --sidebar-text-active: #fff;
  --sidebar-hover:       rgba(255,255,255,0.07);
  --sidebar-active:      rgba(255,255,255,0.10);
  --body-bg:             #f4f5f7;
  --card-bg:             #fff;
  --border:              #e5e7eb;
  --text-primary:        #1a1f2e;
  --text-secondary:      #6b7280;
  --text-muted:          #9ca3af;
  --topbar-h:            52px;
  --sidebar-w:           220px;
  --red:                 #C0392B;
  --blue:                #1A5276;
}

/* =============================================
   RESET + BASE
   ============================================= */
*, *::before, *::after { box-sizing: border-box; }

html { font-size: 14px; -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 14px;
  font-weight: 400;
  line-height: 1.5;
  color: var(--text-primary);
  background: var(--body-bg);
}

a { color: #185FA5; text-decoration: none; }
a:hover { text-decoration: underline; }

h1,h2,h3,h4,h5,h6 { margin-top: 0; margin-bottom: .5rem; font-weight: 500; line-height: 1.3; }
p { margin-top: 0; margin-bottom: 1rem; }

ul, ol { margin-top: 0; margin-bottom: 1rem; }
ul ul, ol ol, ul ol, ol ul { margin-bottom: 0; }

img { max-width: 100%; height: auto; vertical-align: middle; }

table { border-collapse: collapse; }

input, button, select, textarea {
  font-family: inherit;
  font-size: inherit;
  line-height: inherit;
}

button { cursor: pointer; }

/* =============================================
   GRID SYSTEM (12 columnas)
   ============================================= */
.container-fluid {
  width: 100%;
  padding-right: 15px;
  padding-left: 15px;
  margin-right: auto;
  margin-left: auto;
}

.row {
  display: flex;
  flex-wrap: wrap;
  margin-right: -12px;
  margin-left: -12px;
}

[class*="col-"] {
  position: relative;
  width: 100%;
  padding-right: 12px;
  padding-left: 12px;
}

/* xs — todas las pantallas */
.col-12  { flex: 0 0 100%;        max-width: 100%; }
.col-6   { flex: 0 0 50%;         max-width: 50%; }
.col-4   { flex: 0 0 33.3333%;    max-width: 33.3333%; }
.col-3   { flex: 0 0 25%;         max-width: 25%; }

/* sm ≥ 576px */
@media (min-width: 576px) {
  .col-sm-6  { flex: 0 0 50%;      max-width: 50%; }
  .col-sm-12 { flex: 0 0 100%;     max-width: 100%; }
}

/* md ≥ 768px */
@media (min-width: 768px) {
  .col-md-4  { flex: 0 0 33.3333%; max-width: 33.3333%; }
  .col-md-6  { flex: 0 0 50%;      max-width: 50%; }
  .col-md-12 { flex: 0 0 100%;     max-width: 100%; }
}

/* lg ≥ 992px */
@media (min-width: 992px) {
  .col-lg-4  { flex: 0 0 33.3333%; max-width: 33.3333%; }
  .col-lg-12 { flex: 0 0 100%;     max-width: 100%; }
}

/* xl ≥ 1200px */
@media (min-width: 1200px) {
  .col-xl-4  { flex: 0 0 33.3333%; max-width: 33.3333%; }
}

/* =============================================
   UTILIDADES — DISPLAY
   ============================================= */
.d-none    { display: none !important; }
.d-block   { display: block !important; }
.d-flex    { display: flex !important; }
.d-inline  { display: inline !important; }

@media (min-width: 992px) {
  .d-lg-none  { display: none !important; }
  .d-lg-flex  { display: flex !important; }
  .d-lg-block { display: block !important; }
}

/* =============================================
   UTILIDADES — FLEX
   ============================================= */
.flex-row     { flex-direction: row !important; }
.flex-column  { flex-direction: column !important; }
.flex-wrap    { flex-wrap: wrap !important; }

.align-items-center  { align-items: center !important; }
.align-items-top     { align-items: flex-start !important; }
.align-self-center   { align-self: center !important; }
.justify-content-center  { justify-content: center !important; }
.justify-content-between { justify-content: space-between !important; }
.justify-content-end     { justify-content: flex-end !important; }

/* =============================================
   UTILIDADES — SPACING
   ============================================= */
.p-0  { padding: 0 !important; }
.p-2  { padding: .5rem !important; }
.p-3  { padding: 1rem !important; }

.pb-2 { padding-bottom: .5rem !important; }
.pt-2 { padding-top: .5rem !important; }

.mb-0 { margin-bottom: 0 !important; }
.mb-2 { margin-bottom: .5rem !important; }
.mb-4 { margin-bottom: 1.5rem !important; }
.mt-2 { margin-top: .5rem !important; }
.mt-4 { margin-top: 1.5rem !important; }
.mr-4 { margin-right: 1rem !important; }
.ml-4 { margin-left: 1rem !important; }

.mx-auto { margin-left: auto !important; margin-right: auto !important; }
.w-100   { width: 100% !important; }

/* =============================================
   UTILIDADES — TEXTO
   ============================================= */
.text-center    { text-align: center !important; }
.text-left      { text-align: left !important; }
.text-right     { text-align: right !important; }
.text-truncate  { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.text-wrap      { white-space: normal !important; }

.text-danger    { color: #C0392B !important; }
.text-secondary { color: var(--text-secondary) !important; }
.text-muted     { color: var(--text-muted) !important; }
.text-white     { color: #fff !important; }

.font-weight-bold   { font-weight: 700 !important; }
.font-weight-normal { font-weight: 400 !important; }

/* =============================================
   SKIP LINK (accesibilidad)
   ============================================= */
.skip-link {
  position: absolute;
  top: -40px;
  left: 0;
  background: #000;
  color: #fff;
  padding: 8px 12px;
  z-index: 10000;
  font-size: 13px;
  text-decoration: none;
}
.skip-link:focus { top: 0; }

/* =============================================
   TOPBAR / NAVBAR
   ============================================= */
.navbar {
  display: flex;
  align-items: center;
  flex-wrap: nowrap;
}

.fixed-top {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 1030;
}

.navbar.default-layout {
  background: var(--topbar-bg) !important;
  height: var(--topbar-h) !important;
  min-height: var(--topbar-h) !important;
  border-bottom: 1px solid rgba(255,255,255,0.07) !important;
  box-shadow: none !important;
  padding: 0 !important;
  width: 100%;
}

.navbar-brand-wrapper {
  background: var(--topbar-bg) !important;
  width: var(--sidebar-w) !important;
  min-width: var(--sidebar-w) !important;
  height: var(--topbar-h) !important;
  border-right: 1px solid rgba(255,255,255,0.07) !important;
  padding: 0 16px !important;
  display: flex !important;
  justify-content: flex-start !important;
  align-items: center !important;
  flex-shrink: 0;
}

/* Logo: oculta imagen PHP, construye brand con favicon + texto */
.navbar-brand-wrapper .navbar-brand img { display: none !important; }

.navbar-brand-wrapper .navbar-brand.brand-logo {
  display: flex !important;
  flex-direction: row !important;
  align-items: center !important;
  gap: 9px !important;
  text-decoration: none !important;
  line-height: 1;
}

/* Favicon */
.navbar-brand-wrapper .navbar-brand.brand-logo::before {
  content: '' !important;
  display: block !important;
  width: 28px !important;
  height: 28px !important;
  background: url('/favicon.ico') center / contain no-repeat !important;
  flex-shrink: 0 !important;
  border-radius: 4px !important;
}

/* Texto principal */
.navbar-brand-wrapper .navbar-brand.brand-logo::after {
  content: "HUAP Docs" !important;
  display: block !important;
  font-size: 14px !important;
  font-weight: 600 !important;
  color: #fff !important;
  line-height: 1 !important;
  letter-spacing: 0.01em !important;
}

.navbar-brand-wrapper .navbar-brand.brand-logo-mini { display: none !important; }

.navbar-menu-wrapper {
  background: var(--topbar-bg) !important;
  padding: 0 20px !important;
  height: var(--topbar-h) !important;
  display: flex !important;
  align-items: center !important;
  justify-content: space-between !important;
  flex: 1;
}

/* Pills de server info */
.navbar-nav-left.header-links {
  display: flex !important;
  flex-direction: row !important;
  align-items: center;
  gap: 4px;
  margin: 0 !important;
  padding: 0 !important;
  list-style: none;
}
.navbar-nav-left.header-links .nav-item { padding: 0 !important; }
.navbar-nav-left.header-links .nav-item .nav-link {
  display: flex !important;
  align-items: center;
  gap: 5px;
  color: rgba(255,255,255,0.40) !important;
  font-size: 11px !important;
  padding: 0 10px !important;
  line-height: var(--topbar-h) !important;
  text-decoration: none !important;
  white-space: nowrap;
  transition: color 0.15s;
}
.navbar-nav-left.header-links .nav-item .nav-link:hover {
  color: rgba(255,255,255,0.70) !important;
  background: transparent !important;
}
.navbar-nav-left.header-links .nav-item .nav-link i { font-size: 14px; opacity: 0.50; }
.navbar-nav-left.header-links .nav-item .nav-link strong {
  color: rgba(255,255,255,0.70);
  font-weight: 500;
}

/* Ícono cuenta (derecha navbar) */
.navbar-nav { display: flex; flex-direction: row; list-style: none; margin: 0; padding: 0; }
.navbar-nav-right .nav-item .nav-link,
.navbar-menu-wrapper .navbar-nav .nav-item .nav-link {
  color: rgba(255,255,255,0.55) !important;
  font-size: 18px;
  padding: 0 8px !important;
  line-height: var(--topbar-h);
  transition: color 0.15s;
  text-decoration: none;
}
.navbar-nav-right .nav-item .nav-link:hover { color: #fff !important; }

.navbar-toggler {
  background: transparent;
  border: none !important;
  color: rgba(255,255,255,0.65) !important;
  font-size: 20px;
  box-shadow: none !important;
  padding: 4px 8px;
  cursor: pointer;
}

/* =============================================
   LAYOUT PRINCIPAL
   ============================================= */
.container-scroller {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.container-fluid.page-body-wrapper {
  display: flex !important;
  flex-direction: row !important;
  padding: 0 !important;
  margin-top: var(--topbar-h) !important;
  min-height: calc(100vh - var(--topbar-h));
  background: var(--body-bg);
  flex: 1;
}

/* =============================================
   SIDEBAR
   ============================================= */
.sidebar,
.sidebar.sidebar-offcanvas {
  background: #1a1f2e !important;
  background-color: #1a1f2e !important;
  transition: none !important;
  width: var(--sidebar-w) !important;
  min-width: var(--sidebar-w) !important;
  min-height: 100%;
  flex-shrink: 0;
  position: relative !important;
  top: 0 !important;
  padding-top: 0 !important;
  border-right: none !important;
  box-shadow: none !important;
  z-index: 100;
}

/* Reset nuclear — transparente en todos los hijos */
.sidebar * {
  background: transparent !important;
  background-color: transparent !important;
}

.sidebar .nav {
  padding: 0 !important;
  flex-direction: column !important;
  list-style: none;
  margin: 0;
}

/* Etiqueta "PRINCIPAL" inyectada por CSS */
.sidebar .nav::before {
  content: "PRINCIPAL";
  display: block;
  padding: 20px 20px 6px;
  color: rgba(255,255,255,0.25);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.10em;
  text-transform: uppercase;
  line-height: 1;
}

.sidebar .nav-item {
  padding: 0 !important;
  margin: 0 !important;
  display: block;
  list-style: none;
}

.sidebar .nav .nav-item .nav-link,
.sidebar .nav-item .nav-link {
  display: block !important;
  padding: 8px 20px !important;
  color: rgba(255,255,255,0.65) !important;
  font-size: 13px !important;
  font-weight: 400 !important;
  text-decoration: none !important;
  transition: background 0.15s, color 0.15s;
  border-radius: 0 !important;
  border: none !important;
  box-shadow: none !important;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.5;
  height: auto !important;
}

.sidebar .nav .nav-item .nav-link:hover,
.sidebar .nav .nav-item:hover > .nav-link,
.sidebar .nav:not(.sub-menu) > .nav-item:hover:not(.nav-profile) > .nav-link {
  background: rgba(255,255,255,0.08) !important;
  background-color: rgba(255,255,255,0.08) !important;
  color: #fff !important;
}

.sidebar .nav .nav-item.active .nav-link,
.sidebar .nav .nav-item.active > .nav-link,
.sidebar .nav-item.active > .nav-link,
.sidebar .nav-item .nav-link.active {
  background: rgba(255,255,255,0.10) !important;
  background-color: rgba(255,255,255,0.10) !important;
  color: #fff !important;
}

.sidebar .menu-icon { display: none !important; }

.sidebar .menu-title,
.sidebar .menu-title strong,
.sidebar .nav-item .nav-link strong,
.sidebar .nav-item .nav-link b {
  font-weight: 400 !important;
  font-size: 13px !important;
  color: inherit !important;
}

/* =============================================
   PANEL PRINCIPAL
   ============================================= */
.main-panel {
  flex: 1 !important;
  display: flex !important;
  flex-direction: column !important;
  min-height: calc(100vh - var(--topbar-h));
  background: var(--body-bg) !important;
  box-shadow: none !important;
  overflow: hidden;
  min-width: 0;
}

.main-panel .content-wrapper {
  flex: 1;
  padding: 24px !important;
  background: var(--body-bg) !important;
}

/* =============================================
   ENCABEZADO DE PÁGINA
   ============================================= */
.dash-page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  flex-wrap: wrap;
  gap: 10px;
}
.dash-page-header h2 {
  font-size: 20px !important;
  font-weight: 500 !important;
  color: var(--text-primary) !important;
  margin: 0 0 3px !important;
  line-height: 1.3;
}
.dash-subtitle {
  font-size: 12px !important;
  color: var(--text-secondary) !important;
  margin: 0 !important;
}

/* =============================================
   CARDS
   ============================================= */
.card {
  background: var(--card-bg) !important;
  border: 1px solid var(--border) !important;
  border-radius: 8px !important;
  box-shadow: none !important;
  position: relative;
  display: flex;
  flex-direction: column;
  min-width: 0;
  word-wrap: break-word;
}
.card-body { padding: 16px !important; flex: 1 1 auto; }
.grid-margin { margin-bottom: 16px !important; }
.stretch-card { display: flex; align-items: stretch; justify-content: stretch; }
.stretch-card > .card { width: 100%; min-width: 100%; }

/* =============================================
   BUSCADOR
   ============================================= */
.search-card { margin-bottom: 20px; }
.search-card .card-body { padding: 10px 14px !important; }

.search-row {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}
.search-input-wrap { flex: 1; min-width: 200px; }
.search-input-wrap label {
  font-size: 11px;
  font-weight: 500;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 4px;
  display: block;
}
.btn-group-search { display: flex; gap: 6px; flex-shrink: 0; }

/* =============================================
   FORMULARIOS
   ============================================= */
.form-group { margin-bottom: 1rem; }

.form-control {
  display: block;
  width: 100%;
  padding: 7px 10px;
  font-size: 13px;
  font-weight: 400;
  line-height: 1.5;
  color: var(--text-primary);
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 6px;
  box-shadow: none;
  transition: border-color 0.15s, box-shadow 0.15s;
  appearance: none;
  -webkit-appearance: none;
}
.form-control:focus {
  outline: none;
  border-color: var(--sidebar-bg) !important;
  box-shadow: 0 0 0 2px rgba(26,31,46,0.08) !important;
}
.form-control::placeholder { color: var(--text-muted); }

.input-group {
  position: relative;
  display: flex;
  flex-wrap: nowrap;
  align-items: stretch;
  width: 100%;
}
.input-group .form-control {
  position: relative;
  flex: 1 1 auto;
  width: 1%;
  min-width: 0;
  border-top-right-radius: 0;
  border-bottom-right-radius: 0;
}
.input-group-append {
  display: flex;
  margin-left: -1px;
}
.input-group-text {
  display: flex;
  align-items: center;
  padding: 7px 10px;
  font-size: 13px;
  font-weight: 400;
  color: var(--text-muted);
  background: #f9fafb;
  border: 1px solid var(--border);
  border-radius: 0 6px 6px 0;
}

label {
  display: inline-block;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 4px;
}

/* =============================================
   BOTONES
   ============================================= */
.btn {
  display: inline-flex !important;
  align-items: center;
  justify-content: center;
  gap: 5px;
  font-size: 12px !important;
  font-weight: 500 !important;
  border-radius: 6px !important;
  padding: 7px 14px !important;
  line-height: 1.4 !important;
  cursor: pointer;
  transition: opacity 0.15s, background 0.15s;
  white-space: nowrap;
  text-decoration: none;
  border: 1px solid transparent;
  vertical-align: middle;
  user-select: none;
}
.btn:focus { outline: none; box-shadow: none !important; }

.btn.btn-secondary {
  background: var(--sidebar-bg) !important;
  border-color: var(--sidebar-bg) !important;
  color: #fff !important;
}
.btn.btn-secondary:hover { opacity: 0.85; }

.btn.btn-primary {
  background: #f3f4f6 !important;
  border-color: var(--border) !important;
  color: #374151 !important;
}
.btn.btn-primary:hover { background: #e5e7eb !important; }

.btn.btn-sm {
  font-size: 12px !important;
  padding: 5px 11px !important;
}

.btn.btn-block { width: 100%; display: flex !important; }

/* Estado carga botón login */
.btn.is-loading { opacity: 0.7; pointer-events: none; }

/* Buscar / Limpiar dentro del buscador */
.btn-group-search .btn.btn-secondary {
  background: #C0392B !important;
  border-color: #C0392B !important;
  color: #fff !important;
  padding: 5px 12px !important;
  border-radius: 5px !important;
  opacity: 1;
}
.btn-group-search .btn.btn-secondary:hover { background: #a93226 !important; border-color: #a93226 !important; }

.btn-group-search .btn.btn-primary {
  background: #1A5276 !important;
  border-color: #1A5276 !important;
  color: #fff !important;
  padding: 5px 12px !important;
  border-radius: 5px !important;
}
.btn-group-search .btn.btn-primary:hover { background: #154360 !important; border-color: #154360 !important; }

/* Botones de tipos/categorías (.btn-rounded) */
.btn.btn-rounded {
  background: #fff !important;
  border: 1px solid #dee2e6 !important;
  color: #212529 !important;
  border-radius: 6px !important;
  font-size: 12px !important;
  font-weight: 400 !important;
  padding: 6px 12px !important;
  white-space: normal !important;
  text-align: left !important;
  width: 100%;
  display: flex !important;
  align-items: center !important;
  justify-content: space-between !important;
  gap: 8px !important;
  opacity: 1 !important;
  transition: background 0.15s, box-shadow 0.15s !important;
}
.btn.btn-rounded:hover {
  background: #f8f9fa !important;
  border-color: #adb5bd !important;
  color: #212529 !important;
  text-decoration: none;
  box-shadow: 0 1px 4px rgba(0,0,0,0.08) !important;
}

/* Badge de color — círculo a la derecha generado con ::after */
.btn.btn-rounded::after {
  content: '' !important;
  display: inline-block !important;
  width: 10px !important;
  height: 10px !important;
  border-radius: 50% !important;
  flex-shrink: 0 !important;
  margin-left: auto !important;
  opacity: 0.85;
}

/* Color cycling — 7 colores para el badge */
.blockquote .row [class*="col-"]:nth-child(7n+1) .btn.btn-rounded::after { background: #3b82f6 !important; }
.blockquote .row [class*="col-"]:nth-child(7n+2) .btn.btn-rounded::after { background: #10b981 !important; }
.blockquote .row [class*="col-"]:nth-child(7n+3) .btn.btn-rounded::after { background: #f59e0b !important; }
.blockquote .row [class*="col-"]:nth-child(7n+4) .btn.btn-rounded::after { background: #8b5cf6 !important; }
.blockquote .row [class*="col-"]:nth-child(7n+5) .btn.btn-rounded::after { background: #ef4444 !important; }
.blockquote .row [class*="col-"]:nth-child(7n+6) .btn.btn-rounded::after { background: #06b6d4 !important; }
.blockquote .row [class*="col-"]:nth-child(7n+7) .btn.btn-rounded::after { background: #f97316 !important; }

/* =============================================
   "10 MÁS DESCARGADOS" — GRID DE CATEGORÍAS
   ============================================= */
.blockquote {
  margin: 0 0 16px;
  padding: 0;
}

/* La fila de categorías se muestra como grid de 3 columnas */
.blockquote .row {
  display: grid !important;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin: 0 0 20px !important;
}

/* Cada celda ocupa toda la celda del grid */
.blockquote .row [class*="col-"] {
  padding: 0 !important;
  width: 100% !important;
  max-width: 100% !important;
  flex: none !important;
}

.blockquote .row .pb-2 { padding-bottom: 0 !important; }

/* =============================================
   TÍTULO DE SECCIÓN
   ============================================= */
.section-title {
  font-size: 13px !important;
  font-weight: 500 !important;
  color: var(--text-primary) !important;
  margin: 0 0 12px !important;
  display: flex !important;
  align-items: center;
  gap: 6px;
}
.section-title i { color: var(--text-secondary); font-size: 16px; }

/* =============================================
   TABLA
   ============================================= */
.table-responsive {
  display: block;
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.table {
  margin: 0 !important;
  border-collapse: collapse !important;
  width: 100% !important;
  font-size: 12px;
}

.table thead th {
  font-size: 11px !important;
  font-weight: 500 !important;
  color: var(--text-muted) !important;
  padding: 10px 16px !important;
  text-align: left !important;
  border-bottom: 1px solid #f3f4f6 !important;
  border-top: none !important;
  letter-spacing: 0.04em !important;
  text-transform: uppercase !important;
  background: transparent !important;
}

.table tbody td {
  font-size: 12px !important;
  padding: 9px 16px !important;
  border-bottom: 1px solid #f9fafb !important;
  color: var(--text-primary) !important;
  vertical-align: middle !important;
}
.table tbody tr:last-child td { border-bottom: none !important; }
.table tbody td a { color: #185FA5 !important; text-decoration: none !important; }
.table tbody td a:hover { text-decoration: underline !important; }
.table-hover tbody tr:hover td { background: #fafbfc !important; }

/* Fix: PHP emite text-danger en los <td> — neutralizamos */
.table tbody td.text-danger { color: var(--text-secondary) !important; }
.table tbody td a.text-danger { color: #185FA5 !important; }

/* =============================================
   TABLA "MÁS DESCARGADOS" — UX RANKING
   ============================================= */

/* Columna nombre: más espacio para el número de ranking */
.table tbody td:first-child {
  padding-left: 38px !important;
  position: relative;
}

/* Número de ranking con CSS counter */
.table tbody { counter-reset: rank; }
.table tbody tr { counter-increment: rank; }

.table tbody tr td:first-child::before {
  content: counter(rank);
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #e5e7eb;
  color: #6b7280;
  font-size: 9px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 18px;
  text-align: center;
  flex-shrink: 0;
}

/* Top 1 — dorado */
.table tbody tr:nth-child(1) td { background: #fffbeb !important; }
.table tbody tr:nth-child(1) td:first-child::before {
  background: #fef3c7;
  color: #92400e;
  box-shadow: 0 0 0 1px #fcd34d;
}

/* Top 2 — plateado */
.table tbody tr:nth-child(2) td { background: #f8fafc !important; }
.table tbody tr:nth-child(2) td:first-child::before {
  background: #e2e8f0;
  color: #475569;
  box-shadow: 0 0 0 1px #cbd5e1;
}

/* Top 3 — bronce */
.table tbody tr:nth-child(3) td { background: #fff8f5 !important; }
.table tbody tr:nth-child(3) td:first-child::before {
  background: #fde8d8;
  color: #9a3412;
  box-shadow: 0 0 0 1px #fba97a;
}

/* Hover override para top 3 */
.table tbody tr:nth-child(1):hover td { background: #fef9e0 !important; }
.table tbody tr:nth-child(2):hover td { background: #f1f5f9 !important; }
.table tbody tr:nth-child(3):hover td { background: #fff1eb !important; }

/* Columna descargas — badge estilo pill */
.table tbody td:nth-child(2) {
  color: #374151 !important;
  font-weight: 600 !important;
  font-size: 11px !important;
  white-space: nowrap;
}
.table tbody td:nth-child(2)::before {
  content: "↓ ";
  font-size: 10px;
  color: #9ca3af;
}

/* Columna vencimiento — fecha discreta */
.table tbody td:nth-child(3) {
  color: var(--text-muted) !important;
  font-size: 11px !important;
  white-space: nowrap;
}

/* =============================================
   BADGES
   ============================================= */
.badge {
  display: inline-block;
  padding: 2px 7px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 500;
}
.badge-warning { background: #fef3c7 !important; color: #854F0B !important; }
.badge-success { background: #d1fae5 !important; color: #065f46 !important; }
.badge-danger  { background: #fee2e2 !important; color: #991b1b !important; }
.badge-info    { background: #dbeafe !important; color: #1e40af !important; }

/* =============================================
   ALERTAS
   ============================================= */
.alert {
  position: relative;
  padding: 10px 16px;
  margin-bottom: 1rem;
  border: 1px solid transparent;
  border-radius: 6px;
  font-size: 13px;
}
.alert-danger  { background: #fee2e2; color: #991b1b; border-color: #fca5a5; }
.alert-success { background: #d1fae5; color: #065f46; border-color: #6ee7b7; }
.alert-warning { background: #fef3c7; color: #854F0B; border-color: #fcd34d; }
.alert-info    { background: #dbeafe; color: #1e40af; border-color: #93c5fd; }

/* =============================================
   TARJETAS DE ESTADÍSTICAS
   ============================================= */
.card.card-statistics { border-radius: 8px !important; }
.card-statistics .card-body { padding: 20px !important; }

.stat-icon {
  width: 44px !important;
  height: 44px !important;
  border-radius: 8px !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  flex-shrink: 0;
  margin-right: 16px;
}
.stat-icon i { font-size: 22px !important; color: #fff !important; margin: 0 !important; }
.stat-icon.icon-primary { background: var(--sidebar-bg) !important; }
.stat-icon.icon-danger  { background: #e5484d !important; }
.stat-icon.icon-success { background: #18794e !important; }
.stat-icon.icon-warning { background: #c2830a !important; }

.stat-label {
  font-size: 11px !important;
  color: var(--text-muted) !important;
  text-transform: uppercase !important;
  letter-spacing: 0.04em !important;
  font-weight: 500 !important;
  margin-bottom: 2px !important;
}
.stat-value {
  font-size: 24px !important;
  font-weight: 600 !important;
  color: var(--text-primary) !important;
  line-height: 1.2 !important;
  margin: 0 !important;
}

/* Fila stat cards */
.stat-cards-row { margin-bottom: 20px; }
.stat-cards-row .grid-margin { margin-bottom: 16px !important; }

/* =============================================
   PÁGINA DE LOGIN
   ============================================= */
.full-page-wrapper {
  min-height: 100vh;
  display: flex;
}

/* Sin margin-top: no hay navbar en el login */
.container-fluid.page-body-wrapper.full-page-wrapper {
  margin-top: 0 !important;
}

/* El background-image es un inline style en .content-wrapper — lo neutralizamos */
.auth-page .content-wrapper {
  background-image: none !important;
  background: linear-gradient(135deg, #1a1f2e 0%, #1A5276 100%) !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  min-height: 100vh !important;
  width: 100% !important;
  padding: 32px 16px !important;
}

.auth-page .row.w-100 {
  width: 100% !important;
  margin: 0 !important;
  justify-content: center;
}

.auth-page .col-lg-4 {
  max-width: 400px;
  width: 100%;
  padding: 0;
  left: 0 !important; /* neutraliza el style="left:16px" inline */
}

/* Card */
.auth-page .auto-form-wrapper {
  background: #fff !important;
  border: none !important;
  border-radius: 14px !important;
  padding: 0 !important;
  box-shadow: 0 16px 56px rgba(0,0,0,0.35) !important;
  overflow: hidden !important;
}

/* Barra de acento rojo → azul en el tope del card */
.auth-page .auto-form-wrapper::before {
  content: '' !important;
  display: block !important;
  height: 5px !important;
  background: linear-gradient(90deg, #C0392B 0%, #1A5276 100%) !important;
}

/* Oculta imagen logo PHP */
.auth-page .auto-form-wrapper > img { display: none !important; }

/* Área del encabezado (favicon + título) */
.auth-page .display-4 {
  display: block !important;
  text-align: center !important;
  padding: 28px 32px 22px !important;
  margin: 0 !important;
  border-bottom: 1px solid #f3f4f6 !important;
  font-size: 14px !important;
  font-weight: 400 !important;
  color: var(--text-secondary) !important;
  line-height: 1.4 !important;
}

/* Favicon como ícono de app (fondo oscuro redondeado) */
.auth-page .display-4::before {
  content: '' !important;
  display: block !important;
  width: 66px !important;
  height: 66px !important;
  background-image: url('/favicon.ico') !important;
  background-color: #1a1f2e !important;
  background-size: 58% !important;
  background-repeat: no-repeat !important;
  background-position: center !important;
  border-radius: 18px !important;
  margin: 0 auto 16px !important;
  box-shadow: 0 6px 18px rgba(26,31,46,0.35) !important;
}

/* Texto del título */
.auth-page .display-4 strong {
  display: block !important;
  font-size: 16px !important;
  font-weight: 700 !important;
  color: #1a1f2e !important;
  letter-spacing: -0.01em !important;
  line-height: 1.3 !important;
  margin-bottom: 4px !important;
}

/* Área del formulario */
.auth-page form {
  padding: 22px 32px 28px !important;
}

.auth-page .form-group { margin-bottom: 16px !important; }

/* Labels */
.auth-page .label,
.auth-page label {
  font-size: 11px !important;
  font-weight: 600 !important;
  color: var(--text-secondary) !important;
  text-transform: uppercase !important;
  letter-spacing: 0.05em !important;
  margin-bottom: 6px !important;
  display: block !important;
}

/* Inputs */
.auth-page .form-control {
  padding: 9px 12px !important;
  height: auto !important;
  border-color: #e5e7eb !important;
}
.auth-page .form-control:focus {
  border-color: #1A5276 !important;
  box-shadow: 0 0 0 3px rgba(26,82,118,0.12) !important;
}

/* Ícono del input group en azul */
.auth-page .input-group-text {
  background: #f9fafb !important;
  border-color: #e5e7eb !important;
  color: #1A5276 !important;
  transition: background 0.15s, color 0.15s !important;
}
.auth-page .input-group-text:hover {
  background: #e8f0f7 !important;
  color: #154360 !important;
}

/* Botón Ingresar — rojo como "Buscar" */
.auth-page .btn.btn-secondary.submit-btn {
  background: #C0392B !important;
  border-color: #C0392B !important;
  color: #fff !important;
  width: 100% !important;
  padding: 11px 14px !important;
  font-size: 12px !important;
  font-weight: 700 !important;
  justify-content: center !important;
  letter-spacing: 0.08em !important;
  text-transform: uppercase !important;
  border-radius: 8px !important;
}
.auth-page .btn.btn-secondary.submit-btn:hover {
  background: #a93226 !important;
  border-color: #a93226 !important;
}

/* Mensaje de error */
.auth-page #msje {
  font-size: 12px !important;
  padding: 0 !important;
  color: #C0392B !important;
}

/* =============================================
   RESPONSIVE
   ============================================= */

/* Tablet — ≤ 1024px */
@media (max-width: 1024px) {
  .blockquote .row {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* ≤ 991px — sidebar oculto, hamburger visible */
@media (max-width: 991px) {
  :root { --sidebar-w: 220px; }

  .navbar-brand-wrapper {
    width: 200px !important;
    min-width: 200px !important;
  }

  /* Sidebar: desliza desde la izquierda */
  .sidebar,
  .sidebar.sidebar-offcanvas {
    position: fixed !important;
    top: var(--topbar-h) !important;
    left: calc(-1 * var(--sidebar-w)) !important;
    height: calc(100vh - var(--topbar-h)) !important;
    overflow-y: auto;
    transition: left 0.25s ease !important;
    z-index: 999;
  }

  .sidebar.sidebar-offcanvas.active {
    left: 0 !important;
  }

  /* Overlay al abrir el sidebar en móvil */
  .sidebar.sidebar-offcanvas.active::before {
    content: '';
    position: fixed;
    top: 0; left: var(--sidebar-w);
    right: 0; bottom: 0;
    background: rgba(0,0,0,0.3);
    z-index: -1;
  }

  .main-panel {
    width: 100% !important;
    min-width: 0 !important;
    margin-left: 0 !important;
  }

  .container-fluid.page-body-wrapper {
    margin-top: var(--topbar-h) !important;
  }

  .dash-page-header { flex-direction: column; align-items: flex-start; }

  .search-row { flex-direction: column; align-items: stretch; }
  .btn-group-search { justify-content: flex-end; }
}

/* ≤ 768px — tablet pequeña / móvil grande */
@media (max-width: 768px) {
  .main-panel .content-wrapper { padding: 16px !important; }

  .stat-cards-row .col-sm-6 { flex: 0 0 50%; max-width: 50%; }

  .blockquote .row {
    grid-template-columns: repeat(2, 1fr);
  }

  .navbar-nav-left.header-links .nav-item:nth-child(n+3) {
    display: none;
  }
}

/* ≤ 575px — móvil */
@media (max-width: 575px) {
  .main-panel .content-wrapper { padding: 12px !important; }

  .navbar-brand-wrapper {
    width: 150px !important;
    min-width: 150px !important;
  }

  .blockquote .row {
    grid-template-columns: 1fr;
  }

  .stat-cards-row .col-sm-6,
  .stat-cards-row [class*="col-"] {
    flex: 0 0 100%;
    max-width: 100%;
  }

  .stat-value { font-size: 20px !important; }

  .table thead th,
  .table tbody td { padding: 7px 10px !important; }

  .dash-page-header h2 { font-size: 17px !important; }

  .auth-page form { padding: 18px 20px 24px !important; }
  .auth-page .display-4 { padding: 24px 20px 18px !important; }
  .auth-page .col-lg-4 { max-width: 100% !important; padding: 0 !important; }

  .btn-group-search { width: 100%; }

  .navbar-nav-left.header-links { display: none !important; }
}

/* ── Bootstrap Dropdown ── */
.dropdown, .dropleft, .dropright, .dropup { position: relative }
.dropdown-toggle { white-space: nowrap }
.dropdown-toggle::after {
  display: inline-block; margin-left: .255em; vertical-align: .255em;
  content: ""; border-top: .3em solid;
  border-right: .3em solid transparent; border-bottom: 0; border-left: .3em solid transparent
}
.dropdown-toggle:empty::after { margin-left: 0 }
.dropdown-menu {
  position: absolute; top: 100%; left: 0; z-index: 1000;
  display: none; float: left; min-width: 10rem;
  padding: .5rem 0; margin: .125rem 0 0;
  font-size: 1rem; color: #212529; text-align: left;
  list-style: none; background-color: #fff;
  background-clip: padding-box;
  border: 1px solid rgba(17,17,17,.15); border-radius: 4px
}
.dropdown-menu-right { right: 0; left: auto }
.dropdown-menu.show { display: block }
.dropdown-item {
  display: block; width: 100%; padding: .4rem 1.2rem;
  clear: both; font-weight: 400; color: #212529;
  text-align: inherit; white-space: nowrap;
  background-color: transparent; border: 0; text-decoration: none
}
.dropdown-item:hover { color: #16181b; background-color: #f8f9fa }
.dropdown-item.text-danger:hover { color: #dc3545 !important; background-color: #fff5f5 }
.dropdown-divider { height: 0; margin: .5rem 0; overflow: hidden; border-top: 1px solid #e9ecef }

/* ── Bootstrap Modal ── */
.fade { transition: opacity .15s linear }
@media (prefers-reduced-motion:reduce) { .fade { transition: none } }
.fade:not(.show) { opacity: 0 }

.modal-open { overflow: hidden }
.modal-open .modal { overflow-x: hidden; overflow-y: auto }
.modal {
  position: fixed; top: 0; left: 0; z-index: 1050;
  display: none; width: 100%; height: 100%;
  overflow: hidden; outline: 0
}
.modal-dialog { position: relative; width: auto; margin: .5rem; pointer-events: none }
.modal.fade .modal-dialog {
  transition: transform .3s ease-out;
  -webkit-transform: translate(0,-50px); transform: translate(0,-50px)
}
@media (prefers-reduced-motion:reduce) { .modal.fade .modal-dialog { transition: none } }
.modal.show .modal-dialog { -webkit-transform: none; transform: none }
.modal-content {
  position: relative; display: flex; flex-direction: column;
  width: 100%; pointer-events: auto;
  background-color: #fff; background-clip: padding-box;
  border: 1px solid rgba(17,17,17,.2); border-radius: 8px; outline: 0
}
.modal-backdrop {
  position: fixed; top: 0; left: 0; z-index: 1040;
  width: 100vw; height: 100vh; background-color: #111
}
.modal-backdrop.fade { opacity: 0 }
.modal-backdrop.show { opacity: .5 }
.modal-header {
  display: flex; align-items: flex-start; justify-content: space-between;
  padding: 1rem; border-bottom: 1px solid #dee2e6;
  border-top-left-radius: 8px; border-top-right-radius: 8px
}
.modal-header .close { padding: 1rem; margin: -1rem -1rem -1rem auto }
.modal-title { margin-bottom: 0; line-height: 1.35 }
.modal-body { position: relative; flex: 1 1 auto; padding: 1rem }
.modal-footer {
  display: flex; flex-wrap: wrap; align-items: center;
  justify-content: flex-end; padding: .75rem;
  border-top: 1px solid #dee2e6;
  border-bottom-right-radius: 8px; border-bottom-left-radius: 8px
}
.modal-footer > * { margin: .25rem }
@media (min-width:576px) {
  .modal-dialog { max-width: 500px; margin: 1.75rem auto }
}
@media (min-width:992px) {
  .modal-lg { max-width: 800px }
}

/* Overlay de carga al subir archivos */
#upload-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  z-index: 9999;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
}
#upload-overlay.activo { display: flex; }
#upload-overlay .upload-card {
  background: #fff;
  border-radius: 12px;
  padding: 32px 40px;
  text-align: center;
  box-shadow: 0 8px 32px rgba(0,0,0,0.18);
  min-width: 220px;
}
#upload-overlay .upload-spinner {
  width: 44px;
  height: 44px;
  border: 4px solid #e5e7eb;
  border-top-color: #1a1f2e;
  border-radius: 50%;
  animation: upload-spin 0.8s linear infinite;
  margin: 0 auto 16px;
}
@keyframes upload-spin { to { transform: rotate(360deg); } }
#upload-overlay .upload-texto {
  font-size: 14px;
  font-weight: 500;
  color: #1a1f2e;
  margin: 0 0 4px;
}
#upload-overlay .upload-sub {
  font-size: 12px;
  color: #6b7280;
  margin: 0 0 12px;
}
#upload-overlay .upload-progress-bar {
  width: 100%;
  height: 6px;
  background: #e5e7eb;
  border-radius: 99px;
  overflow: hidden;
}
#upload-overlay .upload-progress-fill {
  height: 100%;
  width: 0%;
  background: #1a1f2e;
  border-radius: 99px;
  transition: width 0.2s ease;
}
#upload-overlay .upload-percent {
  font-size: 12px;
  color: #6b7280;
  margin: 6px 0 0;
}
