/* ================================================
   GESTIÓN DE PRODUCTOS - MODAL UX V2
   Sistema de tabs progresivos con validación
   ================================================ */

/* ========================================
   MODAL BASE
   ======================================== */
/* Scoped a #modal-producto-backdrop para no chocar con otras modales
   que usan `.tv-modal-backdrop` + toggle `.hidden` (ej. elaborados-recetas). */
#modal-producto-backdrop.tv-modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.5);
  backdrop-filter: blur(4px);
  display: none;
  align-items: flex-start; /* ✅ CRÍTICO: flex-start evita centrado que clipea */
  justify-content: center;
  z-index: 9999;
  padding: 0.5rem;
  overflow-y: auto;
  overflow-x: hidden;
}

#modal-producto-backdrop.tv-modal-backdrop.is-open {
  display: flex;
}

/* ========================================
   FIX: Lock background scroll sin clipear el modal
   ----------------------------------------
   IMPORTANTE: El modal se mueve a document.body (portal)
   para evitar clipping por overflow/transform en #main-content.
   Solo bloqueamos el scroll del body, NO del main.
   ======================================== */
body.tv-modal-open {
  overflow: hidden;
}

body.tv-modal-open #main-content {
  transform: none !important;
}

/* ❌ ELIMINADO: overflow: hidden en main causaba clipping del modal
   body.tv-modal-open #main-content > main {
     overflow: hidden;
   }
   El modal ahora vive en document.body (portal), por lo que
   este bloqueo no es necesario y causaba corte en laptops pequeñas.
*/

/* ========================================
   FIX: Ajustes para laptops altura media (ej: 1440×900)
   ----------------------------------------
   Se activa para pantallas hasta 920px de altura.
   ======================================== */
@media (max-height: 920px) {
  #modal-producto-backdrop.tv-modal-backdrop {
    align-items: flex-start;
    padding: 0.5rem;
  }

  .tv-modal {
    max-height: calc(100vh - 1rem);
  }

  .modal-header {
    padding: 0.875rem 1.25rem;
  }

  .modal-tabs {
    padding: 0 0.875rem;
  }

  .modal-body {
    padding: 0.875rem 1.25rem 0.5rem 1.25rem;
    overflow-y: auto;
    overflow-x: hidden;
  }

  .modal-footer {
    padding: 0.75rem 1.25rem;
    min-height: 70px;
  }

  .field-group {
    margin-bottom: 1rem;
    padding-bottom: 1rem;
  }

  .field-group:last-child {
    padding-bottom: 0.25rem;
  }

  .conversion-intro,
  .provider-intro {
    padding: 0.875rem;
    margin-bottom: 0.875rem;
  }

  .conversion-item {
    padding: 0.875rem 1rem;
    margin-bottom: 0.625rem;
  }

  .tab-footer {
    margin-top: 1rem;
    padding: 0.875rem 0 0.375rem 0;
  }
}

/* ========================================
   FIX: Ajustes AGRESIVOS para laptops con muy poca altura (ej: 1366×768)
   ----------------------------------------
   CRÍTICO para laptops como 1366×758px.
   Reduce padding/margins de forma más extrema.
   ======================================== */
@media (max-height: 820px) {
  #modal-producto-backdrop.tv-modal-backdrop {
    padding: 0.25rem;
  }

  .tv-modal {
    max-height: calc(100vh - 0.5rem);
  }

  .modal-header {
    padding: 0.75rem 1rem;
  }

  .modal-tabs {
    padding: 0 0.75rem;
  }

  .modal-body {
    padding: 0.75rem 1rem 0.5rem 1rem;
    overflow-y: auto;
    overflow-x: hidden;
  }

  .modal-footer {
    padding: 0.625rem 1rem;
    min-height: 60px;
  }

  /* Reducir spacing en field-groups para pantallas muy bajas */
  .field-group {
    margin-bottom: 0.875rem;
    padding-bottom: 0.875rem;
  }

  .field-group:last-child {
    padding-bottom: 0.125rem;
  }

  /* Reducir spacing en conversiones/provider cards */
  .conversion-intro,
  .provider-intro {
    padding: 0.75rem;
    margin-bottom: 0.75rem;
  }

  .conversion-item {
    padding: 0.75rem 0.875rem;
    margin-bottom: 0.5rem;
  }

  .tab-footer {
    margin-top: 0.875rem;
    padding: 0.75rem 0 0.25rem 0;
  }
}

.tv-modal {
  background: #fff;
  border-radius: 20px;
  box-shadow: 0 20px 60px rgba(15, 23, 42, 0.3);
  width: 100%;
  max-width: min(980px, calc(100vw - 2rem));
  max-height: calc(100vh - 2rem);
  display: flex;
  flex-direction: column;
  position: relative;
  animation: modalSlideIn 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  overflow: hidden;
  min-height: 0;
}

