/* ========================================
   RASTI - Story Form Wizard Styles
   ======================================== */

/* Wizard Container */
.story-form-page {
    min-height: calc(100vh - var(--navbar-height));
    padding-top: calc(var(--navbar-height) + 2rem);
    padding-bottom: 3rem;
    background: var(--white);
}

.story-form-container {
    max-width: 720px;
    margin: 0 auto;
    padding: 0 1.5rem;
}

/* HTMX Transition Animations */
#wizard-content {
    transition: opacity 0.2s ease;
}

#wizard-content.htmx-swapping {
    opacity: 0;
}

#wizard-content.htmx-settling {
    opacity: 1;
}

/* ──────────────────────────────────────
   Progress Indicator
   ────────────────────────────────────── */
.wizard-progress {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    margin-bottom: 2.5rem;
}

.progress-step {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--gray-200);
    border: 2px solid var(--gray-300);
    transition: all 0.3s ease;
}

.progress-step.active {
    background: var(--primary);
    border-color: var(--primary);
    box-shadow: 0 0 0 4px color-mix(in srgb, var(--primary) 20%, transparent);
}

.progress-step.completed {
    background: var(--primary);
    border-color: var(--primary);
}

.progress-line {
    width: 40px;
    height: 2px;
    background: var(--gray-200);
    transition: background 0.3s ease;
}

.progress-line.completed {
    background: var(--primary);
}

/* ──────────────────────────────────────
   Step Content
   ────────────────────────────────────── */
.wizard-step {
    animation: fadeInUp 0.4s ease;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.step-title {
    font-family: var(--font-body);
    font-weight: 700;
    font-size: 1.75rem;
    color: var(--primary);
    text-align: center;
    margin-bottom: 0.5rem;
    line-height: 1.3;
}

.step-subtitle {
    font-size: 1rem;
    color: var(--gray-600);
    text-align: center;
    margin-bottom: 2rem;
}

/* ──────────────────────────────────────
   Motivo Selection Cards
   ────────────────────────────────────── */
.motivo-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.75rem;
    margin-bottom: 2rem;
    max-width: 600px;
    margin-left: auto;
    margin-right: auto;
    align-items: stretch;
    justify-items: stretch;
}

.motivo-card {
    position: relative;
    background: var(--white);
    border: 2px solid var(--gray-200);
    border-radius: 12px;
    padding: 1.25rem;
    cursor: pointer;
    transition: all 0.25s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    gap: 0.75rem;
    min-height: 120px;
    box-sizing: border-box;
    width: 100% !important;
    /* Sobrescribe pico.css label:has([type=radio]) */
}

.motivo-card:hover {
    border-color: var(--gray-300);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.06);
    transform: translateY(-2px);
}

.motivo-card.selected {
    border-color: var(--primary);
    background: color-mix(in srgb, var(--primary) 5%, var(--white));
    box-shadow: 0 4px 16px color-mix(in srgb, var(--primary) 15%, transparent);
}

.motivo-card.selected .motivo-icon {
    color: var(--primary);
}

.motivo-icon {
    font-size: 2rem;
    color: var(--gray-600);
    transition: color 0.25s ease;
}

.motivo-icon svg {
    width: 40px;
    height: 40px;
}

.motivo-label {
    font-weight: 600;
    font-size: 0.95rem;
    color: var(--gray-800);
    line-height: 1.3;
    width: 100%;
}

.motivo-content {
    width: 100%;
}

.motivo-example {
    font-size: 0.8rem;
    color: var(--gray-500);
    line-height: 1.4;
}

/* ──────────────────────────────────────
   Info Button & Tooltip
   ────────────────────────────────────── */

.info-button {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 22px;
    height: 22px;
    z-index: 10;
}

.info-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: var(--gray-100);
    color: var(--gray-500);
    transition: all 0.2s ease;
}

.info-icon svg {
    width: 14px;
    height: 14px;
}

.info-button:hover .info-icon {
    background: var(--primary);
    color: var(--white);
}

.info-tooltip {
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 8px;
    padding: 10px 12px;
    background: var(--white);
    color: black;
    font-size: 0.8rem;
    font-weight: 400;
    line-height: 1.4;
    border-radius: 8px;
    border: 1px solid var(--gray-200);
    white-space: normal;
    width: 220px;
    text-align: left;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-4px);
    transition: all 0.2s ease;
    pointer-events: none;
    z-index: 100;
}

