/**
 * AIHT Modal Styles — Version Sombre Spatiale
 * 
 * Modal de capture et de sélection de paiement
 * Design glass-plate cohérent avec le thème aiht.online
 * Mobile-first, animations fluides
 * 
 * @package AIHT_Core
 * @since 2.0.0
 */

/* ============================================================
   MODAL OVERLAY
   ============================================================ */

.aiht-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: var(--aiht-z-modal);
    display: none;
    align-items: center;
    justify-content: center;
    padding: var(--aiht-space-lg);
}

.aiht-modal.is-open {
    display: flex;
}

.aiht-modal__overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    animation: aiht-fade-in 0.3s ease-out;
}

.aiht-modal__container {
    position: relative;
    background: var(--aiht-bg-card);
    border: 1px solid var(--aiht-border-strong);
    border-radius: var(--aiht-radius-2xl);
    width: 100%;
    max-width: 480px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 
        var(--aiht-shadow-xl),
        0 0 60px rgba(139, 92, 246, 0.1);
    animation: aiht-scale-in 0.3s ease-out;
}

/* ============================================================
   MODAL HEADER
   ============================================================ */

.aiht-modal__header {
    padding: var(--aiht-space-xl) var(--aiht-space-xl) 0;
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
}

.aiht-modal__title {
    font-family: var(--aiht-font-heading);
    font-size: var(--aiht-text-2xl);
    font-weight: var(--aiht-weight-bold);
    color: var(--aiht-text-primary);
    margin: 0;
}

.aiht-modal__close {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--aiht-border-medium);
    width: 36px;
    height: 36px;
    border-radius: 50%;
    font-size: var(--aiht-text-xl);
    color: var(--aiht-text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--aiht-ease-fast);
    flex-shrink: 0;
}

.aiht-modal__close:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--aiht-text-primary);
    border-color: var(--aiht-border-strong);
}

/* ============================================================
   MODAL BODY
   ============================================================ */

.aiht-modal__body {
    padding: var(--aiht-space-xl);
}

.aiht-modal__footer {
    padding: 0 var(--aiht-space-xl) var(--aiht-space-xl);
}

/* ============================================================
   STEPS INDICATOR
   ============================================================ */

.aiht-steps {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--aiht-space-sm);
    margin-bottom: var(--aiht-space-xl);
}

.aiht-step {
    display: flex;
    align-items: center;
    gap: var(--aiht-space-sm);
}

.aiht-step__circle {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: var(--aiht-text-sm);
    font-weight: var(--aiht-weight-semibold);
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--aiht-border-medium);
    color: var(--aiht-text-muted);
    transition: all var(--aiht-ease-normal);
}

.aiht-step.is-active .aiht-step__circle {
    background: var(--aiht-gradient-primary);
    border-color: transparent;
    color: var(--aiht-text-primary);
    box-shadow: 0 0 20px var(--aiht-cobalt-glow);
}

.aiht-step.is-completed .aiht-step__circle {
    background: rgba(52, 211, 153, 0.2);
    border-color: rgba(52, 211, 153, 0.3);
    color: var(--aiht-emerald);
}

.aiht-step__label {
    font-size: var(--aiht-text-xs);
    color: var(--aiht-text-muted);
    font-weight: var(--aiht-weight-medium);
}

.aiht-step.is-active .aiht-step__label {
    color: var(--aiht-violet);
}

.aiht-step__separator {
    width: 40px;
    height: 2px;
    background: rgba(255, 255, 255, 0.08);
    border-radius: 1px;
}

.aiht-step.is-completed .aiht-step__separator {
    background: rgba(52, 211, 153, 0.3);
}

/* ============================================================
   STEP CONTENT
   ============================================================ */

.aiht-modal-step {
    display: none;
    animation: aiht-fade-in-up 0.3s ease-out;
}

.aiht-modal-step.is-active {
    display: block;
}

/* ============================================================
   FORM STYLES
   ============================================================ */

.aiht-form-group {
    margin-bottom: var(--aiht-space-lg);
}

