{{-- Composant de sélection de méthode de paiement - Design Ultra Moderne 2026 --}}
@props(['amount', 'email', 'name' => '', 'phone' => '', 'redirectUrl' => '', 'showMobileMoney' => true, 'wallet' => null])

<div class="payment-ultra-modern">
    {{-- Header avec effet glassmorphism --}}
    <div class="payment-header-modern">
        <div class="header-glow"></div>
        <div class="header-content">
            <div class="header-icon-wrapper">
                <div class="header-icon">
                    <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
                        <rect x="1" y="4" width="22" height="16" rx="3" ry="3"/>
                        <line x1="1" y1="10" x2="23" y2="10"/>
                    </svg>
                </div>
                <div class="header-icon-ring"></div>
            </div>
            <div class="header-text">
                <h3>Mode de Paiement</h3>
                <p>Choisissez votre mode de paiement</p>
            </div>
        </div>
        <div class="amount-display">
            <span class="amount-label">Montant à payer</span>
            <span class="amount-value">{{ number_format($amount, 0, ',', ' ') }} <small>XOF</small></span>
        </div>
    </div>

    {{-- Grille des options de paiement --}}
    <div class="payment-options-grid">
        {{-- Option Wallet --}}
        @if($wallet)
        <div class="payment-card-wrapper">
            <input type="radio" name="payment_method" value="wallet" id="pay_wallet" class="payment-input"
                   @if($wallet->balance >= $amount) checked @endif 
                   @if($wallet->balance < $amount) disabled @endif
                   data-wallet-balance="{{ $wallet->balance }}"
                   data-amount="{{ $amount }}">
            <label for="pay_wallet" class="payment-card {{ $wallet->balance < $amount ? 'insufficient' : '' }}">
                <div class="card-glow wallet-glow"></div>
                <div class="card-content">
                    <div class="card-icon wallet-icon-modern">
                        <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5">
                            <path d="M21 4H3C1.89543 4 1 4.89543 1 6V18C1 19.1046 1.89543 20 3 20H21C22.1046 20 23 19.1046 23 18V6C23 4.89543 22.1046 4 21 4Z"/>
                            <path d="M1 10H23"/>
                            <circle cx="18" cy="15" r="2"/>
                        </svg>
                    </div>
                    <div class="card-info">
                        <span class="card-title">Mon Portefeuille</span>
                        <span class="card-subtitle">
                            <svg viewBox="0 0 24 24" width="14" height="14" fill="currentColor">
                                <path d="M13 10V3L4 14h7v7l9-11h-7z"/>
                            </svg>
                            Paiement instantané
                        </span>
                    </div>
                    <div class="card-check">
                        <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="3">
                            <path d="M20 6L9 17l-5-5"/>
                        </svg>
                    </div>
                </div>
                
                {{-- Wallet Balance Info --}}
                <div class="wallet-balance-section">
                    <div class="balance-row">
                        <span class="balance-label">Solde disponible</span>
                        <span class="balance-value">{{ number_format($wallet->balance, 0, ',', ' ') }} <small>XOF</small></span>
                    </div>
                    @if($wallet->balance >= $amount)
                        <div class="balance-status success-status">
                            <svg viewBox="0 0 24 24" width="16" height="16" fill="currentColor">
                                <path d="M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm-2 15l-5-5 1.41-1.41L10 14.17l7.59-7.59L19 8l-9 9z"/>
                            </svg>
                            <span>Solde suffisant</span>
                            <span class="status-badge">Disponible</span>
                        </div>
                    @else
                        <div class="balance-status warning-status">
                            <svg viewBox="0 0 24 24" width="16" height="16" fill="currentColor">
                                <path d="M1 21h22L12 2 1 21zm12-3h-2v-2h2v2zm0-4h-2v-4h2v4z"/>
                            </svg>
                            <span>{{ number_format($amount - $wallet->balance, 0, ',', ' ') }} XOF manquant</span>
                        </div>
                        @php
                            $walletRoute = match(true) {
                                auth()->check() && auth()->user()->role === 'member' => 'member.wallet.index',
                                auth()->check() && auth()->user()->role === 'seller' => 'seller.wallet.index',
                                default => '#'
                            };
                        @endphp
                        @if($walletRoute !== '#')
                        <a href="{{ route($walletRoute) }}" class="recharge-btn">
                            <svg viewBox="0 0 24 24" width="16" height="16" fill="none" stroke="currentColor" stroke-width="2">
                                <circle cx="12" cy="12" r="10"/>
                                <line x1="12" y1="8" x2="12" y2="16"/>
                                <line x1="8" y1="12" x2="16" y2="12"/>
                            </svg>
                            Recharger
                        </a>
                        @endif
                    @endif
                </div>
            </label>
        </div>
        @endif

        {{-- Option Carte Bancaire --}}
        <div class="payment-card-wrapper">
            <input type="radio" name="payment_method" value="card" id="pay_card" class="payment-input"
                   @if(!$wallet || $wallet->balance < $amount) checked @endif>
            <label for="pay_card" class="payment-card">
                <div class="card-glow card-glow-blue"></div>
                <div class="card-content">
                    <div class="card-icon card-icon-modern">
                        <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5">
                            <rect x="1" y="4" width="22" height="16" rx="3"/>
                            <line x1="1" y1="10" x2="23" y2="10"/>
                            <rect x="4" y="14" width="6" height="2" rx="1"/>
                        </svg>
                    </div>
                    <div class="card-info">
                        <span class="card-title">Carte Bancaire</span>
                        <span class="card-subtitle">
                            <svg viewBox="0 0 24 24" width="14" height="14" fill="currentColor">
                                <path d="M12 1L3 5v6c0 5.55 3.84 10.74 9 12 5.16-1.26 9-6.45 9-12V5l-9-4z"/>
                            </svg>
                            Paiement sécurisé
                        </span>
                    </div>
                    <div class="card-check">
                        <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="3">
                            <path d="M20 6L9 17l-5-5"/>
                        </svg>
                    </div>
                </div>
                
                {{-- Card Logos --}}
                <div class="card-logos">
                    <div class="logo-visa">
                        <svg viewBox="0 0 50 16" fill="currentColor">
                            <path d="M19.13 15.33h-3.71l2.32-14.25h3.71l-2.32 14.25zm15.93-13.89c-.73-.29-1.89-.6-3.32-.6-3.66 0-6.24 1.94-6.26 4.72-.03 2.05 1.84 3.2 3.24 3.88 1.44.7 1.93 1.15 1.92 1.78-.01.96-1.15 1.4-2.22 1.4-1.48 0-2.27-.22-3.49-.75l-.48-.23-.52 3.21c.87.4 2.47.75 4.13.77 3.89 0 6.42-1.92 6.45-4.89.02-1.63-.97-2.87-3.11-3.89-1.29-.66-2.09-1.1-2.08-1.77 0-.59.67-1.23 2.12-1.23 1.21-.02 2.09.26 2.77.55l.33.16.5-3.11zM41.14 1.08h-2.86c-.89 0-1.55.26-1.94 1.19l-5.5 13.06h3.89l.78-2.14h4.75l.45 2.14h3.43l-3-14.25zm-4.58 9.18c.31-.83 1.49-4.01 1.49-4.01-.02.04.31-.84.5-1.38l.25 1.25s.71 3.45.87 4.14h-3.11zM13.33 1.08L9.7 10.66l-.39-1.97c-.67-2.28-2.78-4.75-5.13-5.99l3.32 12.58h3.92l5.83-14.2h-3.92z"/>
                        </svg>
                    </div>
                    <div class="logo-mastercard">
                        <svg viewBox="0 0 50 30" fill="none">
                            <circle cx="18" cy="15" r="12" fill="#EB001B"/>
                            <circle cx="32" cy="15" r="12" fill="#F79E1B"/>
                            <path d="M25 5.5c2.9 2.3 4.8 5.8 4.8 9.5s-1.9 7.2-4.8 9.5c-2.9-2.3-4.8-5.8-4.8-9.5s1.9-7.2 4.8-9.5z" fill="#FF5F00"/>
                        </svg>
                    </div>
                </div>
            </label>
        </div>

        {{-- Option Mobile Money --}}
        @if($showMobileMoney)
        <div class="payment-card-wrapper">
            <input type="radio" name="payment_method" value="mobile_money" id="pay_mobile" class="payment-input">
            <label for="pay_mobile" class="payment-card">
                <div class="card-glow card-glow-orange"></div>
                <div class="card-content">
                    <div class="card-icon mobile-icon-modern">
                        <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5">
                            <rect x="5" y="2" width="14" height="20" rx="3"/>
                            <line x1="12" y1="18" x2="12" y2="18.01" stroke-width="2" stroke-linecap="round"/>
                        </svg>
                    </div>
                    <div class="card-info">
                        <span class="card-title">Mobile Money</span>
                        <span class="card-subtitle">
                            <svg viewBox="0 0 24 24" width="14" height="14" fill="currentColor">
                                <path d="M17 1.01L7 1c-1.1 0-2 .9-2 2v18c0 1.1.9 2 2 2h10c1.1 0 2-.9 2-2V3c0-1.1-.9-1.99-2-1.99zM17 19H7V5h10v14z"/>
                            </svg>
                            Paiement mobile
                        </span>
                    </div>
                    <div class="card-check">
                        <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="3">
                            <path d="M20 6L9 17l-5-5"/>
                        </svg>
                    </div>
                </div>
                
                {{-- Mobile Money Providers --}}
                <div class="mobile-providers">
                    <span class="provider orange">Orange Money</span>
                    <span class="provider wave">Wave</span>
                    <span class="provider mtn">MTN</span>
                    <span class="provider moov">Moov</span>
                </div>
            </label>
        </div>
        @endif
    </div>

    {{-- Mobile Money Fields (Hidden by default) --}}
    @if($showMobileMoney)
    <div id="mobile-money-fields" class="mobile-money-form" style="display: none;">
        <div class="form-notice">
            <svg viewBox="0 0 24 24" width="20" height="20" fill="currentColor">
                <path d="M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm1 15h-2v-6h2v6zm0-8h-2V7h2v2z"/>
            </svg>
            <div>
                <strong>Paiement Mobile Money</strong>
                <span>Remplissez les informations ci-dessous pour continuer</span>
            </div>
        </div>
        
        <div class="form-grid">
            <div class="form-group">
                <label>Pays <span class="required">*</span></label>
                <select name="mm_country" id="mm_country" class="form-input" onchange="updateNetworks()">
                    <option value="">Sélectionnez un pays</option>
                    <option value="CI">🇨🇮 Côte d'Ivoire</option>
                    <option value="SN">🇸🇳 Sénégal</option>
                    <option value="BF">🇧🇫 Burkina Faso</option>
                    <option value="CM">🇨🇲 Cameroun</option>
                </select>
            </div>

            <div class="form-group">
                <label>Réseau <span class="required">*</span></label>
                <select name="mm_network" id="mm_network" class="form-input">
                    <option value="">Sélectionnez d'abord un pays</option>
                </select>
            </div>

            <div class="form-group">
                <label>Numéro de téléphone <span class="required">*</span></label>
                <input type="tel" name="mm_phone" id="mm_phone" class="form-input" 
                       placeholder="Ex: 225XXXXXXXXX" value="{{ $phone }}">
                <span class="form-hint">Format international sans le +</span>
            </div>
        </div>

        {{-- Authorization Code for Orange Money BF --}}
        <div id="authorization-code-field" class="auth-code-section" style="display: none;">
            <div class="auth-notice">
                <svg viewBox="0 0 24 24" width="20" height="20" fill="currentColor">
                    <path d="M1 21h22L12 2 1 21zm12-3h-2v-2h2v2zm0-4h-2v-4h2v4z"/>
                </svg>
                <div>
                    <strong>Orange Money Burkina Faso</strong>
                    <span>Composez <code>*144*4*6*{{ number_format($amount, 0, '', '') }}*votre_code#</code> pour obtenir le code</span>
                </div>
            </div>
            <div class="form-group">
                <label>Code d'autorisation</label>
                <input type="text" name="mm_authorization_code" id="mm_authorization_code" 
                       class="form-input" placeholder="Entrez le code reçu">
            </div>
        </div>
    </div>
    @endif
