{% load static i18n %}
{% load account %}
{% get_current_language_bidi as LANGUAGE_BIDI %}
{% get_current_language as LANGUAGE_CODE %}
<!DOCTYPE html>
<html lang="{{LANGUAGE_CODE}}" dir="{% if LANGUAGE_BIDI %}rtl{% else %}ltr{% endif %}">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>{% block title %}{% trans "Confirm Email Address" %}{% endblock %}</title>
    
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-QWTKZyjpPEjISv5WaRU9OFeRpok6YctnYmDr5pNlyT2bRjXh0JMhjY6hW+ALEwIH" crossorigin="anonymous">
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.2/css/all.min.css" integrity="sha512-SnH5WK+bZxgPHs44uWIX+LLMDJzL2sKMOz36tM+B7f3/17W6j45+V+qJ9vG9eW0p/L5UqG+J0S3Fv52g+JzI/A==" crossorigin="anonymous" referrerpolicy="no-referrer" />
    
    <style>
        /* -------------------------------------------------------------------------- */
        /* CUSTOM TEAL THEME OVERRIDES (Matching the Sign-In Reference) */
        /* -------------------------------------------------------------------------- */
        :root {
            /* Define TEAL as the primary color for Bootstrap overrides */
            --bs-primary: #00636e; /* Dark Teal */
            --bs-primary-rgb: 0, 99, 110;
            --bs-primary-light: #007a88; /* Lighter Teal for hover */
            
            /* Background and Text Colors */
            --bs-body-bg: #f8f9fa; /* Light gray background */
            --kaauh-primary-text: #212529; /* Dark text */
            
            /* Custom Theme Variables */
            --kaauh-success-icon: #008080; /* Slightly softer teal for success icon */
        }
        
        body {
            font-family: 'Inter', sans-serif;
            background-color: var(--bs-body-bg);
        }

        /* Custom Left Panel (Replicating the original look) */
        .left-panel {
            flex: 1;
            /* Placeholder for image path. Assuming 'image/kaauh_banner.png' is correct based on reference */
            background: url("{% static 'image/kaauh_banner.png' %}") no-repeat center center;
            background-size: cover;
            position: relative;
            display: flex;
            align-items: flex-end;
            padding: 3rem;
            color: white;
            z-index: 1;
        }
        .left-panel::before {
            content: '';
            position: absolute;
            top: 0;
            left: 0;
            right: 0;
            bottom: 0;
            background: linear-gradient(to top, rgba(0,0,0,0.8) 0%, rgba(0,0,0,0) 50%);
            z-index: 0;
        }
        .left-panel-content {
            position: relative;
            z-index: 2;
        }

        /* Right Panel Styling - Used for the confirmation form */
        .right-panel {
            background-color: white;
            padding: 3rem;
        }
        
        /* Component Overrides */
        .btn-main-action {
            background-color: var(--bs-primary) !important;
            border-color: var(--bs-primary) !important;
            color: white !important;
            font-weight: 600;
            border-radius: 0.5rem; 
            box-shadow: 0 4px 8px rgba(0, 99, 110, 0.2); 
            transition: all 0.2s ease;
            padding: 0.75rem 2.5rem; /* Large padding for primary action */
            width: 100%; /* Make the button full width on smaller screens */
        }
        .btn-main-action:hover {
            background-color: var(--bs-primary-light) !important;
            border-color: var(--bs-primary-light) !important;
            box-shadow: 0 6px 10px rgba(0, 99, 110, 0.3);
            transform: translateY(-1px);
        }
        
        /* Secondary Outline Button */
        .btn-outline-secondary {
            color: var(--bs-primary) !important;
            border-color: var(--bs-primary) !important;
            font-weight: 600;
            border-radius: 0.5rem;
            padding: 0.75rem 2.5rem; 
            width: 100%;
        }
        .btn-outline-secondary:hover {
            background-color: var(--bs-primary) !important;
            color: white !important;
            border-color: var(--bs-primary) !important;
        }

        /* Text Accent Color */
        .text-primary-teal {
            color: var(--bs-primary) !important;
        }
        
        /* Confirmation Icon Color */
        .icon-success-teal {
            color: var(--kaauh-success-icon);
        }
        
        /* Card Styling - Matching the 'right-panel' white look */
        .kaauh-card {
            border: none;
            border-radius: 1rem; /* Rounded corners */
            box-shadow: 0 10px 25px rgba(0,0,0,0.08); /* Strong shadow */
            background-color: white;
            overflow: hidden;
        }
        
        /* Layout Adjustments to match reference */
        @media (min-width: 992px) {
            /* 1. Set a NARROWER fixed width for the right panel container */
            .right-panel-col {
                flex: 0 0 450px; 
            }
            /* 2. Ensure the form container doesn't exceed a smaller size and is centered */
            .right-panel-content-wrapper {
                 max-width: 560px;
                 width: 100%;
            }
            /* 3. Button width adjusted for desktop view */
            .btn-main-action, .btn-outline-secondary {
                width: auto;
            }
        }
    </style>
