{% extends "base.html" %}

{% block title %}Korzyści Członkowskie - Norda Biznes Partner{% endblock %}

{% block extra_css %}
<style>
    /* ============================================
       HERO SECTION
       ============================================ */
    .benefits-hero {
        background: linear-gradient(135deg, #1e3a5f 0%, #2d5a87 50%, #3b7cb8 100%);
        color: white;
        padding: 3rem 0;
        margin: -2rem -1rem 2rem -1rem;
        position: relative;
        overflow: hidden;
    }

    .benefits-hero::before {
        content: "";
        position: absolute;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23ffffff' fill-opacity='0.05'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
        opacity: 0.5;
    }

    .benefits-hero-content {
        max-width: 800px;
        margin: 0 auto;
        text-align: center;
        position: relative;
        z-index: 1;
        padding: 0 1rem;
    }

    .benefits-hero-icon {
        width: 80px;
        height: 80px;
        background: rgba(255,255,255,0.15);
        border-radius: 50%;
        display: flex;
        align-items: center;
        justify-content: center;
        margin: 0 auto 1.5rem;
        backdrop-filter: blur(10px);
    }

    .benefits-hero-icon svg {
        width: 40px;
        height: 40px;
        color: white;
    }

    .benefits-hero h1 {
        font-size: 2.5rem;
        font-weight: 700;
        margin-bottom: 1rem;
        text-shadow: 0 2px 4px rgba(0,0,0,0.1);
    }

    .benefits-hero p {
        font-size: 1.2rem;
        opacity: 0.9;
        max-width: 600px;
        margin: 0 auto 1.5rem;
        line-height: 1.6;
    }

    .hero-stats {
        display: flex;
        justify-content: center;
        gap: 3rem;
        margin-top: 2rem;
    }

    .hero-stat {
        text-align: center;
    }

    .hero-stat-value {
        font-size: 2rem;
        font-weight: 700;
        display: block;
    }

    .hero-stat-label {
        font-size: 0.9rem;
        opacity: 0.8;
    }

    /* ============================================
       INFO BANNER
       ============================================ */
    .info-banner {
        background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
        border: 1px solid #f59e0b;
        border-radius: 1rem;
        padding: 1.25rem 1.5rem;
        margin-bottom: 2rem;
        display: flex;
        align-items: center;
        gap: 1rem;
        box-shadow: 0 4px 6px -1px rgba(245, 158, 11, 0.1);
    }

    .info-banner-icon {
        width: 48px;
        height: 48px;
        background: #fbbf24;
        border-radius: 50%;
        display: flex;
        align-items: center;
        justify-content: center;
        flex-shrink: 0;
    }

    .info-banner-icon svg {
        width: 24px;
        height: 24px;
        color: #78350f;
    }

    .info-banner-content {
        flex: 1;
    }

    .info-banner-title {
        font-weight: 700;
        color: #92400e;
        font-size: 1rem;
        margin-bottom: 0.25rem;
    }

    .info-banner-text {
        color: #a16207;
        font-size: 0.9rem;
        line-height: 1.5;
    }

    /* ============================================
       SECTION HEADER
       ============================================ */
    .section-header {
        text-align: center;
        margin-bottom: 2rem;
    }

    .section-header h2 {
        font-size: 1.75rem;
        font-weight: 700;
        color: var(--text-primary);
        margin-bottom: 0.5rem;
    }

    .section-header p {
        color: var(--text-secondary);
        font-size: 1.1rem;
    }

    /* ============================================
       BENEFITS GRID
       ============================================ */
    .benefits-grid {
        display: grid;
        grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
        gap: 1.5rem;
    }

    /* ============================================
       BENEFIT CARD - REDESIGNED
       ============================================ */
    .benefit-card {
        background: white;
        border-radius: 1rem;
        border: 1px solid #e2e8f0;
        box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.03);
        transition: all 0.3s ease;
        position: relative;
        overflow: hidden;
        display: flex;
        flex-direction: column;
    }

    .benefit-card:hover {
        transform: translateY(-8px);
        box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
        border-color: var(--primary);
    }

    .benefit-card.featured {
        border: 2px solid var(--primary);
    }

    .benefit-card.featured::before {
        content: 'Polecane';
        position: absolute;
        top: 16px;
        right: -32px;
        background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
        color: white;
        font-size: 0.75rem;
        font-weight: 700;
        padding: 6px 40px;
        transform: rotate(45deg);
        box-shadow: 0 2px 4px rgba(0,0,0,0.2);
        z-index: 10;
    }

    /* Card Header with gradient accent */
    .benefit-card-header {
        padding: 1.5rem;
        background: linear-gradient(180deg, #f8fafc 0%, white 100%);
        border-bottom: 1px solid #e2e8f0;
        display: flex;
        align-items: center;
        gap: 1rem;
    }

    .benefit-logo {
        width: 64px;
        height: 64px;
        border-radius: 12px;
        object-fit: contain;
        background: white;
        padding: 8px;
        border: 1px solid #e2e8f0;
        box-shadow: 0 2px 4px rgba(0,0,0,0.05);
    }

    .benefit-logo-placeholder {
        width: 64px;
        height: 64px;
        border-radius: 12px;
        background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
        display: flex;
        align-items: center;
        justify-content: center;
        color: white;
        font-weight: 700;
        font-size: 1.5rem;
        box-shadow: 0 4px 6px rgba(var(--primary-rgb), 0.3);
    }

    .benefit-title-section {
        flex: 1;
    }

    .benefit-title {
        font-size: 1.25rem;
        font-weight: 700;
        color: var(--text-primary);
        margin-bottom: 4px;
        line-height: 1.3;
    }

    .benefit-card-link {
        text-decoration: none;
        color: inherit;
        display: block;
    }

    .benefit-card-link:hover .benefit-title {
        color: var(--primary);
    }

    .benefit-category {
        display: inline-flex;
        align-items: center;
        gap: 4px;
        font-size: 0.8rem;
        color: var(--primary);
        background: rgba(var(--primary-rgb), 0.1);
        padding: 4px 10px;
        border-radius: 20px;
        font-weight: 500;
    }

    /* Card Body */
    .benefit-card-body {
        padding: 1.5rem;
        flex: 1;
        display: flex;
        flex-direction: column;
    }

    .benefit-description {
        color: var(--text-secondary);
        font-size: 0.95rem;
        line-height: 1.6;
        margin-bottom: 1rem;
        flex: 1;
    }

    /* Highlight features */
    .benefit-highlights {
        display: flex;
        flex-wrap: wrap;
        gap: 0.5rem;
        margin-bottom: 1rem;
    }

    .benefit-highlight {
        display: inline-flex;
        align-items: center;
        gap: 4px;
        font-size: 0.8rem;
        color: #059669;
        background: #ecfdf5;
        padding: 4px 10px;
        border-radius: 20px;
        font-weight: 500;
    }

    .benefit-highlight svg {
        width: 14px;
        height: 14px;
    }

    /* Pricing section */
    .benefit-pricing {
        background: linear-gradient(135deg, #f0fdf4 0%, #dcfce7 100%);
        border-radius: 12px;
        padding: 1rem;
        margin-bottom: 1rem;
        border: 1px solid #bbf7d0;
    }

    .pricing-row {
        display: flex;
        align-items: center;
        justify-content: space-between;
        margin-bottom: 0.5rem;
    }

    .pricing-row:last-child {
        margin-bottom: 0;
    }

    .benefit-member-price {
        font-size: 1.5rem;
        font-weight: 700;
        color: #059669;
    }

    .benefit-regular-price {
        font-size: 1rem;
        color: #9ca3af;
        text-decoration: line-through;
    }

    .benefit-discount-badge {
        background: linear-gradient(135deg, #059669 0%, #047857 100%);
        color: white;
        font-size: 0.75rem;
        font-weight: 700;
        padding: 4px 12px;
        border-radius: 20px;
        box-shadow: 0 2px 4px rgba(5, 150, 105, 0.3);
    }

    /* Promo code */
    .benefit-promo-code {
        background: linear-gradient(135deg, #eff6ff 0%, #dbeafe 100%);
        border: 2px dashed #3b82f6;
        border-radius: 12px;
        padding: 1rem;
        margin-bottom: 1rem;
        display: flex;
        align-items: center;
        justify-content: space-between;
    }

    .promo-code-label {
        font-size: 0.85rem;
        color: #1e40af;
        font-weight: 500;
    }

    .promo-code-value {
        font-family: 'SF Mono', Monaco, monospace;
        font-weight: 700;
        color: #1d4ed8;
        font-size: 1.1rem;
        background: white;
        padding: 4px 12px;
        border-radius: 6px;
        letter-spacing: 1px;
    }

    /* More link */
    .benefit-more-link {
        display: inline-flex;
        align-items: center;
        gap: 6px;
        color: var(--primary);
        font-size: 0.9rem;
        font-weight: 600;
        text-decoration: none;
        margin-top: auto;
        padding-top: 0.5rem;
    }

    .benefit-more-link:hover {
        text-decoration: underline;
    }

    .benefit-more-link svg {
        width: 16px;
        height: 16px;
        transition: transform 0.2s ease;
    }

    .benefit-more-link:hover svg {
        transform: translateX(4px);
    }

    /* Card Footer */
    .benefit-card-footer {
        padding: 1rem 1.5rem;
        background: linear-gradient(180deg, #f8fafc 0%, #f1f5f9 100%);
        border-top: 1px solid #e2e8f0;
    }

    .benefit-cta {
        width: 100%;
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 0.5rem;
        padding: 0.875rem 1.5rem;
        background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
        color: white;
        border: none;
        border-radius: 10px;
        font-weight: 600;
        font-size: 1rem;
        cursor: pointer;
        transition: all 0.2s ease;
        text-decoration: none;
        box-shadow: 0 4px 6px rgba(var(--primary-rgb), 0.25);
    }

    .benefit-cta:hover {
        transform: translateY(-2px);
        box-shadow: 0 6px 12px rgba(var(--primary-rgb), 0.35);
        color: white;
    }

    .benefit-cta svg {
        width: 18px;
        height: 18px;
    }

    /* ============================================
       EMPTY STATE
       ============================================ */
    .empty-state {
        text-align: center;
        padding: 4rem 2rem;
        background: linear-gradient(180deg, #f8fafc 0%, white 100%);
        border-radius: 1rem;
        border: 2px dashed #e2e8f0;
    }

    .empty-state-icon {
        width: 80px;
        height: 80px;
        background: #f1f5f9;
        border-radius: 50%;
        display: flex;
        align-items: center;
        justify-content: center;
        margin: 0 auto 1.5rem;
    }

    .empty-state-icon svg {
        width: 40px;
        height: 40px;
        color: #94a3b8;
    }

    .empty-state h3 {
        font-size: 1.5rem;
        color: var(--text-primary);
        margin-bottom: 0.5rem;
    }

    .empty-state p {
        color: var(--text-secondary);
        font-size: 1rem;
    }

    /* ============================================
       MOBILE RESPONSIVE
       ============================================ */
    @media (max-width: 768px) {
        .benefits-hero {
            padding: 2rem 0;
            margin: -1rem -1rem 1.5rem -1rem;
        }

        .benefits-hero h1 {
            font-size: 1.75rem;
        }

        .benefits-hero p {
            font-size: 1rem;
        }

        .hero-stats {
            gap: 1.5rem;
        }

        .hero-stat-value {
            font-size: 1.5rem;
        }

        .benefits-grid {
            grid-template-columns: 1fr;
        }

        .info-banner {
            flex-direction: column;
            text-align: center;
        }
    }
</style>
{% endblock %}

{% block content %}
<!-- Hero Section -->
<div class="benefits-hero">
    <div class="benefits-hero-content">
        <div class="benefits-hero-icon">
            <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
                <path d="M12 2L2 7l10 5 10-5-10-5z"></path>
                <path d="M2 17l10 5 10-5"></path>
                <path d="M2 12l10 5 10-5"></path>
            </svg>
        </div>
        <h1>Korzyści Członkowskie</h1>
        <p>Ekskluzywne oferty, zniżki i narzędzia dla członków Izby Przedsiębiorców NORDA. Oszczędzaj na subskrypcjach i oprogramowaniu biznesowym.</p>

        <div class="hero-stats">
            <div class="hero-stat">
                <span class="hero-stat-value">{{ benefits|length if benefits else 0 }}</span>
                <span class="hero-stat-label">Aktywnych ofert</span>
            </div>
            <div class="hero-stat">
                <span class="hero-stat-value">do 50%</span>
                <span class="hero-stat-label">Oszczędności</span>
            </div>
            <div class="hero-stat">
                <span class="hero-stat-value">14 dni</span>
                <span class="hero-stat-label">Darmowy trial</span>
            </div>
        </div>
    </div>
</div>

<div class="container">
    <!-- Test mode banner -->
    <div class="info-banner">
        <div class="info-banner-icon">
            <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
                <path d="M10.29 3.86L1.82 18a2 2 0 0 0 1.71 3h16.94a2 2 0 0 0 1.71-3L13.71 3.86a2 2 0 0 0-3.42 0z"></path>
                <line x1="12" y1="9" x2="12" y2="13"></line>
                <line x1="12" y1="17" x2="12.01" y2="17"></line>
            </svg>
        </div>
        <div class="info-banner-content">
            <div class="info-banner-title">Tryb testowy</div>
            <div class="info-banner-text">
                Ta strona jest widoczna tylko dla administratorów. Po zakończeniu testów zostanie udostępniona wszystkim członkom Izby.
            </div>
        </div>
    </div>

    {% if benefits %}
    <div class="section-header">
        <h2>Dostępne oferty</h2>
        <p>Wybierz ofertę i zacznij oszczędzać już dziś</p>
    </div>

    <div class="benefits-grid">
        {% for benefit in benefits %}
        <div class="benefit-card {% if benefit.is_featured %}featured{% endif %}">
            <a href="{{ url_for('benefits.benefit_detail', slug=benefit.slug) }}" class="benefit-card-link">
                <div class="benefit-card-header">
                    {% if benefit.logo_url %}
                    <img src="{{ benefit.logo_url }}" alt="{{ benefit.name }}" class="benefit-logo">
                    {% else %}
                    <div class="benefit-logo-placeholder">{{ benefit.name[0] }}</div>
                    {% endif %}
                    <div class="benefit-title-section">
                        <div class="benefit-title">{{ benefit.name }}</div>
                        <span class="benefit-category">{{ category_choices.get(benefit.category, benefit.category) }}</span>
                    </div>
                </div>
            </a>

            <div class="benefit-card-body">
                <p class="benefit-description">
                    {{ benefit.short_description or benefit.description[:150] + '...' if benefit.description and benefit.description|length > 150 else benefit.description or 'Brak opisu.' }}
                </p>

                <div class="benefit-highlights">
                    <span class="benefit-highlight">
                        <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
                            <polyline points="20 6 9 17 4 12"></polyline>
                        </svg>
                        14 dni za darmo
                    </span>
                    <span class="benefit-highlight">
                        <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
                            <polyline points="20 6 9 17 4 12"></polyline>
                        </svg>
                        Bez zobowiązań
                    </span>
                </div>

                {% if benefit.member_price or benefit.discount_description %}
                <div class="benefit-pricing">
                    <div class="pricing-row">
                        {% if benefit.member_price %}
                        <span class="benefit-member-price">{{ benefit.member_price }}</span>
                        {% endif %}
                        {% if benefit.discount_description %}
                        <span class="benefit-discount-badge">{{ benefit.discount_description }}</span>
                        {% endif %}
                    </div>
                    {% if benefit.regular_price %}
                    <div class="pricing-row">
                        <span style="font-size: 0.85rem; color: #6b7280;">Cena regularna:</span>
                        <span class="benefit-regular-price">{{ benefit.regular_price }}</span>
                    </div>
                    {% endif %}
                </div>
                {% endif %}

                {% if benefit.promo_code %}
                <div class="benefit-promo-code">
                    <span class="promo-code-label">Kod rabatowy:</span>
                    <span class="promo-code-value">{{ benefit.promo_code }}</span>
                </div>
                {% endif %}

                <a href="{{ url_for('benefits.benefit_detail', slug=benefit.slug) }}" class="benefit-more-link">
                    Zobacz szczegóły oferty
                    <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
                        <polyline points="9 18 15 12 9 6"></polyline>
                    </svg>
                </a>
            </div>

            <div class="benefit-card-footer">
                <a href="{{ url_for('benefits.benefit_redirect', slug=benefit.slug) }}" class="benefit-cta" target="_blank" rel="noopener">
                    Wypróbuj za darmo
                    <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
                        <path d="M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6"></path>
                        <polyline points="15 3 21 3 21 9"></polyline>
                        <line x1="10" y1="14" x2="21" y2="3"></line>
                    </svg>
                </a>
            </div>
        </div>
        {% endfor %}
    </div>
    {% else %}
    <div class="empty-state">
        <div class="empty-state-icon">
            <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round">
                <path d="M12 2L2 7l10 5 10-5-10-5z"></path>
                <path d="M2 17l10 5 10-5"></path>
                <path d="M2 12l10 5 10-5"></path>
            </svg>
        </div>
        <h3>Brak dostępnych ofert</h3>
        <p>Wkrótce pojawią się tutaj ekskluzywne korzyści dla członków Izby.</p>
    </div>
    {% endif %}
</div>
{% endblock %}