.aiht-form-label {
    display: block;
    font-size: var(--aiht-text-sm);
    font-weight: var(--aiht-weight-medium);
    color: var(--aiht-text-secondary);
    margin-bottom: var(--aiht-space-xs);
}

.aiht-form-input {
    width: 100%;
    padding: 14px 16px;
    font-size: var(--aiht-text-base);
    font-family: var(--aiht-font-body);
    color: var(--aiht-text-primary);
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--aiht-border-medium);
    border-radius: var(--aiht-radius-md);
    transition: all var(--aiht-ease-fast);
    outline: none;
    -webkit-appearance: none;
}

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

.aiht-form-input:focus {
    border-color: var(--aiht-violet);
    background: rgba(255, 255, 255, 0.08);
    box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.1);
}

.aiht-form-input.is-error {
    border-color: var(--aiht-red);
    background: rgba(248, 113, 113, 0.05);
}

.aiht-form-input.is-error:focus {
    box-shadow: 0 0 0 3px rgba(248, 113, 113, 0.1);
}

.aiht-form-error {
    display: none;
    font-size: var(--aiht-text-xs);
    color: var(--aiht-red);
    margin-top: var(--aiht-space-xs);
    font-weight: var(--aiht-weight-medium);
}

.aiht-form-error.is-visible {
    display: block;
}

.aiht-form-hint {
    font-size: var(--aiht-text-xs);
    color: var(--aiht-text-muted);
    margin-top: var(--aiht-space-xs);
}

/* ============================================================
   PAYMENT METHODS — GLASS STYLE
   ============================================================ */

.aiht-payment-methods {
    display: flex;
    flex-direction: column;
    gap: var(--aiht-space-md);
}

.aiht-payment-method {
    display: flex;
    align-items: center;
    gap: var(--aiht-space-md);
    padding: var(--aiht-space-lg);
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--aiht-border-medium);
    border-radius: var(--aiht-radius-lg);
    cursor: pointer;
    transition: all var(--aiht-ease-fast);
}

.aiht-payment-method:hover {
    border-color: var(--aiht-violet);
    background: rgba(139, 92, 246, 0.05);
}

.aiht-payment-method.is-selected {
    border-color: var(--aiht-violet);
    background: rgba(139, 92, 246, 0.08);
    box-shadow: 0 0 20px rgba(139, 92, 246, 0.1);
}

.aiht-payment-method__radio {
    width: 22px;
    height: 22px;
    border: 2px solid rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: all var(--aiht-ease-fast);
}

.aiht-payment-method.is-selected .aiht-payment-method__radio {
    border-color: var(--aiht-violet);
}

.aiht-payment-method.is-selected .aiht-payment-method__radio::after {
    content: '';
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--aiht-violet);
    box-shadow: 0 0 8px rgba(139, 92, 246, 0.5);
}

.aiht-payment-method__icon {
    width: 40px;
    height: 40px;
    border-radius: var(--aiht-radius-md);
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--aiht-border-subtle);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: var(--aiht-text-xl);
    flex-shrink: 0;
}

.aiht-payment-method__info {
    flex: 1;
}

.aiht-payment-method__name {
    font-weight: var(--aiht-weight-semibold);
    color: var(--aiht-text-primary);
    font-size: var(--aiht-text-base);
}

.aiht-payment-method__desc {
    font-size: var(--aiht-text-xs);
    color: var(--aiht-text-muted);
    margin-top: 2px;
}

/* ============================================================
   MODAL ACTIONS
   ============================================================ */

.aiht-modal-actions {
    display: flex;
    flex-direction: column;
    gap: var(--aiht-space-sm);
}

.aiht-modal-actions__btn {
    width: 100%;
    padding: 14px 24px;
    font-size: var(--aiht-text-base);
    font-weight: var(--aiht-weight-semibold);
    border: none;
    border-radius: var(--aiht-radius-full);
    cursor: pointer;
    transition: all var(--aiht-ease-fast);
    position: relative;
    font-family: var(--aiht-font-body);
}

