/* =============================================================================
   ARCOPB · Personalización sobre Bootstrap 5
   Plataforma de gestión de derechos ARCOPB · Ley 21.719
   Operador: Mi Técnico SpA (RUT 77.896.663-8)
   Versión: 3.0 (Híbrido con Bootstrap 5.3.2)
   ============================================================================= */

/* =============================================================================
   1. OVERRIDE DE VARIABLES BOOTSTRAP · Paleta ARCOPB
   ============================================================================= */
:root {
  /* Colores primarios de marca */
  --bs-primary: #0b3d91;
  --bs-primary-rgb: 11, 61, 145;

  /* Color de peligro personalizado (rojo corporativo más serio) */
  --bs-danger: #dc2626;
  --bs-danger-rgb: 220, 38, 38;

  /* Color de éxito personalizado */
  --bs-success: #16a34a;
  --bs-success-rgb: 22, 163, 74;

  /* Tipografía */
  --bs-body-font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --bs-body-font-size: 0.9375rem;
  --bs-body-line-height: 1.55;
  --bs-body-color: #1e293b;

  /* Radios más marcados (estilo moderno) */
  --bs-border-radius: 0.5rem;
  --bs-border-radius-sm: 0.375rem;
  --bs-border-radius-lg: 0.75rem;
  --bs-border-radius-xl: 1rem;

  /* Sombras más sutiles */
  --bs-box-shadow-sm: 0 1px 3px rgba(15, 23, 42, 0.06), 0 1px 2px rgba(15, 23, 42, 0.04);
  --bs-box-shadow: 0 4px 12px rgba(15, 23, 42, 0.08), 0 2px 4px rgba(15, 23, 42, 0.04);
  --bs-box-shadow-lg: 0 16px 32px rgba(15, 23, 42, 0.10), 0 8px 16px rgba(15, 23, 42, 0.06);

  /* Variables propias ARCOPB */
  --arcopb-sidebar-w: 260px;
  --arcopb-topbar-h: 64px;
  --arcopb-brand: #0b3d91;
  --arcopb-brand-dark: #082e6e;
}

/* =============================================================================
   2. BASE
   ============================================================================= */
