/**
 * =====================================================
 * INVERSIONES MG - OBLIGACIONES PREMIUM
 * Diseño tipo App Bancaria Nativa
 * Mobile-First: 360px+
 * =====================================================
 */

/* =====================================================
   1. HEADER DE PÁGINA
   ===================================================== */

.obligaciones-header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: white;
  border-bottom: 1px solid var(--corp-gray-200);
  margin-left: calc(var(--space-4) * -1);
  margin-right: calc(var(--space-4) * -1);
  margin-top: calc(var(--space-5) * -1);
  margin-bottom: var(--space-5);
  padding: var(--space-5) var(--space-4);
  box-shadow: 0 1px 3px 0 rgb(0 0 0 / 0.03);
  width: calc(100% + var(--space-4) * 2);
  box-sizing: border-box;
}

.obligaciones-header-content {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  max-width: 1200px;
  margin: 0 auto;
}

.obligaciones-header-text {
  flex: 1;
  min-width: 0;
}

.obligaciones-title {
  font-size: var(--text-2xl);
  font-weight: var(--font-bold);
  color: var(--corp-gray-900);
  margin: 0 0 var(--space-1) 0;
  line-height: 1.2;
}

.obligaciones-subtitle {
  font-size: var(--text-sm);
  color: var(--corp-gray-600);
  margin: 0;
  line-height: 1.4;
}

.btn-nueva-obligacion {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-5);
  background: var(--corp-primary);
  color: white;
  border: none;
  border-radius: var(--radius-full);
  font-size: var(--text-base);
  font-weight: var(--font-semibold);
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 2px 8px rgb(30 64 175 / 0.2);
  flex-shrink: 0;
}

.btn-nueva-obligacion:hover {
  background: var(--corp-primary-dark);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgb(30 64 175 / 0.3);
}

.btn-nueva-obligacion:active {
  transform: translateY(0);
  box-shadow: 0 1px 4px rgb(30 64 175 / 0.2);
}

.btn-nueva-icon {
  font-size: var(--text-xl);
  line-height: 1;
}

/* =====================================================
   2. FILTROS (CHIPS)
   ===================================================== */

.obligaciones-filters {
  display: flex;
  gap: var(--space-2);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  padding: 0 var(--space-4);
  margin-left: calc(var(--space-4) * -1);
  margin-right: calc(var(--space-4) * -1);
  margin-bottom: var(--space-5);
  scrollbar-width: none;
  scroll-padding: var(--space-4);
  width: calc(100% + var(--space-4) * 2);
  box-sizing: border-box;
}

.obligaciones-filters::-webkit-scrollbar {
  display: none;
}

.filter-chip {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-4);
  background: white;
  border: 2px solid var(--corp-gray-200);
  border-radius: var(--radius-full);
  font-size: var(--text-sm);
  font-weight: var(--font-medium);
  color: var(--corp-gray-700);
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.filter-chip:hover {
  border-color: var(--corp-primary-light);
  color: var(--corp-primary);
  transform: translateY(-1px);
}

.filter-chip.active {
  background: var(--corp-primary);
  border-color: var(--corp-primary);
  color: white;
  box-shadow: 0 2px 8px rgb(30 64 175 / 0.2);
}

.filter-chip-icon {
  font-size: var(--text-base);
  line-height: 1;
}

.filter-chip-text {
  line-height: 1;
}

/* =====================================================
   3. LISTA DE OBLIGACIONES
   ===================================================== */

.obligaciones-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  animation: oblListEnter 0.5s ease;
}

