/* ========================================
   RASTI - Story Form Postpago Styles
   Cards flip, grid layouts, and animations
   ======================================== */

/* Override para permitir el grid más ancho */
.postpago-page {
    padding-top: var(--page-header-offset, var(--navbar-height));
    background: var(--white);
}

.postpago-page .story-form-page {
    padding-top: 2rem;
}

@media (max-width: 640px) {
    .postpago-page .story-form-page {
        padding-top: 1.5rem;
    }
}

.postpago-wide .story-form-container {
    max-width: 1200px !important;
}

/* ========================================
   Postpago pasos 3-4 - ancho controlado en desktop
   ======================================== */
.postpago-page {
    --postpago-narrow-width: 560px;
}

.postpago-page #wizard-content[data-step="3"] .wizard-progress,
.postpago-page #wizard-content[data-step="4"] .wizard-progress,
.postpago-page #wizard-content[data-step="5"] .wizard-progress {
    width: min(100%, var(--postpago-narrow-width));
    margin-left: auto;
    margin-right: auto;
    justify-content: space-between;
}

.postpago-page #wizard-content[data-step="6"] .wizard-progress {
    width: min(100%, var(--postpago-narrow-width));
    margin-left: auto;
    margin-right: auto;
    justify-content: space-between;
}

.postpago-page #wizard-content[data-step="3"] .wizard-step,
.postpago-page #wizard-content[data-step="4"] .wizard-step,
.postpago-page #wizard-content[data-step="5"] .wizard-step {
    max-width: var(--postpago-narrow-width);
    margin-left: auto;
    margin-right: auto;
}

.postpago-page #wizard-content[data-step="3"] .step-header,
.postpago-page #wizard-content[data-step="3"] .step-content,
.postpago-page #wizard-content[data-step="4"] .step-header,
.postpago-page #wizard-content[data-step="4"] .step-content,
.postpago-page #wizard-content[data-step="5"] .step-header,
.postpago-page #wizard-content[data-step="5"] .step-content {
    max-width: var(--postpago-narrow-width);
    margin-left: auto;
    margin-right: auto;
}

.postpago-page #wizard-content[data-step="6"] .step-header {
    max-width: var(--postpago-narrow-width);
    margin-left: auto;
    margin-right: auto;
}

/* ========================================
   Invitado Banner
   ======================================== */
.postpago-page .guest-banner {
    max-width: 1100px;
    margin: 12px auto 0;
    padding: 10px 14px;
    background: #fff4f8;
    border: 1px solid rgba(214, 82, 134, 0.25);
    border-radius: 14px;
    display: flex;
    gap: 10px;
    align-items: center;
    color: #7a3852;
    font-size: 0.9rem;
    line-height: 1.4;
    flex-wrap: wrap;
    position: relative;
    z-index: 2;
}

.guest-banner-tag {
    background: #d65286;
    color: #fff;
    font-weight: 700;
    font-size: 0.78rem;
    padding: 4px 10px;
    border-radius: 999px;
    letter-spacing: 0.02em;
}

.guest-banner-text {
    flex: 1;
    min-width: 200px;
}

/* ========================================
   Postpago acciones (pantallas bloqueadas / estado)
   ======================================== */
.postpay-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    justify-content: center;
    margin-top: 1rem;
}

.postpay-actions .btn-next {
    min-width: 220px;
    justify-content: center;
    min-height: 48px;
    box-sizing: border-box;
}

@media (max-width: 640px) {
    .postpay-actions {
        flex-direction: column;
        align-items: stretch;
    }

    .postpay-actions .btn-next {
        width: 100%;
        min-width: 0;
    }
}

@media (max-width: 720px) {
    .postpago-page .guest-banner {
        margin: 8px 12px 0;
        padding: 10px 12px;
        font-size: 0.85rem;
        gap: 8px;
    }

    .guest-banner-tag {
        font-size: 0.74rem;
        padding: 4px 8px;
    }

    .guest-banner-text {
        min-width: 0;
    }
}

/* ========================================
   Grid de Cards (Temas y Tramas)
   ======================================== */
.theme-cards-container {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 24px;
    width: 100%;
    max-width: 1080px;
    margin: 0 auto;
    padding: 40px 20px;
    justify-items: stretch;
}

.theme-cards-container > div {
    width: 100%;
}

