/**
 * ===========================
 *
 * Copyright (c) 2024-2025 Ruben Caramutti / PuntoGAP | dotABC
 * Licensed under MIT License
 *
 * Este archivo es parte del proyecto Al-Día.
 *
 * @author Ruben Caramutti
 * @project Al-Día
 * @repository https://github.com/tuknqn/aldia
 * @created 2025-10-17
 */

/* === TOKENS DE DISEÑO === */
:root {
  /* Base */
  --bg: #F7F8FB;
  --surface: #FFFFFF;
  --text: #0F172A;
  --text-muted: #5B6476;
  --border: #E6E8EF;
  
  /* Primario (gradiente login/botones) */
  --primary-1: #6C63FF;
  --primary-2: #22D3EE;
  
  /* Estados */
  --success: #16A34A;
  --warning: #F59E0B;
  --danger: #EF4444;
  --info: #3B82F6;
  
  /* Pasteles para cards/charts */
  --pastel-a: #C7E8FF;
  --pastel-b: #FAD7E6;
  --pastel-c: #D8F5D0;
  --pastel-d: #FFE6C7;
  
  /* Tipografía y espaciado */
  --font-sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --radius-sm: 10px;
  --radius-md: 16px;
  --radius-lg: 20px;
  --shadow-sm: 0 2px 8px rgba(15,23,42,0.06);
  --shadow-md: 0 8px 24px rgba(15,23,42,0.08);
  --shadow-lg: 0 18px 40px rgba(15,23,42,0.10);
  --gap: 16px;
}

/* === RESET Y BASE === */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  font-size: 16px;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--primary-1);
  text-decoration: none;
  transition: all 0.2s ease;
}

a:hover {
  opacity: 0.8;
}

/* === LAYOUT === */
.container {
  width: min(1200px, 92%);
  margin: 0 auto;
}

.min-h-screen {
  min-height: 100vh;
}

.grid {
  display: grid;
}

.grid.place-items-center {
  place-items: center;
}

.flex {
  display: flex;
}

.flex-col {
  flex-direction: column;
}

.items-center {
  align-items: center;
}

.justify-between {
  justify-content: space-between;
}

.gap-2 {
  gap: calc(var(--gap) / 2);
}

.gap-4 {
  gap: var(--gap);
}

/* === COMPONENTES === */

/* Card */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: 24px;
  transition: all 0.2s ease;
}

.card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}

.card-compact {
  padding: 16px;
}

/* Botones */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0.75rem 1rem;
  border-radius: 16px;
  border: 1px solid transparent;
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
  transition: all 0.2s ease;
  text-decoration: none;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-gradient {
  background: linear-gradient(90deg, var(--primary-1), var(--primary-2));
  color: white;
  box-shadow: var(--shadow-md);
}

.btn-gradient:hover:not(:disabled) {
  filter: brightness(1.05);
  transform: translateY(-1px);
}

.btn-primary {
  background: var(--primary-1);
  color: white;
}

.btn-primary:hover:not(:disabled) {
  filter: brightness(1.1);
}

.btn-ghost {
  background: #fff;
  border: 1px solid var(--border);
  color: var(--text);
}

.btn-ghost:hover:not(:disabled) {
  background: var(--bg);
}

.btn-success {
  background: var(--success);
  color: white;
}

.btn-danger {
  background: var(--danger);
  color: white;
}

.btn-sm {
  padding: 0.5rem 0.75rem;
  font-size: 0.875rem;
}

/* Inputs */
.input, .select, .textarea {
  width: 100%;
  padding: 0.75rem 0.9rem;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: #fff;
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 0.95rem;
  box-shadow: inset 0 1px 0 rgba(0,0,0,0.02);
  transition: all 0.2s ease;
}

.input:focus, .select:focus, .textarea:focus {
  outline: none;
  border-color: var(--primary-1);
  box-shadow: 0 0 0 3px rgba(108,99,255,0.15);
}

.input:disabled, .select:disabled, .textarea:disabled {
  background: var(--bg);
  cursor: not-allowed;
}

.label {
  font-size: 0.9rem;
  color: var(--text-muted);
  margin-bottom: 0.35rem;
  display: block;
  font-weight: 500;
}

.form-group {
  margin-bottom: 1rem;
}

.form-error {
  color: var(--danger);
  font-size: 0.85rem;
  margin-top: 0.25rem;
}

/* Badges */
.badge {
  padding: 0.35rem 0.6rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  background: #F2F4F8;
  color: #475569;
  display: inline-block;
}

.badge-success {
  background: rgba(22, 163, 74, 0.1);
  color: var(--success);
}

.badge-warning {
  background: rgba(245, 158, 11, 0.1);
  color: var(--warning);
}

.badge-danger {
  background: rgba(239, 68, 68, 0.1);
  color: var(--danger);
}