</div>

<style>
/* ===== ULTRA MODERN PAYMENT SELECTOR 2026 ===== */
.payment-ultra-modern {
    --primary: #0ea5e9;
    --primary-dark: #0284c7;
    --secondary: #6366f1;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --gray-50: #f8fafc;
    --gray-100: #f1f5f9;
    --gray-200: #e2e8f0;
    --gray-300: #cbd5e1;
    --gray-400: #94a3b8;
    --gray-500: #64748b;
    --gray-600: #475569;
    --gray-700: #334155;
    --gray-800: #1e293b;
    --gray-900: #0f172a;
    
    background: linear-gradient(180deg, var(--gray-50) 0%, #ffffff 100%);
    border-radius: 24px;
    padding: 0;
    overflow: hidden;
    box-shadow: 
        0 4px 6px -1px rgba(0, 0, 0, 0.1),
        0 2px 4px -2px rgba(0, 0, 0, 0.1),
        0 0 0 1px rgba(0, 0, 0, 0.05);
}

/* ===== HEADER ===== */
.payment-header-modern {
    position: relative;
    background: linear-gradient(135deg, var(--gray-800) 0%, var(--gray-900) 100%);
    padding: 28px 32px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    overflow: hidden;
}

.header-glow {
    position: absolute;
    top: -50%;
    right: -20%;
    width: 300px;
    height: 300px;
    background: radial-gradient(circle, rgba(14, 165, 233, 0.3) 0%, transparent 70%);
    pointer-events: none;
}

.header-content {
    display: flex;
    align-items: center;
    gap: 18px;
    position: relative;
    z-index: 1;
}

.header-icon-wrapper {
    position: relative;
}

.header-icon {
    width: 56px;
    height: 56px;
    background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    box-shadow: 0 8px 24px rgba(14, 165, 233, 0.4);
}

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

.header-icon-ring {
    position: absolute;
    inset: -4px;
    border-radius: 20px;
    border: 2px solid rgba(14, 165, 233, 0.3);
    animation: pulse-ring 2s ease-out infinite;
}

@keyframes pulse-ring {
    0% { transform: scale(1); opacity: 1; }
    100% { transform: scale(1.2); opacity: 0; }
}

.header-text h3 {
    margin: 0;
    font-size: 1.4rem;
    font-weight: 700;
    color: white;
    letter-spacing: -0.5px;
}

.header-text p {
    margin: 4px 0 0;
    font-size: 0.9rem;
    color: var(--gray-400);
}

.amount-display {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    position: relative;
    z-index: 1;
}

.amount-label {
    font-size: 0.8rem;
    color: var(--gray-400);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 4px;
}

.amount-value {
    font-size: 1.8rem;
    font-weight: 800;
    background: linear-gradient(135deg, #ffffff 0%, var(--primary) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.amount-value small {
    font-size: 0.9rem;
    font-weight: 600;
}

/* ===== PAYMENT OPTIONS GRID ===== */
.payment-options-grid {
    display: flex;
    flex-direction: row;
    gap: 15px;
    padding: 24px;
    justify-content: stretch;
}

.payment-card-wrapper {
    flex: 1 1 0;
    min-width: 0;
}

.payment-card-wrapper {
    position: relative;
}

.payment-input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.payment-card {
    position: relative;
    display: flex;
    flex-direction: column;
    background: white;
    border: 2px solid var(--gray-200);
    border-radius: 16px;
    padding: 20px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    overflow: hidden;
    min-height: auto;
    height: 100%;
}

.payment-card:hover {
    border-color: var(--primary);
    transform: translateY(-2px);
    box-shadow: 0 10px 25px rgba(14, 165, 233, 0.15);
}

.card-glow {
    position: absolute;
    top: -100px;
    right: -100px;
    width: 200px;
    height: 200px;
    border-radius: 50%;
    opacity: 0;
    transition: opacity 0.4s ease;
    pointer-events: none;
}

.wallet-glow { background: radial-gradient(circle, rgba(6, 182, 212, 0.4) 0%, transparent 70%); }
.card-glow-blue { background: radial-gradient(circle, rgba(99, 102, 241, 0.4) 0%, transparent 70%); }
.card-glow-orange { background: radial-gradient(circle, rgba(245, 158, 11, 0.4) 0%, transparent 70%); }

.payment-card:hover .card-glow {
    opacity: 1;
}

.card-content {
    display: flex;
    align-items: center;
    gap: 12px;
    position: relative;
    z-index: 1;
}

.card-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: all 0.3s ease;
}

.card-icon svg {
    width: 24px;
    height: 24px;
}

.wallet-icon-modern {
    background: linear-gradient(135deg, #06b6d4 0%, #0891b2 100%);
    color: white;
    box-shadow: 0 4px 12px rgba(6, 182, 212, 0.25);
}

.card-icon-modern {
    background: linear-gradient(135deg, #6366f1 0%, #4f46e5 100%);
    color: white;
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.25);
}

.mobile-icon-modern {
    background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
    color: white;
    box-shadow: 0 4px 12px rgba(245, 158, 11, 0.25);
}

.card-info {
    flex: 1;
    min-width: 0;
}

.card-title {
    display: block;
    font-size: 1rem;
    font-weight: 700;
    color: var(--gray-800);
    margin-bottom: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.card-subtitle {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 0.75rem;
    color: var(--gray-500);
}

.card-check {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--gray-100);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--gray-300);
    transition: all 0.3s ease;
    flex-shrink: 0;
}

.card-check svg {
    width: 12px;
    height: 12px;
}

/* Selected State */
.payment-input:checked + .payment-card {
    border-color: var(--primary);
    background: linear-gradient(135deg, rgba(14, 165, 233, 0.05) 0%, rgba(6, 182, 212, 0.05) 100%);
    box-shadow: 0 8px 20px rgba(14, 165, 233, 0.15);
}

.payment-input:checked + .payment-card .card-glow {
    opacity: 1;
}

.payment-input:checked + .payment-card .card-icon {
    transform: scale(1.05);
}

.payment-input:checked + .payment-card .card-check {
    background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
    color: white;
    box-shadow: 0 2px 8px rgba(14, 165, 233, 0.3);
}

/* ===== WALLET BALANCE SECTION ===== */
.wallet-balance-section {
    margin-top: 12px;
    padding: 12px;
    background: var(--gray-50);
    border-radius: 10px;
    position: relative;
    z-index: 1;
}

.balance-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.balance-label {
    font-size: 0.75rem;
    color: var(--gray-500);
}

.balance-value {
    font-size: 1.1rem;
    font-weight: 800;
    background: linear-gradient(135deg, var(--primary) 0%, #06b6d4 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.balance-value small {
    font-size: 0.75rem;
}

.balance-status {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    border-radius: 10px;
    font-size: 0.85rem;
    font-weight: 600;
}

.success-status {
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.1) 0%, rgba(5, 150, 105, 0.1) 100%);
    color: var(--success);
    border: 1px solid rgba(16, 185, 129, 0.2);
}