/* Bouton primaire — Dégradé violet */
.aiht-modal-actions__btn--primary {
    background: var(--aiht-gradient-primary);
    color: var(--aiht-text-primary);
    box-shadow: 0 4px 20px var(--aiht-cobalt-glow);
    font-weight: var(--aiht-weight-bold);
}

.aiht-modal-actions__btn--primary:hover {
    box-shadow: 0 8px 30px var(--aiht-cobalt-glow);
    transform: translateY(-1px);
}

.aiht-modal-actions__btn--primary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* Bouton secondaire — Outline sombre */
.aiht-modal-actions__btn--secondary {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--aiht-border-medium);
    color: var(--aiht-text-secondary);
}

.aiht-modal-actions__btn--secondary:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--aiht-text-primary);
}

/* Texte sécurisé */
.aiht-modal-actions__secure {
    text-align: center;
    font-size: var(--aiht-text-xs);
    color: var(--aiht-text-muted);
}

/* ============================================================
   GLOBAL ERROR
   ============================================================ */

.aiht-global-error {
    display: none;
    padding: 12px 16px;
    margin: 0 24px 16px;
    background: rgba(248, 113, 113, 0.08);
    border: 1px solid rgba(248, 113, 113, 0.2);
    border-radius: var(--aiht-radius-md);
    color: var(--aiht-red);
    font-size: var(--aiht-text-sm);
    text-align: center;
    font-weight: var(--aiht-weight-medium);
}

/* ============================================================
   RESPONSIVE MODAL
   ============================================================ */

@media (max-width: 640px) {
    .aiht-modal {
        padding: 0;
        align-items: flex-end;
    }

    .aiht-modal__container {
        max-width: 100%;
        max-height: 95vh;
        border-radius: var(--aiht-radius-2xl) var(--aiht-radius-2xl) 0 0;
        animation: aiht-slide-up 0.3s ease-out;
    }

    .aiht-modal__header {
        padding: var(--aiht-space-lg) var(--aiht-space-lg) 0;
    }

    .aiht-modal__body {
        padding: var(--aiht-space-lg);
    }

    .aiht-modal__footer {
        padding: 0 var(--aiht-space-lg) var(--aiht-space-lg);
    }

    .aiht-steps {
        margin-bottom: var(--aiht-space-lg);
    }

    .aiht-step__separator {
        width: 24px;
    }
}

@keyframes aiht-slide-up {
    from {
        transform: translateY(100%);
    }
    to {
        transform: translateY(0);
    }
}

/* ============================================================
   SCROLLBAR DU MODAL
   ============================================================ */

.aiht-modal__container::-webkit-scrollbar {
    width: 4px;
}

.aiht-modal__container::-webkit-scrollbar-track {
    background: transparent;
}

.aiht-modal__container::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 2px;
}

/* ============================================================
   CODE PROMO / COUPON SECTION
   ============================================================ */

.aiht-coupon-container {
    margin-top: 16px;
    margin-bottom: 36px;
    text-align: center;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    padding-bottom: 24px;
}

.aiht-submit-btn,
.aiht-modal-actions__btn {
    margin-top: 0;
    width: 100%;
    padding: 14px 20px;
}

.aiht-toggle-coupon-btn {
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.7);
    font-size: var(--aiht-text-sm);
    font-weight: var(--aiht-weight-medium);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: var(--aiht-space-sm) var(--aiht-space-md);
    border-radius: 20px;
    transition: all var(--aiht-ease-fast);
    outline: none;
}

.aiht-toggle-coupon-btn:hover,
.aiht-toggle-coupon-btn:focus {
    background: rgba(255, 255, 255, 0.1);
    color: var(--aiht-text-primary);
}

/* Wrapper pour le champ code promo */
.aiht-coupon-field-wrapper {
    margin-top: var(--aiht-space-md);
    margin-bottom: 8px;
    animation: aiht-slide-down 0.3s ease;
}

.aiht-coupon-container:has(.aiht-coupon-field-wrapper[style*="block"]) {
    margin-bottom: 36px;
}