.badge-info {
  background: rgba(59, 130, 246, 0.1);
  color: var(--info);
}

/* Tablas */
.table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0 10px;
}

.table thead th {
  color: var(--text-muted);
  font-weight: 600;
  text-align: left;
  font-size: 0.85rem;
  padding: 8px 16px;
}

.table tbody tr {
  background: #fff;
  box-shadow: var(--shadow-sm);
  transition: all 0.2s ease;
}

.table tbody tr:hover {
  box-shadow: var(--shadow-md);
  transform: scale(1.01);
}

.table tbody td {
  padding: 14px 16px;
  border-top: 1px solid transparent;
}

.table tbody tr td:first-child {
  border-radius: var(--radius-md) 0 0 var(--radius-md);
}

.table tbody tr td:last-child {
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
}

/* === LOGIN HERO === */
.login-hero {
  background: linear-gradient(135deg, rgba(108,99,255,0.12), rgba(34,211,238,0.12));
}

/* === SIDEBAR === */
.sidebar {
  position: fixed;
  left: 0;
  top: 0;
  bottom: 0;
  width: 240px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 20px 0;
  overflow-y: auto;
  transition: transform 0.3s ease;
  z-index: 100;
}

.sidebar.collapsed {
  transform: translateX(-100%);
}

.sidebar-logo {
  padding: 0 20px;
  margin-bottom: 30px;
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--primary-1);
}

.sidebar-nav {
  list-style: none;
}

.sidebar-item {
  margin: 4px 10px;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-radius: var(--radius-md);
  color: var(--text-muted);
  transition: all 0.2s ease;
}

.sidebar-link:hover {
  background: var(--bg);
  color: var(--text);
}

.sidebar-link.active {
  background: rgba(108,99,255,0.1);
  color: var(--primary-1);
  font-weight: 600;
}

.sidebar-icon {
  width: 20px;
  height: 20px;
  opacity: 0.9;
}

/* === TOPBAR === */
.topbar {
  position: sticky;
  top: 0;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 16px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  z-index: 50;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 16px;
}

.topbar-search {
  position: relative;
}

.topbar-search input {
  width: 300px;
  padding: 8px 12px 8px 36px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg);
}

.topbar-search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  opacity: 0.5;
}

.topbar-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary-1), var(--primary-2));
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 0.9rem;
}

/* === MAIN CONTENT === */
.main-content {
  margin-left: 240px;
  min-height: 100vh;
  background: var(--bg);
  transition: margin-left 0.3s ease;
}

.main-content.sidebar-collapsed {
  margin-left: 0;
}

.content-wrapper {
  padding: 30px;
}

/* === KPI CARDS === */
.kpi-card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow-sm);
}

.kpi-card.pastel-a {
  background: var(--pastel-a);
}

.kpi-card.pastel-b {
  background: var(--pastel-b);
}

.kpi-card.pastel-c {
  background: var(--pastel-c);
}

.kpi-card.pastel-d {
  background: var(--pastel-d);
}

.kpi-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 12px;
}

.kpi-label {
  font-size: 0.85rem;
  color: var(--text-muted);
  font-weight: 500;
}

.kpi-value {
  font-size: 1.8rem;
  font-weight: 700;
  color: var(--text);
  margin: 8px 0;
}

.sparkline {
  width: 100%;
  height: 60px;
  margin-top: 12px;
}

/* === ALERTS === */
.alert {
  padding: 14px 18px;
  border-radius: var(--radius-md);
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.alert-success {
  background: rgba(22, 163, 74, 0.1);
  border: 1px solid rgba(22, 163, 74, 0.2);
  color: var(--success);
}

.alert-danger {
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.2);
  color: var(--danger);
}

.alert-warning {
  background: rgba(245, 158, 11, 0.1);
  border: 1px solid rgba(245, 158, 11, 0.2);
  color: var(--warning);
}

.alert-info {
  background: rgba(59, 130, 246, 0.1);
  border: 1px solid rgba(59, 130, 246, 0.2);
  color: var(--info);
}

/* === UTILS === */
.text-muted {
  color: var(--text-muted);
}

.text-center {
  text-align: center;
}

.text-right {
  text-align: right;
}

.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }

.w-full { width: 100%; }

/* === OBLIGATIONS CARDS (solo móvil) === */
/* Por defecto, ocultar cards y mostrar tabla */
.obligations-cards-mobile {
  display: none;
}

.obligations-table-desktop {
  display: block;
}

/* === PROVIDERS CARDS (solo móvil) === */
.providers-cards-mobile {
  display: none;
}

.providers-table-desktop {
  display: block;
}

/* === PAYMENTS CARDS (solo móvil) === */
.payments-cards-mobile {
  display: none;
}

.payments-table-desktop {
  display: block;
}

/* === VISTA DETALLE OBLIGACIÓN === */
.obligation-detail-grid {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 24px;
}

