/**
 * Tradeando Checkout - Bloque Dinámico de Destino
 * Compatible con WooCommerce Blocks (Gutenberg) y Checkout Tradicional.
 */

/* 1. Ocultar únicamente los contenedores de facturación y envío (preservando Información de Contacto) */
.wc-block-checkout__billing-fields,
.wc-block-components-checkout-step--billing-address,
.wc-block-components-checkout-step--billing,
.wc-block-checkout__shipping-fields,
.wc-block-components-checkout-step--shipping-address,
.wc-block-components-checkout-step--shipping,
.wc-block-checkout__billing-fields .wc-block-components-address-form,
.wc-block-checkout__shipping-fields .wc-block-components-address-form,
.woocommerce-shipping-fields,
#billing-fields,
#shipping-fields,
.woocommerce-billing-fields__field-wrapper .form-row:has(#billing_address_1),
.woocommerce-billing-fields__field-wrapper .form-row:has(#billing_address_2),
.woocommerce-billing-fields__field-wrapper .form-row:has(#billing_city),
.woocommerce-billing-fields__field-wrapper .form-row:has(#billing_state),
.woocommerce-billing-fields__field-wrapper .form-row:has(#billing_postcode),
.woocommerce-billing-fields__field-wrapper .form-row:has(#billing_country) {
    display: none !important;
}

/* 2. Triggers Inline dentro de la fila de método de envío */
.tradeando-pickup-trigger-wrapper,
.tradeando-shalom-trigger-wrapper {
    margin-top: 5px;
    padding-left: 25px;
    font-size: 0.9em;
    width: 100%;
    flex-basis: 100%;
    box-sizing: border-box;
    line-height: 1.4;
    transition: all 0.2s ease;
}

.tradeando-shalom-trigger-wrapper .tradeando-shalom-selected-info,
.tradeando-pickup-trigger-wrapper .tradeando-pickup-selected-info {
    color: #4caf50 !important;
    font-weight: 500;
}

body.dark-mode .tradeando-shalom-trigger-wrapper .tradeando-shalom-selected-info,
body.dark-mode .tradeando-pickup-trigger-wrapper .tradeando-pickup-selected-info {
    color: #4ade80 !important;
}

.tradeando-shalom-trigger-wrapper a.tradeando-shalom-change-agency,
.tradeando-pickup-trigger-wrapper a.tradeando-pickup-change-store {
    margin-left: 5px;
    font-size: 11px;
    color: #666 !important;
    text-decoration: underline !important;
    font-weight: normal;
}

body.dark-mode .tradeando-shalom-trigger-wrapper a.tradeando-shalom-change-agency,
body.dark-mode .tradeando-pickup-trigger-wrapper a.tradeando-pickup-change-store {
    color: #94a3b8 !important;
}

.tradeando-shalom-trigger-wrapper a.tradeando-shalom-open-modal,
.tradeando-pickup-trigger-wrapper a.tradeando-pickup-open-modal {
    color: #0071a1 !important;
    text-decoration: underline !important;
    font-weight: 600;
}

/* 3. Modal Selector de Agencia Shalom */
#tradeando-shalom-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(4px);
    z-index: 999999;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 16px;
    box-sizing: border-box;
}

#tradeando-shalom-modal.is-visible {
    display: flex !important;
}

#tradeando-shalom-modal .tradeando-modal-box {
    background: #ffffff;
    border-radius: 16px;
    width: 100%;
    max-width: 480px;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.2), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    overflow: hidden;
    animation: tdModalScale 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

body.dark-mode #tradeando-shalom-modal .tradeando-modal-box {
    background: #1e293b;
    border: 1px solid #334155;
    color: #f8fafc;
}

@keyframes tdModalScale {
    from { opacity: 0; transform: scale(0.95); }
    to { opacity: 1; transform: scale(1); }
}

#tradeando-shalom-modal .tradeando-modal-header {
    padding: 16px 20px;
    border-bottom: 1px solid #f1f5f9;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

body.dark-mode #tradeando-shalom-modal .tradeando-modal-header {
    border-bottom-color: #334155;
}