</head>
<body class="d-flex vh-100 w-100">

    <div class="left-panel d-none d-lg-flex flex-grow-1">
        <div class="left-panel-content">
            <h1 class="text-4xl font-weight-bold mb-4" style="font-size: 1.5rem;">
                <span class="text-white">
                    <div class="hospital-text text-center text-md-start me-3">
                        <div class="ar small">جامعة الأميرة نورة بنت عبدالرحمن الأكاديمية</div>
                        <div class="ar small">ومستشفى الملك عبدالله بن عبدالعزيز التخصصي</div>
                        <div class="en small">Princess Nourah bint Abdulrahman University</div>
                        <div class="en small">King Abdullah bin Abdulaziz University Hospital</div>
                    </div>
                </span>
            </h1>
            <small>Powered By TENHAL | تنحل</small>
        </div>
    </div>

    <div class="d-flex flex-column right-panel right-panel-col flex-grow-1 align-items-center justify-content-center">
        
        <div class="right-panel-content-wrapper p-4 p-md-0">
            
            {# Global Header #}
            <div class="text-center mb-4">
                <h3 class="fw-bolder text-primary-teal">{% trans "Account Verification" %}</h3>
                <p class="lead text-muted">{% trans "Verify your email to secure your account and unlock full features." %}</p>
            </div>
            
            <div class="kaauh-card"> 
                <div class="card-body p-5 text-center">

                    {% with email as email %}

                        {% if confirmation %}
                            
                            {# ------------------- CONFIRMATION REQUEST (GET) - Success Theme ------------------- #}
                            {% user_display confirmation.email_address.user as user_display %}
                            
                            <i class="fas fa-check-circle mb-4 icon-success-teal" style="font-size: 4rem;"></i>
                            
                            <h4 class="fw-bold mb-3 text-primary-teal">{% trans "Confirm Your Email Address" %}</h4>

                            <p class="lead" style="color: var(--kaauh-primary-text);">
                                {% blocktrans with email as email %}Please confirm that **{{ email }}** is the correct email address for your account.{% endblocktrans %}
                            </p>

                            {# Confirmation Form #}
                            <form method="post" action="{% url 'account_confirm_email' confirmation.key %}">
                                {% csrf_token %}
                                
                                <button class="btn btn-main-action mt-4" type="submit">
                                    {% trans "Confirm & Activate" %}
                                </button>
                            </form>
                            
                        {% else %}
                            
                            {# ------------------- CONFIRMATION FAILED (Error) - Danger Theme ------------------- #}
                            <i class="fas fa-unlink text-danger mb-4" style="font-size: 4rem;"></i>
                            
                            <h4 class="fw-bold mb-3 text-danger">{% trans "Verification Failed" %}</h4>
                            
                            <p class="lead text-danger">
                                {% trans "The email confirmation link is expired or invalid." %}
                            </p>
                            <p class="text-muted small mb-0">
                                {% trans "If you recently requested a link, please ensure you use the newest one. You can request a new verification email from your account settings." %}
                            </p>
                            
                            <a href="{% url 'account_email' %}" class="btn btn-outline-secondary mt-4">
                                <i class="fas fa-cog me-2"></i> {% trans "Go to Settings" %}
                            </a>

                        {% endif %}

                    {% endwith %}
                </div>
            </div>
            
        </div>
    </div>
    
    <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js" integrity="sha384-YvpcrYf0tY3lHB60NNkmXc5s9fDVZLESaAA55NDzOxhy9GkcIdslK1eN7N6jIeHz" crossorigin="anonymous"></script>
</body>
</html>