.obligation-info-grid {
  display: grid;
  grid-template-columns: 150px 1fr;
  gap: 12px;
}

/* === RESPONSIVE === */
/* === OVERLAY PARA SIDEBAR EN MÓVIL === */
.sidebar-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 90;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

.sidebar-overlay.active {
  opacity: 1;
  visibility: visible;
}

@media (max-width: 1024px) {
  .sidebar {
    transform: translateX(-100%);
    z-index: 100;
    box-shadow: 2px 0 8px rgba(0,0,0,0.1);
  }
  
  .sidebar.open {
    transform: translateX(0);
  }
  
  .main-content {
    margin-left: 0;
  }
  
  .topbar-search input {
    width: 200px;
  }
  
  /* Botón hamburguesa más visible en móvil */
  .sidebar-toggle {
    width: 44px !important;
    height: 44px !important;
    padding: 12px !important;
  }
  
  .sidebar-toggle svg {
    width: 24px !important;
    height: 24px !important;
  }
}

/* ===========================
   THEME TOGGLE BUTTON
   Botón para cambiar entre modo claro y oscuro
   =========================== */

.theme-toggle-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  padding: 0;
  background: rgba(108, 99, 255, 0.1);
  border: 1px solid rgba(108, 99, 255, 0.2);
  border-radius: 50%;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  margin-right: 16px;
}

.theme-toggle-btn:hover {
  background: rgba(108, 99, 255, 0.2);
  border-color: rgba(108, 99, 255, 0.3);
  transform: scale(1.05);
}

.theme-toggle-btn:active {
  transform: scale(0.95);
}

.theme-icon {
  color: var(--primary-1);
  transition: all 0.3s ease;
}

/* Efecto de rotación cuando se hace click */
.theme-toggle-btn[data-current-theme="dark"] .theme-icon {
  color: #22D3EE;
}