@media (max-width: 1080px) {
    .theme-cards-container {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 720px) {
    .theme-cards-container {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 820px) {
    .theme-cards-container {
        padding-left: 16px;
        padding-right: 16px;
        max-width: 100%;
    }

    .estilos-grid {
        padding-left: 16px;
        padding-right: 16px;
        max-width: 100%;
    }
}

/* ========================================
   Flip Cards
   ======================================== */
.flip-card {
    width: 100%;
    max-width: 360px;
    min-width: 0;
    min-height: var(--card-min-height, 340px);
    height: var(--front-height, var(--card-min-height, 340px));
    -webkit-perspective: 1000px;
    perspective: 1000px;
    transition: height 0.4s ease;
}

.flip-card.expanded {
    height: var(--back-height, var(--card-min-height, 340px));
    z-index: 10;
}

/* Hover solo en dispositivos con puntero real (desktop/trackpad) */
@media (hover: hover) {
    .flip-card:hover {
        z-index: 10;
        height: var(--back-height, var(--card-min-height, 340px));
    }

    .flip-card:hover .flip-card-inner {
        -webkit-transform: rotateY(180deg);
        transform: rotateY(180deg);
    }
}

.flip-card-inner {
    position: relative;
    width: 100%;
    height: 100%;
    transition: transform 0.6s;
    -webkit-transform-style: preserve-3d;
    transform-style: preserve-3d;
    min-height: inherit;
}

/* Flip activado por clase JS (click) */
.flip-card-inner.flipped {
    -webkit-transform: rotateY(180deg);
    transform: rotateY(180deg);
}

/* Estilos comunes front/back */
.flip-card-front,
.flip-card-back {
    position: absolute;
    width: 100%;
    height: 100%;
    min-height: inherit;
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
    border-radius: 20px;
    border: 1px solid var(--card-color, #d65286);
    background: #ffffff;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 24px 20px;
    box-sizing: border-box;
}

/* Lado frontal */
.flip-card-front {
    background: linear-gradient(135deg, #ffffff 0%, color-mix(in srgb, var(--card-color, #BD3D75) 8%, white) 100%);
    padding-bottom: 32px;
    overflow: hidden;
}

.flip-card-front .theme-card-button {
    margin-top: auto;
}

/* Iconos decorativos flotantes */
.card-deco-icon {
    position: absolute;
    width: 40px;
    height: 40px;
    opacity: 0.25;
    pointer-events: none;
}

.flip-card-front .theme-card-title {
    color: var(--card-color, #d65286);
    font-size: 1.5rem;
    font-weight: 300;
    text-align: center;
    font-family: 'Lilita One', cursive;
    line-height: 1.3;
    margin-bottom: 16px;
    flex-grow: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}

.flip-card-front .theme-card-separator {
    width: 50px;
    height: 3px;
    background: #f0d4e0;
    border-radius: 2px;
    margin-bottom: 16px;
}

/* Lado trasero */
.flip-card-back {
    -webkit-transform: rotateY(180deg);
    transform: rotateY(180deg);
    justify-content: flex-start;
    padding-top: 28px;
    padding-bottom: 24px;
    gap: 12px;
    align-items: stretch;
    text-align: left;
}

.flip-card-back form {
    margin-top: 0;
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: stretch;
}

.flip-card-back .theme-card-title {
    color: var(--card-color, #d65286);
    font-size: 1.2rem;
    font-weight: 300;
    text-align: center;
    font-family: 'Lilita One', cursive;
    margin-bottom: 16px;
}

.theme-card-field {
    text-align: left;
    width: 100%;
    margin-bottom: 12px;
    font-size: 0.85rem;
    line-height: 1.5;
}

.theme-card-field:last-of-type {
    margin-bottom: 0;
}

.theme-card-comment {
    width: 100%;
    margin: 6px 0 14px;
    text-align: left;
}

.theme-card-comment-label {
    color: var(--primary, #BD3D75);
    font-weight: 600;
    display: block;
    margin-bottom: 6px;
    font-size: 0.85rem;
}

.theme-card-comment-input {
    width: 100%;
    min-height: 80px;
    padding: 10px 12px;
    border: 1px solid var(--primary, #BD3D75);
    border-radius: 12px;
    font-size: 0.85rem;
    line-height: 1.4;
    font-family: inherit;
    resize: vertical;
    background: #fff;
    color: #374151;
    box-sizing: border-box;
}

.theme-card-comment-input:focus {
    outline: none;
    border-color: var(--primary, #BD3D75);
    box-shadow: 0 0 0 2px rgba(189, 61, 117, 0.18);
}

.theme-card-comment-hint {
    margin: 6px 0 0;
    font-size: 0.75rem;
    color: #6b7280;
}

.theme-card-label {
    color: var(--card-color, #d65286);
    font-weight: 600;
    display: block;
    margin-bottom: 4px;
}

.theme-card-value {
    color: #555;
}

.theme-card-button {
    background: var(--card-color, #d65286);
    color: white;
    border: none;
    padding: 12px 28px;
    border-radius: 50px;
    font-weight: 600;
    font-size: 0.95rem;
    cursor: pointer;
    transition: background 0.2s, transform 0.2s;
}

.flip-card-back .theme-card-button {
    width: 100%;
    margin-top: 6px;
}

.theme-card-button:hover {
    background: #c4426f;
    transform: scale(1.05);
}

@media (max-width: 1000px) {
    .theme-cards-container {
        flex-wrap: wrap;
    }
}

@media (max-width: 600px) {
    .theme-cards-container {
        flex-direction: column;
        align-items: center;
    }

    .flip-card {
        width: 100%;
        max-width: 100%;
        min-width: 0;
    }
}

/* ========================================
   Spinner de carga para botón "Ver más"
   ======================================== */
.btn-spinner {
    width: 20px;
    height: 20px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: btn-spin 0.8s linear infinite;
    display: inline-block;
}

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

.btn-loading {
    pointer-events: none;
    opacity: 0.8;
}

/* ========================================
   Estilos Selection Grid
   ======================================== */
.estilos-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 24px;
    max-width: 1100px;
    margin: 0 auto;
    padding: 20px;
}

@media (max-width: 1024px) {
    .estilos-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 600px) {
    .estilos-grid {
        grid-template-columns: 1fr;
    }
}

/* Estilo Card */
.estilo-card {
    border: 2px solid var(--gray-200, #e5e7eb);
    border-radius: 16px;
    background: white;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
    transition: border-color 0.2s ease, box-shadow 0.2s ease, transform 0.2s ease;
    cursor: pointer;
    overflow: hidden;
    -webkit-tap-highlight-color: transparent;
}

/* Hover solo en dispositivos con mouse */
@media (hover: hover) {
    .estilo-card:hover {
        transform: translateY(-4px);
        box-shadow: 0 8px 24px rgba(189, 61, 117, 0.15);
        border-color: var(--primary, #BD3D75);
    }
}

/* Touch/press: feedback inmediato en todos los dispositivos */
.estilo-card:active {
    transform: scale(0.98);
    border-color: var(--primary, #BD3D75);
    box-shadow: 0 2px 12px rgba(189, 61, 117, 0.2);
}

/* Imagen del estilo - siempre con color */
.estilo-card-image {
    width: 100%;
    height: 180px;
    object-fit: contain;
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    padding: 10px;
    box-sizing: border-box;
    /* Fade-in al cargar para evitar renderizado progresivo top-to-bottom */
    opacity: 0;
    transition: opacity 0.3s ease;
}

.estilo-card-image.loaded {
    opacity: 1;
}

/* Contenido del card */
.estilo-card-content {
    padding: 16px;
    text-align: center;
}

.estilo-card-title {
    color: var(--primary, #BD3D75);
    font-size: 1.2rem;
    font-weight: 700;
    margin-bottom: 8px;
    font-family: var(--font-display, 'Baloo 2', sans-serif);
}

.estilo-card-desc {
    color: var(--gray-600, #666);
    font-size: 0.85rem;
    line-height: 1.4;
    margin-bottom: 12px;
}

.estilo-card-button {
    background: var(--primary, #BD3D75);
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 50px;
    font-weight: 600;
    font-size: 0.9rem;
    cursor: pointer;
    transition: background 0.2s ease, transform 0.15s ease;
    width: 100%;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

@media (hover: hover) {
    .estilo-card-button:hover {
        background: #a83468;
        transform: scale(1.02);
    }
}

.estilo-card-button:active {
    background: #a83468;
    transform: scale(0.97);
}

/* ========================================
   Formato Selection Grid
   ======================================== */
.formatos-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 24px;
    max-width: 900px;
    margin: 0 auto;
    padding: 20px;
}

@media (max-width: 768px) {
    .formatos-grid {
        grid-template-columns: 1fr;
        max-width: 320px;
    }
}

.formato-card:hover {
    transform: translateY(-4px);
}

/* ========================================
   Step Familia - Textarea con Ejemplos
   ======================================== */
.step-familia .form-textarea.textarea-with-examples {
    min-height: 160px;
    line-height: 1.6;
    font-size: 0.95rem;
}

.step-familia .form-textarea.textarea-with-examples::placeholder {
    color: var(--gray-500, #6b7280);
    font-size: 0.88rem;
    line-height: 1.7;
    white-space: pre-wrap;
    opacity: 0.62;
}

/* Estilos para cuando el textarea tiene focus */
.step-familia .form-textarea.textarea-with-examples:focus {
    border-color: var(--primary, #BD3D75);
    box-shadow: 0 0 0 3px rgba(189, 61, 117, 0.1);
}

/* Responsive */
@media (max-width: 640px) {
    .step-familia .form-textarea.textarea-with-examples {
        min-height: 180px;
        font-size: 0.9rem;
    }

    .step-familia .form-textarea.textarea-with-examples::placeholder {
        font-size: 0.82rem;
    }
}

/* ========================================
   Step Rutina - Campo con Botón Info
   ======================================== */
.field-with-info {
    position: relative;
}

.info-button-field {
    position: absolute;
    top: 0;
    right: 0;
    width: 24px;
    height: 24px;
    z-index: 10;
}

.info-button-field .info-icon {
    width: 24px;
    height: 24px;
}

.info-button-field .info-icon svg {
    width: 16px;
    height: 16px;
}

/* Tooltip ancho para contenido extenso */
.info-tooltip-wide {
    width: 320px !important;
    padding: 14px 16px !important;
    left: auto;
    right: -8px;
}

.info-tooltip-wide .tooltip-section-title {
    font-size: 12px;
    margin-bottom: 8px;
}

.info-tooltip-wide .tooltip-examples {
    background: #f9fafb;
    padding: 10px 12px;
    border-radius: 8px;
    border: 1px solid #e5e7eb;
}

/* Responsive para el tooltip */
@media (max-width: 640px) {
    .info-tooltip-wide {
        width: 280px !important;
        right: -40px;
    }

    .info-tooltip-wide::before {
        right: 48px;
    }
}