@keyframes oblListEnter {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* =====================================================
   4. CARD DE OBLIGACIÓN (PREMIUM)
   ===================================================== */

.obl-card {
  background: white;
  border-radius: var(--radius-xl);
  padding: var(--space-5);
  border: 1px solid var(--corp-gray-200);
  box-shadow: 0 2px 8px rgb(0 0 0 / 0.04);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  animation: oblCardEnter 0.5s ease backwards;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  overflow: hidden;
}

.obl-card:nth-child(1) { animation-delay: 0.05s; }
.obl-card:nth-child(2) { animation-delay: 0.1s; }
.obl-card:nth-child(3) { animation-delay: 0.15s; }
.obl-card:nth-child(4) { animation-delay: 0.2s; }
.obl-card:nth-child(5) { animation-delay: 0.25s; }

@keyframes oblCardEnter {
  from {
    opacity: 0;
    transform: translateY(20px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.obl-card:hover {
  box-shadow: 0 8px 24px rgb(0 0 0 / 0.08);
  transform: translateY(-2px);
}

.obl-card:active {
  transform: translateY(-1px);
}

/* Header de Card */
.obl-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-3);
  margin-bottom: var(--space-4);
}

.obl-card-header-left {
  flex: 1;
  min-width: 0;
}

.obl-card-title {
  font-size: var(--text-lg);
  font-weight: var(--font-bold);
  color: var(--corp-gray-900);
  margin: 0 0 var(--space-1) 0;
  line-height: 1.3;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
}

.obl-card-subtitle {
  font-size: var(--text-sm);
  color: var(--corp-gray-600);
  margin: 0;
  line-height: 1.4;
}

.obl-card-header-right {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex-shrink: 0;
}

/* Tipo Chip */
.obl-type-chip {
  display: inline-flex;
  align-items: center;
  padding: var(--space-1) var(--space-3);
  border-radius: var(--radius-full);
  font-size: var(--text-xs);
  font-weight: var(--font-semibold);
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.obl-type-prestamo {
  background: #dbeafe;
  color: #1e40af;
}

.obl-type-producto {
  background: #e9d5ff;
  color: #6b21a8;
}

/* Menú Button */
.obl-menu-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  padding: 0;
  background: transparent;
  border: none;
  border-radius: var(--radius-md);
  color: var(--corp-gray-600);
  cursor: pointer;
  transition: all 0.2s ease;
}

.obl-menu-btn:hover {
  background: var(--corp-gray-100);
  color: var(--corp-gray-900);
}

.obl-menu-btn:active {
  background: var(--corp-gray-200);
}

/* Monto Hero */
.obl-card-hero {
  margin-bottom: var(--space-5);
  padding: var(--space-4);
  background: linear-gradient(135deg, var(--corp-primary-bg) 0%, white 100%);
  border-radius: var(--radius-lg);
  border: 1px solid var(--corp-primary-bg);
}

.obl-hero-amount {
  font-size: 2rem;
  font-weight: var(--font-bold);
  color: var(--corp-primary);
  margin: 0 0 var(--space-1) 0;
  line-height: 1.1;
  letter-spacing: -0.02em;
}

.obl-hero-label {
  font-size: var(--text-xs);
  font-weight: var(--font-medium);
  color: var(--corp-gray-600);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin: 0;
}

/* Grid de Información */
.obl-info-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--space-3);
  margin-bottom: var(--space-4);
}

.obl-info-item {
  display: flex;
  align-items: flex-start;
  gap: var(--space-2);
  padding: var(--space-3);
  background: var(--corp-gray-50);
  border-radius: var(--radius-md);
  transition: background 0.2s ease;
}

.obl-info-item:hover {
  background: var(--corp-gray-100);
}

.obl-info-icon {
  font-size: var(--text-lg);
  line-height: 1;
  flex-shrink: 0;
}

.obl-info-content {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}

.obl-info-label {
  font-size: 0.688rem;
  font-weight: var(--font-medium);
  color: var(--corp-gray-600);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  line-height: 1.2;
}

.obl-info-value {
  font-size: var(--text-sm);
  font-weight: var(--font-bold);
  color: var(--corp-gray-900);
  line-height: 1.3;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Badges de Estado */
.obl-badge {
  display: inline-flex;
  align-items: center;
  padding: var(--space-1) var(--space-2);
  border-radius: var(--radius-sm);
  font-size: 0.688rem;
  font-weight: var(--font-bold);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  line-height: 1;
}

.obl-badge-success {
  background: var(--corp-success-light);
  color: var(--corp-success);
}

.obl-badge-danger {
  background: var(--corp-danger-light);
  color: var(--corp-danger);
}

.obl-badge-neutral {
  background: var(--corp-gray-200);
  color: var(--corp-gray-700);
}

/* Barra de Progreso */
.obl-progress-container {
  margin-bottom: var(--space-4);
}

.obl-progress-bar {
  width: 100%;
  height: 8px;
  background: var(--corp-gray-200);
  border-radius: var(--radius-full);
  overflow: hidden;
  margin-bottom: var(--space-2);
}

.obl-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--corp-primary) 0%, var(--corp-primary-light) 100%);
  border-radius: var(--radius-full);
  transition: width 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