@media (max-width: 768px) {
  .topbar-search {
    display: none;
  }
  
  .content-wrapper {
    padding: 20px;
  }
  
  .kpi-value {
    font-size: 1.5rem;
  }
  
  /* En mobile, hacer el toggle un poco más pequeño */
  .theme-toggle-btn {
    width: 36px;
    height: 36px;
    margin-right: 12px;
  }
  
  /* === DASHBOARD LAYOUT MÓVIL === */
  
  /* Grid principal del dashboard: de 2 columnas a 1 columna */
  .dashboard-main-grid {
    grid-template-columns: 1fr !important;
  }
  
  /* KPI Cards: 2 por fila en móvil estándar */
  .kpi-grid {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 12px !important;
  }
  
  /* Reducir padding de KPI cards en móvil */
  .kpi-card {
    padding: 16px !important;
  }
  
  .kpi-label {
    font-size: 0.8rem !important;
  }
  
  .kpi-value {
    font-size: 1.3rem !important;
  }
  
  /* Pagos recientes: mostrar solo 3 en móvil */
  .recent-payments-mobile-limit:nth-child(n+4) {
    display: none !important;
  }
  
  /* Acciones rápidas: botones más grandes para touch */
  .quick-actions .btn {
    padding: 14px 20px !important;
    font-size: 1rem !important;
    min-height: 48px;
  }
  
  /* Charts: 1 columna */
  #chartsGrid {
    grid-template-columns: 1fr !important;
  }
  
  .chart-container {
    height: 250px !important;
  }
  
  /* Títulos de cards más compactos */
  .card h2 {
    font-size: 1.1rem !important;
  }
  
  .card h3 {
    font-size: 1rem !important;
  }
  
  /* === TABLA → CARDS EN MÓVIL === */
  
  /* Ocultar tabla, mostrar cards */
  .obligations-table-desktop {
    display: none !important;
  }
  
  .obligations-cards-mobile {
    display: block !important;
  }
  
  /* Estilo de las cards de obligaciones */
  .obligation-card-mobile {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 16px;
    margin-bottom: 12px;
    box-shadow: var(--shadow-sm);
    transition: all 0.2s ease;
  }
  
  .obligation-card-mobile:active {
    transform: scale(0.98);
    box-shadow: var(--shadow-md);
  }
  
  .obligation-card-header {
    display: flex;
    justify-content: space-between;
    align-items: start;
    margin-bottom: 12px;
    gap: 12px;
  }
  
  .obligation-card-title {
    font-weight: 600;
    font-size: 1rem;
    color: var(--text);
    line-height: 1.3;
  }
  
  .obligation-card-body {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 12px;
  }
  
  .obligation-info-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.9rem;
  }
  
  .obligation-info-label {
    color: var(--text-muted);
    font-weight: 500;
  }
  
  .obligation-info-value {
    color: var(--text);
    font-weight: 600;
  }
  
  .obligation-card-footer {
    padding-top: 12px;
    border-top: 1px solid var(--border);
  }
  
  .obligation-card-footer .btn {
    width: 100%;
    min-height: 44px;
    justify-content: center;
  }
  
  /* === PÁGINAS: OBLIGACIONES, PROVEEDORES === */
  
  /* Header de páginas: stack botones en móvil */
  .page-header-mobile {
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 16px !important;
  }
  
  .page-header-mobile .btn {
    width: 100% !important;
    justify-content: center !important;
  }
  
  /* Filtros: stack en móvil */
  .filters-grid-mobile {
    grid-template-columns: 1fr !important;
  }
  
  .filters-row-mobile {
    grid-template-columns: 1fr !important;
  }
  
  /* Dropdown de exportar: más ancho en móvil */
  #exportMenu {
    left: 0 !important;
    right: 0 !important;
    min-width: 100% !important;
  }
  
  /* === PROVEEDORES CARDS === */
  
  .provider-card-mobile {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 16px;
    margin-bottom: 12px;
    box-shadow: var(--shadow-sm);
  }
  
  .provider-card-mobile:active {
    transform: scale(0.98);
  }
  
  .provider-card-name {
    font-weight: 600;
    font-size: 1.05rem;
    margin-bottom: 8px;
    color: var(--primary-1);
  }
  
  .provider-card-info {
    font-size: 0.9rem;
    color: var(--text-muted);
    margin-bottom: 12px;
    line-height: 1.6;
  }
  
  .provider-card-stats {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 0;
    margin: 12px 0;
    border-top: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
  }
  
  .provider-card-actions {
    display: flex;
    gap: 8px;
    justify-content: stretch;
  }
  
  .provider-card-actions .btn {
    flex: 1;
    justify-content: center;
    min-height: 44px;
  }
  
  /* Tabla proveedores: ocultar, mostrar cards */
  .providers-table-desktop {
    display: none !important;
  }
  
  .providers-cards-mobile {
    display: block !important;
  }
  
  /* === MI PERFIL === */
  
  .profile-grid-mobile {
    grid-template-columns: 1fr !important;
  }
  
  /* Grid interno de información: más compacto */
  .profile-info-grid {
    grid-template-columns: 120px 1fr !important;
    gap: 8px !important;
  }
  
  .profile-info-grid dt {
    font-size: 0.9rem !important;
  }
  
  .profile-info-grid dd {
    font-size: 0.95rem !important;
    word-break: break-word;
  }
  
  /* === VISTA DETALLE OBLIGACIONES === */
  
  .obligation-detail-grid {
    grid-template-columns: 1fr !important;
  }
  
  .obligation-info-grid {
    grid-template-columns: 120px 1fr !important;
    gap: 8px !important;
  }
  
  .obligation-info-grid > div {
    word-break: break-word;
  }
  
  /* Header adaptativo */
  .obligation-header-mobile {
    flex-direction: column !important;
    align-items: flex-start !important;
    gap: 12px !important;
  }
  
  .obligation-header-mobile .btn {
    width: 100% !important;
  }
  
  /* === TABLA DE PAGOS === */
  
  .payments-table-desktop {
    display: none !important;
  }
  
  .payments-cards-mobile {
    display: block !important;
  }
  
  .payment-card-mobile {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 16px;
    margin-bottom: 12px;
    box-shadow: var(--shadow-sm);
  }
  
  .payment-card-mobile.cancelled {
    opacity: 0.6;
    background-color: #f9f9f9;
  }
  
  .payment-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border);
  }
  
  .payment-card-amount {
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--primary-1);
  }
  
  .payment-card-body {
    margin-bottom: 12px;
  }
  
  .payment-info-row {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    border-bottom: 1px solid var(--border-light);
  }
  
  .payment-info-label {
    font-size: 0.85rem;
    color: var(--text-muted);
  }
  
  .payment-info-value {
    font-weight: 500;
    text-align: right;
  }
  
  .payment-card-actions {
    display: flex;
    gap: 8px;
  }
  
  .payment-card-actions .btn {
    flex: 1;
    justify-content: center;
    min-height: 44px;
  }
  
  /* === FORMULARIOS EN VISTA DETALLE === */
  
  /* Sidebar de acciones en móvil */
  .obligation-detail-grid > div:last-child {
    display: flex;
    flex-direction: column;
    gap: 16px;
  }
  
  .obligation-detail-grid > div:last-child .card {
    margin-bottom: 0 !important;
  }
  
  /* Formulario "Registrar Pago" más grande en móvil */
  .obligation-detail-grid .form-group {
    margin-bottom: 16px;
  }
  
  .obligation-detail-grid .input,
  .obligation-detail-grid .label {
    font-size: 1rem !important;
  }
  
  .obligation-detail-grid .btn {
    padding: 14px 20px;
    font-size: 1rem;
    min-height: 48px;
  }
  
  /* === FORMULARIOS === */
  
  .form-grid-2 {
    grid-template-columns: 1fr !important;
  }
  
  .form-actions-mobile {
    flex-direction: column !important;
  }
  
  .form-actions-mobile .btn {
    width: 100% !important;
  }
}

