{% extends 'base/base.html' %}

{% block title %}Login - CryptoSignals Pro{% endblock %}

{% block extra_css %}
<style>
    .auth-wrapper {
        min-height: calc(100vh - 200px);
        display: flex;
        align-items: center;
        justify-content: center;
        padding: 2rem;
    }
    
    .auth-card-new {
        background: rgba(17, 24, 39, 0.8);
        backdrop-filter: blur(20px);
        border: 1px solid rgba(0, 212, 255, 0.2);
        border-radius: 24px;
        padding: 3rem;
        max-width: 420px;
        width: 100%;
        position: relative;
        overflow: hidden;
    }
    
    .auth-card-new::before {
        content: '';
        position: absolute;
        top: 0;
        left: 0;
        right: 0;
        height: 4px;
        background: linear-gradient(90deg, #00d4ff, #7b2ff7, #f107a3);
    }
    
    .auth-card-new::after {
        content: '';
        position: absolute;
        top: -50%;
        left: -50%;
        width: 200%;
        height: 200%;
        background: radial-gradient(circle, rgba(0, 212, 255, 0.05) 0%, transparent 50%);
        pointer-events: none;
    }
    
    .auth-icon-new {
        width: 70px;
        height: 70px;
        border-radius: 20px;
        background: linear-gradient(135deg, rgba(0, 212, 255, 0.2), rgba(123, 47, 247, 0.2));
        display: flex;
        align-items: center;
        justify-content: center;
        margin: 0 auto 1.5rem;
        font-size: 1.75rem;
        color: #00d4ff;
        border: 1px solid rgba(0, 212, 255, 0.3);
    }
    
    .auth-title {
        font-family: 'Space Grotesk', sans-serif;
        font-size: 1.75rem;
        font-weight: 700;
        text-align: center;
        margin-bottom: 0.5rem;
        background: linear-gradient(135deg, #fff 0%, #94a3b8 100%);
        -webkit-background-clip: text;
        -webkit-text-fill-color: transparent;
        background-clip: text;
    }
    
    .auth-subtitle {
        text-align: center;
        color: #94a3b8;
        margin-bottom: 2rem;
    }
    
    .form-group-new {
        margin-bottom: 1.25rem;
    }
    
    .form-label-new {
        display: block;
        color: #94a3b8;
        font-weight: 500;
        margin-bottom: 0.5rem;
        font-size: 0.875rem;
    }
    
    .form-control-new {
        width: 100%;
        padding: 0.875rem 1rem;
        background: #0a0e17;
        border: 1px solid #1e293b;
        border-radius: 12px;
        color: #fff;
        font-size: 1rem;
        transition: all 0.3s ease;
    }
    
    .form-control-new:focus {
        outline: none;
        border-color: #00d4ff;
        box-shadow: 0 0 0 3px rgba(0, 212, 255, 0.1);
    }
    
    .form-control-new::placeholder {
        color: #64748b;
    }
    
    .btn-login {
        width: 100%;
        padding: 1rem;
        background: linear-gradient(135deg, #00d4ff 0%, #7b2ff7 100%);
        border: none;
        border-radius: 12px;
        color: #fff;
        font-weight: 600;
        font-size: 1rem;
        cursor: pointer;
        transition: all 0.3s ease;
        margin-top: 0.5rem;
    }
    
    .btn-login:hover {
        transform: translateY(-2px);
        box-shadow: 0 10px 30px rgba(0, 212, 255, 0.3);
    }
    
    .divider {
        display: flex;
        align-items: center;
        margin: 1.5rem 0;
    }
    
    .divider::before,
    .divider::after {
        content: '';
        flex: 1;
        height: 1px;
        background: #1e293b;
    }
    
    .divider span {
        padding: 0 1rem;
        color: #64748b;
        font-size: 0.875rem;
    }
    
    .auth-footer {
        text-align: center;
        margin-top: 1.5rem;
        color: #94a3b8;
    }
    
    .auth-footer a {
        color: #00d4ff;
        text-decoration: none;
        font-weight: 500;
    }
    
    .auth-footer a:hover {
        text-decoration: underline;
    }
    
    .remember-forgot {
        display: flex;
        justify-content: space-between;
        align-items: center;
        margin-bottom: 1rem;
    }
    
    .form-check-input {
        background-color: #0a0e17;
        border-color: #1e293b;
    }
    
    .form-check-input:checked {
        background-color: #00d4ff;
        border-color: #00d4ff;
    }
    
    .form-check-label {
        color: #94a3b8;
    }
    
    .forgot-link {
        color: #00d4ff;
        font-size: 0.875rem;
    }
    
    .forgot-link:hover {
        text-decoration: underline;
    }

    @media (max-width: 575.98px) {
        .auth-wrapper {
            padding: 1rem;
            min-height: auto;
        }

        .auth-card-new {
            padding: 1.5rem 1rem;
            border-radius: 18px;
        }

        .remember-forgot {
            flex-direction: column;
            align-items: flex-start;
            gap: 0.75rem;
        }

        .auth-title {
            font-size: 1.45rem;
        }
    }
</style>
{% endblock %}

{% block content %}
<div class="auth-wrapper">
    <div class="auth-card-new">
        <div class="auth-icon-new">
            <i class="bi bi-currency-bitcoin"></i>
        </div>
        
        <h1 class="auth-title">Welcome Back</h1>
        <p class="auth-subtitle">Sign in to your account</p>
        
        {% if messages %}
            {% for message in messages %}
            <div class="alert alert-{{ message.tags }} alert-dismissible fade show" role="alert" style="background: rgba(16, 185, 129, 0.1); border: none; color: #10b981; border-radius: 10px;">
                {{ message }}
                <button type="button" class="btn-close" data-bs-dismiss="alert"></button>
            </div>
            {% endfor %}
        {% endif %}
        
        <form method="post" action="{% url 'login' %}">
            {% csrf_token %}
            
            {% if form.errors %}
            <div class="alert alert-danger" style="background: rgba(239, 68, 68, 0.1); border: none; color: #ef4444; border-radius: 10px;">
                Invalid username or password. Please try again.
                <button type="button" class="btn-close" data-bs-dismiss="alert"></button>
            </div>
            {% endif %}
            
            <div class="form-group-new">
                <label class="form-label-new">Username</label>
                <input type="text" class="form-control-new" id="username" name="username" placeholder="Enter your username" required>
            </div>
            
            <div class="form-group-new">
                <label class="form-label-new">Password</label>
                <input type="password" class="form-control-new" id="password" name="password" placeholder="Enter your password" required>
            </div>
            
            <div class="remember-forgot">
                <div class="form-check">
                    <input type="checkbox" class="form-check-input" id="remember">
                    <label class="form-check-label" for="remember">Remember me</label>
                </div>
                <a href="{% url 'password_reset' %}" class="forgot-link">Forgot password?</a>
            </div>
            
            <button type="submit" class="btn-login">Sign In</button>
        </form>
        
        <div class="divider">
            <span>OR</span>
        </div>
        
        <p class="auth-footer">
            Don't have an account? 
            <a href="{% url 'signup' %}">Create Account</a>
        </p>
    </div>
</div>
{% endblock %}
