/**
 * TorlyAI Waitlist Modal - Design System Compliant
 * Follows TORLYAI_DESIGN_SYSTEM.md specifications
 * Version: 2.0.0
 */

/* ============================================
   MODAL BACKDROP
   ============================================ */

.waitlist-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(2px);
    z-index: 9998;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

/* ============================================
   MODAL CONTAINER
   ============================================ */

.waitlist-modal {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid rgba(0, 0, 0, 0.1);
    border-radius: 1rem;                    /* 16px per design system */
    padding: 2.5rem;                        /* 40px spacing */
    max-width: 480px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 20px 25px -5px rgb(0 0 0 / 0.1),
                0 10px 10px -5px rgb(0 0 0 / 0.04);
    z-index: 9999;
    animation: slideIn 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translate(-50%, -48%) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1);
    }
}

/* Smooth scrolling */
.waitlist-modal {
    scroll-behavior: smooth;
}

/* Webkit scrollbar styling */
.waitlist-modal::-webkit-scrollbar {
    width: 8px;
}

.waitlist-modal::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.05);
    border-radius: 4px;
}

.waitlist-modal::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 4px;
}

.waitlist-modal::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 0, 0, 0.3);
}

/* ============================================
   CLOSE BUTTON
   ============================================ */

.waitlist-close {
    position: absolute;
    top: 1rem;
    right: 1rem;
    width: 2.5rem;
    height: 2.5rem;
    border-radius: 0.5rem;
    background: transparent;
    border: none;
    color: var(--text-secondary, rgba(0, 0, 0, 0.7));
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 10;
}