/* Flecha del tooltip */
.info-tooltip::before {
    content: '';
    position: absolute;
    bottom: 100%;
    right: 10px;
    border: 6px solid transparent;
    border-bottom-color: var(--white);
    filter: drop-shadow(0 -1px 0 var(--gray-200));
}

.info-button:hover .info-tooltip {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

/* Hidden radio for selection */
.motivo-card input[type="radio"] {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

/* ──────────────────────────────────────
   Text Input Fields
   ────────────────────────────────────── */
.form-input {
    width: 100%;
    padding: 0.875rem 1rem;
    font-size: 1rem;
    font-family: inherit;
    border: 1.5px solid var(--gray-200);
    border-radius: 10px;
    background: var(--gray-50);
    color: var(--gray-900);
    transition: all 0.25s ease;
}

.form-input::placeholder {
    color: var(--gray-400);
}

.form-input:hover {
    border-color: var(--gray-300);
}

.form-input:focus {
    outline: none;
    border-color: var(--primary);
    background: var(--white);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 15%, transparent);
}

/* ──────────────────────────────────────
   Chip Selector
   ────────────────────────────────────── */
.chip-group {
    display: flex;
    flex-wrap: wrap;
    gap: 0.625rem;
}

.chip {
    display: inline-flex;
    align-items: center;
    padding: 0.625rem 1.25rem;
    background: var(--gray-50);
    border: 1.5px solid var(--gray-200);
    border-radius: 50px;
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--gray-700);
    cursor: pointer;
    transition: all 0.2s ease;
    width: auto !important;
    /* Sobrescribe pico.css */
}

.chip:hover {
    border-color: var(--gray-300);
    background: var(--gray-100);
}

.chip.selected {
    background: color-mix(in srgb, var(--primary) 10%, var(--white));
    border-color: var(--primary);
    color: var(--primary);
}

.chip input[type="radio"],
.chip input[type="checkbox"] {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.form-section-inline {
    margin-top: 1.5rem;
}

/* ──────────────────────────────────────
   Description Textarea
   ────────────────────────────────────── */
.form-section {
    margin-top: 1rem;
    padding-top: 2rem;
    border-top: 1px solid var(--gray-200);
}

.description-section {
    animation: slideDownFade 0.4s ease forwards;
}

.description-section.hidden {
    display: none;
    border-top: none !important;
}

@keyframes slideDownFade {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.form-label {
    display: block;
    font-weight: 600;
    font-size: 1rem;
    color: var(--gray-800);
    margin-bottom: 0.5rem;
}

.form-hint {
    font-size: 0.875rem;
    color: var(--gray-500);
    margin-bottom: 0.75rem;
}

.form-textarea {
    width: 100%;
    min-height: 100px;
    padding: 1rem;
    font-size: 1rem;
    font-family: inherit;
    border: 1.5px solid var(--gray-200);
    border-radius: 10px;
    background: var(--gray-50);
    color: var(--gray-900);
    resize: vertical;
    transition: all 0.25s ease;
}

.form-textarea::placeholder {
    color: var(--gray-400);
}

.form-textarea:hover {
    border-color: var(--gray-300);
}

.form-textarea:focus {
    outline: none;
    border-color: var(--primary);
    background: var(--white);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 15%, transparent);
}

/* ──────────────────────────────────────
   Children Fields (Multi-child)
   ────────────────────────────────────── */
.children-container {
    display: flex;
    flex-direction: column;
    gap: 0;
    margin-top: 0.5rem;
}

.children-count-row {
    max-width: none;
}

.children-count-input {
    text-align: center;
    font-weight: 600;
    max-width: 120px;
}

.child-block {
    padding: 0.5rem 0 0;
}

.child-animate {
    animation: slideDownFade 0.4s ease forwards;
}

.child-block + .child-block {
    margin-top: 1.75rem;
    padding-top: 1.75rem;
    border-top: 1px solid var(--gray-200);
}

.child-title {
    margin: 0 0 0.75rem;
    font-size: 1rem;
    color: var(--gray-800);
}

.child-fields {
    display: grid;
    gap: 1rem;
}

.child-field .form-label {
    margin-bottom: 0.4rem;
}

@media (min-width: 720px) {
    .child-fields {
        grid-template-columns: minmax(0, 1fr);
    }
}

/* ──────────────────────────────────────
   Navigation Buttons
   ────────────────────────────────────── */
.btn-next,
.btn-prev {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    text-decoration: none;
    font-weight: 600;
    font-size: 1rem;
    line-height: 1;
    cursor: pointer;
    transition: all 0.25s ease;
}

.btn-next {
    background: var(--primary);
    color: var(--white);
    border: none;
    padding: 0.875rem 1.5rem;
    border-radius: 6px;
}

.btn-next:hover {
    background: var(--primary-hover);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px color-mix(in srgb, var(--primary) 30%, transparent);
}

.btn-prev {
    background: transparent;
    color: var(--primary);
    border: 2px solid var(--primary);
    padding: 0.875rem 1.5rem;
    border-radius: 6px;
}

.btn-prev:hover {
    background: color-mix(in srgb, var(--primary) 10%, transparent);
}

.wizard-nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-top: 1.5rem;
}