#tradeando-shalom-modal .tradeando-modal-header h3 {
    margin: 0;
    font-size: 1.05rem;
    font-weight: 700;
    color: #0f172a;
}

body.dark-mode #tradeando-shalom-modal .tradeando-modal-header h3 {
    color: #f8fafc;
}

#tradeando-shalom-modal .tradeando-modal-close {
    background: transparent;
    border: none;
    font-size: 1.5rem;
    line-height: 1;
    color: #94a3b8;
    cursor: pointer;
    padding: 0;
}

#tradeando-shalom-modal .tradeando-modal-close:hover {
    color: #0f172a;
}

#tradeando-shalom-modal .tradeando-modal-body {
    padding: 20px;
}

#tradeando-shalom-modal .tradeando-modal-footer {
    padding: 14px 20px;
    background: #f8fafc;
    border-top: 1px solid #f1f5f9;
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

body.dark-mode #tradeando-shalom-modal .tradeando-modal-footer {
    background: #0f172a;
    border-top-color: #334155;
}

#tradeando-shalom-modal .tradeando-store-select {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    font-size: 0.9rem;
    background: #ffffff;
    color: #0f172a;
    outline: none;
    transition: all 0.2s ease;
    box-sizing: border-box;
}

body.dark-mode #tradeando-shalom-modal .tradeando-store-select {
    background: #0f172a;
    border-color: #334155;
    color: #f8fafc;
}

#tradeando-shalom-modal .tradeando-store-info-box {
    background: #eff6ff;
    border: 1px solid #bfdbfe;
    border-radius: 8px;
    padding: 10px 14px;
    font-size: 0.85rem;
    color: #1e40af;
    line-height: 1.4;
}

body.dark-mode #tradeando-shalom-modal .tradeando-store-info-box {
    background: rgba(37, 99, 235, 0.15);
    border-color: rgba(37, 99, 235, 0.4);
    color: #93c5fd;
}

/* Modal Typography and Sections */
#tradeando-shalom-modal .td-modal-section-title {
    font-weight: 700;
    color: #0f172a;
    margin-bottom: 6px;
    font-size: 0.95rem;
    display: flex;
    align-items: center;
    gap: 6px;
}

body.dark-mode #tradeando-shalom-modal .td-modal-section-title {
    color: #f1f5f9 !important;
}

#tradeando-shalom-modal .td-modal-sec-tag {
    font-size: 0.8rem;
    font-weight: normal;
    color: #64748b;
}

body.dark-mode #tradeando-shalom-modal .td-modal-sec-tag {
    color: #94a3b8 !important;
}

#tradeando-shalom-modal .td-modal-section-desc {
    font-size: 0.78rem;
    color: #64748b;
    margin-top: 0;
    margin-bottom: 10px;
    line-height: 1.35;
}

body.dark-mode #tradeando-shalom-modal .td-modal-section-desc {
    color: #94a3b8 !important;
}

#tradeando-shalom-modal .td-modal-field-label {
    display: block;
    font-size: 0.82rem;
    font-weight: 600;
    margin-bottom: 4px;
    color: #374151;
}

body.dark-mode #tradeando-shalom-modal .td-modal-field-label {
    color: #cbd5e1 !important;
}

#tradeando-shalom-modal .td-modal-save-default-wrapper {
    font-size: 0.85rem;
    color: #475569;
    margin-top: 12px;
}

body.dark-mode #tradeando-shalom-modal .td-modal-save-default-wrapper {
    color: #cbd5e1 !important;
}

#tradeando-shalom-modal hr.td-modal-divider {
    border: 0;
    border-top: 1px solid #e2e8f0;
    margin: 16px 0 12px 0;
}

body.dark-mode #tradeando-shalom-modal hr.td-modal-divider {
    border-top-color: #334155 !important;
}