body {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  background: #f8fafc;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

body.is-auth-page {
  background: linear-gradient(135deg, #0b3d91 0%, #082e6e 50%, #061f4d 100%);
  min-height: 100vh;
}

body:not(.is-auth-page):has(.sidebar) {
  padding-top: var(--arcopb-topbar-h);
}

/* Botones primarios con identidad ARCOPB */
.btn-primary {
  --bs-btn-bg: #0b3d91;
  --bs-btn-border-color: #0b3d91;
  --bs-btn-hover-bg: #082e6e;
  --bs-btn-hover-border-color: #082e6e;
  --bs-btn-active-bg: #061f4d;
  --bs-btn-active-border-color: #061f4d;
}

.btn-outline-primary {
  --bs-btn-color: #0b3d91;
  --bs-btn-border-color: #0b3d91;
  --bs-btn-hover-bg: #0b3d91;
  --bs-btn-hover-border-color: #0b3d91;
}

/* Inputs con focus azul corporativo */
.form-control:focus,
.form-select:focus {
  border-color: rgba(11, 61, 145, 0.5);
  box-shadow: 0 0 0 0.2rem rgba(11, 61, 145, 0.15);
}

/* =============================================================================
   3. SKIP LINK · Accesibilidad
   ============================================================================= */
.skip-link {
  position: absolute;
  top: -100px;
  left: 0;
  background: var(--arcopb-brand);
  color: #fff;
  padding: 0.75rem 1rem;
  z-index: 9999;
  border-radius: 0 0 0.5rem 0;
  font-weight: 600;
  transition: top 0.2s;
}

.skip-link:focus {
  top: 0;
  color: #fff;
  text-decoration: none;
}

/* =============================================================================
   4. TOPBAR
   ============================================================================= */
.topbar {
  height: var(--arcopb-topbar-h);
  background: #fff;
  border-bottom: 1px solid #e2e8f0;
  padding: 0 !important;
}

.topbar__inner {
  max-width: 100%;
  margin: 0 auto;
  height: 100%;
  padding: 0 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.topbar__menu-toggle {
  border-color: #e2e8f0;
  color: #334155;
  padding: 0.25rem 0.5rem;
}

.topbar__brand {
  display: flex !important;
  align-items: center !important;
  gap: 0.75rem !important;
  color: inherit !important;
  padding: 0 !important;
  margin-right: 0 !important;
}

.topbar__brand:hover {
  color: inherit !important;
}

.topbar__brand-mark {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.topbar__brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.1;
}

.topbar__brand-name {
  font-size: 1.125rem;
  font-weight: 700;
  color: #0f172a;
  letter-spacing: -0.01em;
}

.topbar__brand-tag {
  font-size: 0.6875rem;
  color: #64748b;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.topbar__user-button {
  display: flex !important;
  align-items: center !important;
  gap: 0.75rem !important;
  padding: 0.375rem 0.75rem !important;
  background: #f8fafc !important;
  border: 1px solid #e2e8f0 !important;
  color: #334155 !important;
}

.topbar__user-button:hover,
.topbar__user-button[aria-expanded="true"] {
  background: #f1f5f9 !important;
  border-color: #cbd5e1 !important;
}

.topbar__user-button::after {
  margin-left: 0.25rem;
}

.topbar__avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, #3a5cff 0%, #0b3d91 100%);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 1rem;
  flex-shrink: 0;
}

.topbar__user-info {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
  text-align: left;
}

.topbar__user-name {
  font-size: 0.875rem;
  font-weight: 600;
  color: #0f172a;
}

.topbar__user-role {
  font-size: 0.75rem;
  color: #64748b;
}

/* =============================================================================
   5. SIDEBAR
   ============================================================================= */
.sidebar {
  position: fixed;
  top: var(--arcopb-topbar-h);
  left: 0;
  width: var(--arcopb-sidebar-w);
  height: calc(100vh - var(--arcopb-topbar-h));
  background: #fff;
  border-right: 1px solid #e2e8f0;
  overflow-y: auto;
  z-index: 80;
  padding: 0;
}

.sidebar__nav {
  padding: 1.5rem 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.sidebar__section {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.sidebar__section-title {
  font-size: 0.75rem;
  font-weight: 600;
  color: #64748b;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 0 0.75rem;
  margin: 0 0 0.5rem 0;
}

.sidebar__list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.sidebar__link {
  display: flex !important;
  align-items: center !important;
  gap: 0.75rem !important;
  padding: 0.5rem 0.75rem !important;
  border-radius: 0.5rem !important;
  color: #334155 !important;
  font-size: 0.875rem !important;
  font-weight: 500 !important;
  text-decoration: none !important;
  transition: background 0.15s, color 0.15s;
  position: relative;
}

.sidebar__link i,
.sidebar__link .bi {
  font-size: 1.1rem;
  width: 1.25rem;
  text-align: center;
  color: #64748b;
  transition: color 0.15s;
}

.sidebar__link:hover {
  background: #f1f5f9 !important;
  color: #0f172a !important;
}

.sidebar__link:hover i,
.sidebar__link:hover .bi {
  color: #0b3d91;
}

.sidebar__link.active,
.sidebar__link.is-active {
  background: #eef4ff !important;
  color: #0b3d91 !important;
  font-weight: 600 !important;
}

.sidebar__link.active i,
.sidebar__link.is-active i,
.sidebar__link.active .bi,
.sidebar__link.is-active .bi {
  color: #0b3d91;
}

.sidebar__link.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 25%;
  bottom: 25%;
  width: 3px;
  background: #0b3d91;
  border-radius: 0 3px 3px 0;
}

/* =============================================================================
   6. MAIN
   ============================================================================= */
.main {
  flex: 1;
  margin-left: var(--arcopb-sidebar-w);
  min-height: calc(100vh - var(--arcopb-topbar-h));
  display: flex;
  flex-direction: column;
}

.main__inner {
  max-width: 1400px;
  width: 100%;
  margin: 0 auto;
  padding: 1.5rem 2rem 3rem;
  flex: 1;
}

/* Page header */
.page-header {
  margin-bottom: 2rem;
  padding-bottom: 1.25rem;
  border-bottom: 1px solid #e2e8f0;
}

.page-title {
  font-size: 1.875rem;
  font-weight: 700;
  color: #0f172a;
  margin: 0 0 0.5rem;
  letter-spacing: -0.02em;
}

.page-subtitle {
  color: #64748b;
  font-size: 0.9375rem;
  margin: 0;
  max-width: 720px;
}

.page-content {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

/* =============================================================================
   7. FOOTER
   ============================================================================= */
.footer {
  margin-top: auto;
  background: #fff;
  border-top: 1px solid #e2e8f0;
  padding: 1.5rem;
}

.footer__inner {
  max-width: 1400px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  text-align: center;
  color: #64748b;
  font-size: 0.8125rem;
}

.footer__brand {
  font-size: 0.875rem;
  color: #334155;
}

.footer__brand strong {
  color: #0b3d91;
}

.footer__legal {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.5rem;
}

.footer__legal strong {
  color: #334155;
}

.footer__sep {
  color: #cbd5e1;
}

.footer__copy {
  color: #94a3b8;
  font-size: 0.75rem;
}

/* =============================================================================
   8. AUTH (LOGIN / REGISTRO)
   ============================================================================= */
.auth-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 1.5rem;
}

.auth-card {
  background: #fff;
  border-radius: 1rem;
  box-shadow: 0 24px 48px rgba(0, 0, 0, 0.2);
  width: 100%;
  max-width: 440px;
  padding: 2.5rem 2rem;
  margin: 1rem 0;
}

.auth-card--wide { max-width: 560px; }

.auth-header {
  text-align: center;
  margin-bottom: 2rem;
}

.auth-logo {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
  font-size: 1.5rem;
  font-weight: 700;
  color: #0b3d91;
  letter-spacing: -0.02em;
}

.auth-info {
  text-align: center;
  color: rgba(255, 255, 255, 0.85);
  font-size: 0.75rem;
  margin-top: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.auth-info strong {
  color: #fff;
  font-weight: 600;
}

/* =============================================================================
   9. SWEETALERT2 · Personalización con marca ARCOPB
   ============================================================================= */
.swal2-popup {
  border-radius: 0.75rem !important;
  font-family: 'Inter', sans-serif !important;
}

.swal2-popup .swal2-title {
  font-size: 1.25rem !important;
  font-weight: 600 !important;
  color: #0f172a !important;
}

.swal2-popup .swal2-html-container {
  font-size: 0.9375rem !important;
  color: #475569 !important;
  line-height: 1.5 !important;
}

.swal2-confirm {
  background: #0b3d91 !important;
  box-shadow: 0 1px 3px rgba(11, 61, 145, 0.3) !important;
}

.swal2-confirm:hover {
  background: #082e6e !important;
}

.swal2-cancel {
  background: #f1f5f9 !important;
  color: #334155 !important;
}

.swal2-cancel:hover {
  background: #e2e8f0 !important;
}

.swal2-icon.swal2-warning {
  border-color: #d97706 !important;
  color: #d97706 !important;
}

.swal2-icon.swal2-error {
  border-color: #dc2626 !important;
}

.swal2-icon.swal2-success {
  border-color: #16a34a !important;
}

.swal2-icon.swal2-success [class^='swal2-success-line'] {
  background-color: #16a34a !important;
}

.swal2-icon.swal2-success .swal2-success-ring {
  border-color: rgba(22, 163, 74, 0.3) !important;
}

/* =============================================================================
   10. OFFCANVAS SIDEBAR (móvil)
   ============================================================================= */
.sidebar-offcanvas {
  width: var(--arcopb-sidebar-w) !important;
}

.sidebar-offcanvas .offcanvas-header {
  padding: 1rem 1.25rem;
}

.sidebar-offcanvas .offcanvas-title {
  display: flex;
  align-items: center;
  font-size: 1.125rem;
  font-weight: 700;
  color: #0f172a;
}

/* =============================================================================
   11. UTILIDADES
   ============================================================================= */
.cursor-pointer { cursor: pointer; }

.text-truncate-2 {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Tabla vacía centrada */
.table-empty {
  text-align: center;
  padding: 3rem 1.5rem;
  color: #64748b;
}

.table-empty i {
  font-size: 3rem;
  color: #cbd5e1;
  margin-bottom: 0.75rem;
  display: block;
}

.table-empty__title {
  font-size: 1rem;
  font-weight: 600;
  color: #334155;
  margin-bottom: 0.25rem;
}

.table-empty__hint {
  font-size: 0.875rem;
  color: #64748b;
}

/* =============================================================================
   12. RESPONSIVE
   ============================================================================= */
@media (max-width: 991.98px) {
  .sidebar {
    display: none !important;
  }
  .main {
    margin-left: 0;
  }
  .main__inner {
    padding: 1rem 1rem 2.5rem;
  }
  .page-title {
    font-size: 1.5rem;
  }
}

@media (max-width: 767.98px) {
  .topbar__inner {
    padding: 0 0.75rem;
  }
  .topbar__brand-tag {
    display: none;
  }
  .topbar__user-button {
    padding: 0.25rem !important;
  }
  .topbar__user-info {
    display: none !important;
  }
}

@media (max-width: 575.98px) {
  .topbar__brand-text {
    display: none;
  }
  .topbar__avatar {
    width: 32px;
    height: 32px;
    font-size: 0.875rem;
  }
}

/* =============================================================================
   13. IMPRESIÓN
   ============================================================================= */
@media print {
  .topbar, .sidebar, .footer, .btn, .pagination, .form-actions {
    display: none !important;
  }
  .main {
    margin: 0;
  }
  .main__inner {
    padding: 0;
  }
  body {
    background: #fff;
  }
  .card {
    box-shadow: none;
    border: 1px solid #ccc;
  }
}