.wizard-nav-spacer {
    flex: 1;
}

.wizard-nav .btn-next {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    background: var(--primary);
    color: var(--white);
    border: none;
    padding: 0.875rem 1.5rem;
    border-radius: 6px;
    font-weight: 600;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.25s ease;
}

.wizard-nav .btn-next:hover {
    background: var(--primary-hover);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px color-mix(in srgb, var(--primary) 30%, transparent);
}

.wizard-nav .btn-next:disabled {
    background: var(--gray-300);
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.wizard-nav .btn-prev {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    background: transparent;
    color: var(--primary);
    border: 2px solid var(--primary);
    padding: 0.875rem 1.5rem;
    border-radius: 6px;
    font-weight: 600;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.25s ease;
}

.wizard-nav .btn-prev:hover {
    background: color-mix(in srgb, var(--primary) 10%, transparent);
}

/* ──────────────────────────────────────
   Responsive
   ────────────────────────────────────── */
@media (max-width: 640px) {
    .story-form-page {
        padding-top: calc(var(--navbar-height) + 1.5rem);
    }

    .story-form-container {
        padding: 0 1rem;
    }

    .wizard-progress {
        margin-bottom: 2rem;
    }

    .progress-step {
        width: 10px;
        height: 10px;
    }

    .progress-line {
        width: 24px;
    }

    .step-title {
        font-size: 1.5rem;
    }

    .motivo-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 0.6rem;
    }

    .motivo-card {
        flex-direction: column;
        text-align: center;
        padding: 0.85rem;
        min-height: 110px;
    }

    .motivo-icon {
        font-size: 1.25rem;
    }

    .motivo-icon svg {
        width: 28px;
        height: 28px;
    }

    .motivo-content {
        width: 100%;
    }

    .motivo-label {
        font-size: 0.85rem;
    }

    .wizard-nav {
        flex-direction: column-reverse;
        gap: 1rem;
    }

    .wizard-nav .btn-next {
        width: 100%;
        justify-content: center;
    }

    .wizard-nav .btn-prev {
        width: 100%;
        justify-content: center;
    }
}

@media (max-width: 820px) {
    .story-form-container {
        max-width: 100%;
        padding: 0 1rem;
    }

    .motivo-grid {
        max-width: 100%;
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    }
}

/* ──────────────────────────────────────
   Dark Mode
   ────────────────────────────────────── */
.dark-mode .story-form-page {
    background: var(--bg-primary);
}

.dark-mode .step-title {
    color: var(--text-primary);
}

.dark-mode .step-subtitle {
    color: var(--text-secondary);
}

.dark-mode .motivo-card {
    background: var(--bg-secondary);
    border-color: var(--gray-200);
}

