{% extends "base.html" %}

{% block title %}Choose Your Class - Code of Conquest{% endblock %}

{% block content %}
<div class="creation-container">
    <!-- Progress Indicator -->
    <div class="creation-progress">
        <div class="progress-step completed">
            <div class="step-number">✓</div>
            <div class="step-label">Origin</div>
        </div>
        <div class="progress-line"></div>
        <div class="progress-step active">
            <div class="step-number">2</div>
            <div class="step-label">Class</div>
        </div>
        <div class="progress-line"></div>
        <div class="progress-step">
            <div class="step-number">3</div>
            <div class="step-label">Customize</div>
        </div>
        <div class="progress-line"></div>
        <div class="progress-step">
            <div class="step-number">4</div>
            <div class="step-label">Confirm</div>
        </div>
    </div>

    <!-- Page Header -->
    <h1 class="page-title">Choose Your Class</h1>
    <p class="page-subtitle">Select your fighting style and role in combat</p>

    <div class="decorative-line"></div>

    <!-- Class Selection Form -->
    <form method="POST" action="{{ url_for('character_views.create_class') }}" id="class-form">
        <div class="class-grid">
            {% for player_class in classes %}
            <div class="class-card" data-class-id="{{ player_class.class_id }}">
                <input
                    type="radio"
                    name="class_id"
                    value="{{ player_class.class_id }}"
                    id="class-{{ player_class.class_id }}"
                    class="class-radio"
                    required
                >
                <label for="class-{{ player_class.class_id }}" class="class-label">
                    <div class="class-header">
                        <h3 class="class-title">{{ player_class.name }}</h3>
                    </div>

                    <div class="class-description">
                        <p>{{ player_class.description }}</p>
                    </div>

                    <!-- Base Stats -->
                    <div class="class-stats">
                        <div class="stats-label">Base Stats</div>
                        <div class="stats-grid">
                            <div class="stat-item">
                                <span class="stat-name">STR</span>
                                <span class="stat-value">{{ player_class.base_stats.strength }}</span>
                            </div>
                            <div class="stat-item">
                                <span class="stat-name">DEX</span>
                                <span class="stat-value">{{ player_class.base_stats.dexterity }}</span>
                            </div>
                            <div class="stat-item">
                                <span class="stat-name">CON</span>
                                <span class="stat-value">{{ player_class.base_stats.constitution }}</span>
                            </div>
                            <div class="stat-item">
                                <span class="stat-name">INT</span>
                                <span class="stat-value">{{ player_class.base_stats.intelligence }}</span>
                            </div>
                            <div class="stat-item">
                                <span class="stat-name">WIS</span>
                                <span class="stat-value">{{ player_class.base_stats.wisdom }}</span>
                            </div>
                            <div class="stat-item">
                                <span class="stat-name">CHA</span>
                                <span class="stat-value">{{ player_class.base_stats.charisma }}</span>
                            </div>
                        </div>
                    </div>

                    <!-- Skill Trees -->
                    <div class="class-trees">
                        <div class="trees-label">Available Specializations</div>
                        <p class="trees-hint">You'll choose your path as you level up</p>
                        <div class="tree-list">
                            {% for tree in player_class.skill_trees %}
                            <div class="tree-item">
                                <span class="tree-icon">🌲</span>
                                <span class="tree-name">{{ tree }}</span>
                            </div>
                            {% endfor %}
                        </div>
                    </div>

                </label>
            </div>
            {% endfor %}
        </div>

        <!-- Navigation Buttons -->
        <div class="creation-nav">
            <a href="{{ url_for('character_views.create_origin') }}" class="btn btn-secondary">
                ← Back to Origin
            </a>
            <button type="submit" class="btn btn-primary">
                Next: Customize →
            </button>
        </div>
    </form>
</div>

<style>
/* ===== PROGRESS INDICATOR ===== */
.creation-progress {
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 2rem;
    padding: 1.5rem 0;
}

.progress-step {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    min-width: 80px;
}

.step-number {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-secondary);
    border: 2px solid var(--border-primary);
    color: var(--text-muted);
    font-family: var(--font-heading);
    font-weight: 600;
    font-size: var(--text-sm);
}

.progress-step.completed .step-number {
    background: var(--accent-gold);
    border-color: var(--accent-gold);
    color: var(--bg-primary);
}

.progress-step.active .step-number {
    background: var(--bg-primary);
    border-color: var(--accent-gold);
    color: var(--accent-gold);
    box-shadow: 0 0 10px rgba(243, 156, 18, 0.3);
}

.step-label {
    font-size: var(--text-xs);
    color: var(--text-muted);
    text-transform: uppercase;
    font-weight: 600;
    text-align: center;
}

.progress-step.active .step-label {
    color: var(--accent-gold);
}

.progress-step.completed .step-label {
    color: var(--text-secondary);
}

.progress-line {
    width: 60px;
    height: 2px;
    background: var(--border-primary);
    margin: 0 0.5rem;
    margin-bottom: 1.5rem;
}

.progress-step.completed ~ .progress-line {
    background: var(--accent-gold);
}

/* ===== CLASS GRID ===== */
.class-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

/* ===== CLASS CARDS ===== */
.class-card {
    position: relative;
}

.class-radio {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.class-label {
    display: block;
    padding: 1.5rem;
    background: var(--bg-secondary);
    border: 2px solid var(--border-primary);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    height: 100%;
}

.class-label:hover {
    border-color: var(--accent-gold);
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.class-radio:checked + .class-label {
    border-color: var(--accent-gold);
    box-shadow: var(--shadow-glow);
    background: linear-gradient(135deg, var(--bg-secondary) 0%, rgba(243, 156, 18, 0.1) 100%);
}

.class-header {
    margin-bottom: 1rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border-primary);
}

.class-title {
    font-family: var(--font-heading);
    font-size: var(--text-xl);
    color: var(--accent-gold);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 0.25rem;
}

.class-description {
    margin-bottom: 1rem;
    color: var(--text-secondary);
    font-size: var(--text-sm);
    line-height: 1.5;
}

/* ===== STATS SECTION ===== */
.class-stats {
    margin-bottom: 1rem;
    padding: 1rem;
    background: var(--bg-input);
    border-radius: 4px;
}

.stats-label {
    font-family: var(--font-heading);
    font-size: var(--text-sm);
    color: var(--accent-gold);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 0.75rem;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.75rem;
}

.stat-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 0.5rem;
    background: var(--bg-secondary);
    border-radius: 4px;
    border: 1px solid var(--border-primary);
}

.stat-name {
    font-size: var(--text-xs);
    color: var(--text-muted);
    text-transform: uppercase;
    font-weight: 600;
    margin-bottom: 0.25rem;
}

.stat-value {
    font-family: var(--font-heading);
    font-size: var(--text-lg);
    color: var(--text-primary);
    font-weight: 600;
}

/* ===== SKILL TREES SECTION ===== */
.class-trees {
    margin-bottom: 1rem;
}

.trees-label {
    font-family: var(--font-heading);
    font-size: var(--text-sm);
    color: var(--accent-gold);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 0.25rem;
}

.trees-hint {
    font-size: var(--text-xs);
    color: var(--text-muted);
    font-style: italic;
    margin-bottom: 0.5rem;
    margin-top: 0;
}

.tree-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.tree-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem;
    background: var(--bg-input);
    border-radius: 4px;
    color: var(--text-secondary);
    font-size: var(--text-sm);
}

.tree-icon {
    font-size: var(--text-base);
}

.tree-name {
    font-weight: 500;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
    .class-grid {
        grid-template-columns: 1fr;
    }

    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}
</style>
{% endblock %}
