<?php
include __DIR__ . '/../app/sidebar.php';
// Demo kullanıcı bilgileri
$demo_user = [
    'id' => 123,
    'name' => 'Selim Doğan',
    'email' => 'selim@example.com',
    'phone' => '+90 555 123 4567',
    'avatar' => 'https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcTMsfi9M24wQshij4U1U7hJJNMrtlzHqSUF3g&s',
    'created_at' => '2023-01-15',
    'iban' => 'TR00 0000 0000 0000 0000 0000 00',
    'bank_name' => 'Ziraat Bankası',
    'account_holder' => 'Selim Doğan'
];

// Demo ayarlar
$demo_settings = [
    'notification_email' => true,
    'notification_sms' => false,
    'theme' => 'light',
    'language' => 'tr'
];

// Form işlemleri
$message = '';
$error = '';

if ($_SERVER['REQUEST_METHOD'] === 'POST') {
    if (isset($_POST['update_profile'])) {
        $demo_user['name'] = $_POST['name'] ?? $demo_user['name'];
        $demo_user['email'] = $_POST['email'] ?? $demo_user['email'];
        $demo_user['phone'] = $_POST['phone'] ?? $demo_user['phone'];
        $message = 'Profil bilgileriniz başarıyla güncellendi.';
    }
    elseif (isset($_POST['change_password'])) {
        $current = $_POST['current_password'] ?? '';
        $new = $_POST['new_password'] ?? '';
        $confirm = $_POST['confirm_password'] ?? '';
        
        if ($new === $confirm && strlen($new) >= 6) {
            $message = 'Şifreniz başarıyla değiştirildi.';
        } else {
            $error = 'Şifreler uyuşmuyor veya çok kısa.';
        }
    }
    elseif (isset($_POST['update_notifications'])) {
        $demo_settings['notification_email'] = isset($_POST['notification_email']);
        $demo_settings['notification_sms'] = isset($_POST['notification_sms']);
        $message = 'Bildirim ayarlarınız güncellendi.';
    }
    elseif (isset($_POST['update_preferences'])) {
        $demo_settings['theme'] = $_POST['theme'] ?? 'light';
        $demo_settings['language'] = $_POST['language'] ?? 'tr';
        $message = 'Tercihleriniz güncellendi.';
    }
    elseif (isset($_POST['update_bank'])) {
        $demo_user['iban'] = $_POST['iban'] ?? $demo_user['iban'];
        $demo_user['bank_name'] = $_POST['bank_name'] ?? $demo_user['bank_name'];
        $demo_user['account_holder'] = $_POST['account_holder'] ?? $demo_user['account_holder'];
        $message = 'Banka bilgileriniz güncellendi.';
    }
    elseif (isset($_POST['delete_account'])) {
        if (($_POST['confirm_delete'] ?? '') === 'SİL') {
            $message = 'DEMO: Hesap silme işlemi başlatıldı (gerçek uygulamada silinirdi)';
        } else {
            $error = 'Hesap silmek için "SİL" yazmanız gerekiyor.';
        }
    }
}
?>