.success-status .status-badge {
    margin-left: auto;
    background: var(--success);
    color: white;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 700;
}

.warning-status {
    background: linear-gradient(135deg, rgba(245, 158, 11, 0.1) 0%, rgba(217, 119, 6, 0.1) 100%);
    color: var(--warning);
    border: 1px solid rgba(245, 158, 11, 0.2);
}

.recharge-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-top: 12px;
    padding: 10px;
    background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
    color: white;
    border-radius: 10px;
    font-size: 0.9rem;
    font-weight: 600;
    text-decoration: none;
    transition: all 0.3s ease;
}

.recharge-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(14, 165, 233, 0.3);
    color: white;
}

/* Insufficient Balance */
.payment-card.insufficient {
    opacity: 0.7;
}

.payment-card.insufficient:hover {
    transform: none;
    box-shadow: none;
    cursor: not-allowed;
}

/* ===== CARD LOGOS ===== */
.card-logos {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 12px;
    padding-top: 10px;
    border-top: 1px solid var(--gray-100);
    position: relative;
    z-index: 1;
}

.logo-visa {
    color: #1a1f71;
    height: 18px;
}

.logo-visa svg {
    height: 100%;
    width: auto;
}

.logo-mastercard svg {
    height: 20px;
    width: auto;
}

