/* ==============================================================
 * 📄 Archivo: xml-import.css
 * 📁 Ruta: includes/modules/xml-import/xml-import.css
 *
 * 🎯 Descripción:
 *   Estilos del importador XML de eventos:
 *   - Bloque del shortcode público.
 *   - Modal emergente bonito y responsive (2 columnas).
 *   - Formulario de revisión con editor HTML, imagen y metadatos.
 *   - Bloque de metadatos avanzados a todo el ancho.
 *   - Toasts de notificación y spinners de carga.
 *
 * ✅ Upgrade:
 *   - Estilos para errores reales del XML (Detalles técnicos)
 *   - Aviso en modal cuando hay "used_recovery" o warnings
 *
 * ✅ FIX UI (2026-01):
 *   - Modal sin “cortes” en móvil (overflow-x + min-width)
 *   - Scroll interno SOLO en contenido
 *   - Footer/botones ANCLADOS abajo (sticky real + safe area iOS)
 * ============================================================== */

/* =========================== */
/*  BASE DEL SHORTCODE         */
/* =========================== */

.ec-xml-import-box {
    max-width: 900px;
    margin: 24px auto;
    padding: 24px 20px 28px;
    border-radius: 18px;
    background: #ffffff;
    box-shadow: 0 14px 35px rgba(15, 23, 42, 0.12);
    border: 1px solid rgba(148, 163, 184, 0.3);
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.ec-xml-import-title {
    font-size: 1.6rem;
    font-weight: 700;
    margin: 0 0 6px;
    color: #0f172a;
}

.ec-xml-import-intro {
    margin: 0 0 16px;
    font-size: 0.95rem;
    color: #4b5563;
    line-height: 1.5;
}

.ec-xml-import-form {
    margin-top: 8px;
}

.ec-xml-import-label {
    display: block;
    font-size: 0.9rem;
    font-weight: 600;
    color: #374151;
    margin-bottom: 6px;
}

.ec-xml-import-textarea {
    width: 100%;
    min-height: 220px;
    border-radius: 12px;
    border: 1px solid #e5e7eb;
    padding: 10px 12px;
    font-size: 0.9rem;
    resize: vertical;
    outline: none;
    background: #f9fafb;
    color: #111827;
    transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

.ec-xml-import-textarea:focus {
    border-color: #6366f1;
    background: #ffffff;
    box-shadow: 0 0 0 1px rgba(99, 102, 241, 0.2);
}

.ec-xml-import-help {
    margin: 6px 0 14px;
    font-size: 0.8rem;
    color: #6b7280;
}

/* Botón principal */

.ec-xml-import-submit {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 18px;
    border-radius: 999px;
    border: none;
    background: linear-gradient(135deg, #4f46e5, #6366f1);
    color: #ffffff;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 10px 25px rgba(79, 70, 229, 0.35);
    transition: transform 0.12s ease, box-shadow 0.12s ease, background 0.12s ease;
}

.ec-xml-import-submit:hover {
    transform: translateY(-1px);
    box-shadow: 0 14px 30px rgba(79, 70, 229, 0.45);
}

.ec-xml-import-submit:active {
    transform: translateY(0);
    box-shadow: 0 8px 18px rgba(79, 70, 229, 0.35);
}

.ec-xml-import-submit:disabled {
    opacity: 0.5;
    cursor: default;
    box-shadow: none;
}

.ec-xml-import-btn-label {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

/* Spinners */

.ec-xml-import-spinner {
    display: none;
    width: 16px;
    height: 16px;
    border-radius: 999px;
    border: 2px solid rgba(255, 255, 255, 0.4);
    border-top-color: #ffffff;
    animation: ec-xml-spin 0.7s linear infinite;
}

.ec-xml-import-btn--loading .ec-xml-import-spinner {
    display: inline-block;
}

.ec-xml-import-inline-spinner {
    display: inline-block;
    width: 14px;
    height: 14px;
    border-radius: 999px;
    border: 2px solid rgba(37, 99, 235, 0.25);
    border-top-color: #2563eb;
    animation: ec-xml-spin 0.7s linear infinite;
    vertical-align: -2px;
    margin-right: 6px;
}

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

/* Mensajes bajo el formulario */

.ec-xml-import-result {
    margin-top: 14px;
    font-size: 0.88rem;
    border-radius: 999px;
    padding: 8px 12px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    max-width: 100%;
}

.ec-xml-import-result--loading { background: #eff6ff; color: #1d4ed8; }
.ec-xml-import-result--success { background: #ecfdf3; color: #166534; }
.ec-xml-import-result--error   { background: #fef2f2; color: #b91c1c; }

/* ✅ Cuando hay errores reales, el result puede contener HTML y varias líneas */
.ec-xml-import-result--error,
.ec-xml-import-result--success {
    align-items: flex-start;
    border-radius: 14px;
    display: block;
    line-height: 1.45;
}

.ec-xml-import-error-main { font-weight: 700; margin: 0; }

.ec-xml-import-error-details {
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px dashed rgba(185, 28, 28, 0.25);
    color: #7f1d1d;
}

.ec-xml-import-error-details-title {
    font-size: 0.78rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.02em;
    opacity: 0.9;
    margin-bottom: 6px;
}

.ec-xml-import-error-list {
    margin: 0;
    padding-left: 18px;
    font-size: 0.82rem;
}

.ec-xml-import-error-list li { margin: 4px 0; }

/* =========================== */
/*  MODAL EMERGENTE            */
/* =========================== */

body.ec-xml-import-modal-open { overflow: hidden; }

.ec-xml-import-modal {
    position: fixed;
    inset: 0;
    z-index: 9999;
    display: none;
    align-items: center;
    justify-content: center;
}

.ec-xml-import-modal--open { display: flex; }

.ec-xml-import-modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, 0.55);
    backdrop-filter: blur(3px);
}

/* ✅ FIX: box-sizing consistente y evitar overflow lateral dentro del modal */
.ec-xml-import-modal,
.ec-xml-import-modal * {
    box-sizing: border-box;
}

.ec-xml-import-modal-dialog {
    position: relative;
    z-index: 1;
    width: 100%;
    max-width: 980px;

    /* ✅ FIX: usar dvh para móviles modernos */
    max-height: calc(100dvh - 40px);

    background: #ffffff;
    border-radius: 20px;
    box-shadow: 0 20px 45px rgba(15, 23, 42, 0.38);

    display: flex;
    flex-direction: column;

    /* ✅ Importante: para que el sticky funcione y nada se salga */
    overflow: hidden;
}

/* Cabecera */

.ec-xml-import-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 18px 10px;
    border-bottom: 1px solid #e5e7eb;
    background: linear-gradient(135deg, #eef2ff, #f9fafb);
}

.ec-xml-import-modal-title-wrapper {
    display: flex;
    align-items: center;
    gap: 10px;
}

.ec-xml-import-modal-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    border-radius: 999px;
    background: #4f46e5;
    color: #ffffff;
    font-size: 18px;
}

.ec-xml-import-modal-title {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 700;
    color: #111827;
}

.ec-xml-import-modal-close {
    border: none;
    background: transparent;
    font-size: 1.4rem;
    line-height: 1;
    cursor: pointer;
    width: 32px;
    height: 32px;
    border-radius: 999px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #6b7280;
    transition: background 0.12s ease, color 0.12s ease, transform 0.12s ease;
}

.ec-xml-import-modal-close:hover {
    background: rgba(148, 163, 184, 0.18);
    color: #111827;
    transform: translateY(-1px);
}

/* Contenido */
/* ✅ FIX: scroll SOLO aquí + padding bottom para que el footer sticky no tape */
.ec-xml-import-modal-content {
    padding: 14px 18px 10px;
    flex: 1 1 auto;

    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;

    /* deja hueco para footer anclado */
    padding-bottom: calc(96px + env(safe-area-inset-bottom));
}

/* ✅ Aviso (recovery / warnings) insertado por JS */
.ec-xml-import-parse-notice {
    border-radius: 14px;
    border: 1px solid rgba(245, 158, 11, 0.35);
    background: linear-gradient(180deg, rgba(255, 251, 235, 1), rgba(255, 255, 255, 1));
    padding: 12px 12px 10px;
    margin: 0 0 12px;
    box-shadow: 0 10px 22px rgba(15, 23, 42, 0.08);
}

.ec-xml-import-parse-notice-title {
    font-weight: 800;
    color: #92400e;
    margin-bottom: 4px;
    font-size: 0.92rem;
}

.ec-xml-import-parse-notice-text {
    color: #78350f;
    font-size: 0.84_toggle-extra;
    line-height: 1.45;
    margin-bottom: 8px;
}

.ec-xml-import-parse-notice-list {
    margin: 0;
    padding-left: 18px;
    color: #78350f;
    font-size: 0.82rem;
}

.ec-xml-import-parse-notice-list li { margin: 4px 0; }

/* =========================== */
/*  FORMULARIO PREVIEW         */
/* =========================== */

.ec-xml-import-preview-form {
    display: flex;
    flex-direction: column;
    gap: 18px;

    /* ✅ FIX: permitir encoger contenidos para no “cortar” en móvil */
    min-width: 0;
}

/* ✅ FIX: evitar overflow por min-width/flex/grid */
.ec-xml-import-preview-grid,
.ec-xml-import-preview-col,
.ec-xml-import-header-preview,
.ec-xml-import-header-text {
    min-width: 0;
}

.ec-xml-import-preview-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.7fr) minmax(0, 1.1fr);
    gap: 18px;
}

.ec-xml-import-preview-col {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.ec-xml-import-preview-col--main {
    border-right: 1px dashed #e5e7eb;
    padding-right: 4px;
}

.ec-xml-import-preview-col--side { padding-left: 4px; }

.ec-xml-import-field {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.ec-xml-import-field label {
    font-size: 0.83rem;
    font-weight: 600;
    color: #4b5563;
}

/* Inputs más altos */

.ec-xml-import-input,
.ec-xml-import-textarea-modal {
    width: 100%;
    max-width: 100%;

    border-radius: 12px;
    border: 1px solid #e5e7eb;
    padding: 10px 12px;
    font-size: 0.9rem;
    outline: none;
    background: #f9fafb;
    color: #111827;
    transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
    min-height: 44px;
}

.ec-xml-import-input:focus,
.ec-xml-import-textarea-modal:focus {
    border-color: #6366f1;
    background: #ffffff;
    box-shadow: 0 0 0 1px rgba(99, 102, 241, 0.19);
}

.ec-xml-import-textarea-modal {
    resize: vertical;
    min-height: 80px;
}

.ec-xml-import-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
}

.ec-xml-import-small {
    margin: 4px 0 0;
    font-size: 0.75rem;
    color: #9ca3af;
}

/* =========================== */
/*  HEADER PREVIEW SUPERIOR    */
/* =========================== */

.ec-xml-import-header-preview {
    display: flex;
    gap: 16px;
    align-items: stretch;
    margin-bottom: 18px;
}

.ec-xml-import-header-text { flex: 2; min-width: 0; }

.ec-xml-import-summary-title {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 6px;
}

.ec-xml-import-summary-icon { font-size: 16px; }

.ec-xml-import-summary-title strong {
    font-size: 16px;
    line-height: 1.3;
}

.ec-xml-import-summary-pills {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 2px;
}

.ec-xml-import-pill {
    display: inline-flex;
    align-items: center;
    padding: 4px 8px;
    border-radius: 999px;
    font-size: 12px;
    line-height: 1.3;
    white-space: nowrap;
}

.ec-xml-import-pill--date  { background: #e5f0ff; }
.ec-xml-import-pill--place { background: #ffe7e0; }
.ec-xml-import-pill--price { background: #e4f7e5; }
.ec-xml-import-pill--link  { background: #f3e9ff; }

.ec-xml-import-header-image {
    flex: 1;
    min-width: 140px;
    max-width: 220px;
}

/* =========================== */
/*  DROPZONE DE IMAGEN         */
/* =========================== */

.ec-xml-import-dropzone {
    position: relative;
    border: 1px dashed #d1d5db;
    border-radius: 10px;
    padding: 6px;
    background: #f9fafb;
    cursor: pointer;
    overflow: hidden;
    min-height: 120px;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;

    max-width: 100%;
}

.ec-xml-import-dropzone-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 8px;
}

.ec-xml-import-dropzone-empty {
    padding: 8px;
    font-size: 12px;
    line-height: 1.3;
}

/* =========================== */
/*  EDITOR HTML TOOLBAR        */
/* =========================== */

.ec-xml-import-editor {
    border-radius: 10px;
    border: 1px solid #e5e7eb;
    background: #ffffff;
    display: flex;
    flex-direction: column;
    max-height: 340px;
    overflow: hidden;
    max-width: 100%;
}

.ec-xml-import-editor .ec-xml-import-textarea-modal {
    flex: 1 1 auto;
    border: none;
    border-radius: 0;
    background: #ffffff;
    padding: 10px 12px;
    min-height: 140px;
}

/* Barra fija abajo dentro del editor */
.ec-xml-import-editor-toolbar { display: flex; flex-wrap: wrap; gap: 4px; margin: 0; }

.ec-xml-import-editor-toolbar--sticky {
    flex: 0 0 auto;
    position: sticky;
    bottom: 0;
    background: #ffffff;
    border-top: 1px solid #e5e7eb;
    padding: 6px 8px;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    z-index: 3;
}

.ec-xml-editor-btn {
    border: none;
    background: #e5e7eb;
    padding: 3px 8px;
    border-radius: 999px;
    font-size: 0.78rem;
    cursor: pointer;
    color: #374151;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 3px;
    transition: background 0.12s ease, transform 0.12s ease, box-shadow 0.12s ease;
}

.ec-xml-editor-btn strong,
.ec-xml-editor-btn em { font-size: 0.8rem; }

.ec-xml-editor-btn:hover {
    background: #d1d5db;
    transform: translateY(-1px);
    box-shadow: 0 4px 10px rgba(148, 163, 184, 0.4);
}

/* =========================== */
/*  IMAGEN + ACCIONES          */
/* =========================== */

.ec-xml-import-image-actions {
    margin-top: 6px;
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.button-small {
    padding: 4px 10px !important;
    font-size: 0.8rem !important;
    border-radius: 999px !important;
}

.button-link {
    background: transparent !important;
    border: none !important;
    color: #2563eb !important;
    box-shadow: none !important;
}

.ec-xml-import-image-preview {
    margin-top: 8px;
    border-radius: 12px;
    border: 1px dashed #d1d5db;
    background: #f9fafb;
    padding: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    max-width: 100%;
}

.ec-xml-import-image-preview img {
    display: block;
    max-width: 100%;
    max-height: 200px;
    border-radius: 10px;
}

/* =========================== */
/*  METADATOS AVANZADOS        */
/* =========================== */

.ec-xml-import-raw-details {
    margin-top: 8px;
    padding: 10px 10px 8px;
    border-radius: 14px;
    background: #f9fafb;
    border: 1px dashed #e5e7eb;
}

.ec-xml-import-toggle-extra {
    border-radius: 999px !important;
    font-size: 0.8rem !important;
    padding: 4px 12px !important;
}

.ec-xml-import-extra-meta { margin-top: 10px; }

/* =========================== */
/*  FOOTER DEL MODAL           */
/* =========================== */

/* ✅ FIX: footer ANCLADO abajo (sticky real + iOS) */
.ec-xml-import-preview-footer {
    padding: 10px 18px 16px;
    border-top: 1px solid #e5e7eb;
    display: flex;
    justify-content: flex-end;
    gap: 10px;

    background: #f9fafb;

    /* sticky real dentro del contenedor scroll */
    position: -webkit-sticky;
    position: sticky;
    bottom: 0;
    z-index: 999;

    /* visual */
    box-shadow: 0 -10px 18px rgba(15, 23, 42, 0.08);

    /* safe-area iPhone */
    padding-bottom: calc(16px + env(safe-area-inset-bottom));
}

.ec-xml-import-btn-cancel {
    border-radius: 999px !important;
    padding: 7px 16px !important;
    font-size: 0.88rem !important;
    background: #e5e7eb !important;
    border: none !important;
    color: #374151 !important;
}

.ec-xml-import-btn-cancel:hover { background: #d1d5db !important; }

.ec-xml-import-btn-save {
    border-radius: 999px !important;
    padding: 7px 18px !important;
    font-size: 0.9rem !important;
    font-weight: 600 !important;
    display: inline-flex !important;
    align-items: center;
    gap: 8px;
}

/* =========================== */
/*  TOASTS DE NOTIFICACIÓN     */
/* =========================== */

.ec-xml-import-toast-container {
    position: absolute;
    right: 16px;
    bottom: 14px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    pointer-events: none;
}

.ec-xml-import-toast {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    border-radius: 999px;
    font-size: 0.8rem;
    box-shadow: 0 8px 20px rgba(15, 23, 42, 0.22);
    pointer-events: auto;
    opacity: 1;
    transform: translateY(0);
    transition: opacity 0.18s ease, transform 0.18s ease;
}

.ec-xml-import-toast--hide { opacity: 0; transform: translateY(10px); }

.ec-xml-import-toast--success { background: #ecfdf3; color: #166534; }
.ec-xml-import-toast--error   { background: #fef2f2; color: #b91c1c; }
.ec-xml-import-toast--info    { background: #eff6ff; color: #1d4ed8; }

.ec-xml-import-toast-icon {
    width: 20px;
    height: 20px;
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    font-weight: 700;
    background: rgba(15, 23, 42, 0.12);
}

.ec-xml-import-toast--success .ec-xml-import-toast-icon { background: rgba(22, 163, 74, 0.12); }
.ec-xml-import-toast--error .ec-xml-import-toast-icon   { background: rgba(239, 68, 68, 0.12); }
.ec-xml-import-toast--info .ec-xml-import-toast-icon    { background: rgba(37, 99, 235, 0.12); }

.ec-xml-import-toast-text { white-space: nowrap; }

/* =========================== */
/*  RESPONSIVE                 */
/* =========================== */

@media (max-width: 900px) {
    .ec-xml-import-modal-dialog {
        max-height: calc(100dvh - 24px);
        border-radius: 14px;
        margin: 0 10px;
    }
}

@media (max-width: 768px) {

    /* ✅ más aire en el shortcode */
    .ec-xml-import-box {
        width: calc(100% - 20px);
        margin: 14px auto;
        padding: 18px 14px 20px;
        border-radius: 16px;
    }

    /* ✅ modal más usable */
    .ec-xml-import-modal-dialog {
        max-height: calc(100dvh - 16px);
        margin: 0 8px;
        border-radius: 14px;
    }

    .ec-xml-import-modal-header { padding: 12px 14px 10px; }

    .ec-xml-import-modal-content {
        padding: 12px 14px 10px;
        padding-bottom: calc(110px + env(safe-area-inset-bottom)); /* extra seguridad */
    }

    .ec-xml-import-preview-grid {
        grid-template-columns: minmax(0, 1fr);
    }

    .ec-xml-import-preview-col--main {
        border-right: none;
        padding-right: 0;
        border-bottom: 1px dashed #e5e7eb;
        padding-bottom: 10px;
        margin-bottom: 8px;
    }

    .ec-xml-import-preview-col--side { padding-left: 0; }

    .ec-xml-import-header-preview { flex-direction: column-reverse; }

    .ec-xml-import-header-image { max-width: 100%; min-width: 0; }

    /* ✅ footer anclado y botones full width */
    .ec-xml-import-preview-footer {
        flex-direction: column-reverse;
        align-items: stretch;
        padding-left: 14px;
        padding-right: 14px;
    }

    .ec-xml-import-preview-footer .button {
        width: 100%;
        justify-content: center;
    }

    .ec-xml-import-toast-container { right: 10px; left: 10px; }
    .ec-xml-import-toast { justify-content: center; }
}
/* ==============================================================
 * FIX DEFINITIVO: footer anclado ABAJO de la caja (no flotante)
 * ==============================================================
 */

/* El scroll sigue aquí, pero SIN padding-bottom extra */
.ec-xml-import-modal-content{
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;

  /* mantenemos padding normal, pero quitamos el "hueco" del sticky */
  padding-bottom: 10px !important;
}

/* El "hueco" para que no tape el footer lo damos al FORM */
.ec-xml-import-preview-form{
  padding-bottom: calc(96px + env(safe-area-inset-bottom)) !important;
}

/* Footer realmente pegado abajo DE LA CAJA del modal-content */
.ec-xml-import-preview-footer{
  position: -webkit-sticky !important;
  position: sticky !important;
  bottom: 0 !important;
  z-index: 999 !important;

  /* clave: eliminar separación por inline styles */
  margin-top: 0 !important;

  /* romper el padding lateral/inferior del modal-content para que pegue */
  margin-left: -18px !important;
  margin-right: -18px !important;
  margin-bottom: -10px !important;

  /* que ocupe ancho completo del modal */
  width: calc(100% + 36px) !important;

  /* look */
  background: #f9fafb !important;
  border-top: 1px solid #e5e7eb !important;
  box-shadow: 0 -10px 18px rgba(15, 23, 42, 0.08) !important;

  /* padding correcto + safe area iOS */
  padding: 12px 18px calc(16px + env(safe-area-inset-bottom)) !important;
}

/* En móvil el padding del modal-content suele ser 14px */
@media (max-width: 768px){
  .ec-xml-import-preview-footer{
    margin-left: -14px !important;
    margin-right: -14px !important;
    width: calc(100% + 28px) !important;
    padding-left: 14px !important;
    padding-right: 14px !important;
  }
}