.obl-progress-text {
  font-size: var(--text-xs);
  color: var(--corp-gray-600);
  text-align: center;
  line-height: 1.4;
}

/* Acciones de Card */
.obl-card-actions {
  display: flex;
  gap: var(--space-2);
  padding-top: var(--space-4);
  border-top: 1px solid var(--corp-gray-200);
}

.obl-btn {
  flex: 1;
  padding: var(--space-3) var(--space-4);
  border: none;
  border-radius: var(--radius-md);
  font-size: var(--text-base);
  font-weight: var(--font-semibold);
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  min-height: 44px;
}

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

.obl-btn-primary:hover {
  background: var(--corp-primary-dark);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgb(30 64 175 / 0.2);
}

.obl-btn-primary:active {
  transform: translateY(0);
}

.obl-btn-secondary {
  background: white;
  color: var(--corp-gray-700);
  border: 2px solid var(--corp-gray-300);
}

.obl-btn-secondary:hover {
  background: var(--corp-gray-50);
  border-color: var(--corp-gray-400);
  transform: translateY(-1px);
}

.obl-btn-secondary:active {
  transform: translateY(0);
  background: var(--corp-gray-100);
}

/* =====================================================
   5. BOTTOM SHEET (MÓVIL)
   ===================================================== */

.obl-bottom-sheet-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  width: 100%;
  height: 100%;
  max-width: 100vw;
  background: rgba(0, 0, 0, 0);
  z-index: var(--z-modal);
  display: flex;
  align-items: flex-end;
  transition: background 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  box-sizing: border-box;
}

.obl-bottom-sheet-overlay.active {
  background: rgba(0, 0, 0, 0.5);
}

.obl-bottom-sheet {
  width: 100%;
  max-width: 100%;
  max-height: 80vh;
  background: white;
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  padding: var(--space-5) 0;
  transform: translateY(100%);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  overflow-y: auto;
  overflow-x: hidden;
  box-shadow: 0 -4px 24px rgb(0 0 0 / 0.15);
  box-sizing: border-box;
}

.obl-bottom-sheet-overlay.active .obl-bottom-sheet {
  transform: translateY(0);
}

.obl-bottom-sheet-handle {
  width: 40px;
  height: 4px;
  background: var(--corp-gray-300);
  border-radius: var(--radius-full);
  margin: 0 auto var(--space-4);
}

.obl-bottom-sheet-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--space-5) var(--space-4);
  border-bottom: 1px solid var(--corp-gray-200);
  margin-bottom: var(--space-4);
}

.obl-bottom-sheet-header h3 {
  font-size: var(--text-lg);
  font-weight: var(--font-bold);
  color: var(--corp-gray-900);
  margin: 0;
}

.obl-bottom-sheet-close {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  padding: 0;
  background: transparent;
  border: none;
  border-radius: var(--radius-md);
  color: var(--corp-gray-600);
  cursor: pointer;
  transition: all 0.2s ease;
}

.obl-bottom-sheet-close:hover {
  background: var(--corp-gray-100);
  color: var(--corp-gray-900);
}

.obl-bottom-sheet-content {
  padding: 0 var(--space-5);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.obl-bottom-sheet-btn {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-4);
  background: white;
  border: 1px solid var(--corp-gray-200);
  border-radius: var(--radius-lg);
  cursor: pointer;
  transition: all 0.2s ease;
  text-align: left;
  width: 100%;
}

.obl-bottom-sheet-btn:hover {
  background: var(--corp-gray-50);
  border-color: var(--corp-gray-300);
}

.obl-bottom-sheet-btn:active {
  background: var(--corp-gray-100);
}

.obl-bottom-sheet-btn-icon {
  font-size: 1.5rem;
  line-height: 1;
  flex-shrink: 0;
}

.obl-bottom-sheet-btn-content {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}

.obl-bottom-sheet-btn-title {
  font-size: var(--text-base);
  font-weight: var(--font-semibold);
  color: var(--corp-gray-900);
  line-height: 1.3;
}