.waitlist-close:hover {
    background: rgba(0, 0, 0, 0.05);
    color: var(--black, #000000);
}

.waitlist-close:focus-visible {
    outline: 2px solid var(--color-chat-green, #10b981);
    outline-offset: 2px;
}

/* ============================================
   STEP MANAGEMENT
   ============================================ */

.waitlist-step {
    display: none;
    animation: stepFadeIn 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.waitlist-step.active {
    display: block;
}

@keyframes stepFadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ============================================
   TYPOGRAPHY (Design System Compliant)
   ============================================ */

.waitlist-title {
    font-size: clamp(1.5rem, 3vw, 2rem);    /* Fluid scaling */
    font-weight: 700;
    line-height: 1.1;
    color: var(--black, #000000);
    margin-bottom: 0.75rem;
    text-align: center;
}

.waitlist-subtitle {
    font-size: clamp(1rem, 1.5vw, 1.125rem);
    font-weight: 400;
    line-height: 1.6;
    color: var(--text-secondary, rgba(0, 0, 0, 0.7));
    text-align: center;
    margin-bottom: 2rem;                    /* 32px spacing */
}

/* ============================================
   SUCCESS ICON
   ============================================ */

.success-icon {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: var(--color-chat-green, #10b981);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 1.5rem;
    animation: successPop 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes successPop {
    0% {
        transform: scale(0);
        opacity: 0;
    }
    50% {
        transform: scale(1.1);
    }
    100% {
        transform: scale(1);
        opacity: 1;
    }
}

/* ============================================
   FORM ELEMENTS (Design System Compliant)
   ============================================ */

.waitlist-form {
    width: 100%;
}

.form-group {
    margin-bottom: 1.5rem;                  /* 24px spacing */
}

.form-label {
    display: block;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--black, #000000);
    margin-bottom: 0.5rem;                  /* 8px spacing */
}

.form-input,
.form-select {
    width: 100%;
    padding: 1rem 1.25rem;                  /* 16px 20px */
    font-size: 1rem;
    border: 2px solid var(--border-color, #e5e7eb);
    border-radius: 0.75rem;                 /* 12px per design system */
    background: var(--white, #ffffff);
    color: var(--black, #000000);
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    font-family: inherit;
}

.form-input:focus,
.form-select:focus {
    outline: none;
    border-color: var(--color-chat-green, #10b981);
    box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.1);
}

.form-input::placeholder {
    color: var(--text-tertiary, rgba(0, 0, 0, 0.5));
}

.form-input.invalid {
    border-color: #ef4444;
}

.form-error {
    display: none;
    color: #ef4444;
    font-size: 0.875rem;
    margin-top: 0.5rem;
}

.form-input.invalid ~ .form-error {
    display: block;
}

/* ============================================
   RADIO BUTTONS (Design System)
   ============================================ */

.radio-group {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;                           /* 12px spacing */
}

.radio-option {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem 1.25rem;
    border: 2px solid var(--border-color, #e5e7eb);
    border-radius: 0.75rem;                 /* 12px per design system */
    cursor: pointer;
    transition: all 0.15s cubic-bezier(0.4, 0, 0.2, 1);
    background: var(--white, #ffffff);
}

.radio-option:hover {
    border-color: var(--color-chat-green, #10b981);
    background: rgba(16, 185, 129, 0.03);
}

.radio-option input[type="radio"] {
    width: 20px;
    height: 20px;
    accent-color: var(--color-chat-green, #10b981);
    cursor: pointer;
}

.radio-option input[type="radio"]:checked ~ .radio-label {
    color: var(--color-chat-green, #10b981);
    font-weight: 600;
}

.radio-option:has(input:checked) {
    border-color: var(--color-chat-green, #10b981);
    background: rgba(16, 185, 129, 0.05);
}

.radio-label {
    flex: 1;
    font-size: 1rem;
    color: var(--text-primary, #000000);
    transition: all 0.15s;
}

/* ============================================
   BUTTONS (Glass-Morphism from Design System)
   ============================================ */

.btn-primary {
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid rgba(255, 255, 255, 0.95);
    border-radius: 9999px;                  /* Pill shape */
    padding: 0.875rem 2rem;
    font-size: 1rem;
    font-weight: 600;
    color: var(--black, #000000);
    cursor: pointer;
    transition: all 0.15s cubic-bezier(0.4, 0, 0.2, 1);
    transform: translateZ(0);               /* GPU acceleration */
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12), 0 1px 3px rgba(0, 0, 0, 0.08);
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    gap: 0.5rem;
    text-decoration: none;
}

.btn-primary:hover {
    background: rgba(255, 255, 255, 0.8);
    transform: scale(1.02) translateZ(0);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15);
}

.btn-primary:active {
    transform: scale(0.98) translateZ(0);
}

.btn-primary:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.btn-text {
    background: transparent;
    border: none;
    color: var(--text-secondary, rgba(0, 0, 0, 0.7));
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    padding: 0.75rem 1rem;
    transition: color 0.15s;
    width: 100%;
    text-align: center;
}

.btn-text:hover {
    color: var(--black, #000000);
}

/* Submit button specific styling */
.btn-submit {
    width: fit-content !important;
    min-width: 160px;
    margin: 0 auto !important;
}

/* Button loading state */
.btn-loading {
    display: none !important;
}

.btn-primary.loading .btn-text {
    display: none;
}

.btn-primary.loading .btn-loading {
    display: flex !important;
}

/* Spinner animation */
.spinner {
    animation: spin 1s linear infinite;
}

.spinner-circle {
    stroke-dasharray: 60;
    stroke-dashoffset: 45;
    animation: spinCircle 1.5s ease-in-out infinite;
}

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

@keyframes spinCircle {
    0% {
        stroke-dashoffset: 60;
    }
    50% {
        stroke-dashoffset: 15;
    }
    100% {
        stroke-dashoffset: 60;
    }
}

/* ============================================
   OPTIONAL CTA SECTION
   ============================================ */

.optional-cta {
    text-align: center;
    padding: 1.5rem 0;
}

.optional-badge {
    display: inline-block;
    background: rgba(16, 185, 129, 0.1);
    color: var(--color-chat-green, #10b981);
    padding: 0.375rem 0.875rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 1rem;
}

.optional-title {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--black, #000000);
    margin-bottom: 0.5rem;
}

.optional-description {
    font-size: 1rem;
    color: var(--text-secondary, rgba(0, 0, 0, 0.7));
    line-height: 1.6;
    margin-bottom: 1.5rem;
}

.cta-buttons {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;                           /* 12px spacing */
}

/* ============================================
   SURVEY FORM
   ============================================ */

.survey-form {
    max-height: calc(90vh - 200px);
    overflow-y: auto;
    padding-right: 0.5rem;
}

.survey-actions {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-top: 2rem;                       /* 32px spacing */
    padding-top: 1.5rem;
    border-top: 1px solid var(--border-color, #e5e7eb);
}

.survey-note {
    text-align: center;
    font-size: 0.875rem;
    color: var(--text-tertiary, rgba(0, 0, 0, 0.5));
    margin-top: 1rem;
    line-height: 1.5;
}

/* ============================================
   BACK BUTTON
   ============================================ */

.back-button {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    background: transparent;
    border: none;
    color: var(--text-secondary, rgba(0, 0, 0, 0.7));
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    padding: 0.5rem 0;
    margin-bottom: 1.5rem;
    transition: color 0.15s;
}

.back-button:hover {
    color: var(--black, #000000);
}

/* ============================================
   PRIVACY NOTE
   ============================================ */

.waitlist-privacy {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    font-size: 0.875rem;
    color: var(--text-tertiary, rgba(0, 0, 0, 0.5));
    margin-top: 1.5rem;
    text-align: center;
}

.waitlist-privacy svg {
    flex-shrink: 0;
}

/* ============================================
   FINAL CTA
   ============================================ */

.final-cta {
    text-align: center;
    padding: 1.5rem 0;
}

.final-message {
    font-size: 1rem;
    color: var(--text-secondary, rgba(0, 0, 0, 0.7));
    margin-bottom: 1.5rem;
}

/* ============================================
   MOBILE OPTIMIZATION
   ============================================ */

@media (max-width: 768px) {
    .waitlist-modal {
        position: fixed;
        top: auto;
        bottom: 0;
        left: 0;
        right: 0;
        transform: none;
        max-width: 100%;
        width: 100%;
        max-height: 95vh;
        border-radius: 1rem 1rem 0 0;       /* Bottom sheet style */
        padding: 1.5rem;
        animation: slideUp 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    }

    @keyframes slideUp {
        from {
            transform: translateY(100%);
        }
        to {
            transform: translateY(0);
        }
    }

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

    .waitlist-subtitle {
        font-size: 1rem;
    }

    .waitlist-close {
        top: 0.75rem;
        right: 0.75rem;
    }

    .radio-option {
        padding: 1rem;
        min-height: 52px;                   /* Larger tap target for mobile */
    }

    .form-input,
    .form-select {
        font-size: 16px;                    /* Prevent zoom on iOS */
    }

    .optional-title {
        font-size: 1.125rem;
    }

    .survey-form {
        max-height: calc(95vh - 180px);
    }
}

/* Tablet adjustments */
@media (min-width: 769px) and (max-width: 1024px) {
    .waitlist-modal {
        max-width: 540px;
    }
}

/* ============================================
   ACCESSIBILITY
   ============================================ */

/* Focus visible for all interactive elements */
.waitlist-modal *:focus-visible {
    outline: 2px solid var(--color-chat-green, #10b981);
    outline-offset: 2px;
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    .waitlist-modal,
    .waitlist-backdrop,
    .waitlist-step,
    .success-icon,
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* High contrast mode */
@media (prefers-contrast: high) {
    .waitlist-modal {
        border: 2px solid var(--black, #000000);
    }

    .form-input,
    .form-select,
    .radio-option {
        border-width: 2px;
    }
}
