/* --- 1. DESIGN TOKENS --- */
:root {
    /* Ana Renkler */
    --primary: #6366f1;       
    --primary-hover: #4f46e5;
    --secondary: #8b5cf6;     
    --dark-bg: #0f172a;       
    --card-bg: #1e293b;       
    --input-bg: #334155;      
    
    /* Metin Renkleri */
    --text-main: #f8fafc;     
    --text-muted: #94a3b8;    
    
    /* Durum Renkleri */
    --success: #10b981;       
    --danger: #ef4444;        
    --warning: #f59e0b;       
    --info: #3b82f6;          

    /* Yapısal */
    --border: #334155;
    --shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.5);
    --radius: 16px;
    --font: 'Plus Jakarta Sans', sans-serif;
    --nav-bg: rgba(30, 41, 59, 0.95);
}

.light-theme {
    --bg-body: #f8fafc;
    --bg-card: #ffffff;
    --text-main: #1e293b;
    --input-bg: #f1f5f9;
    --border: #e2e8f0;
}

/* --- 2. RESET & BASE --- */
* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; outline: none; touch-action: manipulation; }
body { font-family: var(--font); background-color: var(--dark-bg); color: var(--text-main); padding-bottom: 110px; font-size: 14px; overflow-x: hidden; position: relative; }

input, select, textarea { font-size: 16px !important; }

::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 10px; }

/* --- 3. UTILITIES --- */
.hidden { display: none !important; }
.flex { display: flex; align-items: center; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.flex-col { display: flex; flex-direction: column; }
.w-full { width: 100%; }
.text-sm { font-size: 12px; }
.text-lg { font-size: 18px; }
.font-bold { font-weight: 700; }
.opacity-70 { opacity: 0.7; }
.mt-10 { margin-top: 10px; }
.flex-center { display: flex; align-items: center; justify-content: center; }

/* --- 4. AUTHENTICATION --- */
#authContainer { 
    position: fixed; inset: 0; 
    background: var(--dark-bg); 
    z-index: 9999; 
    display: flex; align-items: center; justify-content: center; padding: 20px;
}
.auth-card { 
    background: var(--card-bg); 
    padding: 30px; border-radius: 24px; width: 100%; max-width: 400px; 
    text-align: center; 
    box-shadow: 0 20px 60px rgba(0,0,0,0.5); 
    color: var(--text-main); 
    border: 1px solid var(--border); 
    animation: slideUp 0.4s ease-out;
}
.auth-header h1 { font-size: 24px; color: var(--primary); margin-bottom: 8px; font-weight: 800; }
.auth-header p { color: var(--text-muted); margin-bottom: 25px; font-size: 14px; }

.auth-input { 
    width: 100%; padding: 14px; 
    border: 1px solid var(--border); 
    border-radius: 14px; 
    margin-bottom: 12px; 
    background: var(--input-bg); 
    color: var(--text-main);
    font-size: 16px;
    transition: 0.3s; 
}
.auth-input::placeholder { color: var(--text-muted); opacity: 0.6; }
.auth-input:focus { border-color: var(--primary); box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.15); }

input[type="checkbox"] {
    appearance: auto !important;
    width: auto !important;
    margin-right: 5px;
    cursor: pointer;
}

.auth-btn { 
    width: 100%; padding: 14px; 
    background: var(--primary); color: white; border: none; 
    border-radius: 14px; font-weight: 700; cursor: pointer; transition: 0.2s; font-size: 16px; 
    margin-top: 10px; box-shadow: 0 4px 15px rgba(99, 102, 241, 0.4);
}

/* YENİ: Global Buton Tıklama Efekti */
button:active, .auth-btn:active, .glass-btn:active, .chip-btn:active, .notif-btn:active, .tx-action-btn:active { 
    transform: scale(0.96) !important; 
    transition: transform 0.1s cubic-bezier(0.4, 0, 0.2, 1);
}

.auth-link { margin-top: 20px; font-size: 14px; color: var(--text-muted); cursor: pointer; padding: 10px; }
.auth-link span { color: var(--primary); font-weight: 700; }