/* === MÓVIL MUY PEQUEÑO (< 480px) === */
@media (max-width: 480px) {
  /* KPI Cards: 1 por fila en pantallas muy pequeñas */
  .kpi-grid {
    grid-template-columns: 1fr !important;
  }
  
  .content-wrapper {
    padding: 16px !important;
  }
  
  /* Font sizes aún más pequeños */
  .kpi-label {
    font-size: 0.75rem !important;
  }
  
  .kpi-value {
    font-size: 1.2rem !important;
  }
  
  /* Badges más pequeños */
  .badge {
    font-size: 0.7rem !important;
    padding: 4px 8px !important;
  }
  
  /* Botones más compactos verticalmente */
  .btn {
    padding: 10px 16px !important;
  }
  
  .btn-sm {
    padding: 8px 12px !important;
  }
  
  /* === MI PERFIL: 1 columna en móviles pequeños === */
  .profile-info-grid {
    grid-template-columns: 1fr !important;
    gap: 4px !important;
  }
  
  .profile-info-grid dt {
    font-size: 0.75rem !important;
    margin-bottom: 2px;
    color: var(--text-muted) !important;
  }
  
  .profile-info-grid dd {
    font-size: 0.95rem !important;
    margin-bottom: 12px !important;
    font-weight: 500;
  }
  
  /* === VISTA DETALLE OBLIGACIONES === */
  .obligation-detail-grid {
    grid-template-columns: 1fr !important;
  }
  
  .obligation-info-grid {
    grid-template-columns: 1fr !important;
    gap: 4px !important;
  }
  
  .obligation-info-grid > div:nth-child(odd) {
    font-size: 0.75rem !important;
    margin-bottom: 2px;
  }
  
  .obligation-info-grid > div:nth-child(even) {
    font-size: 0.95rem !important;
    margin-bottom: 12px !important;
    font-weight: 500;
  }
}

/* ===========================
   RECURRENCE BUILDER STYLES
   Builder visual para configurar recurrencia
   =========================== */

/* Botones de frecuencia */
.recurrence-frequency-btn {
  background: white;
  border: 2px solid var(--border);
  border-radius: 12px;
  padding: 12px 8px;
  cursor: pointer;
  transition: all 0.2s ease;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 80px;
}

.recurrence-frequency-btn:hover {
  border-color: var(--primary-1);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(108, 99, 255, 0.15);
}

.recurrence-frequency-btn.active {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  border-color: #667eea;
  color: white;
}

/* Tarjetas de opciones */
.recurrence-option-card {
  display: flex;
  gap: 10px;
  padding: 12px;
  border: 2px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
  align-items: flex-start;
}

.recurrence-option-card:hover {
  border-color: var(--primary-1);
  background: rgba(108, 99, 255, 0.03);
}

.recurrence-option-card input[type="radio"] {
  margin-top: 4px;
  cursor: pointer;
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

.recurrence-option-card:has(input[type="radio"]:checked) {
  border-color: var(--primary-1);
  background: rgba(108, 99, 255, 0.05);
}

.recurrence-option-content {
  flex: 1;
}

/* Checkboxes de meses */
.recurrence-month-checkbox {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 10px;
  border: 2px solid var(--border);
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s ease;
  font-size: 0.85rem;
  user-select: none;
}

.recurrence-month-checkbox:hover {
  border-color: var(--primary-1);
  background: rgba(108, 99, 255, 0.03);
}

.recurrence-month-checkbox:has(input:checked) {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  border-color: #667eea;
  color: white;
  font-weight: 600;
}

.recurrence-month-checkbox input {
  margin: 0;
  cursor: pointer;
  width: 16px;
  height: 16px;
}

/* Preview container */
#recurrence-preview {
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.2);
}

/* === RESPONSIVE: MÓVIL === */
@media (max-width: 768px) {
  /* Grid de frecuencia más compacto en móvil */
  .recurrence-frequency-grid {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 8px !important;
  }
  
  .recurrence-frequency-btn {
    padding: 10px 6px !important;
    min-height: 70px !important;
    font-size: 0.85rem !important;
  }
  
  .recurrence-frequency-btn > div:first-child {
    font-size: 1.1rem !important;
  }
  
  /* Tarjetas de opciones más compactas */
  .recurrence-option-card {
    padding: 10px !important;
    gap: 8px !important;
  }
  
  /* Checkboxes de meses 3 columnas en móvil */
  .recurrence-months-grid {
    grid-template-columns: repeat(3, 1fr) !important;
    gap: 6px !important;
  }
  
  .recurrence-month-checkbox {
    padding: 8px 6px !important;
    font-size: 0.8rem !important;
  }
  
  .recurrence-month-checkbox span {
    font-size: 0.8rem !important;
  }
  
  /* Preview más compacto */
  #recurrence-preview {
    padding: 12px !important;
  }
  
  #recurrence-description {
    font-size: 0.9rem !important;
  }
  
  #recurrence-dates {
    font-size: 0.8rem !important;
  }
  
  /* Inputs dentro del builder */
  .recurrence-options input[type="number"],
  .recurrence-options select {
    font-size: 0.9rem !important;
    padding: 6px 8px !important;
  }
}