.dark-mode .motivo-card:hover {
    border-color: var(--gray-300);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.dark-mode .motivo-card.selected {
    border-color: var(--primary);
    background: color-mix(in srgb, var(--primary) 10%, var(--bg-secondary));
}

.dark-mode .motivo-label {
    color: var(--text-primary);
}

.dark-mode .motivo-example {
    color: var(--text-muted);
}

.dark-mode .motivo-icon {
    color: var(--text-secondary);
}

.dark-mode .info-icon {
    background: var(--bg-tertiary);
    color: var(--text-muted);
}

.dark-mode .info-button:hover .info-icon {
    background: var(--primary);
    color: var(--white);
}

.dark-mode .info-tooltip {
    background: var(--gray-100);
    color: var(--gray-900);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
}

.dark-mode .info-tooltip::before {
    border-bottom-color: var(--gray-100);
}

.dark-mode .form-section {
    border-top-color: var(--gray-200);
}

.dark-mode .form-label {
    color: var(--text-primary);
}

.dark-mode .form-hint {
    color: var(--text-muted);
}

.dark-mode .form-textarea {
    background: var(--bg-secondary);
    border-color: var(--gray-200);
    color: var(--text-primary);
}

.dark-mode .form-textarea::placeholder {
    color: var(--text-muted);
}

.dark-mode .form-textarea:focus {
    background: var(--bg-tertiary);
    border-color: var(--primary);
}

.dark-mode .wizard-nav {
    border-top-color: var(--gray-200);
}

.dark-mode .wizard-nav .btn-prev {
    color: var(--text-secondary);
}

.dark-mode .wizard-nav .btn-prev:hover {
    color: var(--text-primary);
    background: var(--bg-tertiary);
}

.dark-mode .form-input {
    background: var(--bg-secondary);
    border-color: var(--gray-200);
    color: var(--text-primary);
}

.dark-mode .form-input::placeholder {
    color: var(--text-muted);
}

.dark-mode .form-input:focus {
    background: var(--bg-tertiary);
    border-color: var(--primary);
}

.dark-mode .chip {
    background: var(--bg-secondary);
    border-color: var(--gray-200);
    color: var(--text-secondary);
}

.dark-mode .chip:hover {
    background: var(--bg-tertiary);
    border-color: var(--gray-300);
}

.dark-mode .chip.selected {
    background: color-mix(in srgb, var(--primary) 15%, var(--bg-secondary));
    border-color: var(--primary);
    color: var(--primary);
}

/* ──────────────────────────────────────
   Cierre Step
   ────────────────────────────────────── */
.step-cierre .step-content {
    text-align: center;
    padding: 3rem 1rem;
}

.cierre-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.5rem;
}

.cierre-icon {
    width: 64px;
    height: 64px;
    color: var(--primary);
    background: color-mix(in srgb, var(--primary) 10%, transparent);
    padding: 0.75rem;
    border-radius: 12px;
    box-sizing: content-box;
}

.cierre-message {
    font-size: 1.25rem;
    color: var(--gray-700);
    line-height: 1.6;
    max-width: 400px;
}

/* Botón Crear mi cuento */
.btn-create {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-hover) 100%);
    font-size: 1.1rem;
    padding: 1rem 2rem !important;
    gap: 0.75rem;
}

.btn-create:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px color-mix(in srgb, var(--primary) 40%, transparent);
}

/* ──────────────────────────────────────
   Confirmación Step (Post-pago)
   ────────────────────────────────────── */
.step-confirmacion .step-content {
    text-align: center;
    padding: 3rem 1rem;
}

.confirmacion-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
}

.confirmacion-icon {
    width: 80px;
    height: 80px;
    color: #22c55e;
}

.confirmacion-message {
    font-size: 1.25rem;
    color: var(--gray-700);
    line-height: 1.6;
    max-width: 400px;
}

.confirmacion-submessage {
    font-size: 1rem;
    color: var(--gray-500);
    max-width: 350px;
}

/* ──────────────────────────────────────
   Bienvenida Step (Post-pago)
   ────────────────────────────────────── */
.step-bienvenida .step-content {
    text-align: center;
    padding: 3rem 1rem;
}

.bienvenida-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.5rem;
}

.bienvenida-icon {
    width: 80px;
    height: 80px;
    color: var(--primary);
    background: color-mix(in srgb, var(--primary) 10%, transparent);
    padding: 1rem;
    border-radius: 12px;
    box-sizing: content-box;
}

.bienvenida-message {
    font-size: 1.25rem;
    color: var(--gray-600);
    line-height: 1.6;
    max-width: 400px;
}

/* Rutina + Bienvenida combinado */
.step-rutina-bienvenida {
    text-align: center;
}

.bienvenida-icon-wrapper {
    margin-bottom: 1.5rem;
}

.form-section-divider {
    height: 1px;
    max-width: 200px;
    margin: 0 auto 1.5rem;
    background: var(--gray-200);
}

.form-section-inline {
    text-align: left;
}