@keyframes aiht-slide-down {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Input group pour le code promo */
.aiht-input-group {
    display: flex;
    gap: var(--aiht-space-sm);
    margin-top: var(--aiht-space-sm);
}

.aiht-input-group .aiht-form-input {
    flex: 1;
}

.aiht-apply-coupon-btn {
    background: linear-gradient(135deg, #3b82f6, #8b5cf6);
    border: 1px solid rgba(139, 92, 246, 0.3);
    border-radius: var(--aiht-radius-md);
    padding: 14px 20px;
    color: white;
    font-weight: var(--aiht-weight-semibold);
    font-size: var(--aiht-text-sm);
    cursor: pointer;
    transition: all var(--aiht-ease-fast);
    white-space: nowrap;
    outline: none;
}

.aiht-apply-coupon-btn:hover {
    opacity: 0.9;
    box-shadow: 0 0 15px rgba(139, 92, 246, 0.3);
}

.aiht-apply-coupon-btn:active {
    opacity: 0.8;
}

/* Message de confirmation / erreur */
.aiht-coupon-message {
    margin-top: var(--aiht-space-sm);
    font-size: var(--aiht-text-xs);
    padding: var(--aiht-space-sm) var(--aiht-space-md);
    border-radius: var(--aiht-radius-md);
    text-align: center;
    font-weight: var(--aiht-weight-medium);
}

.aiht-coupon-message.success {
    background: rgba(52, 211, 153, 0.15);
    color: #34d399;
    border: 1px solid rgba(52, 211, 153, 0.3);
}

.aiht-coupon-message.error {
    background: rgba(239, 68, 68, 0.15);
    color: #ef4444;
    border: 1px solid rgba(239, 68, 68, 0.3);
}

/* Responsive */
@media (max-width: 640px) {
    .aiht-coupon-container {
        margin-bottom: 28px;
    }

    .aiht-coupon-container:has(.aiht-coupon-field-wrapper[style*="block"]) {
        margin-bottom: 32px;
    }

    .aiht-toggle-coupon-btn {
        font-size: var(--aiht-text-xs);
        padding: var(--aiht-space-xs) var(--aiht-space-sm);
    }

    .aiht-input-group {
        flex-direction: column;
    }

    .aiht-apply-coupon-btn {
        width: 100%;
    }
}

/* ============================================================
   PRICING DISPLAY (APRÈS COUPON)
   ============================================================ */

.aiht-coupon-pricing-display {
    margin-bottom: 24px;
    animation: aiht-fade-in-up 0.3s ease-out;
}

.aiht-coupon-pricing-inner {
    background: rgba(52, 211, 153, 0.05);
    border: 1px solid rgba(52, 211, 153, 0.15);
    border-radius: var(--aiht-radius-lg);
    padding: var(--aiht-space-lg);
    text-align: center;
}

.aiht-coupon-badge {
    display: inline-block;
    background: rgba(52, 211, 153, 0.15);
    color: #34d399;
    font-size: var(--aiht-text-xs);
    font-weight: var(--aiht-weight-bold);
    padding: 4px 12px;
    border-radius: 20px;
    margin-bottom: var(--aiht-space-md);
}

.aiht-coupon-pricing-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 4px 0;
    font-size: var(--aiht-text-sm);
}

.aiht-coupon-pricing-row--final {
    margin-top: var(--aiht-space-xs);
    padding-top: var(--aiht-space-sm);
    border-top: 1px solid rgba(52, 211, 153, 0.1);
}

.aiht-coupon-label {
    color: var(--aiht-text-muted);
}

.aiht-coupon-original-price {
    color: var(--aiht-text-muted);
    text-decoration: line-through;
}

.aiht-coupon-discounted-price {
    color: #34d399;
    font-weight: var(--aiht-weight-bold);
    font-size: var(--aiht-text-lg);
}

/* Coupon spinner */
.aiht-coupon-spinner {
    display: none;
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255, 255, 255, 0.1);
    border-top-color: #fff;
    border-radius: 50%;
    animation: aiht-spinner-rotate 0.6s linear infinite;
}

.aiht-coupon-spinner.is-visible {
    display: inline-block;
}

@keyframes aiht-spinner-rotate {
    to { transform: rotate(360deg); }
}