/* --- 5. HEADER (Z-Index Düzeltmesi) --- */
.header { 
    background: linear-gradient(135deg, var(--primary) 0%, #4f46e5 100%); 
    padding: 20px 20px 80px; 
    border-radius: 0 0 35px 35px; color: white; 
    box-shadow: 0 10px 30px -10px var(--primary); 
    position: relative; 
    z-index: 10; 
    margin-bottom: -60px;
}

.top-row { 
    display: grid; 
    grid-template-columns: auto 1fr auto; 
    align-items: center; 
    gap: 15px; 
    margin-bottom: 20px; 
    position: relative; 
    z-index: 50; 
}

/* --- 6. LAYOUT & CARDS --- */
.container { 
    max-width: 1200px; margin: 0 auto; padding: 0 15px; 
    position: relative; 
    z-index: 20; 
}

.grafik_page{ position: relative; top: -55px; }

.dashboard-grid { display: grid; grid-template-columns: 1fr; gap: 15px; }
.top-section { 
    display: grid; 
    grid-template-columns: 1fr; 
    gap: 15px; 
    margin-bottom: 15px; 
    position: relative; 
    z-index: 30; 
}

/* Masaüstü Grid Yapısı: Sol (Liste) Geniş, Sağ (Form) Dar */
@media (min-width: 992px) { 
    .dashboard-grid { 
        grid-template-columns: 2fr 1fr; /* Sol 2 birim, Sağ 1 birim */
        align-items: start; 
        gap: 20px;
    } 
    .top-section { grid-template-columns: 1fr 1fr; margin-top: -60px; } 
    
    /* Masaüstünde grafik kutularını yan yana koy */
    .charts-wrapper {
        flex-wrap: nowrap !important;
    }
}

/* Mobil Optimizasyon */
@media (max-width: 991px) {
    .container { 
        padding: 0 15px; 
        max-width: 600px;
        margin: 0 auto;
    }

    .header { 
        padding-bottom: 160px; 
        margin-bottom: -100px; 
        text-align: center; 
    }

    .top-row {
        display: flex !important;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 15px;
        width: 100%;
        pointer-events: auto;
    }

    .user-profile { width: 100%; justify-content: center; }
    .market-center-bar { width: 100%; justify-content: center; flex-wrap: wrap; gap: 8px; }
    .action-btns { width: 100%; justify-content: center; margin-bottom: 5px; }

    .top-section { 
        padding: 0 !important; 
        margin-top: -80px; 
        gap: 15px; 
        display: flex; 
        flex-direction: column;
        width: 100%; 
    }

    .dashboard-grid {
        display: flex;
        flex-direction: column;
        width: 100%;
        margin: 0;
        gap: 15px;
    }

    .card, .form-card { 
        width: 100% !important;
        max-width: 100% !important;
        padding: 20px !important;
        box-sizing: border-box !important;
        border-radius: 20px; 
        box-shadow: 0 10px 30px -5px rgba(0, 0, 0, 0.3); 
    }

    .big-value { font-size: 28px; margin: 8px 0; }
    .auth-card { padding: 25px; width: 90%; max-width: 400px; margin: 0 auto; }
    .summary-grid { gap: 5px; }
    .sum-item p { font-size: 16px; }
    .sum-item h5 { font-size: 11px; }

    .quick-action-wrapper {
        padding-bottom: 5px;
        margin-bottom: 20px;
        justify-content: flex-start;
    }
    .chip-btn { padding: 12px 18px; font-size: 13px; min-height: 44px; }

    .bottom-nav {
        bottom: 20px;
        width: 90%;
        max-width: 500px; 
        padding: 12px 20px;
        justify-content: space-around;
        gap: 0;
    }
}

.card { 
    background: var(--card-bg); border-radius: 24px; padding: 25px; 
    box-shadow: var(--shadow); border: 1px solid var(--border); 
    position: relative; overflow: hidden; 
}
.invest-card { 
    background: linear-gradient(135deg, #1e293b, #0f172a); 
    color: white; min-height: 150px; display: flex; flex-direction: column; justify-content: center;
}
.card-header-row { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }

.glass-btn { 
    background: rgba(255,255,255,0.15); border: none; color: white; 
    padding: 8px 16px; 
    border-radius: 20px; font-size: 12px; font-weight: 600; cursor: pointer; 
    backdrop-filter: blur(4px); transition: 0.2s; 
    min-height: 36px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.big-value { font-size: 32px; font-weight: 800; letter-spacing: -1px; margin: 5px 0; word-break: break-word; }

.summary-grid { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 5px; text-align: center; width: 100%; }
.sum-item p { font-size: 15px; font-weight: 800; }

.tx-list { display: flex; flex-direction: column; gap: 10px; max-height: 500px; overflow-y: auto; padding-right: 2px; }
.tx-item { 
    display: flex; justify-content: space-between; padding: 14px; 
    background: var(--dark-bg); border-radius: 16px; align-items: center; 
    border-left: 4px solid transparent; 
    transition: background 0.2s;
    cursor: pointer;
    position: relative;
    z-index: 1;
}
.tx-icon { width: 36px; height: 36px; border-radius: 10px; display: flex; align-items: center; justify-content: center; font-size: 16px; flex-shrink: 0; }

input:not([type="checkbox"]), select { 
    width: 100%; padding: 14px; border-radius: 14px; 
    border: 1px solid var(--border); background: rgba(0,0,0,0.2); 
    color: var(--text-main); font-size: 16px;
    appearance: none;
}

select option { background-color: var(--card-bg); color: var(--text-main); padding: 15px; font-size: 14px; }
select optgroup { background-color: var(--dark-bg); color: var(--primary); font-weight: 800; padding: 10px; }

.light-theme select option { background-color: #ffffff; color: #0f172a; }
.light-theme select optgroup { background-color: #f1f5f9; color: var(--primary); }

/* --- CHART & GRAFIK DUZENLEMELERI --- */

/* Kapsayıcı Konteyner */
.chart-container { 
    position: relative; 
    height: 250px; 
    width: 100%; 
    display: flex; 
    align-items: center; 
    justify-content: center; 
    margin-bottom: 15px; 
    overflow: hidden; /* Taşmayı engelle */
}

/* Grafik Kutuları (Stats Sayfası) */
.chart-box {
    position: relative;
    height: 250px;  /* Sabit Yükseklik */
    width: 100%;
    min-width: 0;   /* Flex taşma fix */
    background: rgba(255,255,255,0.02);
    border-radius: 20px;
    padding: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

/* Canvas Ayarları */
canvas {
    max-width: 100% !important;
    max-height: 100% !important;
    width: 100% !important;
    height: auto !important;
}

.bottom-nav { 
    position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); 
    background: var(--nav-bg); backdrop-filter: blur(15px); 
    padding: 12px 30px; border-radius: 40px; 
    display: flex; gap: 40px; 
    box-shadow: 0 10px 40px rgba(0,0,0,0.4); 
    z-index: 900; border: 1px solid rgba(255,255,255,0.1);
    width: auto; max-width: 90%;
    pointer-events: auto;
}

.nav-item {
    font-size: 22px; color: var(--text-muted); cursor: pointer;
    transition: all 0.2s ease; padding: 10px;
}
.nav-item.active { color: var(--primary); transform: scale(1.1); filter: drop-shadow(0 0 8px rgba(99,102,241,0.5)); }
.nav-item:active { transform: scale(0.9); }

#toast { 
    position: fixed; top: 20px; left: 50%; transform: translate(-50%, -150%); 
    background: var(--card-bg); padding: 12px 24px; border-radius: 50px; 
    box-shadow: var(--shadow); border: 1px solid var(--border); z-index: 10000; 
    transition: 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275); 
    display: flex; align-items: center; gap: 10px; font-weight: 600; width: max-content; max-width: 90%; 
}
.show-toast { transform: translate(-50%, 10px) !important; }

.text-success { color: var(--success); } .bg-success { background: rgba(16, 185, 129, 0.15); }
.text-danger { color: var(--danger); } .bg-danger { background: rgba(239, 68, 68, 0.15); }

/* --- YENİ ANİMASYONLAR --- */

/* 1. slideInUp: Öğelerin aşağıdan yukarı süzülmesi */
@keyframes slideInUp { 
    from { opacity: 0; transform: translateY(20px); } 
    to { opacity: 1; transform: translateY(0); } 
}

/* 2. fadeInScale: Modalların merkezden büyümesi */
@keyframes fadeInScale {
    from { opacity: 0; transform: scale(0.95); }
    to { opacity: 1; transform: scale(1); }
}

/* 3. Stagger Item: Liste elemanları için */
.stagger-item {
    opacity: 0; /* JS ile delay eklendiğinde başlangıçta gizli olmalı */
    animation: slideInUp 0.4s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

/* 4. Page Transition: Sayfa geçiş efekti */
.page-transition {
    animation: fadeInScale 0.3s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

.page { display: none; } 
.page.active { display: block; }
/* Varsayılan eski fadeIn animasyonu yerine page-transition kullanılacak */
/* @keyframes fadeIn { from { opacity:0; } to { opacity:1; } } */

.quick-action-wrapper {
    display: flex; gap: 10px; overflow-x: auto; padding: 5px 2px 15px 2px; margin-bottom: 15px;
    -webkit-overflow-scrolling: touch; scrollbar-width: none;
}
.quick-action-wrapper::-webkit-scrollbar { display: none; }

.chip-btn {
    background: rgba(255,255,255,0.05); border: 1px solid var(--border);
    padding: 8px 16px; border-radius: 50px; color: var(--text-muted); font-size: 12px;
    font-weight: 600; white-space: nowrap; cursor: pointer; display: flex; align-items: center;
    gap: 8px; transition: all 0.2s ease; user-select: none;
    min-height: 40px; 
}
.chip-btn i { font-size: 14px; }
.chip-btn:hover { background: rgba(255,255,255,0.1); color: var(--text-main); transform: translateY(-2px); border-color: rgba(255,255,255,0.2); }

.light-theme .chip-btn { background: #f1f5f9; border-color: #e2e8f0; color: #64748b; }
.light-theme .chip-btn:hover { background: #e2e8f0; color: #0f172a; }


/* --- CHAT PENCERESİ VE MESAJLAR (GÜNCELLENMİŞ) --- */

.chat-fab {
    position: fixed; bottom: 100px; right: 20px; width: 50px; height: 50px;
    background: var(--primary); color: white; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    box-shadow: 0 4px 15px rgba(99, 102, 241, 0.4); cursor: pointer; z-index: 990;
    transition: transform 0.2s;
}
.chat-fab:active { transform: scale(0.9); }

/* 1. Chat Penceresi (Flex Konteyner) */
.chat-window {
    position: fixed; 
    bottom: 110px; 
    right: 20px; 
    width: 360px; /* Biraz daha geniş */
    max-width: 90vw; 
    height: 550px; /* Daha yüksek */
    max-height: 60vh;
    background: var(--card-bg); 
    border: 1px solid var(--border);
    border-radius: 24px; 
    box-shadow: 0 20px 60px rgba(0,0,0,0.5); 
    z-index: 995;
    display: none; 
    flex-direction: column; 
    overflow: hidden; 
    animation: slideUp 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}
.chat-window.active { display: flex !important; }

/* 2. Mesaj Alanı (Flexbox Yapısı - KRİTİK KISIM) */
#chatBody {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column; /* Mesajları alt alta dizer */
    gap: 12px; /* Mesajlar arası boşluk */
    scroll-behavior: smooth;
}

/* 3. Mesaj Baloncukları Genel Stil */
.chat-msg {
    max-width: 85%; 
    padding: 12px 16px; 
    border-radius: 18px;
    font-size: 14px; 
    line-height: 1.5; 
    word-wrap: break-word; 
    position: relative;
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
    animation: fadeIn 0.3s ease;
}

/* BOT Mesajı (SOL - GRİ) */
.msg-bot { 
    background: rgba(255, 255, 255, 0.08); 
    color: var(--text-main); 
    align-self: flex-start; /* Sola yaslar */
    border-bottom-left-radius: 4px;
    border: 1px solid var(--border);
}

/* KULLANICI Mesajı (SAĞ - MOR) */
.msg-user { 
    background: var(--primary); 
    color: white; 
    align-self: flex-end; /* Sağa yaslar */
    border-bottom-right-radius: 4px;
    box-shadow: 0 4px 15px rgba(99, 102, 241, 0.3);
}

/* Yükleniyor Mesajı */
.loading-msg {
    opacity: 0.7;
    font-style: italic;
    font-size: 12px;
}

/* Light Tema Uyumu */
.light-theme .msg-bot { 
    background: #f1f5f9; 
    color: #334155; 
    border-color: #e2e8f0;
}

/* 4. Alt Input Alanı */
.chat-footer {
    padding: 15px;
    border-top: 1px solid var(--border);
    background: var(--card-bg);
    display: flex;
    gap: 10px;
    align-items: center;
}

/* Input ve Buton Düzenlemeleri */
#chatInput {
    margin: 0 !important; 
    border-radius: 25px !important;
    font-size: 14px !important;
    padding: 12px 15px !important;
    background: rgba(0,0,0,0.2) !important;
    border: 1px solid var(--border) !important;
}
.light-theme #chatInput { background: #f8fafc !important; }

/* Mobil Uyumluluk */
@media (max-width: 576px) {
    .chat-window {
        position: fixed; bottom: 0 !important; left: 0 !important; right: 0 !important;
        width: 100% !important; max-width: 100% !important; height: 60vh !important;
        max-height: 60vh !important; border-radius: 25px 25px 0 0 !important;
        border-bottom: none; box-shadow: 0 -10px 40px rgba(0,0,0,0.3); z-index: 10000;
        transform: translateY(100%); transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    }
    .chat-window.active { display: flex !important; transform: translateY(0); }
    body:has(.chat-window.active) .chat-fab { display: none; }
}

.tx-right { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }
.tx-actions {
    display: flex; gap: 12px; opacity: 0.6; transition: opacity 0.2s;
    margin-top: 2px; position: relative; z-index: 5;
}
.tx-item:hover .tx-actions { opacity: 1; }
@media (max-width: 768px) { .tx-actions { opacity: 1; } }

.tx-action-btn { font-size: 14px; cursor: pointer; padding: 8px; transition: transform 0.2s, color 0.2s; }
.action-edit { color: var(--info); }
.action-edit:hover { transform: scale(1.2); color: #60a5fa; }
.action-delete { color: var(--danger); }
.action-delete:hover { transform: scale(1.2); color: #f87171; }
.light-theme .action-edit { color: #3b82f6; }
.light-theme .action-delete { color: #ef4444; }

/* Mobilde klavye açılınca UI bozulmasın diye */
@media (max-width: 768px) {
    .bottom-nav {
        /* Klavye açıldığında alt menüyü gizle */
        display: flex;
    }
    body.keyboard-open .bottom-nav {
        display: none;
    }
    
    /* Listeler daha rahat kaydırılsın */
    .tx-list {
        padding-bottom: 80px; 
    }
}

/* --- PRIVACY MODE --- */
.privacy-mode .money-value {
    filter: blur(6px);
    user-select: none;
    cursor: default;
    transition: filter 0.3s ease;
}

/* --- BÜTÇE DURUM ÇUBUĞU --- */
.budget-bar-container {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 15px 20px;
    box-shadow: var(--shadow);
    margin: 0 10px 20px 10px; /* Hizalama ayarı */
    position: relative;
    z-index: 20;
    backdrop-filter: blur(10px);
}
.budget-header {
    display: flex;
    justify-content: space-between;
    font-size: 11px;
    font-weight: 700;
    color: var(--text-muted);
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.budget-progress-track {
    width: 100%;
    height: 8px;
    background: rgba(255,255,255,0.05);
    border-radius: 10px;
    overflow: hidden;
}
.budget-progress-fill {
    height: 100%;
    border-radius: 10px;
    width: 0%;
    transition: width 0.6s cubic-bezier(0.4, 0, 0.2, 1), background-color 0.3s;
    box-shadow: 0 0 10px rgba(0,0,0,0.1);
}
.light-theme .budget-bar-container {
    background: #ffffff;
    border-color: #e2e8f0;
}
.light-theme .budget-progress-track {
    background: #f1f5f9;
}