/* ==========================================================================
   Catálogo de Tarjetas Regalo Mianchara - Frontend & Divi
   ========================================================================== */

.tr-mianchara-catalog-wrapper {
    width: 100%;
    margin: 30px auto;
    box-sizing: border-box;
}

.tr-catalog-header {
    text-align: center;
    margin-bottom: 35px;
}

.tr-catalog-header h2 {
    font-size: 2.1em;
    font-weight: 800;
    color: #0f172a;
    margin-bottom: 10px;
}

.tr-catalog-header p {
    font-size: 1.1em;
    color: #64748b;
    max-width: 650px;
    margin: 0 auto;
}

/* Grilla flexible con soporte de alineación (space-between, center, flex-start, etc.) */
.tr-cards-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 25px;
    margin-bottom: 40px;
    width: 100%;
    box-sizing: border-box;
    justify-content: center;
}

/* Sizing base según número de columnas */
.tr-cards-grid.tr-cols-1 .tr-card-item {
    flex: 0 1 480px;
    width: 100%;
    max-width: 480px;
}

.tr-cards-grid.tr-cols-2 .tr-card-item {
    flex: 0 1 calc(50% - 15px);
    width: calc(50% - 15px);
    max-width: 580px;
}

.tr-cards-grid.tr-cols-3 .tr-card-item {
    flex: 0 1 calc(33.333% - 18px);
    width: calc(33.333% - 18px);
    max-width: 420px;
}

.tr-cards-grid.tr-cols-4 .tr-card-item {
    flex: 0 1 calc(25% - 20px);
    width: calc(25% - 20px);
    max-width: 320px;
}

@media (max-width: 991px) {
    .tr-cards-grid .tr-card-item,
    .tr-cards-grid.tr-cols-3 .tr-card-item,
    .tr-cards-grid.tr-cols-4 .tr-card-item {
        flex: 0 1 calc(50% - 15px) !important;
        width: calc(50% - 15px) !important;
        max-width: 100% !important;
    }
}

@media (max-width: 640px) {
    .tr-cards-grid .tr-card-item,
    .tr-cards-grid.tr-cols-1 .tr-card-item,
    .tr-cards-grid.tr-cols-2 .tr-card-item,
    .tr-cards-grid.tr-cols-3 .tr-card-item,
    .tr-cards-grid.tr-cols-4 .tr-card-item {
        flex: 1 1 100% !important;
        width: 100% !important;
        max-width: 100% !important;
    }
}

/* Card individual */
.tr-card-item {
    cursor: pointer;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), box-shadow 0.3s cubic-bezier(0.4, 0, 0.2, 1), border-color 0.3s ease;
    border-radius: 16px;
    overflow: hidden;
    position: relative;
    background: #ffffff;
    border: 2px solid #e2e8f0;
    box-shadow: 0 4px 15px rgba(0,0,0,0.05);
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
}

.tr-card-item:hover {
    transform: translateY(-6px);
}

.tr-card-inner {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
}

.tr-card-badge {
    position: absolute;
    top: 15px;
    left: 15px;
    background: rgba(15, 23, 42, 0.85);
    color: #ffffff;
    font-size: 11px;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    font-weight: 700;
    padding: 4px 12px;
    border-radius: 20px;
    z-index: 2;
    backdrop-filter: blur(4px);
}

/* Contenedor de la imagen con soporte cover y fallback */
.tr-card-image-wrapper {
    width: 100%;
    height: 220px;
    position: relative;
    overflow: hidden;
    background-color: #1e293b;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
}

.tr-card-img-element {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform 0.4s ease;
}

.tr-card-item:hover .tr-card-img-element {
    transform: scale(1.05);
}

/* Ocultar iconos rotos de WooCommerce en la card */
.tr-card-image-wrapper .woocommerce-placeholder,
.tr-card-image-wrapper img.woocommerce-placeholder {
    display: none !important;
}

.tr-card-placeholder-art {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #1e293b 0%, #334155 100%);
    color: #cbd5e1;
}

.tr-card-placeholder-art .tr-art-icon {
    font-size: 45px;
    margin-bottom: 5px;
}

.tr-card-placeholder-art span {
    font-size: 13px;
    letter-spacing: 2px;
    text-transform: uppercase;
    font-weight: 700;
    color: #94a3b8;
}

.tr-card-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(15, 23, 42, 0.65);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.25s ease;
}

.tr-card-item:hover .tr-card-overlay {
    opacity: 1;
}

.tr-btn-select {
    background: #0284c7;
    color: #ffffff;
    font-weight: 700;
    font-size: 13.5px;
    padding: 10px 18px;
    border-radius: 8px;
}