body.dark-mode #tradeando-shalom-modal #btn-cancel-shalom {
    background: #334155 !important;
    color: #e2e8f0 !important;
    border: 1px solid #475569 !important;
}

body.dark-mode #tradeando-shalom-modal #btn-cancel-shalom:hover {
    background: #475569 !important;
    color: #ffffff !important;
}

/* 4. Selector de Tienda (Pick-up / Consolidado) */
.tradeando-store-selector-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.tradeando-store-selector-group label {
    font-size: 0.9rem;
    font-weight: 600;
    color: #334155;
}

body.dark-mode .tradeando-store-selector-group label {
    color: #cbd5e1;
}

.tradeando-store-select {
    width: 100%;
    padding: 10px 14px;
    border-radius: 8px;
    border: 1px solid #cbd5e1;
    background: #ffffff;
    color: #0f172a;
    font-size: 0.95rem;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.tradeando-store-select:focus {
    border-color: #2563eb;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

body.dark-mode .tradeando-store-select {
    background: #0f172a;
    border-color: #475569;
    color: #ffffff;
}

body.dark-mode .tradeando-store-select:focus {
    border-color: #8b5cf6;
    box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.2);
}

.tradeando-store-info-box {
    margin-top: 10px;
    padding: 12px 14px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-left: 4px solid #0284c7;
    border-radius: 6px;
    font-size: 0.88rem;
    color: #334155;
    line-height: 1.5;
}

body.dark-mode .tradeando-store-info-box {
    background: #0f172a;
    border-color: #334155;
    border-left-color: #38bdf8;
    color: #e2e8f0;
}

/* 5. Tarjeta de Resumen de Destino (Fondo Neutro + Acento Celeste) */
.tradeando-shalom-card {
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-left: 3px solid #0284c7;
    border-radius: 8px;
    padding: 16px 18px;
    position: relative;
    transition: all 0.2s ease;
}

body.dark-mode .tradeando-shalom-card {
    background: #1e293b;
    border-color: #334155;
    border-left-color: #38bdf8;
}

.tradeando-shalom-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 6px;
}

.tradeando-shalom-card-title {
    font-weight: 700;
    color: #0f172a;
    font-size: 0.92rem;
    display: flex;
    align-items: center;
    gap: 6px;
}

body.dark-mode .tradeando-shalom-card-title {
    color: #f8fafc;
}

.tradeando-shalom-agency-name {
    font-size: 1.05rem;
    font-weight: 700;
    color: #0f172a;
    margin-bottom: 4px;
}

body.dark-mode .tradeando-shalom-agency-name {
    color: #ffffff;
}

.tradeando-shalom-agency-addr {
    font-size: 0.88rem;
    color: #64748b;
    line-height: 1.45;
}

body.dark-mode .tradeando-shalom-agency-addr {
    color: #94a3b8;
}

/* Botón de edición/cambio (Estilo Outline sutil / Texto interactivo) */
.tradeando-btn-change-dest {
    background: transparent !important;
    border: 1px solid #cbd5e1 !important;
    border-radius: 6px !important;
    color: #0284c7 !important;
    font-size: 0.84rem !important;
    font-weight: 600 !important;
    cursor: pointer !important;
    text-decoration: none !important;
    padding: 6px 14px !important;
    margin-top: 10px !important;
    display: inline-flex !important;
    align-items: center !important;
    gap: 5px !important;
    transition: all 0.2s ease !important;
    box-shadow: none !important;
}

.tradeando-btn-change-dest:hover {
    background: #f0f9ff !important;
    border-color: #0284c7 !important;
    color: #0369a1 !important;
}

body.dark-mode .tradeando-btn-change-dest {
    border-color: #475569 !important;
    color: #38bdf8 !important;
    background: transparent !important;
}

body.dark-mode .tradeando-btn-change-dest:hover {
    background: rgba(56, 189, 248, 0.1) !important;
    border-color: #38bdf8 !important;
    color: #7dd3fc !important;
}

