<!DOCTYPE html>
<html lang="es">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Registro Revendedor | Wincar Colecciona & Gana</title>
    <link rel="preconnect" href="https://fonts.googleapis.com">
    <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
    <link href="https://fonts.googleapis.com/css2?family=Outfit:wght@400;500;600;700;800;900&display=swap" rel="stylesheet">
    <style>
        :root {
            --bg-color: #080705;
            --surface-color: #17150F;
            --surface-light: #262218;
            --primary-gold: #F5C542;
            --gold-light: #FFE885;
            --burgundy: #6B0E23;
            --burgundy-bright: #C72548;
            --burgundy-dark: #3B0813;
            --text-primary: #FFFFFF;
            --text-secondary: #B8B09D;
            --text-muted: #736E62;
        }

        * {
            box-sizing: border-box;
            margin: 0;
            padding: 0;
            font-family: 'Outfit', -apple-system, BlinkMacSystemFont, sans-serif;
        }

        body {
            background-color: var(--bg-color);
            color: var(--text-primary);
            min-height: 100vh;
            display: flex;
            flex-direction: column;
            align-items: center;
            justify-content: center;
            padding: 20px 16px;
            position: relative;
            overflow-x: hidden;
        }

        /* Ambient Glow Background */
        .ambient-glow {
            position: absolute;
            top: -100px;
            left: 50%;
            transform: translateX(-50%);
            width: 380px;
            height: 380px;
            background: radial-gradient(circle, rgba(199, 37, 72, 0.25) 0%, rgba(107, 14, 35, 0.15) 50%, transparent 70%);
            z-index: 0;
            pointer-events: none;
        }

        .container {
            width: 100%;
            max-width: 440px;
            z-index: 1;
        }

        .header {
            text-align: center;
            margin-bottom: 24px;
        }

        .logo-img {
            height: 70px;
            margin-bottom: 12px;
            filter: drop-shadow(0 4px 12px rgba(245, 197, 66, 0.2));
        }

        .inviter-card {
            background: linear-gradient(135deg, rgba(59, 8, 19, 0.8), rgba(23, 21, 15, 0.95));
            border: 1px solid rgba(245, 197, 66, 0.35);
            border-radius: 20px;
            padding: 16px 20px;
            margin-bottom: 24px;
            box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5), inset 0 1px 0 rgba(255, 232, 133, 0.2);
            display: flex;
            align-items: center;
            gap: 14px;
        }

        .inviter-avatar {
            width: 50px;
            height: 50px;
            border-radius: 50%;
            background: linear-gradient(135deg, var(--burgundy-bright), var(--burgundy));
            border: 2px solid var(--primary-gold);
            display: flex;
            align-items: center;
            justify-content: center;
            font-size: 20px;
            flex-shrink: 0;
        }

        .inviter-info h3 {
            font-size: 11px;
            text-transform: uppercase;
            letter-spacing: 1px;
            color: var(--primary-gold);
            margin-bottom: 2px;
        }

        .inviter-info h2 {
            font-size: 16px;
            font-weight: 700;
            color: #FFF;
        }

        .inviter-info p {
            font-size: 12px;
            color: var(--text-secondary);
        }

        .badge-code {
            display: inline-block;
            background: rgba(245, 197, 66, 0.15);
            color: var(--primary-gold);
            padding: 2px 8px;
            border-radius: 6px;
            font-weight: 700;
            font-size: 11px;
            margin-top: 4px;
            border: 1px solid rgba(245, 197, 66, 0.3);
        }

        .card-form {
            background: var(--surface-color);
            border: 1px solid var(--surface-light);
            border-radius: 24px;
            padding: 28px 22px;
            box-shadow: 0 16px 40px rgba(0, 0, 0, 0.6);
        }

        .form-title {
            font-size: 20px;
            font-weight: 800;
            margin-bottom: 6px;
            text-align: center;
            background: linear-gradient(135deg, #FFF, var(--primary-gold));
            -webkit-background-clip: text;
            -webkit-text-fill-color: transparent;
        }

        .form-subtitle {
            font-size: 13px;
            color: var(--text-secondary);
            text-align: center;
            margin-bottom: 24px;
            line-height: 1.4;
        }

        .form-group {
            margin-bottom: 16px;
        }

        .form-label {
            display: block;
            font-size: 12px;
            font-weight: 600;
            color: var(--text-secondary);
            margin-bottom: 6px;
            text-transform: uppercase;
            letter-spacing: 0.5px;
        }

        .form-input {
            width: 100%;
            background: var(--bg-color);
            border: 1.5px solid var(--surface-light);
            border-radius: 12px;
            padding: 14px 16px;
            color: #FFF;
            font-size: 14px;
            transition: all 0.2s ease;
        }

        .form-input:focus {
            outline: none;
            border-color: var(--primary-gold);
            box-shadow: 0 0 0 3px rgba(245, 197, 66, 0.15);
        }

        .alert-error {
            background: rgba(199, 37, 72, 0.15);
            border: 1px solid var(--burgundy-bright);
            border-radius: 12px;
            padding: 12px 16px;
            margin-bottom: 20px;
            color: #FFB3C1;
            font-size: 13px;
        }

        .alert-error ul {
            padding-left: 18px;
            margin-top: 4px;
        }

        .btn-submit {
            width: 100%;
            background: linear-gradient(135deg, #FFE885 0%, #F5C542 50%, #C9961A 100%);
            border: none;
            border-radius: 14px;
            padding: 16px;
            color: #17150F;
            font-size: 15px;
            font-weight: 800;
            text-transform: uppercase;
            letter-spacing: 1px;
            cursor: pointer;
            box-shadow: 0 6px 20px rgba(245, 197, 66, 0.35);
            transition: transform 0.2s ease, box-shadow 0.2s ease;
            margin-top: 10px;
        }

        .btn-submit:hover {
            transform: translateY(-2px);
            box-shadow: 0 8px 25px rgba(245, 197, 66, 0.5);
        }

        .btn-submit:active {
            transform: translateY(0);
        }

        .raffles-section {
            margin-top: 28px;
        }

        .raffles-title {
            font-size: 14px;
            font-weight: 700;
            color: var(--text-secondary);
            margin-bottom: 12px;
            text-align: center;
        }

        .raffles-grid {
            display: grid;
            grid-template-columns: 1fr 1fr;
            gap: 10px;
        }

        .raffle-badge {
            background: var(--surface-color);
            border: 1px solid var(--surface-light);
            border-radius: 12px;
            padding: 10px;
            text-align: center;
        }

        .raffle-badge img {
            width: 100%;
            height: 70px;
            object-fit: cover;
            border-radius: 8px;
            margin-bottom: 6px;
        }

        .raffle-badge h4 {
            font-size: 12px;
            color: #FFF;
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
        }

        .raffle-badge span {
            font-size: 11px;
            color: var(--primary-gold);
            font-weight: 700;
        }

        .footer {
            margin-top: 30px;
            text-align: center;
            color: var(--text-muted);
            font-size: 12px;
        }
    </style>
</head>
<body>
    <div class="ambient-glow"></div>

    <div class="container">
        <!-- Header con Logo -->
        <div class="header">
            <img src="/assets/images/Win Card Transparente.png" alt="Wincar Logo" class="logo-img" onerror="this.src='https://via.placeholder.com/150x60?text=WINCAR'">
        </div>

        <!-- Tarjeta del Revendedor Invitante -->
        @if(!empty($refCode))
        <div class="inviter-card">
            <div class="inviter-avatar">🏎️</div>
            <div class="inviter-info">
                <h3>Invitación Especial</h3>
                <h2>{{ $resellerName ?? 'Revendedor Wincar' }}</h2>
                <span class="badge-code">CÓDIGO: {{ $refCode }}</span>
            </div>
        </div>
        @endif

        <!-- Formulario de Registro -->
        <div class="card-form">
            <h1 class="form-title">Crea tu Cuenta Wincar</h1>
            <p class="form-subtitle">Completa tus datos para participar en los sorteos exclusivos de autos y premios acumulados.</p>

            @if($errors->any())
            <div class="alert-error">
                <strong>Por favor corrige los siguientes errores:</strong>
                <ul>
                    @foreach($errors->all() as $error)
                        <li>{{ $error }}</li>
                    @endforeach
                </ul>
            </div>
            @endif

            <form action="{{ route('web.reseller.register.submit') }}" method="POST">
                @csrf

                @if(!empty($refCode))
                <input type="hidden" name="referred_by_code" value="{{ $refCode }}">
                @endif

                <div class="form-group">
                    <label class="form-label" for="name">Nombre Completo</label>
                    <input type="text" id="name" name="name" class="form-input" placeholder="Nombre y Apellidos" value="{{ old('name') }}" required>
                </div>

                <div class="form-group">
                    <label class="form-label" for="cedula">Cédula o Identificación</label>
                    <input type="text" id="cedula" name="cedula" class="form-input" placeholder="Ej: 112340567" value="{{ old('cedula') }}" required>
                </div>

                <div class="form-group">
                    <label class="form-label" for="phone">Teléfono / WhatsApp</label>
                    <input type="tel" id="phone" name="phone" class="form-input" placeholder="Ej: 88888888" value="{{ old('phone') }}" required>
                </div>

                <div class="form-group">
                    <label class="form-label" for="email">Correo Electrónico</label>
                    <input type="email" id="email" name="email" class="form-input" placeholder="tu@correo.com" value="{{ old('email') }}" required>
                </div>

                <div class="form-group">
                    <label class="form-label" for="password">Contraseña</label>
                    <input type="password" id="password" name="password" class="form-input" placeholder="Mínimo 8 caracteres" required>
                </div>

                <div class="form-group">
                    <label class="form-label" for="password_confirmation">Confirmar Contraseña</label>
                    <input type="password" id="password_confirmation" name="password_confirmation" class="form-input" placeholder="Repite tu contraseña" required>
                </div>

                <button type="submit" class="btn-submit">
                    REGISTRARSE & ACTIVAR
                </button>
            </form>
        </div>

        <!-- Sorteos Destacados -->
        @if(isset($activeRaffles) && $activeRaffles->count() > 0)
        <div class="raffles-section">
            <h3 class="raffles-title">🔥 SORTEOS DISPONIBLES AHORA</h3>
            <div class="raffles-grid">
                @foreach($activeRaffles as $raffle)
                <div class="raffle-badge">
                    <h4>{{ $raffle->title }}</h4>
                    <span>₡{{ number_format($raffle->price_per_ticket, 0, ',', '.') }} /núm</span>
                </div>
                @endforeach
            </div>
        </div>
        @endif

        <div class="footer">
            <p>© {{ date('Y') }} Wincar Costa Rica. Todos los derechos reservados.</p>
        </div>
    </div>
</body>
</html>