@media (max-width: 480px) {
  /* En pantallas muy pequeñas, 2 columnas para meses */
  .recurrence-months-grid {
    grid-template-columns: repeat(2, 1fr) !important;
  }
  
  /* Frecuencia 2x2 en pantallas muy pequeñas */
  .recurrence-frequency-grid {
    grid-template-columns: repeat(2, 1fr) !important;
  }
}

/* ===========================
   FILTER BADGE
   Indicador visual de filtro activo en lista de obligaciones
   =========================== */

.filter-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  background: linear-gradient(135deg, var(--primary-1), var(--primary-2));
  color: white;
  border-radius: 20px;
  font-size: 0.875rem;
  font-weight: 500;
  line-height: 1.2;
  box-shadow: 0 2px 8px rgba(108, 99, 255, 0.2);
  animation: slideInFromRight 0.3s ease;
}

.filter-badge-close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  background: rgba(255, 255, 255, 0.2);
  color: white;
  border-radius: 50%;
  font-size: 0.75rem;
  text-decoration: none;
  transition: all 0.2s ease;
  cursor: pointer;
}

.filter-badge-close:hover {
  background: rgba(255, 255, 255, 0.3);
  transform: scale(1.1);
  color: white;
}

.filter-badge-close:active {
  transform: scale(0.95);
}

@keyframes slideInFromRight {
  from {
    opacity: 0;
    transform: translateX(10px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

/* Responsive: badge más pequeño en móviles */
@media (max-width: 768px) {
  .filter-badge {
    font-size: 0.75rem;
    padding: 4px 10px;
    gap: 6px;
  }
  
  .filter-badge-close {
    width: 18px;
    height: 18px;
    font-size: 0.7rem;
  }
}

/* ===========================
   ADMIN - TEMPLATES SECTION
   Estilos para gestión de templates por defecto
   =========================== */

/* === BREADCRUMB === */
.breadcrumb-nav {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 24px;
  padding: 12px 16px;
  background: var(--surface);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  font-size: 0.875rem;
}

.breadcrumb-item {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--text-muted);
  text-decoration: none;
  transition: color 0.2s ease;
}

.breadcrumb-item:hover {
  color: var(--primary-1);
}

.breadcrumb-item.active {
  color: var(--text);
  font-weight: 500;
}

.breadcrumb-icon {
  font-size: 1rem;
}

.breadcrumb-separator {
  color: var(--border);
  font-weight: 300;
}

/* === PAGE HEADER ADMIN === */
.page-header-admin {
  margin-bottom: 32px;
}

.page-header-content {
  display: flex;
  align-items: center;
  gap: 16px;
}

.page-header-icon {
  font-size: 3rem;
  line-height: 1;
}

.page-title-admin {
  font-size: 2.5rem;
  font-weight: 700;
  color: var(--text);
  margin: 0 0 8px 0;
  background: linear-gradient(135deg, var(--primary-1), var(--primary-2));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.page-subtitle-admin {
  font-size: 1rem;
  color: var(--text-muted);
  margin: 0;
  line-height: 1.5;
}

/* === TEMPLATES KPI CARDS === */
.templates-kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 24px;
  margin-bottom: 48px;
}

.templates-kpi-card {
  position: relative;
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 24px;
  background: var(--surface);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  overflow: hidden;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.templates-kpi-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: linear-gradient(90deg, var(--primary-1), var(--primary-2));
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 0.3s ease;
}

.templates-kpi-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-lg);
}

.templates-kpi-card:hover::before {
  transform: scaleX(1);
}

.templates-kpi-icon {
  font-size: 3rem;
  line-height: 1;
  opacity: 0.9;
}

.templates-kpi-content {
  flex: 1;
}

.templates-kpi-label {
  font-size: 0.875rem;
  color: var(--text-muted);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 8px;
}

.templates-kpi-value {
  font-size: 2.5rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1;
  margin-bottom: 12px;
}

.templates-kpi-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.875rem;
  color: var(--primary-1);
  text-decoration: none;
  font-weight: 500;
  transition: all 0.2s ease;
}

.templates-kpi-link:hover {
  gap: 8px;
  color: var(--primary-2);
}