.obl-bottom-sheet-btn-subtitle {
  font-size: var(--text-sm);
  color: var(--corp-gray-600);
  line-height: 1.4;
}

.obl-bottom-sheet-btn-danger {
  border-color: var(--corp-danger-light);
}

.obl-bottom-sheet-btn-danger:hover {
  background: var(--corp-danger-light);
  border-color: var(--corp-danger);
}

.obl-bottom-sheet-btn-danger .obl-bottom-sheet-btn-title {
  color: var(--corp-danger);
}

.obl-bottom-sheet-divider {
  height: 1px;
  background: var(--corp-gray-200);
  margin: var(--space-3) 0;
}

/* =====================================================
   6. RESPONSIVIDAD
   ===================================================== */

/* 360px - iPhone SE, Galaxy pequeños */
@media (max-width: 374px) {
  .obligaciones-title {
    font-size: var(--text-xl);
  }
  
  .btn-nueva-text {
    display: none;
  }
  
  .btn-nueva-obligacion {
    padding: var(--space-3);
    width: 44px;
    height: 44px;
  }
  
  .obl-hero-amount {
    font-size: 1.75rem;
  }
  
  .obl-info-grid {
    grid-template-columns: 1fr;
  }
}

/* 375px - 411px - iPhones, Pixels */
@media (min-width: 375px) and (max-width: 411px) {
  .obligaciones-header {
    padding: var(--space-4);
  }
}

/* 768px+ - Tablets */
@media (min-width: 768px) {
  .obligaciones-list {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: var(--space-5);
  }
  
  .obligaciones-header {
    margin-left: calc(var(--space-5) * -1);
    margin-right: calc(var(--space-5) * -1);
    padding: var(--space-6) var(--space-5);
    width: calc(100% + var(--space-5) * 2);
  }
  
  .obligaciones-filters {
    padding: 0 var(--space-5);
    margin-left: calc(var(--space-5) * -1);
    margin-right: calc(var(--space-5) * -1);
    margin-bottom: var(--space-6);
    width: calc(100% + var(--space-5) * 2);
  }
  
  .obl-info-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* 1024px+ - Desktop */
@media (min-width: 1024px) {
  .obligaciones-list {
    grid-template-columns: repeat(2, 1fr);
  }
  
  .obl-info-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* 1280px+ - Desktop grande */
@media (min-width: 1280px) {
  .obligaciones-list {
    grid-template-columns: repeat(3, 1fr);
  }
}

/* =====================================================
   7. ANIMACIONES ADICIONALES
   ===================================================== */

@keyframes shimmer {
  0% {
    background-position: -1000px 0;
  }
  100% {
    background-position: 1000px 0;
  }
}

/* Loading state para cards */
.obl-card-loading {
  background: linear-gradient(
    90deg,
    var(--corp-gray-100) 25%,
    var(--corp-gray-200) 50%,
    var(--corp-gray-100) 75%
  );
  background-size: 1000px 100%;
  animation: shimmer 2s infinite;
}

/* =====================================================
   8. ESTADOS VACÍOS Y MENSAJES
   ===================================================== */

.obl-empty-state {
  text-align: center;
  padding: var(--space-12) var(--space-4);
}

.obl-empty-icon {
  font-size: 4rem;
  margin-bottom: var(--space-4);
  opacity: 0.5;
}

.obl-empty-title {
  font-size: var(--text-xl);
  font-weight: var(--font-bold);
  color: var(--corp-gray-900);
  margin: 0 0 var(--space-2) 0;
}

.obl-empty-text {
  font-size: var(--text-base);
  color: var(--corp-gray-600);
  margin: 0;
}

/* =====================================================
   9. ACCESIBILIDAD
   ===================================================== */

@media (prefers-reduced-motion: reduce) {
  .obl-card,
  .filter-chip,
  .obl-btn,
  .obl-bottom-sheet,
  .obl-bottom-sheet-overlay {
    animation: none;
    transition: none;
  }
  
  .obl-progress-fill {
    transition: none;
  }
}

/* Focus visible para teclado */
.filter-chip:focus-visible,
.obl-btn:focus-visible,
.obl-menu-btn:focus-visible,
.obl-bottom-sheet-btn:focus-visible {
  outline: 2px solid var(--corp-primary);
  outline-offset: 2px;
}