<!DOCTYPE html>
<html lang="tr">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
    <title>Hesap Ayarları</title>
    <script src="https://unpkg.com/lucide@latest"></script>
    
    <style>
        :root {
            --white: #ffffff;
            --black: #000000;
            --gray-50: #fafafa;
            --gray-100: #f5f5f5;
            --gray-200: #e5e5e5;
            --gray-300: #d4d4d4;
            --gray-400: #a3a3a3;
            --gray-500: #737373;
            --gray-600: #525252;
            --gray-700: #404040;
            --gray-800: #262626;
            --gray-900: #171717;
            --red-50: #fef2f2;
            --red-500: #ef4444;
            --green-50: #f0fdf4;
            --green-500: #10b981;
            --blue-50: #eff6ff;
            --blue-500: #3b82f6;
            --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
            --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
            --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
        }
        
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
            -webkit-tap-highlight-color: transparent;
        }
        
        html {
            font-size: 16px;
            -webkit-text-size-adjust: 100%;
        }
        
        body {
            font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, system-ui, sans-serif;
            background: var(--white);
            color: var(--black);
            line-height: 1.5;
            overflow-x: hidden;
            min-height: 100vh;
        }
        
        /* Container */
        .container {
            width: 100%;
            max-width: 1200px;
            margin: 0 auto;
            padding: 0;
        }
        
        /* Header */
        .header {
            background: var(--white);
            padding: 1.5rem 1rem;
            border-bottom: 1px solid var(--gray-200);
            position: sticky;
            top: 0;
            z-index: 50;
            backdrop-filter: blur(8px);
            -webkit-backdrop-filter: blur(8px);
        }
        
        .header h1 {
            font-size: 1.75rem;
            font-weight: 700;
            color: var(--black);
            margin-bottom: 0.25rem;
        }
        
        .header p {
            font-size: 0.875rem;
            color: var(--gray-600);
        }
        
        /* Main Layout */
        .main-layout {
            display: flex;
            min-height: calc(100vh - 92px);
        }
        
        @media (max-width: 768px) {
            .main-layout {
                flex-direction: column;
            }
        }
        
        /* Sidebar */
        .sidebar {
            width: 280px;
            background: var(--white);
            border-right: 1px solid var(--gray-200);
            padding: 1.5rem;
            position: sticky;
            top: 92px;
            height: calc(100vh - 92px);
            overflow-y: auto;
        }
        
        @media (max-width: 768px) {
            .sidebar {
                display: none;
            }
        }
        
        /* User Profile */
        .user-profile {
            text-align: center;
            padding-bottom: 1.5rem;
            margin-bottom: 1.5rem;
            border-bottom: 1px solid var(--gray-200);
        }
        
        .user-avatar {
            width: 5rem;
            height: 5rem;
            border-radius: 50%;
            margin: 0 auto 1rem;
            border: 2px solid var(--black);
            overflow: hidden;
            background: var(--gray-100);
        }
        
        .user-avatar img {
            width: 100%;
            height: 100%;
            object-fit: cover;
        }
        
        .user-name {
            font-size: 1.125rem;
            font-weight: 600;
            color: var(--black);
            margin-bottom: 0.25rem;
        }
        
        .user-email {
            font-size: 0.875rem;
            color: var(--gray-600);
        }
        
        /* Navigation */
        .nav-list {
            list-style: none;
        }
        
        .nav-item {
            margin-bottom: 0.5rem;
        }
        
        .nav-link {
            display: flex;
            align-items: center;
            padding: 0.75rem 1rem;
            color: var(--gray-700);
            text-decoration: none;
            border-radius: 0.5rem;
            transition: all 0.2s;
            background: var(--white);
        }
        
        .nav-link:hover {
            background: var(--gray-100);
            color: var(--black);
        }
        
        .nav-link.active {
            background: var(--black);
            color: var(--white);
        }
        
        .nav-icon {
            width: 1.25rem;
            height: 1.25rem;
            margin-right: 0.75rem;
        }
        
        /* Mobile Navigation */
        .mobile-nav {
            display: none;
            background: var(--white);
            border-bottom: 1px solid var(--gray-200);
            padding: 0.75rem 1rem;
            position: sticky;
            top: 92px;
            z-index: 40;
            overflow-x: auto;
            -webkit-overflow-scrolling: touch;
            scrollbar-width: none;
        }
        
        .mobile-nav::-webkit-scrollbar {
            display: none;
        }
        
        @media (max-width: 768px) {
            .mobile-nav {
                display: block;
            }
        }
        
        .mobile-nav-items {
            display: flex;
            gap: 0.5rem;
            min-width: max-content;
        }
        
        .mobile-nav-item {
            padding: 0.5rem 0.75rem;
            font-size: 0.875rem;
            color: var(--gray-600);
            text-decoration: none;
            white-space: nowrap;
            border-radius: 0.5rem;
            transition: all 0.2s;
            background: var(--white);
        }
        
        .mobile-nav-item:hover,
        .mobile-nav-item.active {
            background: var(--gray-100);
            color: var(--black);
        }
        
        /* Main Content */
        .main-content {
            flex: 1;
            padding: 2rem;
            overflow-y: auto;
            background: var(--white);
        }
        
        @media (max-width: 768px) {
            .main-content {
                padding: 1.5rem 1rem;
                min-height: calc(100vh - 140px);
            }
        }
        
        @media (max-width: 480px) {
            .main-content {
                padding: 1rem;
            }
        }
        
        /* Tab Content */
        .tab-content {
            display: none;
            animation: fadeIn 0.3s ease;
        }
        
        .tab-content.active {
            display: block;
        }
        
        @keyframes fadeIn {
            from { opacity: 0; transform: translateY(10px); }
            to { opacity: 1; transform: translateY(0); }
        }
        
        /* Section */
        .section {
            max-width: 800px;
            margin-bottom: 3rem;
        }
        
        .section-title {
            font-size: 1.5rem;
            font-weight: 700;
            color: var(--black);
            margin-bottom: 0.5rem;
        }
        
        .section-description {
            font-size: 0.875rem;
            color: var(--gray-600);
            margin-bottom: 2rem;
        }
        
        /* Form */
        .form {
            display: flex;
            flex-direction: column;
            gap: 2rem;
        }
        
        .form-grid {
            display: grid;
            gap: 1.5rem;
        }
        
        @media (min-width: 640px) {
            .form-grid {
                grid-template-columns: repeat(2, 1fr);
            }
        }
        
        .form-group {
            display: flex;
            flex-direction: column;
            gap: 0.5rem;
        }
        
        .form-label {
            font-size: 0.875rem;
            font-weight: 500;
            color: var(--black);
        }
        
        .form-control {
            width: 100%;
            padding: 0.75rem 1rem;
            font-size: 0.875rem;
            color: var(--black);
            background: var(--white);
            border: 1px solid var(--gray-300);
            border-radius: 0.5rem;
            transition: all 0.2s;
        }
        
        .form-control:focus {
            outline: none;
            border-color: var(--black);
            box-shadow: 0 0 0 3px rgba(0, 0, 0, 0.05);
        }
        
        .form-control::placeholder {
            color: var(--gray-400);
        }
        
        /* File Upload */
        .file-upload {
            display: inline-block;
            position: relative;
            overflow: hidden;
        }
        
        .file-upload input[type="file"] {
            position: absolute;
            left: 0;
            top: 0;
            opacity: 0;
            width: 100%;
            height: 100%;
            cursor: pointer;
        }
        
        .file-upload-btn {
            display: inline-flex;
            align-items: center;
            padding: 0.625rem 1rem;
            background: var(--white);
            border: 1px solid var(--gray-300);
            border-radius: 0.5rem;
            font-size: 0.875rem;
            font-weight: 500;
            color: var(--black);
            cursor: pointer;
            transition: all 0.2s;
        }
        
        .file-upload-btn:hover {
            background: var(--gray-100);
            border-color: var(--gray-400);
        }
        
        /* Switch */
        .switch {
            position: relative;
            display: inline-block;
            width: 3rem;
            height: 1.5rem;
        }
        
        .switch input {
            opacity: 0;
            width: 0;
            height: 0;
        }
        
        .slider {
            position: absolute;
            cursor: pointer;
            top: 0;
            left: 0;
            right: 0;
            bottom: 0;
            background: var(--gray-300);
            transition: .2s;
            border-radius: 1.5rem;
            border: 1px solid var(--gray-400);
        }
        
        .slider:before {
            position: absolute;
            content: "";
            height: 1.125rem;
            width: 1.125rem;
            left: 0.1875rem;
            bottom: 0.1875rem;
            background: var(--white);
            transition: .2s;
            border-radius: 50%;
            box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
        }
        
        input:checked + .slider {
            background: var(--black);
            border-color: var(--black);
        }
        
        input:checked + .slider:before {
            transform: translateX(1.5rem);
        }
        
        /* Radio Group */
        .radio-group {
            display: grid;
            grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
            gap: 1rem;
            margin-top: 0.5rem;
        }
        
        @media (max-width: 640px) {
            .radio-group {
                grid-template-columns: 1fr;
            }
        }
        
        .radio-option {
            padding: 1rem;
            border: 1px solid var(--gray-300);
            border-radius: 0.5rem;
            cursor: pointer;
            transition: all 0.2s;
            background: var(--white);
        }
        
        .radio-option:hover {
            border-color: var(--gray-400);
            background: var(--gray-50);
        }
        
        .radio-option.active {
            border-color: var(--black);
            background: var(--gray-50);
        }
        
        .radio-option input[type="radio"] {
            margin-right: 0.5rem;
        }
        
        .radio-title {
            font-weight: 500;
            color: var(--black);
            margin-bottom: 0.25rem;
        }
        
        .radio-description {
            font-size: 0.75rem;
            color: var(--gray-600);
        }
        
        /* Buttons */
        .btn {
            display: inline-flex;
            align-items: center;
            justify-content: center;
            gap: 0.5rem;
            padding: 0.75rem 1.5rem;
            font-size: 0.875rem;
            font-weight: 500;
            border: 1px solid transparent;
            border-radius: 0.5rem;
            cursor: pointer;
            transition: all 0.2s;
            text-decoration: none;
            background: var(--white);
        }
        
        .btn-primary {
            background: var(--black);
            color: var(--white);
            border-color: var(--black);
        }
        
        .btn-primary:hover {
            background: var(--gray-800);
            border-color: var(--gray-800);
        }
        
        .btn-secondary {
            background: var(--white);
            color: var(--black);
            border-color: var(--gray-300);
        }
        
        .btn-secondary:hover {
            background: var(--gray-100);
            border-color: var(--gray-400);
        }
        
        .btn-danger {
            background: var(--white);
            color: var(--red-500);
            border-color: var(--red-500);
        }
        
        .btn-danger:hover {
            background: var(--red-50);
            border-color: var(--red-500);
        }
        
        .btn-icon {
            width: 1rem;
            height: 1rem;
        }
        
        /* Button Group */
        .button-group {
            display: flex;
            gap: 1rem;
            flex-wrap: wrap;
        }
        
        @media (max-width: 640px) {
            .button-group {
                flex-direction: column;
            }
            
            .button-group .btn {
                width: 100%;
            }
        }
        
        /* Messages */
        .alert {
            padding: 1rem 1.25rem;
            border-radius: 0.5rem;
            margin-bottom: 2rem;
            border: 1px solid transparent;
            display: flex;
            align-items: center;
            gap: 0.75rem;
            background: var(--white);
        }
        
        .alert-success {
            background: var(--green-50);
            border-color: #bbf7d0;
            color: #166534;
        }
        
        .alert-error {
            background: var(--red-50);
            border-color: #fecaca;
            color: #991b1b;
        }
        
        /* Danger Zone */
        .danger-zone {
            background: var(--red-50);
            border: 1px solid #fecaca;
            border-radius: 0.5rem;
            padding: 1.5rem;
            margin-top: 3rem;
        }
        
        .danger-zone-title {
            font-size: 1.125rem;
            font-weight: 600;
            color: var(--red-500);
            margin-bottom: 0.75rem;
            display: flex;
            align-items: center;
            gap: 0.5rem;
        }
        
        .danger-zone-description {
            font-size: 0.875rem;
            color: var(--gray-600);
            margin-bottom: 1rem;
        }
        
        /* Bank Info Section */
        .bank-info {
            background: var(--blue-50);
            border: 1px solid #bfdbfe;
            border-radius: 0.5rem;
            padding: 1.5rem;
            margin-top: 2rem;
        }
        
        .bank-info-title {
            font-size: 1.125rem;
            font-weight: 600;
            color: var(--blue-500);
            margin-bottom: 1rem;
            display: flex;
            align-items: center;
            gap: 0.5rem;
        }
        
        /* Card */
        .card {
            background: var(--white);
            border: 1px solid var(--gray-200);
            border-radius: 0.75rem;
            padding: 1.5rem;
            margin-bottom: 1.5rem;
            box-shadow: var(--shadow-sm);
        }
        
        /* Touch Device Optimizations */
        @media (hover: none) and (pointer: coarse) {
            .btn,
            .nav-link,
            .mobile-nav-item {
                min-height: 44px;
            }
            
            .form-control {
                font-size: 1rem;
                padding: 1rem;
            }
            
            .switch {
                transform: scale(1.1);
            }
        }
        
        /* Scrollbar Styling */
        ::-webkit-scrollbar {
            width: 6px;
            height: 6px;
        }
        
        ::-webkit-scrollbar-track {
            background: var(--gray-100);
        }
        
        ::-webkit-scrollbar-thumb {
            background: var(--gray-300);
            border-radius: 3px;
        }
        
        ::-webkit-scrollbar-thumb:hover {
            background: var(--gray-400);
        }
    </style>