.templates-kpi-link-disabled {
  font-size: 0.875rem;
  color: var(--text-muted);
  font-style: italic;
}

/* Colores específicos para cada card */
.templates-kpi-categories .templates-kpi-icon {
  color: #6C63FF;
}

.templates-kpi-subcategories .templates-kpi-icon {
  color: #FF6B9D;
}

.templates-kpi-providers .templates-kpi-icon {
  color: #16A34A;
}

/* === ADMIN SECTIONS === */
.admin-section {
  background: var(--surface);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  padding: 32px;
  margin-bottom: 32px;
}

.admin-section-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 32px;
  padding-bottom: 20px;
  border-bottom: 2px solid var(--border);
}

.admin-section-title {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text);
  margin: 0 0 8px 0;
}

.admin-section-subtitle {
  font-size: 0.875rem;
  color: var(--text-muted);
  margin: 0;
}

/* === CATEGORIES GRID === */
.templates-categories-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 20px;
}

.template-category-card {
  position: relative;
  display: flex;
  align-items: flex-start;
  gap: 16px;
  padding: 20px;
  background: linear-gradient(135deg, #F7F8FB 0%, #FFFFFF 100%);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  transition: all 0.3s ease;
}

.template-category-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: var(--primary-1);
}

.template-category-inactive {
  opacity: 0.6;
  border-left: 4px solid var(--warning);
}

.template-category-icon {
  font-size: 2.5rem;
  line-height: 1;
  flex-shrink: 0;
}

.template-category-content {
  flex: 1;
  min-width: 0;
}

.template-category-name {
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--text);
  margin: 0 0 8px 0;
}

.template-category-description {
  font-size: 0.875rem;
  color: var(--text-muted);
  line-height: 1.5;
  margin: 0 0 12px 0;
}

.template-category-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.template-category-badge {
  display: inline-block;
  padding: 4px 10px;
  background: var(--pastel-a);
  color: var(--text);
  border-radius: 12px;
  font-size: 0.75rem;
  font-weight: 500;
}

.template-category-badge-warning {
  display: inline-block;
  padding: 4px 10px;
  background: var(--warning);
  color: white;
  border-radius: 12px;
  font-size: 0.75rem;
  font-weight: 500;
}

.template-category-actions {
  flex-shrink: 0;
}

/* === PROVIDERS GRID === */
.templates-providers-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 12px;
}

.template-provider-card {
  padding: 12px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  transition: all 0.2s ease;
}

.template-provider-card:hover {
  border-color: var(--primary-1);
  box-shadow: var(--shadow-sm);
}

.template-provider-inactive {
  opacity: 0.5;
}

.template-provider-name {
  font-weight: 500;
  color: var(--text);
  font-size: 0.9rem;
  margin-bottom: 4px;
}

.template-provider-category {
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* === EMPTY STATE === */
.empty-state {
  text-align: center;
  padding: 60px 24px;
}

.empty-state-icon {
  font-size: 4rem;
  margin-bottom: 16px;
  opacity: 0.5;
}

.empty-state-title {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--text);
  margin: 0 0 8px 0;
}

.empty-state-text {
  font-size: 0.875rem;
  color: var(--text-muted);
  margin: 0;
}

/* === INFO CARD === */
.info-card {
  display: flex;
  gap: 20px;
  padding: 24px;
  background: linear-gradient(135deg, #EEF2FF 0%, #E0E7FF 100%);
  border: 1px solid #C7D2FE;
  border-left: 4px solid var(--info);
  border-radius: var(--radius-md);
  margin-top: 32px;
}

.info-card-icon {
  font-size: 2rem;
  line-height: 1;
  flex-shrink: 0;
}

.info-card-content {
  flex: 1;
}

.info-card-title {
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--text);
  margin: 0 0 12px 0;
}

.info-card-list {
  margin: 0;
  padding-left: 20px;
}

.info-card-list li {
  margin-bottom: 8px;
  color: var(--text);
  line-height: 1.6;
}

.info-card-list li:last-child {
  margin-bottom: 0;
}

/* === RESPONSIVE === */
@media (max-width: 768px) {
  .page-header-content {
    flex-direction: column;
    align-items: flex-start;
  }
  
  .page-header-icon {
    font-size: 2rem;
  }
  
  .page-title-admin {
    font-size: 1.75rem;
  }
  
  .page-subtitle-admin {
    font-size: 0.875rem;
  }
  
  .templates-kpi-grid {
    grid-template-columns: 1fr;
  }
  
  .admin-section {
    padding: 20px;
  }
  
  .admin-section-header {
    flex-direction: column;
    gap: 16px;
  }
  
  .templates-categories-grid {
    grid-template-columns: 1fr;
  }
  
  .templates-providers-grid {
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  }
  
  .info-card {
    flex-direction: column;
  }
}

/* ========================================
   PAYMENT HISTORY PAGE
   ======================================== */