/* Ensure modal form doesn't inherit global form padding/gaps (prevents footer clipping). */
#form-producto {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  gap: 0;
  padding: 0;
  margin: 0;
}

/* Override legacy inline modal rules so the flex layout & scroll work in all breakpoints. */
body .tv-modal {
  display: flex;
  flex-direction: column;
  padding: 0;
  overflow: hidden;
  max-height: calc(100vh - 2rem);
}

body #modal-producto-backdrop.tv-modal-backdrop {
  z-index: 9999;
}

@keyframes modalSlideIn {
  from {
    opacity: 0;
    transform: translateY(-20px) scale(0.96);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* ========================================
   MODAL HEADER (Contextual)
   ======================================== */
.modal-header {
  padding: 1.5rem 1.75rem;
  border-bottom: 2px solid var(--neutral-200);
  background: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
  flex-shrink: 0;
}

.modal-breadcrumb {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.813rem;
  color: var(--neutral-700);
  margin-bottom: 0.5rem;
}

.modal-breadcrumb .muted {
  opacity: 0.7;
}

.modal-breadcrumb .chevron {
  width: 12px;
  height: 12px;
  color: var(--neutral-400);
}

.modal-breadcrumb .current {
  font-weight: 700;
  color: var(--neutral-900);
}

.modal-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.375rem 0.75rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.025em;
  border: 1px solid transparent;
}

.badge-primary {
  background: var(--primary-50);
  color: var(--primary-500);
  border-color: rgba(98, 115, 255, 0.2);
}

.badge-success {
  background: var(--ok-50);
  color: var(--ok-600);
  border-color: #bbf7d0;
}

.badge-info {
  background: #eff6ff;
  color: #3b82f6;
  border-color: #bfdbfe;
}

.badge-warning {
  background: var(--warn-50);
  color: var(--warn-600);
  border-color: #fde68a;
}

.badge-sm {
  padding: 0.25rem 0.5rem;
  font-size: 0.688rem;
}

.modal-header h2 {
  margin: 0;
  font-size: 1.5rem;
  font-weight: 900;
  color: var(--neutral-900);
}

.modal-subtitle {
  margin: 0.5rem 0 0;
  font-size: 0.875rem;
  color: var(--neutral-700);
  line-height: 1.5;
}

.modal-subtitle a {
  color: var(--primary-500);
  text-decoration: none;
  font-weight: 600;
}

.modal-subtitle a:hover {
  text-decoration: underline;
}

/* ========================================
   MODAL TABS
   ======================================== */
.modal-tabs {
  display: flex;
  gap: 0.25rem;
  padding: 0 1.5rem;
  background: #fff;
  border-bottom: 2px solid var(--neutral-200);
  overflow-x: auto;
  flex-shrink: 0;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

.modal-tabs::-webkit-scrollbar {
  display: none;
}

.tab-btn {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  padding: 0.875rem 1.25rem;
  border: none;
  background: transparent;
  color: var(--neutral-700);
  font-weight: 700;
  font-size: 0.875rem;
  cursor: pointer;
  border-bottom: 3px solid transparent;
  transition: all 0.2s ease;
  white-space: nowrap;
  position: relative;
  flex-shrink: 0;
}

.tab-btn:hover:not(:disabled) {
  color: var(--primary-500);
  background: var(--primary-50);
}

.tab-btn.active {
  color: var(--primary-500);
  border-bottom-color: var(--primary-500);
  background: linear-gradient(180deg, transparent 0%, var(--primary-50) 100%);
}

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

.tab-number {
  width: 1.75rem;
  height: 1.75rem;
  border-radius: 50%;
  background: var(--neutral-200);
  color: var(--neutral-700);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.813rem;
  font-weight: 900;
  transition: all 0.2s ease;
  flex-shrink: 0;
}

.tab-btn.active .tab-number {
  background: var(--primary-500);
  color: #fff;
}

.tab-btn:disabled .tab-number {
  background: var(--neutral-100);
}

.tab-label {
  flex: 1;
}

.tab-status {
  font-size: 1rem;
  line-height: 1;
}

.tab-status.status-complete {
  color: var(--ok-600);
}

.tab-status.status-incomplete {
  color: var(--warn-600);
}

.tab-status.status-error {
  color: var(--err-600);
}

.tab-status.status-warning {
  color: var(--warn-600);
}

.tab-status.status-disabled {
  color: var(--neutral-400);
}

/* ========================================
   MODAL BODY & TAB CONTENT
   ======================================== */
.modal-body {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 1.75rem 1.75rem 1.25rem 1.75rem; /* Reducido padding inferior */
  background: #fff;
  min-height: 0; /* Permite que flex funcione correctamente */
  overscroll-behavior: contain; /* Evita scroll del background cuando se llega al límite */
}

.tab-content {
  display: none;
  animation: fadeIn 0.25s ease;
}

.tab-content.active {
  display: block;
}

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

/* ========================================
   FIELD GROUPS
   ======================================== */
.field-group {
  margin-bottom: 1.75rem; /* Reducido de 2rem */
  padding-bottom: 1.75rem; /* Reducido de 2rem */
  border-bottom: 1px solid var(--neutral-200);
}

.field-group:last-child {
  border-bottom: none;
  margin-bottom: 0;
  padding-bottom: 0.5rem; /* Pequeño padding para evitar corte visual */
}

.field-group-title {
  margin: 0 0 0.5rem;
  font-size: 1.125rem;
  font-weight: 800;
  color: var(--neutral-900);
}

.field-group-description {
  margin: 0 0 1.25rem;
  font-size: 0.875rem;
  color: var(--neutral-700);
  line-height: 1.6;
}

/* ========================================
   FIELDS
   ======================================== */
.field {
  margin-bottom: 1.25rem;
}

.field:last-child {
  margin-bottom: 0;
}

.field-row {
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(12, 1fr);
  min-width: 0; /* FIX: Evita overflow horizontal en grids flex */
}

.field-row .field {
  margin-bottom: 0;
}

.field-12 {
  grid-column: span 12;
}

.field-6 {
  grid-column: span 6;
}

.field-4 {
  grid-column: span 4;
}

.field-3 {
  grid-column: span 3;
}

@media (max-width: 768px) {
  .field-6,
  .field-4,
  .field-3 {
    grid-column: span 12;
  }
}

.label {
  display: block;
  font-size: 0.813rem;
  font-weight: 700;
  color: var(--neutral-700);
  margin-bottom: 0.5rem;
}

.required {
  color: var(--err-600);
  margin-left: 0.25rem;
}

.input,
.select {
  width: 100%;
  height: 48px;
  border: 1.5px solid var(--neutral-200);
  border-radius: 12px;
  padding: 0 1rem;
  background: #fff;
  color: var(--neutral-900);
  outline: none;
  transition: all 0.2s ease;
  font-size: 0.938rem;
  font-family: inherit;
}

.input:focus,
.select:focus {
  border-color: var(--primary-500);
  box-shadow: 0 0 0 4px var(--primary-50);
}

.input:disabled,
.select:disabled {
  background: var(--neutral-50);
  color: var(--neutral-700);
  cursor: not-allowed;
  opacity: 0.6;
}

.input-sm {
  height: 40px;
  font-size: 0.875rem;
}

.input-group {
  display: flex;
  gap: 0.5rem;
}

.select-addon {
  width: auto;
  min-width: 100px;
}

textarea.input {
  height: auto;
  min-height: 80px;
  padding: 0.75rem 1rem;
  resize: vertical;
}

.field-hint {
  margin-top: 0.5rem;
  font-size: 0.813rem;
  color: var(--neutral-700);
  line-height: 1.5;
}

.field-hint b {
  font-weight: 700;
  color: var(--neutral-900);
}

/* ========================================
   RADIO GROUPS
   ======================================== */
.radio-group {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.radio-option {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 1rem;
  border: 1.5px solid var(--neutral-200);
  border-radius: 12px;
  background: #fff;
  cursor: pointer;
  transition: all 0.2s ease;
}

.radio-option:hover {
  border-color: var(--primary-500);
  background: var(--primary-50);
}

.radio-option input[type="radio"] {
  margin-top: 0.125rem;
  flex-shrink: 0;
  cursor: pointer;
}

.radio-option input[type="radio"]:checked ~ .radio-content {
  color: var(--primary-500);
}

.radio-content {
  flex: 1;
}

.radio-content strong {
  display: block;
  font-size: 0.938rem;
  font-weight: 700;
  margin-bottom: 0.25rem;
}

.radio-content small {
  display: block;
  font-size: 0.813rem;
  color: var(--neutral-700);
}

/* ========================================
   CHECKBOX
   ======================================== */
.checkbox-label {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 0.875rem 1rem;
  border: 1.5px solid var(--neutral-200);
  border-radius: 12px;
  background: #fff;
  cursor: pointer;
  transition: all 0.2s ease;
}

.checkbox-label:hover {
  border-color: var(--primary-500);
  background: var(--primary-50);
}

.checkbox-label input[type="checkbox"] {
  margin-top: 0.125rem;
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  cursor: pointer;
}

.checkbox-label > div {
  flex: 1;
}

.checkbox-label strong {
  display: block;
  font-size: 0.938rem;
  font-weight: 700;
  margin-bottom: 0.25rem;
}

.checkbox-label small {
  display: block;
  font-size: 0.813rem;
  color: var(--neutral-700);
}

/* ========================================
   PRESENTACIONES MANAGER
   ======================================== */
.presentaciones-manager {
  border: 1.5px solid var(--neutral-200);
  border-radius: 14px;
  padding: 1rem;
  background: #fff;
}

.chips-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  min-height: 48px;
  align-items: center;
  margin-bottom: 1rem;
}

.chip-edit {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.5rem 0.625rem;
  border-radius: 999px;
  font-size: 0.813rem;
  font-weight: 700;
  background: var(--primary-50);
  color: var(--primary-500);
  border: 1px solid rgba(98, 115, 255, 0.3);
}

.chip-label {
  flex: 1;
}

.chip-remove {
  border: none;
  background: transparent;
  cursor: pointer;
  width: 18px;
  height: 18px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  font-size: 1.125rem;
  line-height: 1;
  color: var(--primary-500);
  transition: all 0.15s ease;
}

.chip-remove:hover {
  background: rgba(98, 115, 255, 0.15);
  transform: scale(1.1);
}

.chip-placeholder {
  font-size: 0.875rem;
  color: var(--neutral-700);
  opacity: 0.7;
  font-style: italic;
}

.add-presentacion .select {
  height: 44px;
}

/* ========================================
   CONVERSIONS GRID
   ======================================== */
.conversion-intro {
  background: linear-gradient(135deg, var(--primary-50) 0%, #f8fafc 100%);
  border: 1.5px solid var(--primary-500);
  border-radius: 16px;
  padding: 1.25rem; /* Reducido de 1.5rem */
  margin-bottom: 1.5rem; /* Reducido de 2rem */
}

.conversion-intro h3 {
  margin: 0 0 0.75rem;
  font-size: 1.25rem;
  font-weight: 900;
  color: var(--primary-500);
}

.conversion-intro > p {
  margin: 0 0 1rem;
  font-size: 0.938rem;
  color: var(--neutral-900);
  line-height: 1.6;
}

.example-box {
  background: #fff;
  border-radius: 12px;
  padding: 1rem;
  border: 1px solid var(--primary-500);
}

.example-box strong {
  display: block;
  font-size: 0.875rem;
  font-weight: 800;
  color: var(--primary-500);
  margin-bottom: 0.5rem;
}

.example-content {
  font-size: 0.875rem;
  color: var(--neutral-900);
  line-height: 1.6;
}

.example-content ul {
  margin: 0.5rem 0 0;
  padding-left: 1.5rem;
}

.example-content li {
  margin-bottom: 0.375rem;
}

.example-content li strong {
  display: inline;
  color: var(--primary-500);
  font-weight: 700;
}

.conversions-grid {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

/* ========================================
   CONVERSIONS — minimal design
   ======================================== */
.conversion-header {
  background: transparent;
  border: 0;
  border-bottom: 1px solid var(--neutral-200);
  border-radius: 0;
  padding: 0 0 0.75rem;
  margin-bottom: 0.75rem;
}

.conversion-header strong {
  display: block;
  font-size: 0.9375rem;
  font-weight: 700;
  color: var(--neutral-900);
  margin-bottom: 0.25rem;
  letter-spacing: -0.005em;
}

.conversion-header strong::before {
  content: none;
}

.conversion-header p {
  font-size: 0.8125rem;
  color: var(--neutral-500);
  margin: 0;
  line-height: 1.5;
}

.conversion-item {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding: 0.875rem 1rem;
  border: 1px solid var(--neutral-200);
  border-radius: 10px;
  background: #fff;
  transition: border-color 0.15s ease;
}

.conversion-item:hover {
  border-color: var(--neutral-300);
  box-shadow: none;
  transform: none;
}

.conversion-base {
  background: #fff;
  border-color: var(--neutral-200);
  border-left: 3px solid var(--ok-600);
}

.conversion-base:hover {
  border-color: var(--neutral-300);
  border-left-color: var(--ok-600);
  box-shadow: none;
}

.conversion-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  min-width: 0;
}

.conversion-label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex: 1;
  min-width: 120px;
}

.presentation-name {
  font-weight: 700;
  font-size: 0.9375rem;
  color: var(--neutral-900);
  letter-spacing: -0.005em;
}

.conversion-formula {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.formula-text {
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--neutral-500);
}

.input-conversion {
  width: 120px;
  height: 36px;
  text-align: center;
  font-size: 0.9375rem;
  font-weight: 600;
  border: 1px solid var(--neutral-200);
  border-radius: 8px;
  padding: 0 0.625rem;
  background: #fff;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.input-conversion:focus {
  border-color: var(--primary-500);
  box-shadow: 0 0 0 3px rgba(98, 115, 255, 0.12);
  outline: none;
}

.input-conversion[readonly] {
  background: var(--neutral-100);
  border-color: var(--neutral-200);
  color: var(--neutral-500);
  cursor: not-allowed;
}

.formula-unit {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--neutral-700);
  background: transparent;
  padding: 0;
  border-radius: 0;
}

.conversion-explanation {
  font-size: 0.8125rem;
  line-height: 1.5;
  color: var(--neutral-500);
  padding: 0;
  background: transparent;
  border-radius: 0;
  border-left: 0;
}

.conversion-explanation strong {
  color: var(--neutral-700);
  font-weight: 600;
}

.conversion-explanation .text-warning {
  color: var(--warn-600);
  font-weight: 600;
}

.conversion-status {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.status-icon {
  font-size: 1.25rem;
  line-height: 1;
}

.status-icon.success {
  color: var(--ok-600);
}

.status-icon.warning {
  color: var(--warn-600);
}

.status-icon.error {
  color: var(--err-600);
}

.conversion-summary {
  display: flex;
  gap: 1rem;
  padding: 1.25rem;
  border: 1.5px solid #bfdbfe;
  border-radius: 14px;
  background: #eff6ff;
  margin-top: 1.5rem;
}

.summary-icon {
  font-size: 1.5rem;
  flex-shrink: 0;
}

.summary-content {
  flex: 1;
}

.summary-content strong {
  display: block;
  font-size: 0.938rem;
  font-weight: 800;
  color: #1e40af;
  margin-bottom: 0.5rem;
}

.summary-content ul {
  margin: 0;
  padding-left: 1.25rem;
  font-size: 0.875rem;
  color: #1e3a8a;
  line-height: 1.7;
}

.summary-content li {
  margin-bottom: 0.375rem;
}

.summary-content li strong {
  display: inline;
  color: #1e40af;
  font-weight: 700;
}

/* ========================================
   PROVIDER CARDS & SELECTOR
   ======================================== */
.provider-intro {
  background: linear-gradient(135deg, #f8fafc 0%, #eff6ff 100%);
  border: 1.5px solid #bfdbfe;
  border-radius: 16px;
  padding: 1.25rem; /* Reducido de 1.5rem */
  margin-bottom: 1.5rem; /* Reducido de 2rem */
  min-width: 0;
}

.provider-intro h3 {
  margin: 0 0 0.75rem;
  font-size: 1.25rem;
  font-weight: 900;
  color: #1e40af;
}

.provider-intro > p {
  margin: 0 0 1rem;
  font-size: 0.938rem;
  color: var(--neutral-900);
  line-height: 1.6;
}

.info-box {
  display: flex;
  gap: 1rem;
  padding: 1rem;
  background: #fff;
  border-radius: 12px;
  border: 1px solid #bfdbfe;
  min-width: 0;
}

.info-icon {
  font-size: 1.5rem;
  flex-shrink: 0;
}

.info-content {
  flex: 1;
}

.info-content strong {
  display: block;
  font-size: 0.875rem;
  font-weight: 800;
  color: #1e40af;
  margin-bottom: 0.5rem;
}

.info-content ul {
  margin: 0;
  padding-left: 1.25rem;
  font-size: 0.875rem;
  color: #1e3a8a;
  line-height: 1.7;
}

.provider-list {
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
}

.provider-card {
  border: 1.5px solid var(--neutral-200);
  border-radius: 14px;
  padding: 1.25rem;
  background: #fff;
  transition: all 0.2s ease;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.provider-card:hover {
  border-color: var(--primary-500);
  box-shadow: 0 4px 16px rgba(98, 115, 255, 0.15);
  transform: translateY(-2px);
}

.provider-inactive {
  opacity: 0.7;
  background: var(--neutral-50);
}

.provider-add {
  border-style: dashed;
  justify-content: center;
  align-items: center;
  min-height: 200px;
  cursor: pointer;
}

.provider-add:hover {
  background: var(--primary-50);
}

.provider-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 1rem;
  gap: 0.75rem;
  min-width: 0;
}

.provider-info {
  flex: 1;
  min-width: 0;
}

.provider-info strong {
  display: block;
  font-size: 1rem;
  font-weight: 800;
  color: var(--neutral-900);
  margin-bottom: 0.25rem;
}

.provider-key {
  font-size: 0.75rem;
  color: var(--neutral-700);
  font-family: 'Courier New', monospace;
  background: var(--neutral-100);
  padding: 0.125rem 0.375rem;
  border-radius: 4px;
}

.provider-summary {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-bottom: 1rem;
  flex: 1;
  min-width: 0;
}

.summary-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.875rem;
}

.summary-item .label {
  color: var(--neutral-700);
  font-size: 0.813rem;
  font-weight: 600;
  margin: 0;
}

.summary-item .value {
  font-weight: 700;
}

.summary-item .value.success {
  color: var(--ok-600);
}

.summary-item .value.error {
  color: var(--err-600);
}

/* ========================================
   PROVIDER EDITOR
   ======================================== */
.provider-editor {
  margin-top: 2rem;
  border: 2px solid var(--primary-500);
  border-radius: 16px;
  padding: 1.5rem;
  background: linear-gradient(180deg, #fff 0%, var(--primary-50) 100%);
  animation: slideDown 0.3s ease;
  min-width: 0;
}

@keyframes slideDown {
  from {
    opacity: 0;
    transform: translateY(-12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.editor-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.25rem;
  padding-bottom: 1rem;
  border-bottom: 2px solid var(--primary-500);
  min-width: 0;
}

.editor-header h3 {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 900;
  color: var(--primary-500);
}

.editor-header span {
  font-weight: 700;
  color: var(--neutral-900);
}

.editor-tabs {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1.5rem;
  border-bottom: 2px solid var(--neutral-200);
  overflow-x: auto;
  min-width: 0;
}

.editor-tab {
  padding: 0.75rem 1rem;
  border: none;
  background: transparent;
  color: var(--neutral-700);
  font-weight: 700;
  font-size: 0.875rem;
  cursor: pointer;
  border-bottom: 3px solid transparent;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.editor-tab:hover {
  color: var(--primary-500);
  background: rgba(98, 115, 255, 0.05);
}

.editor-tab.active {
  color: var(--primary-500);
  border-bottom-color: var(--primary-500);
}

.editor-content {
  background: #fff;
  border-radius: 12px;
  padding: 1.5rem;
  border: 1px solid var(--neutral-200);
}

.editor-tab-content {
  display: none;
}

.editor-tab-content.active {
  display: block;
  animation: fadeIn 0.2s ease;
}

/* ========================================
   FIELD ADVANCED (Details)
   ======================================== */
.field-advanced {
  margin-top: 1rem;
  border: 1.5px solid var(--neutral-200);
  border-radius: 12px;
  padding: 1rem;
  background: #fff;
}

.field-advanced summary {
  cursor: pointer;
  font-weight: 800;
  font-size: 0.875rem;
  color: var(--neutral-900);
  list-style: none;
  user-select: none;
}

.field-advanced summary::-webkit-details-marker {
  display: none;
}

.field-advanced summary:hover {
  color: var(--primary-500);
}

.field-advanced[open] summary {
  margin-bottom: 1rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--neutral-200);
}

.field-advanced-content {
  animation: fadeIn 0.2s ease;
}

.field-advanced-content > p {
  margin: 0 0 1rem;
  font-size: 0.875rem;
  color: var(--neutral-700);
}

.calculation-display {
  margin-top: 1rem;
  padding: 1rem;
  background: var(--ok-50);
  border: 1px solid var(--ok-600);
  border-radius: 10px;
}

.calculation-display strong {
  display: block;
  font-size: 0.875rem;
  font-weight: 800;
  color: var(--ok-600);
  margin-bottom: 0.5rem;
}

.calc-item {
  font-size: 0.875rem;
  color: var(--neutral-900);
  margin-bottom: 0.375rem;
}

.calc-item span {
  font-weight: 700;
  color: var(--ok-600);
}

/* ========================================
   PREVIEW CARD
   ======================================== */
.preview-container {
  max-width: 500px;
  margin: 0 auto;
}

.preview-container h4 {
  margin: 0 0 1rem;
  font-size: 1.125rem;
  font-weight: 800;
  color: var(--neutral-900);
  text-align: center;
}

.preview-card {
  border: 2px solid var(--neutral-200);
  border-radius: 16px;
  overflow: hidden;
  background: #fff;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
}

.preview-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.25rem;
  background: linear-gradient(135deg, var(--primary-50) 0%, #f8fafc 100%);
  border-bottom: 2px solid var(--neutral-200);
}

.preview-header strong {
  font-size: 1.125rem;
  font-weight: 900;
  color: var(--neutral-900);
}

.preview-body {
  padding: 1.5rem;
}

.preview-section {
  margin-bottom: 1.5rem;
}

.preview-section:last-child {
  margin-bottom: 0;
}

.preview-section h5 {
  margin: 0 0 0.5rem;
  font-size: 0.813rem;
  font-weight: 800;
  color: var(--neutral-700);
  text-transform: uppercase;
  letter-spacing: 0.025em;
}

.preview-value {
  font-size: 1rem;
  font-weight: 700;
  color: var(--neutral-900);
  margin-bottom: 0.375rem;
}

.preview-value.large {
  font-size: 1.5rem;
  color: var(--primary-500);
}

.preview-detail {
  font-size: 0.875rem;
  color: var(--neutral-700);
  line-height: 1.6;
}

.preview-detail strong {
  color: var(--neutral-900);
  font-weight: 700;
}

.preview-actions {
  display: flex;
  gap: 1rem;
  justify-content: space-between;
  margin-top: 1.5rem;
}

/* ========================================
   TAB FOOTER
   ======================================== */
.tab-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  margin-top: 2rem; /* Reducido de 2.5rem */
  padding: 1.25rem 0 0.5rem 0; /* Ajustado para mejor espaciado */
  border-top: 2px solid var(--neutral-200);
  flex-wrap: wrap;
}

.status-summary {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 1rem;
  border-radius: 999px;
  font-size: 0.875rem;
  font-weight: 700;
  border: 1.5px solid transparent;
}

.status-summary.success {
  background: var(--ok-50);
  color: var(--ok-600);
  border-color: var(--ok-600);
}

.status-summary.warning {
  background: var(--warn-50);
  color: var(--warn-600);
  border-color: var(--warn-600);
}

.status-summary.error {
  background: var(--err-50);
  color: var(--err-600);
  border-color: var(--err-600);
}

.provider-summary {
  flex: 1;
  text-align: center;
}

/* ========================================
   MODAL FOOTER
   ======================================== */
.modal-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding: 1.25rem 1.75rem; /* Reducido de 1.5rem */
  border-top: 2px solid var(--neutral-200);
  background: linear-gradient(180deg, #fafbfc 0%, #f1f5f9 100%);
  flex-shrink: 0;
  min-height: 76px; /* Altura mínima consistente, ajustada */
  box-shadow: 0 -4px 12px rgba(15, 23, 42, 0.05);
  margin-top: 0; /* Eliminar cualquier margen superior no deseado */
}

/* ========================================
   BUTTONS
   ======================================== */
.btn {
  height: 48px;
  padding: 0 1.5rem;
  border-radius: 999px;
  border: 1.5px solid transparent;
  font-weight: 800;
  font-size: 0.938rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  cursor: pointer;
  transition: all 0.2s ease;
  background: #fff;
  color: var(--neutral-900);
  white-space: nowrap;
}

.btn svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

.btn-primary {
  background: var(--primary-500);
  color: #fff;
  border-color: var(--primary-500);
}

.btn-primary:hover:not(:disabled) {
  background: #5163ec;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(98, 115, 255, 0.4);
}

.btn-ghost {
  background: #fff;
  border-color: var(--neutral-200);
  color: var(--neutral-900);
}

.btn-ghost:hover:not(:disabled) {
  border-color: var(--neutral-700);
  background: var(--neutral-50);
}

.btn-danger {
  background: #fff;
  border-color: #fecaca;
  color: #b91c1c;
}

.btn-danger:hover:not(:disabled) {
  background: #fef2f2;
  border-color: #ef4444;
}

.btn-outline {
  background: #fff;
  border-color: var(--neutral-200);
}

.btn-outline:hover:not(:disabled) {
  border-color: var(--primary-500);
  box-shadow: 0 0 0 4px var(--primary-50);
}

.btn-sm {
  height: 40px;
  padding: 0 1rem;
  font-size: 0.875rem;
}

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

.btn.is-loading {
  position: relative;
  color: transparent !important;
  pointer-events: none;
}

.btn.is-loading::after {
  content: "";
  position: absolute;
  width: 18px;
  height: 18px;
  border: 2px solid transparent;
  border-top-color: currentColor;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* ========================================
   VALIDATION MODAL
   ======================================== */
.validation-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 99999;
  padding: 1rem;
  animation: fadeIn 0.2s ease;
}

.validation-modal {
  background: #fff;
  border-radius: 20px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  max-width: 560px;
  width: 100%;
  animation: modalSlideIn 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.validation-modal.error {
  border: 3px solid var(--err-600);
}

.validation-modal.warning {
  border: 3px solid var(--warn-600);
}

.validation-header {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1.5rem;
  border-bottom: 2px solid var(--neutral-200);
  background: linear-gradient(180deg, #fff 0%, #f8fafc 100%);
}

.validation-icon {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  font-weight: 900;
  flex-shrink: 0;
}

.validation-modal.error .validation-icon {
  background: var(--err-50);
  color: var(--err-600);
  border: 2px solid var(--err-600);
}

.validation-modal.warning .validation-icon {
  background: var(--warn-50);
  color: var(--warn-600);
  border: 2px solid var(--warn-600);
}

.validation-header h3 {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 900;
  color: var(--neutral-900);
}

.validation-body {
  padding: 1.5rem;
  max-height: 400px;
  overflow-y: auto;
}

.validation-section {
  margin-bottom: 1.5rem;
}

.validation-section:last-child {
  margin-bottom: 0;
}

.validation-section strong {
  display: block;
  font-size: 0.938rem;
  font-weight: 800;
  margin-bottom: 0.75rem;
}

.validation-section.errors strong {
  color: var(--err-600);
}

.validation-section.warnings strong {
  color: var(--warn-600);
}

.validation-section ul {
  margin: 0;
  padding-left: 1.5rem;
  font-size: 0.875rem;
  line-height: 1.7;
}

.validation-section li {
  margin-bottom: 0.5rem;
  color: var(--neutral-900);
}

.validation-actions {
  display: flex;
  justify-content: flex-end;
  gap: 1rem;
  padding: 1.25rem 1.5rem;
  border-top: 2px solid var(--neutral-200);
  background: var(--neutral-50);
}

/* ========================================
   ALERT BOXES
   ======================================== */
.alert {
  display: flex;
  gap: 0.75rem;
  padding: 1rem;
  border-radius: 12px;
  border: 1.5px solid transparent;
  font-size: 0.875rem;
  line-height: 1.6;
}

.alert strong {
  font-weight: 700;
}

.alert-info {
  background: #eff6ff;
  color: #1e3a8a;
  border-color: #bfdbfe;
}

.alert-success {
  background: var(--ok-50);
  color: #166534;
  border-color: #bbf7d0;
}

.alert-warning {
  background: var(--warn-50);
  color: #92400e;
  border-color: #fde68a;
}

.alert-error {
  background: var(--err-50);
  color: #991b1b;
  border-color: #fecaca;
}

/* ========================================
   PILL STATUS (Mini badges)
   ======================================== */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.375rem 0.75rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 900;
  border: 1px solid transparent;
  white-space: nowrap;
}

.pill.ok {
  background: var(--ok-50);
  color: var(--ok-600);
  border-color: #bbf7d0;
}

.pill.warn {
  background: var(--warn-50);
  color: var(--warn-600);
  border-color: #fde68a;
}

.pill.bad {
  background: var(--err-50);
  color: var(--err-600);
  border-color: #fecaca;
}

.pill.info {
  background: #eff6ff;
  color: #3b82f6;
  border-color: #bfdbfe;
}

/* ========================================
   RESPONSIVE
   ======================================== */
@media (max-width: 768px) {
  .modal-body {
    padding: 1.25rem 1rem 1rem 1rem; /* Ajustado para móvil */
  }

  .modal-header {
    padding: 1rem;
  }

  .modal-footer {
    padding: 1rem;
    min-height: 70px; /* Reducido en móvil */
    flex-direction: column;
  }

  .field-group {
    margin-bottom: 1.5rem;
    padding-bottom: 1.5rem;
  }

  .field-group:last-child {
    padding-bottom: 0.5rem;
  }

  .tab-footer {
    flex-direction: column;
    align-items: stretch;
    margin-top: 1.5rem; /* Reducido en móvil */
    padding: 1rem 0 0.5rem 0;
  }

  .tab-footer .btn {
    width: 100%;
  }

  .provider-list {
    grid-template-columns: 1fr;
  }

  .preview-actions {
    flex-direction: column;
  }

  .preview-actions .btn {
    width: 100%;
  }

  .modal-footer .btn {
    width: 100%;
  }
}

@media (max-width: 480px) {
  .modal-tabs {
    padding: 0 0.75rem;
  }

  .tab-btn {
    padding: 0.75rem;
  }

  .tab-label {
    font-size: 0.813rem;
  }

  .modal-header h2 {
    font-size: 1.25rem;
  }

  .field-group-title {
    font-size: 1rem;
  }
}

/* ========================================
   UTILITIES
   ======================================== */
.hidden {
  display: none !important;
}

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

.text-muted {
  color: var(--neutral-700);
}

.font-bold {
  font-weight: 700;
}

.mb-0 {
  margin-bottom: 0 !important;
}

.mt-0 {
  margin-top: 0 !important;
}