</head>
<body>
    <div class="container">
        <!-- Header -->
        <div class="header">
            <h1>Hesap Ayarları</h1>
            <p>Hesap bilgilerinizi ve tercihlerinizi yönetin</p>
        </div>
        
        <!-- Messages -->
        <?php if ($message): ?>
            <div class="alert alert-success">
                <i data-lucide="check-circle" class="w-5 h-5"></i>
                <span><?php echo htmlspecialchars($message); ?></span>
            </div>
        <?php endif; ?>
        
        <?php if ($error): ?>
            <div class="alert alert-error">
                <i data-lucide="alert-circle" class="w-5 h-5"></i>
                <span><?php echo htmlspecialchars($error); ?></span>
            </div>
        <?php endif; ?>
        
        <!-- Mobile Navigation -->
        <nav class="mobile-nav">
            <div class="mobile-nav-items">
                <a href="#profile" class="mobile-nav-item active" data-tab="profile">
                    Profil
                </a>
                <a href="#password" class="mobile-nav-item" data-tab="password">
                    Şifre
                </a>
                <a href="#bank" class="mobile-nav-item" data-tab="bank">
                    Banka
                </a>
                <a href="#notifications" class="mobile-nav-item" data-tab="notifications">
                    Bildirimler
                </a>
                <a href="#preferences" class="mobile-nav-item" data-tab="preferences">
                    Tercihler
                </a>
                <a href="#security" class="mobile-nav-item" data-tab="security">
                    Güvenlik
                </a>
            </div>
        </nav>
        
        <!-- Main Layout -->
        <div class="main-layout">
            <!-- Desktop Sidebar -->
            <aside class="sidebar">
                <!-- User Profile -->
                <div class="user-profile">
                    <div class="user-avatar">
                        <img src="<?php echo htmlspecialchars($demo_user['avatar']); ?>" alt="Profil">
                    </div>
                    <div class="user-name"><?php echo htmlspecialchars($demo_user['name']); ?></div>
                    <div class="user-email"><?php echo htmlspecialchars($demo_user['email']); ?></div>
                </div>
                
                <!-- Desktop Navigation -->
                <nav class="desktop-nav">
                    <ul class="nav-list">
                        <li class="nav-item">
                            <a href="#profile" class="nav-link active" data-tab="profile">
                                <i data-lucide="user" class="nav-icon"></i>
                                <span>Profil Bilgileri</span>
                            </a>
                        </li>
                        <li class="nav-item">
                            <a href="#password" class="nav-link" data-tab="password">
                                <i data-lucide="lock" class="nav-icon"></i>
                                <span>Şifre Değiştir</span>
                            </a>
                        </li>
                        <li class="nav-item">
                            <a href="#bank" class="nav-link" data-tab="bank">
                                <i data-lucide="credit-card" class="nav-icon"></i>
                                <span>Banka Bilgileri</span>
                            </a>
                        </li>
                        <li class="nav-item">
                            <a href="#notifications" class="nav-link" data-tab="notifications">
                                <i data-lucide="bell" class="nav-icon"></i>
                                <span>Bildirim Ayarları</span>
                            </a>
                        </li>
                        <li class="nav-item">
                            <a href="#preferences" class="nav-link" data-tab="preferences">
                                <i data-lucide="settings" class="nav-icon"></i>
                                <span>Tercihler</span>
                            </a>
                        </li>
                        <li class="nav-item">
                            <a href="#security" class="nav-link" data-tab="security">
                                <i data-lucide="shield" class="nav-icon"></i>
                                <span>Güvenlik</span>
                            </a>
                        </li>
                    </ul>
                </nav>
            </aside>
            
            <!-- Main Content -->
            <main class="main-content">
                <!-- Profile Tab -->
                <div id="profile" class="tab-content active">
                    <div class="section">
                        <h2 class="section-title">Profil Bilgileri</h2>
                        <p class="section-description">Kişisel bilgilerinizi güncelleyin</p>
                        
                        <div class="card">
                            <form method="POST" class="form">
                                <!-- Avatar Section -->
                                <div class="form-group">
                                    <label class="form-label">Profil Fotoğrafı</label>
                                    <div style="display: flex; align-items: center; gap: 1.5rem; flex-wrap: wrap;">
                                        <div class="user-avatar" style="width: 80px; height: 80px;">
                                            <img src="<?php echo htmlspecialchars($demo_user['avatar']); ?>" alt="Profil">
                                        </div>
                                        <div>
                                            <label class="file-upload">
                                                <input type="file" accept="image/*">
                                                <span class="file-upload-btn">
                                                    <i data-lucide="upload" class="w-4 h-4 mr-2"></i>
                                                    Fotoğraf Seç
                                                </span>
                                            </label>
                                            <div style="font-size: 0.75rem; color: var(--gray-600); margin-top: 0.5rem;">
                                                JPG, PNG veya GIF. Maksimum 5MB.
                                            </div>
                                        </div>
                                    </div>
                                </div>
                                
                                <!-- Form Fields -->
                                <div class="form-grid">
                                    <div class="form-group">
                                        <label class="form-label">Ad Soyad</label>
                                        <input type="text" name="name" class="form-control" 
                                               value="<?php echo htmlspecialchars($demo_user['name']); ?>" 
                                               placeholder="Adınızı girin">
                                    </div>
                                    
                                    <div class="form-group">
                                        <label class="form-label">Email Adresi</label>
                                        <input type="email" name="email" class="form-control" 
                                               value="<?php echo htmlspecialchars($demo_user['email']); ?>" 
                                               placeholder="email@example.com">
                                    </div>
                                    
                                    <div class="form-group">
                                        <label class="form-label">Telefon Numarası</label>
                                        <input type="tel" name="phone" class="form-control" 
                                               value="<?php echo htmlspecialchars($demo_user['phone']); ?>" 
                                               placeholder="+90 555 123 4567">
                                    </div>
                                </div>
                                
                                <div class="button-group">
                                    <button type="submit" name="update_profile" class="btn btn-primary">
                                        <i data-lucide="save" class="btn-icon"></i>
                                        Kaydet
                                    </button>
                                    <button type="button" class="btn btn-secondary" onclick="resetForm(this.form)">
                                        <i data-lucide="refresh-ccw" class="btn-icon"></i>
                                        Sıfırla
                                    </button>
                                </div>
                            </form>
                        </div>
                    </div>
                </div>
                
                <!-- Password Tab -->
                <div id="password" class="tab-content">
                    <div class="section">
                        <h2 class="section-title">Şifre Değiştir</h2>
                        <p class="section-description">Hesap güvenliğiniz için şifrenizi güncelleyin</p>
                        
                        <div class="card">
                            <form method="POST" class="form">
                                <div class="form-grid">
                                    <div class="form-group">
                                        <label class="form-label">Mevcut Şifre</label>
                                        <input type="password" name="current_password" class="form-control" 
                                               placeholder="Mevcut şifrenizi girin" required>
                                    </div>
                                    
                                    <div class="form-group">
                                        <label class="form-label">Yeni Şifre</label>
                                        <input type="password" name="new_password" class="form-control" 
                                               placeholder="En az 6 karakter" required minlength="6">
                                        <div style="font-size: 0.75rem; color: var(--gray-600); margin-top: 0.25rem;">
                                            Şifreniz en az 6 karakter uzunluğunda olmalıdır.
                                        </div>
                                    </div>
                                    
                                    <div class="form-group">
                                        <label class="form-label">Yeni Şifre (Tekrar)</label>
                                        <input type="password" name="confirm_password" class="form-control" 
                                               placeholder="Yeni şifrenizi tekrar girin" required minlength="6">
                                    </div>
                                </div>
                                
                                <div class="button-group">
                                    <button type="submit" name="change_password" class="btn btn-primary">
                                        <i data-lucide="lock" class="btn-icon"></i>
                                        Şifreyi Değiştir
                                    </button>
                                </div>
                            </form>
                        </div>
                    </div>
                </div>
                
                <!-- Bank Information Tab -->
                <div id="bank" class="tab-content">
                    <div class="section">
                        <h2 class="section-title">Banka Bilgileri</h2>
                        <p class="section-description">Ödeme almak için banka bilgilerinizi girin</p>
                        
                        <div class="card">
                            <form method="POST" class="form">
                                <div class="form-grid">
                                    <div class="form-group">
                                        <label class="form-label">Banka Adı</label>
                                        <input type="text" name="bank_name" class="form-control" 
                                               value="<?php echo htmlspecialchars($demo_user['bank_name']); ?>" 
                                               placeholder="Örn: Ziraat Bankası">
                                    </div>
                                    
                                    <div class="form-group">
                                        <label class="form-label">IBAN Numarası</label>
                                        <input type="text" name="iban" class="form-control" 
                                               value="<?php echo htmlspecialchars($demo_user['iban']); ?>" 
                                               placeholder="TR00 0000 0000 0000 0000 0000 00"
                                               pattern="[A-Z]{2}[0-9]{2}[A-Z0-9]{1,30}"
                                               maxlength="34">
                                        <div style="font-size: 0.75rem; color: var(--gray-600); margin-top: 0.25rem;">
                                            IBAN numaranızı boşluksuz ve büyük harflerle girin.
                                        </div>
                                    </div>
                                    
                                    <div class="form-group">
                                        <label class="form-label">Hesap Sahibi Adı</label>
                                        <input type="text" name="account_holder" class="form-control" 
                                               value="<?php echo htmlspecialchars($demo_user['account_holder']); ?>" 
                                               placeholder="Hesap sahibinin tam adı">
                                    </div>
                                </div>
                                
                                <div class="button-group">
                                    <button type="submit" name="update_bank" class="btn btn-primary">
                                        <i data-lucide="save" class="btn-icon"></i>
                                        Banka Bilgilerini Kaydet
                                    </button>
                                </div>
                            </form>
                        </div>
                        
                        <!-- IBAN Format Info -->
                        <div class="bank-info">
                            <h3 class="bank-info-title">
                                <i data-lucide="info" class="w-5 h-5"></i>
                                IBAN Formatı Hakkında
                            </h3>
                            <div style="font-size: 0.875rem; color: var(--gray-700); line-height: 1.6;">
                                <p style="margin-bottom: 0.5rem;"><strong>Doğru IBAN formatı:</strong> TR00 0000 0000 0000 0000 0000 00</p>
                                <ul style="padding-left: 1.25rem; margin-bottom: 0;">
                                    <li>İlk 2 harf ülke kodu (TR)</li>
                                    <li>Sonraki 2 rakam kontrol rakamları</li>
                                    <li>26 hanelik hesap numarası</li>
                                    <li>Toplam 28 karakter</li>
                                </ul>
                            </div>
                        </div>
                    </div>
                </div>
                
                <!-- Notifications Tab -->
                <div id="notifications" class="tab-content">
                    <div class="section">
                        <h2 class="section-title">Bildirim Ayarları</h2>
                        <p class="section-description">Hangi bildirimleri almak istediğinizi seçin</p>
                        
                        <div class="card">
                            <form method="POST" class="form">
                                <div style="display: flex; flex-direction: column; gap: 1.5rem;">
                                    <div style="display: flex; justify-content: space-between; align-items: flex-start;">
                                        <div style="flex: 1; margin-right: 1rem;">
                                            <div style="font-weight: 500; color: var(--black); margin-bottom: 0.25rem;">
                                                Email Bildirimleri
                                            </div>
                                            <div style="font-size: 0.875rem; color: var(--gray-600);">
                                                Yeni mesajlar, siparişler ve sistem güncellemeleri
                                            </div>
                                        </div>
                                        <label class="switch">
                                            <input type="checkbox" name="notification_email" 
                                                   <?php echo $demo_settings['notification_email'] ? 'checked' : ''; ?>>
                                            <span class="slider"></span>
                                        </label>
                                    </div>
                                    
                                    <div style="display: flex; justify-content: space-between; align-items: flex-start;">
                                        <div style="flex: 1; margin-right: 1rem;">
                                            <div style="font-weight: 500; color: var(--black); margin-bottom: 0.25rem;">
                                                SMS Bildirimleri
                                            </div>
                                            <div style="font-size: 0.875rem; color: var(--gray-600);">
                                                Önemli güvenlik bildirimleri ve acil durumlar
                                            </div>
                                        </div>
                                        <label class="switch">
                                            <input type="checkbox" name="notification_sms" 
                                                   <?php echo $demo_settings['notification_sms'] ? 'checked' : ''; ?>>
                                            <span class="slider"></span>
                                        </label>
                                    </div>
                                </div>
                                
                                <div class="button-group" style="margin-top: 1.5rem;">
                                    <button type="submit" name="update_notifications" class="btn btn-primary">
                                        <i data-lucide="save" class="btn-icon"></i>
                                        Bildirim Ayarlarını Kaydet
                                    </button>
                                </div>
                            </form>
                        </div>
                    </div>
                </div>
                
                <!-- Preferences Tab -->
                <div id="preferences" class="tab-content">
                    <div class="section">
                        <h2 class="section-title">Tercihler</h2>
                        <p class="section-description">Platformu kişiselleştirin</p>
                        
                        <div class="card">
                            <form method="POST" class="form">
                                <div class="form-group">
                                    <label class="form-label">Tema</label>
                                    <div class="radio-group">
                                        <label class="radio-option <?php echo $demo_settings['theme'] === 'light' ? 'active' : ''; ?>">
                                            <input type="radio" name="theme" value="light" 
                                                   <?php echo $demo_settings['theme'] === 'light' ? 'checked' : ''; ?>>
                                            <div>
                                                <div class="radio-title">Açık Tema</div>
                                                <div class="radio-description">Varsayılan açık renk teması</div>
                                            </div>
                                        </label>
                                        
                                        <label class="radio-option <?php echo $demo_settings['theme'] === 'dark' ? 'active' : ''; ?>">
                                            <input type="radio" name="theme" value="dark" 
                                                   <?php echo $demo_settings['theme'] === 'dark' ? 'checked' : ''; ?>>
                                            <div>
                                                <div class="radio-title">Koyu Tema</div>
                                                <div class="radio-description">Gece modu için koyu tema</div>
                                            </div>
                                        </label>
                                        
                                        <label class="radio-option <?php echo $demo_settings['theme'] === 'auto' ? 'active' : ''; ?>">
                                            <input type="radio" name="theme" value="auto" 
                                                   <?php echo ($demo_settings['theme'] ?? 'light') === 'auto' ? 'checked' : ''; ?>>
                                            <div>
                                                <div class="radio-title">Otomatik</div>
                                                <div class="radio-description">Sistem temasına göre ayarla</div>
                                            </div>
                                        </label>
                                    </div>
                                </div>
                                
                                <div class="form-group">
                                    <label class="form-label">Dil</label>
                                    <select name="language" class="form-control">
                                        <option value="tr" <?php echo $demo_settings['language'] === 'tr' ? 'selected' : ''; ?>>Türkçe</option>
                                        <option value="en" <?php echo $demo_settings['language'] === 'en' ? 'selected' : ''; ?>>English</option>
                                        <option value="de" <?php echo $demo_settings['language'] === 'de' ? 'selected' : ''; ?>>Deutsch</option>
                                    </select>
                                </div>
                                
                                <div class="button-group">
                                    <button type="submit" name="update_preferences" class="btn btn-primary">
                                        <i data-lucide="save" class="btn-icon"></i>
                                        Tercihleri Kaydet
                                    </button>
                                </div>
                            </form>
                        </div>
                    </div>
                </div>
                
                <!-- Security Tab -->
                <div id="security" class="tab-content">
                    <div class="section">
                        <h2 class="section-title">Güvenlik</h2>
                        <p class="section-description">Hesap güvenliğinizi yönetin</p>
                        
                        <div class="card">
                            <div style="display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 1.5rem;">
                                <div style="flex: 1; margin-right: 1rem;">
                                    <div style="font-weight: 500; color: var(--black); margin-bottom: 0.25rem;">
                                        İki Adımlı Doğrulama
                                    </div>
                                    <div style="font-size: 0.875rem; color: var(--gray-600);">
                                        Hesabınıza ekstra güvenlik katmanı ekleyin
                                    </div>
                                </div>
                                <label class="switch">
                                    <input type="checkbox" disabled>
                                    <span class="slider"></span>
                                </label>
                            </div>
                            
                            <div class="button-group">
                                <button type="button" class="btn btn-secondary" onclick="alert('DEMO: İki adımlı doğrulama kurulumu başlatıldı')">
                                    <i data-lucide="shield" class="btn-icon"></i>
                                    Kurulumu Başlat
                                </button>
                            </div>
                        </div>
                        
                        <!-- Danger Zone -->
                        <div class="danger-zone">
                            <h3 class="danger-zone-title">
                                <i data-lucide="alert-triangle" class="w-5 h-5"></i>
                                Hesabı Sil
                            </h3>
                            <p class="danger-zone-description">
                                Hesabınızı silmek istediğinizden emin misiniz? Bu işlem geri alınamaz.
                                Tüm kişisel verileriniz, ayarlarınız ve içerikleriniz kalıcı olarak silinecektir.
                            </p>
                            
                            <form method="POST" onsubmit="return confirmDeleteAccount()">
                                <div class="form-group">
                                    <label class="form-label">Onay için "SİL" yazın</label>
                                    <input type="text" name="confirm_delete" class="form-control" 
                                           placeholder="SİL yazarak onaylayın" required>
                                </div>
                                
                                <div class="button-group">
                                    <button type="submit" name="delete_account" class="btn btn-danger">
                                        <i data-lucide="trash-2" class="btn-icon"></i>
                                        Hesabımı Kalıcı Olarak Sil
                                    </button>
                                </div>
                            </form>
                        </div>
                    </div>
                </div>
            </main>
        </div>
    </div>

    <script>
        // Initialize Lucide icons
        lucide.createIcons();
        
        // Tab switching function
        function switchTab(tabId) {
            // Hide all tab contents
            document.querySelectorAll('.tab-content').forEach(tab => {
                tab.classList.remove('active');
            });
            
            // Remove active class from all navigation items
            document.querySelectorAll('.nav-link, .mobile-nav-item').forEach(item => {
                item.classList.remove('active');
            });
            
            // Show selected tab
            const selectedTab = document.getElementById(tabId);
            if (selectedTab) {
                selectedTab.classList.add('active');
                
                // Scroll to top of tab content on mobile
                if (window.innerWidth < 768) {
                    window.scrollTo({ top: 0, behavior: 'smooth' });
                }
            }
            
            // Update active navigation items
            document.querySelectorAll(`[data-tab="${tabId}"]`).forEach(item => {
                item.classList.add('active');
            });
        }
        
        // Set up tab switching
        document.addEventListener('DOMContentLoaded', function() {
            // Add click event to all navigation links
            document.querySelectorAll('.nav-link, .mobile-nav-item').forEach(link => {
                link.addEventListener('click', function(e) {
                    e.preventDefault();
                    const tabId = this.getAttribute('data-tab');
                    switchTab(tabId);
                    
                    // Update URL hash for deep linking
                    history.pushState(null, '', `#${tabId}`);
                });
            });
            
            // Check for hash in URL on page load
            const hash = window.location.hash.substring(1);
            if (hash && document.getElementById(hash)) {
                switchTab(hash);
            }
            
            // Handle back/forward navigation
            window.addEventListener('popstate', function() {
                const hash = window.location.hash.substring(1);
                if (hash && document.getElementById(hash)) {
                    switchTab(hash);
                }
            });
            
            // Avatar upload preview
            const avatarInput = document.querySelector('input[type="file"]');
            const avatarImg = document.querySelector('.user-avatar img');
            
            if (avatarInput && avatarImg) {
                avatarInput.addEventListener('change', function(e) {
                    const file = e.target.files[0];
                    if (file) {
                        if (file.size > 5 * 1024 * 1024) {
                            alert('Dosya boyutu 5MB\'dan büyük olamaz.');
                            return;
                        }
                        
                        const reader = new FileReader();
                        reader.onload = function(e) {
                            avatarImg.src = e.target.result;
                            
                            // Also update the avatar in the form
                            const formAvatar = document.querySelector('#profile .user-avatar img');
                            if (formAvatar) {
                                formAvatar.src = e.target.result;
                            }
                        };
                        reader.readAsDataURL(file);
                    }
                });
            }
            
            // IBAN formatting
            const ibanInput = document.querySelector('input[name="iban"]');
            if (ibanInput) {
                ibanInput.addEventListener('input', function(e) {
                    let value = e.target.value.toUpperCase().replace(/[^A-Z0-9]/g, '');
                    
                    // Format with spaces every 4 characters
                    if (value.length > 2) {
                        value = value.replace(/(.{4})/g, '$1 ').trim();
                    }
                    
                    e.target.value = value;
                });
                
                // Add pattern validation feedback
                ibanInput.addEventListener('blur', function() {
                    const value = this.value.replace(/\s/g, '');
                    const pattern = /^[A-Z]{2}[0-9]{2}[A-Z0-9]{1,30}$/;
                    
                    if (value && !pattern.test(value)) {
                        this.style.borderColor = 'var(--red-500)';
                    } else {
                        this.style.borderColor = '';
                    }
                });
            }
            
            // Form reset function
            window.resetForm = function(form) {
                if (confirm('Formu sıfırlamak istediğinizden emin misiniz?')) {
                    form.reset();
                    if (avatarImg) {
                        const originalAvatar = '<?php echo htmlspecialchars($demo_user["avatar"]); ?>';
                        avatarImg.src = originalAvatar;
                        
                        const formAvatar = document.querySelector('#profile .user-avatar img');
                        if (formAvatar) {
                            formAvatar.src = originalAvatar;
                        }
                    }
                    
                    // Reset IBAN border color
                    if (ibanInput) {
                        ibanInput.style.borderColor = '';
                    }
                }
            };
            
            // Account delete confirmation
            window.confirmDeleteAccount = function() {
                const confirmText = document.querySelector('[name="confirm_delete"]').value;
                if (confirmText !== 'SİL') {
                    alert('Lütfen "SİL" yazarak onaylayın.');
                    return false;
                }
                
                return confirm('Hesabınızı kalıcı olarak silmek istediğinizden emin misiniz?\n\nBu işlem geri alınamaz!');
            };
            
            // Auto-hide messages
            setTimeout(() => {
                document.querySelectorAll('.alert').forEach(alert => {
                    alert.style.opacity = '0';
                    alert.style.transition = 'opacity 0.5s';
                    setTimeout(() => {
                        if (alert.parentNode) {
                            alert.parentNode.removeChild(alert);
                        }
                    }, 500);
                });
            }, 5000);
            
            // Mobile nav scroll handling
            const mobileNav = document.querySelector('.mobile-nav-items');
            if (mobileNav && window.innerWidth < 768) {
                // Scroll active item into view on mobile
                const activeItem = mobileNav.querySelector('.active');
                if (activeItem) {
                    setTimeout(() => {
                        activeItem.scrollIntoView({
                            behavior: 'smooth',
                            inline: 'center',
                            block: 'nearest'
                        });
                    }, 300);
                }
            }
            
            // Handle window resize
            let resizeTimer;
            window.addEventListener('resize', function() {
                clearTimeout(resizeTimer);
                resizeTimer = setTimeout(function() {
                    // Re-initialize Lucide icons after resize
                    lucide.createIcons();
                }, 250);
            });
            
            // Touch-friendly optimizations for mobile
            if ('ontouchstart' in window) {
                // Increase tap target sizes on mobile
                document.querySelectorAll('.btn, .nav-link, .mobile-nav-item').forEach(element => {
                    element.style.minHeight = '44px';
                    element.style.minWidth = '44px';
                });
                
                // Prevent zoom on input focus in iOS
                document.querySelectorAll('input, select, textarea').forEach(input => {
                    input.addEventListener('focus', function() {
                        this.style.fontSize = '16px';
                    });
                    
                    input.addEventListener('blur', function() {
                        this.style.fontSize = '';
                    });
                });
            }
            
            // Add smooth scrolling for anchor links
            document.querySelectorAll('a[href^="#"]').forEach(anchor => {
                anchor.addEventListener('click', function(e) {
                    const href = this.getAttribute('href');
                    if (href !== '#') {
                        e.preventDefault();
                        const target = document.querySelector(href);
                        if (target) {
                            target.scrollIntoView({
                                behavior: 'smooth',
                                block: 'start'
                            });
                        }
                    }
                });
            });
        });
        
        // Handle page load with hash
        window.addEventListener('load', function() {
            const hash = window.location.hash.substring(1);
            if (hash && document.getElementById(hash)) {
                setTimeout(() => {
                    switchTab(hash);
                }, 100);
            }
        });
    </script>
</body>
</html>