/* Tabla de pagos - efecto hover */
.payments-table-desktop .table tbody tr:hover {
  background: rgba(99, 102, 241, 0.04);
  transform: scale(1.001);
}

.payments-table-desktop .table tbody tr a:hover {
  color: var(--primary-hover) !important;
  text-decoration: underline;
}

/* Mobile: ocultar tabla, mostrar cards */
@media (max-width: 768px) {
  .payments-table-desktop {
    display: none;
  }
  
  .payments-cards-mobile {
    display: block;
  }
}

/* Desktop: mostrar tabla, ocultar cards */
@media (min-width: 769px) {
  .payments-table-desktop {
    display: block;
  }
  
  .payments-cards-mobile {
    display: none;
  }
}

/* ========================================
   MEJORAS VISUALES DE TABLAS (v1.25.1)
   ======================================== */

/* Estilos mejorados para todas las tablas de datos */
.data-table {
  width: 100%;
  border-collapse: collapse;
}

/* Header de tabla */
.data-table thead tr {
  border-bottom: 2px solid var(--border);
}

.data-table thead th {
  padding: 12px;
  text-align: left;
  font-weight: 600;
  color: var(--text-muted);
  font-size: 0.875rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  background: var(--bg);
}

/* Filas del body - padding reducido */
.data-table tbody tr {
  border-bottom: 1px solid var(--gray-100);
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
}

.data-table tbody td {
  padding: 12px; /* Reducido de 16px a 12px */
  vertical-align: middle;
}

/* Hover effect elegante */
.data-table tbody tr:hover {
  background: rgba(99, 102, 241, 0.04);
  transform: scale(1.001);
  box-shadow: inset 3px 0 0 0 var(--primary-1);
}

/* Links dentro de tablas */
.data-table tbody tr a {
  color: var(--primary-1);
  text-decoration: none;
  font-weight: 600;
  transition: all 0.2s ease;
}

.data-table tbody tr a:hover {
  color: var(--primary-2);
  text-decoration: underline;
}

/* Badges y estados */
.data-table .badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 12px;
  font-size: 0.75rem;
  font-weight: 600;
  transition: all 0.2s ease;
}

/* Iconos en celdas */
.data-table svg {
  transition: transform 0.2s ease;
}

.data-table tbody tr:hover svg {
  transform: scale(1.05);
}

/* Aplicar estilos a tablas específicas */
.providers-table-desktop table,
.obligations-table-desktop table,
.categories-table-desktop table,
.payments-table-desktop table {
  width: 100%;
  border-collapse: collapse;
}

/* Headers específicos */
.providers-table-desktop thead tr,
.obligations-table-desktop thead tr,
.categories-table-desktop thead tr,
.payments-table-desktop thead tr {
  border-bottom: 2px solid var(--border);
}

.providers-table-desktop thead th,
.obligations-table-desktop thead th,
.categories-table-desktop thead th,
.payments-table-desktop thead th {
  padding: 12px;
  text-align: left;
  font-weight: 600;
  color: var(--text-muted);
  font-size: 0.875rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  background: var(--bg);
}

/* Body específicos - padding reducido */
.providers-table-desktop tbody tr,
.obligations-table-desktop tbody tr,
.categories-table-desktop tbody tr,
.payments-table-desktop tbody tr {
  border-bottom: 1px solid var(--gray-100);
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
}

.providers-table-desktop tbody td,
.obligations-table-desktop tbody td,
.categories-table-desktop tbody td,
.payments-table-desktop tbody td {
  padding: 12px; /* Reducido de 16px */
}

/* Hover effect para todas las tablas */
.providers-table-desktop tbody tr:hover,
.obligations-table-desktop tbody tr:hover,
.categories-table-desktop tbody tr:hover,
.payments-table-desktop tbody tr:hover {
  background: rgba(99, 102, 241, 0.04);
  transform: scale(1.001);
  box-shadow: inset 3px 0 0 0 var(--primary-1);
}

/* Links en tablas */
.providers-table-desktop tbody tr a,
.obligations-table-desktop tbody tr a,
.categories-table-desktop tbody tr a,
.payments-table-desktop tbody tr a {
  color: var(--primary-1);
  text-decoration: none;
  font-weight: 600;
  transition: all 0.2s ease;
}

.providers-table-desktop tbody tr a:hover,
.obligations-table-desktop tbody tr a:hover,
.categories-table-desktop tbody tr a:hover,
.payments-table-desktop tbody tr a:hover {
  color: var(--primary-2);
  text-decoration: underline;
}

/* Iconos en tablas - efecto sutil */
.providers-table-desktop tbody tr:hover svg,
.obligations-table-desktop tbody tr:hover svg,
.categories-table-desktop tbody tr:hover svg,
.payments-table-desktop tbody tr:hover svg {
  transform: scale(1.05);
}