/* Botón de estado vacío (Seleccionar Tienda) */
.tradeando-btn-select-store {
    background: #f8fafc !important;
    border: 1px dashed #0284c7 !important;
    border-radius: 6px !important;
    color: #0284c7 !important;
    font-size: 0.88rem !important;
    font-weight: 600 !important;
    padding: 8px 16px !important;
    cursor: pointer !important;
    display: inline-flex !important;
    align-items: center !important;
    gap: 6px !important;
    transition: all 0.2s ease !important;
    box-shadow: none !important;
}

.tradeando-btn-select-store:hover {
    background: #f0f9ff !important;
    border-style: solid !important;
    color: #0369a1 !important;
}

body.dark-mode .tradeando-btn-select-store {
    background: #0f172a !important;
    border-color: #38bdf8 !important;
    color: #38bdf8 !important;
}

body.dark-mode .tradeando-btn-select-store:hover {
    background: rgba(56, 189, 248, 0.1) !important;
    color: #7dd3fc !important;
}

/* 6. Desplegable de Override Shalom */
.tradeando-shalom-override-box {
    margin-top: 14px;
    padding: 16px;
    background: #f8fafc;
    border: 1px dashed #cbd5e1;
    border-radius: 8px;
    display: none;
    animation: tdFadeIn 0.25s ease;
}

body.dark-mode .tradeando-shalom-override-box {
    background: #0f172a;
    border-color: #475569;
}

.tradeando-shalom-override-box.is-open {
    display: block;
}

.tradeando-override-fields-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: 12px;
}

@media (max-width: 640px) {
    .tradeando-override-fields-grid {
        grid-template-columns: 1fr;
    }
}

.tradeando-save-default-wrapper {
    margin-top: 10px;
    font-size: 0.88rem;
    display: flex;
    align-items: center;
    gap: 8px;
    color: #334155;
}

body.dark-mode .tradeando-save-default-wrapper {
    color: #cbd5e1;
}

/* 7. Avisos / Alertas de Perfil Incompleto */
.tradeando-dest-notice {
    padding: 12px 14px;
    border-radius: 8px;
    margin-bottom: 14px;
    font-size: 0.9rem;
    line-height: 1.4;
    display: flex;
    align-items: flex-start;
    gap: 10px;
}

.tradeando-dest-notice.is-warning {
    background: #fffbeb;
    border: 1px solid #fde68a;
    border-left: 4px solid #d97706;
    color: #92400e;
}

body.dark-mode .tradeando-dest-notice.is-warning {
    background: rgba(217, 119, 6, 0.15);
    border-color: rgba(217, 119, 6, 0.3);
    color: #fde68a;
}

/* ============================================================
   8. AJUSTES RESPONSIVOS Y SEPARACIÓN LATERAL EN MÓVILES
   ============================================================ */
@media (max-width: 768px) {
    /* Padding lateral sutil (8px) para evitar bordes pegados sin desperdiciar espacio */
    .wp-block-woocommerce-checkout,
    .wc-block-checkout,
    .woocommerce-checkout,
    .woocommerce-cart,
    .wp-block-woocommerce-cart,
    .wc-block-checkout__main,
    .entry-content > .woocommerce,
    main .woocommerce {
        padding-left: 8px !important;
        padding-right: 8px !important;
        padding-bottom: 0 !important;
        margin-bottom: 0 !important;
        box-sizing: border-box !important;
    }

    /* Ajustar pasos de checkout y eliminar espacios vacíos tras el botón de pedido */
    .wc-block-components-checkout-step,
    .wc-block-checkout__sidebar,
    .wc-block-components-sidebar,
    .wc-block-checkout__actions,
    .wc-block-checkout__actions_row {
        padding-left: 0 !important;
        padding-right: 0 !important;
        padding-bottom: 0 !important;
        margin-bottom: 8px !important;
        width: 100% !important;
        box-sizing: border-box !important;
    }

    /* Contenedor del Bloque de Destino */
    .tradeando-destination-block {
        margin-left: 0 !important;
        margin-right: 0 !important;
        border-radius: 10px !important;
    }
}

