/* DUAL_FORM_v2 — Panel lateral sincronizado con chat
 * Desktop: panel 30vw a la izquierda del drawer (chat se estrecha a 40vw)
 * Mobile:  bottom sheet que se desliza desde abajo (no interfiere con el teclado)
 */

/* ═══ PANEL BASE ═══ */
.form-panel {
  position: fixed; z-index: 1002;
  bottom: 0; right: 70vw;
  width: 30vw; min-width: 300px; height: 100%;
  background: var(--navy-mid, #1b3a4b);
  display: none;
  flex-direction: column;
  border-right: 1px solid rgba(255,255,255,0.07);
  box-shadow: -4px 0 24px rgba(0,0,0,0.3);
  transform: translateX(100%);
  transition: transform 0.35s cubic-bezier(0.16,1,0.3,1);
}

/* Desktop: panel visible cuando chat está abierto */
body.dual-form-active.chat-open .form-panel {
  display: flex;
  transform: translateX(0);
}
/* Chat se estrecha para dar espacio al panel */
body.dual-form-active.chat-open .chat-drawer {
  width: 40vw;
  min-width: 340px;
}

/* ═══ HEADER DEL PANEL ═══ */
.form-panel-header {
  background: var(--navy, #0d1b2a);
  padding: 16px 20px;
  display: flex; align-items: center; gap: 10px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
  flex-shrink: 0;
}
.form-panel-title { font-size: 14px; font-weight: 600; color: var(--white,#fff); }
.form-panel-hint  { margin-left: auto; font-size: 11px; color: var(--gray-300,#9ca3af); }

/* Botón cerrar (solo visible en móvil) */
.form-panel-close-btn {
  display: none;
  background: none; border: none; color: var(--gray-300,#9ca3af);
  font-size: 22px; cursor: pointer; line-height: 1;
  padding: 4px 8px; border-radius: 8px;
  transition: background 0.2s;
  margin-right: auto;
}
.form-panel-close-btn:hover { background: rgba(255,255,255,0.08); }

/* ═══ CUERPO DEL PANEL ═══ */
.form-panel-body {
  flex: 1; min-height: 0;
  overflow-y: auto; -webkit-overflow-scrolling: touch;
  padding: 16px 20px;
  display: flex; flex-direction: column; gap: 14px;
}
.form-section {
  display: flex; flex-direction: column; gap: 10px;
  padding-bottom: 14px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
}
.form-section:last-child { border-bottom: 0; padding-bottom: 0; }
.form-section-title {
  font-size: 11px; font-weight: 700; color: var(--cyan,#22d3ee);
  text-transform: uppercase; letter-spacing: 1px; margin-bottom: 2px;
}
.form-field { display: flex; flex-direction: column; gap: 4px; }
.form-field-label {
  font-size: 11px; color: var(--gray-300,#9ca3af);
  text-transform: uppercase; letter-spacing: 0.5px; font-weight: 600;
}
.form-field-input, .form-field select.form-field-input {
  background: rgba(255,255,255,0.04); border: 1px solid rgba(255,255,255,0.08);
  color: var(--white,#fff); border-radius: 8px; padding: 10px 12px;
  font-size: 14px; transition: all 0.2s; outline: none;
  width: 100%; box-sizing: border-box; font-family: inherit;
}
.form-field-input:focus      { border-color: var(--cyan,#22d3ee); background: rgba(255,255,255,0.06); }
.form-field-input.captured   { border-color: rgba(0,212,170,0.4); background: rgba(0,212,170,0.05); }
.form-field-input.error      { border-color: rgba(239,68,68,0.6); background: rgba(239,68,68,0.05); }
.form-field-input.saving     { opacity: 0.6; }
.form-field-error            { font-size: 11px; color: #ef4444; min-height: 13px; }
.form-field-input::placeholder { color: rgba(255,255,255,0.25); }

/* ═══ FOOTER: PROGRESO + BOTÓN CONTINUAR ═══ */
.form-panel-footer {
  flex-shrink: 0;
  padding: 12px 16px;
  border-top: 1px solid rgba(255,255,255,0.06);
  display: flex; flex-direction: column; gap: 8px;
}
.form-progress {
  font-size: 12px; color: var(--gray-300,#9ca3af); text-align: center;
}
.form-progress b { color: var(--cyan,#22d3ee); }

/* Botón "Continuar" — se muestra cuando hay datos pendientes de procesar */
.form-panel-continue {
  width: 100%;
  padding: 13px 20px;
  background: var(--coral, #FF6B5A);
  color: #fff; border: none; border-radius: 12px;
  font-size: 14px; font-weight: 700; cursor: pointer;
  transition: background 0.2s, transform 0.1s;
  display: none;
}
.form-panel-continue:hover  { background: var(--coral-dark, #e55a49); }
.form-panel-continue:active { transform: scale(0.97); }
.form-panel-continue.visible { display: block; }

/* ═══ BOTÓN ABRIR PANEL (dentro del chat-drawer-header) ═══ */
.panel-open-btn {
  display: none;
  background: none; border: none;
  color: var(--gray-300,#9ca3af); font-size: 18px; cursor: pointer;
  width: 36px; height: 36px; border-radius: 10px;
  align-items: center; justify-content: center;
  transition: background 0.2s;
}
.panel-open-btn:hover { background: rgba(255,255,255,0.08); color: var(--teal,#00D4AA); }
/* Aparece cuando el panel está disponible */
body.dual-form-active .panel-open-btn { display: flex; }

/* ═══ BACKDROP PARA MOBILE ═══ */
.form-panel-backdrop {
  display: none;
  position: fixed; inset: 0; z-index: 1003;
  background: rgba(0,0,0,0.55);
}
body.dual-form-active.chat-open.form-tab-active .form-panel-backdrop { display: block; }

/* ═══ DRAG HANDLE (solo móvil) ═══ */
.form-panel-drag {
  display: none;
  width: 36px; height: 4px;
  background: rgba(255,255,255,0.2);
  border-radius: 2px; margin: 10px auto 0;
  flex-shrink: 0;
}

/* ═══ MOBILE ≤640px: BOTTOM SHEET ═══ */
@media (max-width: 640px) {
  /* Panel: bottom sheet, sale desde abajo */
  .form-panel {
    right: 0 !important; left: 0 !important;
    bottom: 0 !important; top: auto !important;
    width: 100% !important; min-width: 0 !important;
    height: 82dvh !important;
    border-radius: 20px 20px 0 0 !important;
    border-right: 0 !important;
    border-top: 1px solid rgba(255,255,255,0.12) !important;
    box-shadow: 0 -8px 40px rgba(0,0,0,0.5) !important;
    transform: translateY(100%) !important;
    transition: transform 0.32s cubic-bezier(0.16,1,0.3,1) !important;
    z-index: 1004 !important;
  }
  body.dual-form-active.chat-open.form-tab-active .form-panel {
    display: flex !important;
    transform: translateY(0) !important;
  }
  /* Chat NO cambia de ancho en móvil */
  body.dual-form-active.chat-open .chat-drawer {
    width: 100% !important;
    min-width: 0 !important;
  }
  /* Drag handle y botón cerrar visibles */
  .form-panel-drag { display: block; }
  .form-panel-close-btn { display: flex; align-items: center; }
  /* Inputs grandes para touch (evita zoom iOS) */
  .form-field-input { padding: 12px 14px; font-size: 16px; }
  .form-field select.form-field-input { font-size: 16px; }
  /* Footer más compacto */
  .form-panel-footer { padding: 10px 14px; }
}

/* Ocultar dual-tabs legacy (reemplazados por panel-open-btn en el header) */
.dual-tabs { display: none !important; }