.tr-card-info {
    padding: 20px;
    text-align: center;
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.tr-card-title {
    margin: 0 0 10px 0;
    font-size: 1.25em;
    font-weight: 700;
    color: #0f172a;
}

.tr-card-price {
    font-size: 1.35em;
    font-weight: 800;
    color: #0284c7;
}

/* Modal / Drawer interactivo */
.tr-customizer-drawer {
    display: none !important;
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    background: rgba(15, 23, 42, 0.8) !important;
    z-index: 2147483647 !important; /* Valor máximo absoluto de CSS para superar cualquier menú o cabecera de Divi */
    align-items: center !important;
    justify-content: center !important;
    padding: 30px 20px !important;
    box-sizing: border-box !important;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch;
    scroll-behavior: smooth;
}

/* Cuando el script JS abra el modal, debe añadir la clase o cambiar a display flex */
.tr-customizer-drawer.tr-modal-open {
    display: flex !important;
}

/* En el editor visual de Divi, BLOQUEA el modal para que NUNCA aparezca mientras se diseña */
.et-fb .tr-customizer-drawer,
body.et-fb .tr-customizer-drawer {
    display: none !important;
}

.tr-drawer-inner {
    background: #ffffff !important;
    border-radius: 20px !important;
    max-width: 960px !important;
    width: 100% !important;
    max-height: 85vh !important;
    overflow-y: auto !important;
    margin: auto !important;
    position: relative !important;
    padding: 30px !important;
    box-sizing: border-box !important;
    box-shadow: 0 25px 50px rgba(0,0,0,0.3) !important;
    -webkit-overflow-scrolling: touch;
    scroll-behavior: smooth;
}

.tr-close-drawer {
    position: absolute !important;
    top: 15px !important;
    right: 20px !important;
    background: #f1f5f9 !important;
    border: none !important;
    font-size: 26px !important;
    line-height: 1 !important;
    color: #475569 !important;
    cursor: pointer !important;
    border-radius: 50% !important;
    width: 38px !important;
    height: 38px !important;
    z-index: 10 !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
}

.tr-close-drawer:hover {
    background: #e2e8f0 !important;
    color: #0f172a !important;
}

.tr-drawer-layout {
    display: flex;
    gap: 35px;
    align-items: flex-start;
}

.tr-preview-panel {
    flex: 1 1 42%;
    width: 100%;
}

.tr-form-panel {
    flex: 1 1 58%;
    width: 100%;
}

.tr-preview-card {
    background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
    border-radius: 16px;
    overflow: hidden;
    color: #ffffff;
    border: 1px solid rgba(255,255,255,0.1);
}

.tr-preview-header-img img {
    width: 100%;
    height: 180px;
    object-fit: cover;
    display: block;
}

.tr-preview-body {
    padding: 20px;
    text-align: center;
}

.tr-preview-badge {
    font-size: 11px;
    letter-spacing: 2px;
    color: #94a3b8;
    margin-bottom: 5px;
}

.tr-preview-treatment-name {
    font-size: 20px;
    font-weight: 800;
    color: #38bdf8;
    margin: 0 0 8px 0;
}

.tr-preview-price-tag {
    font-size: 19px;
    font-weight: 700;
    color: #f8fafc;
    margin-bottom: 15px;
}

.tr-preview-message-box {
    background: rgba(255,255,255,0.08);
    border-left: 3px solid #38bdf8;
    padding: 12px;
    border-radius: 6px;
    text-align: left;
    margin-bottom: 15px;
    font-size: 13.5px;
    line-height: 1.45;
    color: #f1f5f9;
    font-style: italic;
    min-height: 50px;
}

.tr-preview-sender-sign,
.tr-preview-recip-sign {
    font-size: 12px;
    font-weight: 600;
    margin-top: 4px;
    font-style: normal;
    color: #38bdf8;
}

.tr-preview-code-mockup {
    font-size: 13px;
    font-weight: bold;
    letter-spacing: 1px;
    color: #cbd5e1;
    background: rgba(255,255,255,0.06);
    padding: 8px 12px;
    border-radius: 6px;
    border: 1px dashed rgba(255,255,255,0.2);
}

.tr-preview-code-mockup span {
    font-size: 10px;
    color: #94a3b8;
    display: block;
}

.tr-form-row {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 12px;
}

.tr-col {
    flex: 1 1 calc(50% - 12px);
    display: flex;
    flex-direction: column;
}

.tr-col-100 {
    flex: 1 1 100%;
}

.tr-col label {
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 5px;
    color: #334155;
}

.tr-col input[type="text"],
.tr-col input[type="email"],
.tr-col textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    font-size: 14px;
    box-sizing: border-box;
    background: #ffffff;
    color: #1e293b;
}

.tr-char-counter {
    display: block;
    text-align: right;
    font-size: 11px;
    color: #94a3b8;
    margin-top: 4px;
}

.tr-btn-buy-card {
    width: 100%;
    background: #0284c7 !important;
    color: #ffffff !important;
    border: none !important;
    font-size: 16px !important;
    font-weight: 800 !important;
    padding: 14px 20px !important;
    border-radius: 10px !important;
    cursor: pointer !important;
    box-shadow: 0 4px 15px rgba(2, 132, 199, 0.35) !important;
    margin-top: 10px;
}

.tr-btn-buy-card:hover {
    background: #0369a1 !important;
}

/* Responsividad móvil del modal */
@media (max-width: 860px) {
    .tr-customizer-drawer {
        align-items: flex-start !important;
        padding: 12px !important;
    }

    .tr-drawer-inner {
        padding: 25px 18px !important;
        max-height: 94vh !important;
        border-radius: 16px !important;
        margin: auto !important;
    }

    .tr-drawer-layout {
        flex-direction: column !important; /* Apilar vista previa arriba y formulario abajo */
        gap: 25px !important;
    }

    .tr-preview-panel,
    .tr-form-panel {
        flex: 1 1 100% !important;
        width: 100% !important;
        max-width: 100% !important;
    }
}

@media (max-width: 600px) {
    .tr-form-row {
        flex-direction: column !important;
        gap: 10px !important;
    }

    .tr-col {
        flex: 1 1 100% !important;
        width: 100% !important;
    }
}