/* ===== MOBILE PROVIDERS ===== */
.mobile-providers {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    margin-top: 12px;
    padding-top: 10px;
    border-top: 1px solid var(--gray-100);
    position: relative;
    z-index: 1;
}

.provider {
    padding: 4px 8px;
    border-radius: 6px;
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.provider.orange {
    background: linear-gradient(135deg, #ff6b00 0%, #ff8c00 100%);
    color: white;
}

.provider.wave {
    background: linear-gradient(135deg, #1dc8ff 0%, #00a3cc 100%);
    color: white;
}

.provider.mtn {
    background: linear-gradient(135deg, #ffcc00 0%, #e6b800 100%);
    color: #000;
}

.provider.moov {
    background: linear-gradient(135deg, #0066cc 0%, #004c99 100%);
    color: white;
}

/* ===== MOBILE MONEY FORM ===== */
.mobile-money-form {
    margin: 0 28px 28px;
    padding: 24px;
    background: linear-gradient(135deg, rgba(245, 158, 11, 0.05) 0%, rgba(217, 119, 6, 0.05) 100%);
    border: 2px solid rgba(245, 158, 11, 0.2);
    border-radius: 20px;
    animation: slideDown 0.4s ease;
}

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

.form-notice, .auth-notice {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    padding: 16px;
    background: rgba(14, 165, 233, 0.1);
    border-radius: 12px;
    margin-bottom: 20px;
    color: var(--primary-dark);
}

.auth-notice {
    background: rgba(245, 158, 11, 0.15);
    color: #b45309;
}

.form-notice strong, .auth-notice strong {
    display: block;
    font-size: 0.95rem;
    margin-bottom: 4px;
}

.form-notice span, .auth-notice span {
    font-size: 0.85rem;
    opacity: 0.9;
}

.auth-notice code {
    display: inline-block;
    background: rgba(0,0,0,0.1);
    padding: 2px 8px;
    border-radius: 6px;
    font-family: monospace;
    font-weight: 600;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.form-group label {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--gray-700);
}

.form-group .required {
    color: var(--danger);
}

.form-input {
    padding: 14px 16px;
    border: 2px solid var(--gray-200);
    border-radius: 12px;
    font-size: 1rem;
    transition: all 0.3s ease;
    background: white;
}

.form-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(14, 165, 233, 0.15);
}

.form-hint {
    font-size: 0.8rem;
    color: var(--gray-500);
}

.auth-code-section {
    margin-top: 20px;
    animation: slideDown 0.4s ease;
}

/* ===== SECURITY FOOTER ===== */
.security-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 28px;
    background: var(--gray-50);
    border-top: 1px solid var(--gray-100);
}

.security-badge {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--gray-600);
    font-size: 0.9rem;
    font-weight: 500;
}

.security-badge svg {
    color: var(--success);
}

.security-logos {
    display: flex;
    gap: 8px;
}

.logo-badge {
    padding: 6px 12px;
    background: white;
    border: 1px solid var(--gray-200);
    border-radius: 8px;
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--gray-600);
}

.logo-badge.mobile {
    background: linear-gradient(135deg, var(--warning) 0%, #d97706 100%);
    color: white;
    border: none;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 992px) {
    .payment-options-grid {
        gap: 12px;
        padding: 20px;
    }
    
    .card-icon {
        width: 40px;
        height: 40px;
    }
    
    .card-icon svg {
        width: 20px;
        height: 20px;
    }
    
    .card-title {
        font-size: 0.9rem;
    }
    
    .card-subtitle {
        font-size: 0.7rem;
    }
}

@media (max-width: 768px) {
    .payment-header-modern {
        flex-direction: column;
        align-items: flex-start;
        gap: 16px;
        padding: 20px;
    }
    
    .amount-display {
        align-items: flex-start;
    }
    
    .payment-options-grid {
        flex-direction: column;
        padding: 16px;
        gap: 10px;
    }
    
    .payment-card-wrapper {
        flex: 1 1 100%;
        min-width: auto;
        max-width: none;
    }
    
    .payment-card {
        min-height: auto;
        padding: 16px;
    }
    
    .security-footer {
        flex-direction: column;
        gap: 16px;
        text-align: center;
    }
    
    .form-grid {
        grid-template-columns: 1fr;
    }
}

/* ===== DARK MODE SUPPORT ===== */
@media (prefers-color-scheme: dark) {
    .payment-ultra-modern {
        background: linear-gradient(180deg, var(--gray-800) 0%, var(--gray-900) 100%);
    }
    
    .payment-card {
        background: var(--gray-800);
        border-color: var(--gray-700);
    }
    
    .card-title {
        color: white;
    }
    
    .wallet-balance-section {
        background: var(--gray-700);
    }
    
    .form-input {
        background: var(--gray-700);
        border-color: var(--gray-600);
        color: white;
    }
    
    .security-footer {
        background: var(--gray-800);
        border-color: var(--gray-700);
    }
}
</style>

<script>
// ===== ULTRA MODERN PAYMENT SELECTOR JS =====
const mobileMoneyNetworks = {
    'BF': [
        {value: 'ORANGEMONEY', label: '🟠 Orange Money'},
        {value: 'MOBICASH', label: '📱 Mobicash'}
    ],
    'CM': [
        {value: 'MTN', label: '🟡 MTN Mobile Money'},
        {value: 'ORANGEMONEY', label: '🟠 Orange Money'}
    ],
    'CI': [
        {value: 'MTN', label: '🟡 MTN Mobile Money'},
        {value: 'ORANGEMONEY', label: '🟠 Orange Money'},
        {value: 'MOOV', label: '🔵 Moov Money'},
        {value: 'WAVE', label: '🌊 Wave'}
    ],
    'SN': [
        {value: 'ORANGEMONEY', label: '🟠 Orange Money'},
        {value: 'WAVE', label: '🌊 Wave'}
    ]
};

document.addEventListener('DOMContentLoaded', function() {
    const paymentInputs = document.querySelectorAll('.payment-input');
    
    paymentInputs.forEach(input => {
        input.addEventListener('change', function() {
            handlePaymentMethodChange(this.value);
        });
    });
    
    // Initialize
    const checkedInput = document.querySelector('.payment-input:checked');
    if (checkedInput) {
        handlePaymentMethodChange(checkedInput.value);
    }
});

function handlePaymentMethodChange(method) {
    const mobileMoneyFields = document.getElementById('mobile-money-fields');
    
    if (mobileMoneyFields) {
        if (method === 'mobile_money') {
            mobileMoneyFields.style.display = 'block';
            setMobileMoneyFieldsRequired(true);
        } else {
            mobileMoneyFields.style.display = 'none';
            setMobileMoneyFieldsRequired(false);
        }
    }
}

function setMobileMoneyFieldsRequired(required) {
    ['mm_country', 'mm_network', 'mm_phone'].forEach(id => {
        const field = document.getElementById(id);
        if (field) field.required = required;
    });
}

function updateNetworks() {
    const country = document.getElementById('mm_country')?.value;
    const networkSelect = document.getElementById('mm_network');
    const authCodeField = document.getElementById('authorization-code-field');
    
    if (!networkSelect) return;
    
    networkSelect.innerHTML = '<option value="">Sélectionnez un réseau</option>';
    
    if (country && mobileMoneyNetworks[country]) {
        mobileMoneyNetworks[country].forEach(network => {
            const option = document.createElement('option');
            option.value = network.value;
            option.textContent = network.label;
            networkSelect.appendChild(option);
        });
    }
    
    if (authCodeField) {
        networkSelect.addEventListener('change', function() {
            authCodeField.style.display = 
                (country === 'BF' && this.value === 'ORANGEMONEY') ? 'block' : 'none';
        });
    }
}

function validatePaymentSelection() {
    const selectedMethod = document.querySelector('.payment-input:checked');
    
    if (!selectedMethod) {
        alert('Veuillez choisir un mode de paiement');
        return false;
    }
    
    if (selectedMethod.value === 'wallet') {
        const balance = parseFloat(selectedMethod.dataset.walletBalance || 0);
        const amount = parseFloat(selectedMethod.dataset.amount || 0);
        if (balance < amount) {
            alert('Solde insuffisant dans votre portefeuille');
            return false;
        }
    }
    
    if (selectedMethod.value === 'mobile_money') {
        const country = document.getElementById('mm_country')?.value;
        const network = document.getElementById('mm_network')?.value;
        const phone = document.getElementById('mm_phone')?.value;
        
        if (!country || !network || !phone) {
            alert('Veuillez remplir tous les champs Mobile Money');
            return false;
        }
    }
    
    return true;
}
</script>
