{% extends "base.html" %}

{% block title %}Prywatność - Moje konto - Norda Biznes Partner{% endblock %}

{% block extra_css %}
<style>
    .konto-layout {
        display: grid;
        grid-template-columns: 240px 1fr;
        gap: var(--spacing-xl);
        max-width: 1000px;
        margin: 0 auto;
    }

    .konto-sidebar {
        background: var(--surface);
        border-radius: var(--radius-lg);
        padding: var(--spacing-lg);
        box-shadow: var(--shadow);
        height: fit-content;
        position: sticky;
        top: 100px;
    }

    .konto-sidebar-header {
        display: flex;
        align-items: center;
        gap: var(--spacing-md);
        padding-bottom: var(--spacing-md);
        margin-bottom: var(--spacing-md);
        border-bottom: 1px solid var(--border);
    }

    .konto-avatar {
        width: 48px;
        height: 48px;
        border-radius: 50%;
        background: linear-gradient(135deg, var(--primary), #1e40af);
        color: white;
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: 20px;
        font-weight: 600;
    }

    .konto-sidebar-name {
        font-weight: 600;
        color: var(--text-primary);
        font-size: var(--font-size-sm);
    }

    .konto-sidebar-email {
        font-size: 11px;
        color: var(--text-secondary);
        word-break: break-all;
    }

    .konto-nav {
        display: flex;
        flex-direction: column;
        gap: var(--spacing-xs);
    }

    .konto-nav a {
        display: flex;
        align-items: center;
        gap: var(--spacing-sm);
        padding: var(--spacing-sm) var(--spacing-md);
        border-radius: var(--radius);
        text-decoration: none;
        color: var(--text-secondary);
        font-size: var(--font-size-sm);
        transition: all 0.2s;
    }

    .konto-nav a:hover {
        background: var(--background);
        color: var(--text-primary);
    }

    .konto-nav a.active {
        background: var(--primary);
        color: white;
    }

    .konto-nav a svg {
        width: 18px;
        height: 18px;
        flex-shrink: 0;
    }

    .konto-content {
        background: var(--surface);
        border-radius: var(--radius-lg);
        padding: var(--spacing-xl);
        box-shadow: var(--shadow);
    }

    .konto-header {
        margin-bottom: var(--spacing-xl);
        padding-bottom: var(--spacing-lg);
        border-bottom: 1px solid var(--border);
    }

    .konto-header h1 {
        font-size: var(--font-size-2xl);
        color: var(--text-primary);
        margin-bottom: var(--spacing-xs);
    }

    .konto-header p {
        color: var(--text-secondary);
    }

    .settings-card {
        background: var(--background);
        border-radius: var(--radius);
        padding: var(--spacing-lg);
        margin-bottom: var(--spacing-lg);
    }

    .settings-card h2 {
        font-size: var(--font-size-lg);
        color: var(--text-primary);
        margin-bottom: var(--spacing-md);
        padding-bottom: var(--spacing-sm);
        border-bottom: 1px solid var(--border);
    }

    .setting-item {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: var(--spacing-md) 0;
        border-bottom: 1px solid var(--border);
    }

    .setting-item:last-child {
        border-bottom: none;
    }

    .setting-info {
        flex: 1;
    }

    .setting-label {
        font-weight: 500;
        color: var(--text-primary);
        margin-bottom: var(--spacing-xs);
    }

    .setting-description {
        font-size: var(--font-size-sm);
        color: var(--text-secondary);
    }

    .toggle-switch {
        position: relative;
        width: 50px;
        height: 26px;
        flex-shrink: 0;
        margin-left: var(--spacing-md);
    }

    .toggle-switch input {
        opacity: 0;
        width: 0;
        height: 0;
    }

    .toggle-slider {
        position: absolute;
        cursor: pointer;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background-color: #ccc;
        transition: 0.3s;
        border-radius: 26px;
    }

    .toggle-slider:before {
        position: absolute;
        content: "";
        height: 20px;
        width: 20px;
        left: 3px;
        bottom: 3px;
        background-color: white;
        transition: 0.3s;
        border-radius: 50%;
    }

    input:checked + .toggle-slider {
        background-color: var(--success);
    }

    input:checked + .toggle-slider:before {
        transform: translateX(24px);
    }

    .form-actions {
        padding-top: var(--spacing-lg);
    }

    @media (max-width: 768px) {
        .konto-layout {
            grid-template-columns: 1fr;
        }

        .konto-sidebar {
            position: static;
        }

        .konto-nav {
            flex-direction: row;
            flex-wrap: wrap;
        }

        .setting-item {
            flex-direction: column;
            align-items: flex-start;
            gap: var(--spacing-sm);
        }

        .toggle-switch {
            margin-left: 0;
        }
    }
</style>
{% endblock %}

{% block content %}
<div class="konto-layout">
    <aside class="konto-sidebar">
        <div class="konto-sidebar-header">
            <div class="konto-avatar">
                {{ (current_user.name or current_user.email)[0].upper() }}
            </div>
            <div>
                <div class="konto-sidebar-name">{{ current_user.name or 'Użytkownik' }}</div>
                <div class="konto-sidebar-email">{{ current_user.email }}</div>
            </div>
        </div>
        <nav class="konto-nav">
            <a href="{{ url_for('konto_dane') }}">
                <svg fill="none" stroke="currentColor" stroke-width="2" viewBox="0 0 24 24">
                    <path d="M16 7a4 4 0 11-8 0 4 4 0 018 0zM12 14a7 7 0 00-7 7h14a7 7 0 00-7-7z"/>
                </svg>
                Twoje dane
            </a>
            <a href="{{ url_for('konto_prywatnosc') }}" class="active">
                <svg fill="none" stroke="currentColor" stroke-width="2" viewBox="0 0 24 24">
                    <path d="M12 15v2m-6 4h12a2 2 0 002-2v-6a2 2 0 00-2-2H6a2 2 0 00-2 2v6a2 2 0 002 2zm10-10V7a4 4 0 00-8 0v4h8z"/>
                </svg>
                Prywatność
            </a>
            <a href="{{ url_for('konto_bezpieczenstwo') }}">
                <svg fill="none" stroke="currentColor" stroke-width="2" viewBox="0 0 24 24">
                    <path d="M9 12l2 2 4-4m5.618-4.016A11.955 11.955 0 0112 2.944a11.955 11.955 0 01-8.618 3.04A12.02 12.02 0 003 9c0 5.591 3.824 10.29 9 11.622 5.176-1.332 9-6.03 9-11.622 0-1.042-.133-2.052-.382-3.016z"/>
                </svg>
                Bezpieczeństwo
            </a>
            <a href="{{ url_for('konto_blokady') }}">
                <svg fill="none" stroke="currentColor" stroke-width="2" viewBox="0 0 24 24">
                    <path d="M18.364 18.364A9 9 0 005.636 5.636m12.728 12.728A9 9 0 015.636 5.636m12.728 12.728L5.636 5.636"/>
                </svg>
                Blokady
            </a>
        </nav>
    </aside>

    <main class="konto-content">
        <div class="konto-header">
            <h1>Prywatność</h1>
            <p>Kontroluj, które Twoje dane są widoczne dla innych użytkowników</p>
        </div>

        <form method="POST" action="{{ url_for('konto_prywatnosc') }}">
            <input type="hidden" name="csrf_token" value="{{ csrf_token() }}">

            <div class="settings-card">
                <h2>Widoczność danych kontaktowych</h2>

                <div class="setting-item">
                    <div class="setting-info">
                        <div class="setting-label">Pokaż numer telefonu</div>
                        <div class="setting-description">
                            Twój numer telefonu ({{ user.phone or 'nie podano' }}) będzie widoczny dla innych członków
                        </div>
                    </div>
                    <label class="toggle-switch">
                        <input type="checkbox" name="show_phone" {% if show_phone %}checked{% endif %}>
                        <span class="toggle-slider"></span>
                    </label>
                </div>

                <div class="setting-item">
                    <div class="setting-info">
                        <div class="setting-label">Pokaż adres email</div>
                        <div class="setting-description">
                            Twój adres email ({{ user.email }}) będzie widoczny dla innych członków
                        </div>
                    </div>
                    <label class="toggle-switch">
                        <input type="checkbox" name="show_email" {% if show_email %}checked{% endif %}>
                        <span class="toggle-slider"></span>
                    </label>
                </div>
            </div>

            <div class="settings-card">
                <h2>Preferowane kanały kontaktu</h2>

                <div class="setting-item">
                    <div class="setting-info">
                        <div class="setting-label">Email</div>
                        <div class="setting-description">Preferuję kontakt przez email</div>
                    </div>
                    <label class="toggle-switch">
                        <input type="checkbox" name="prefer_email" {% if user.contact_prefer_email != False %}checked{% endif %}>
                        <span class="toggle-slider"></span>
                    </label>
                </div>

                <div class="setting-item">
                    <div class="setting-info">
                        <div class="setting-label">Telefon</div>
                        <div class="setting-description">Preferuję kontakt telefoniczny</div>
                    </div>
                    <label class="toggle-switch">
                        <input type="checkbox" name="prefer_phone" {% if user.contact_prefer_phone != False %}checked{% endif %}>
                        <span class="toggle-slider"></span>
                    </label>
                </div>

                <div class="setting-item">
                    <div class="setting-info">
                        <div class="setting-label">Wiadomości w portalu</div>
                        <div class="setting-description">Preferuję kontakt przez system wiadomości w portalu</div>
                    </div>
                    <label class="toggle-switch">
                        <input type="checkbox" name="prefer_portal" {% if user.contact_prefer_portal != False %}checked{% endif %}>
                        <span class="toggle-slider"></span>
                    </label>
                </div>
            </div>

            <div class="form-actions">
                <button type="submit" class="btn btn-primary">Zapisz ustawienia</button>
            </div>
        </form>
    </main>
</div>
{% endblock %}
