/* =========================================
   1. TEMEL AYARLAR & RESET
   ========================================= */
:root {
    --p-red: #D32F2F;
    --p-green: #16a34a;
    --p-yellow: #FFD700;
    --dark: #111827;
    --bg-gray: #F3F4F6;
    --border: #E5E7EB;
    --card-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
}

* {
    box-sizing: border-box; /* Bu çok önemli, taşmaları engeller */
    -webkit-tap-highlight-color: transparent;
}

html, body {
    margin: 0; padding: 0;
    background-color: var(--bg-gray);
    font-family: 'Inter', sans-serif;
    color: var(--dark);
    
    
    min-height: 100%; /* height: 100% yerine min-height */
    height: auto;     /* Yüksekliği serbest bırak */
    overflow-x: hidden; 
    overflow-y: auto; /* Dikey scroll'u zorla aç */
    width: 100%;
}

/* =========================================
   2. NAVIGASYON (GÖMÜLÜ & RESPONSIVE)
   ========================================= */
/* MASAÜSTÜ VARSAYILAN */
.nav-rail {
    background: #FFFFFF;
    border-right: 1px solid var(--border);
    width: 80px;
    height: 100vh;
    position: fixed;
    top: 0; left: 0;
    display: flex; flex-direction: column; align-items: center;
    padding: 20px 0;
    z-index: 1000;
    box-shadow: 2px 0 10px rgba(0,0,0,0.03);
}

.desktop-logo {
    font-family: 'Orbitron', sans-serif; font-weight: 900;
    font-size: 1.5rem; color: var(--p-red); margin-bottom: 40px;
}

.nav-links { display: flex; flex-direction: column; gap: 15px; width: 100%; align-items: center; }
.nav-item {
    color: #94A3B8; font-size: 1.4rem; padding: 12px;
    border-radius: 12px; transition: 0.3s; text-decoration: none;
    display: flex; justify-content: center; align-items: center;
    width: 50px; height: 50px; position: relative;
}
.nav-item:hover, .nav-item.active { background: #FFF1F2; color: var(--p-red); transform: translateX(3px); }

.nav-hot-tag {
    position: absolute; top: -5px; right: -5px;
    background: var(--p-yellow); color: #000;
    font-size: 0.5rem; padding: 2px 4px; font-weight: 900;
    border-radius: 4px; border: 1px solid #000; font-family: 'Orbitron';
}

/* =========================================
   3. DASHBOARD LAYOUT (MASAÜSTÜ)
   ========================================= */
.city-dashboard {
    width: 100%;
    padding: 30px; 
    padding-left: 110px; /* Masaüstü Nav Payı */
    max-width: 1600px;
    margin: 0 auto;
}

/* Header */
.city-header {
    display: flex; justify-content: space-between; align-items: center;
    background: #fff; padding: 20px 30px; margin-bottom: 25px;
    border: 1px solid var(--border); border-left: 6px solid var(--p-red);
    box-shadow: var(--card-shadow); border-radius: 8px;
    flex-wrap: wrap; gap: 10px;
}
.city-header h1 { font-family: 'Orbitron'; font-size: 2.2rem; margin: 0; letter-spacing: 1px; text-transform: uppercase; line-height: 1; }
.market-badge { background: var(--dark); color: #fff; padding: 8px 16px; font-family: 'Orbitron'; font-size: 0.8rem; border-radius: 6px; }

/* KPI Grid (İstatistik Kartları) */
.kpi-grid {
    display: grid; 
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); /* Esnek kolonlar */
    gap: 20px; margin-bottom: 25px;
}
.kpi-card {
    background: #fff; padding: 20px; display: flex; align-items: center; gap: 15px;
    border: 1px solid var(--border); border-radius: 12px;
    box-shadow: var(--card-shadow);
}
.kpi-icon {
    width: 50px; height: 50px; display: flex; align-items: center; justify-content: center;
    font-size: 1.4rem; border-radius: 12px; flex-shrink: 0; /* İkon küçülmesin */
}
.kpi-icon.red { background: #FEF2F2; color: var(--p-red); }
.kpi-icon.dark { background: #F3F4F6; color: var(--dark); }
.kpi-icon.yellow { background: #FFFBEB; color: #D97706; }

.kpi-info { overflow: hidden; } /* Metin taşmasını engelle */
.kpi-info span { display: block; font-size: 0.7rem; color: #666; font-weight: 800; margin-bottom: 3px; white-space: nowrap; }
.kpi-info strong { font-family: 'Teko'; font-size: 2rem; line-height: 1; color: var(--dark); white-space: nowrap; }

/* Analysis Grid (2 Kolonlu Yapı) */
.analysis-grid {
    display: grid;
    grid-template-columns: 1fr 1fr; /* Yarı yarıya */
    gap: 25px;
}

.data-card {
    background: #fff; border: 1px solid var(--border);
    border-radius: 12px; margin-bottom: 25px;
    box-shadow: var(--card-shadow); 
    display: flex; flex-direction: column;
    overflow: hidden; /* İçerik taşarsa gizle */
}

.card-head {
    padding: 15px 20px; border-bottom: 1px solid var(--border);
    display: flex; justify-content: space-between; align-items: center;
    background: #fff;
}
.card-head h3 { margin: 0; font-family: 'Orbitron'; font-size: 1rem; color: var(--dark); }
.card-head small { font-weight: 600; color: #888; font-size: 0.7rem; }

/* =========================================
   4. LİSTELER (TAŞMAYI ENGELLEYEN KISIM)
   ========================================= */
.scroll-list { 
    max-height: 350px; 
    overflow-y: auto; 
    overflow-x: hidden; /* Yan scroll çıkmasın */
}

.list-item {
    display: flex; 
    justify-content: space-between; 
    align-items: center;
    padding: 15px 20px; 
    border-bottom: 1px solid #f3f4f6;
    width: 100%; /* Kapsayıcıya tam otur */
}

/* SOL KISIM (İSİM) */
.list-item > div:first-child {
    display: flex; 
    align-items: center; 
    gap: 10px;
    min-width: 0; /* Flexbox içinde text-overflow çalışması için ŞART! */
    flex: 1; /* Kalan boşluğu doldur */
    padding-right: 10px;
}

.model-name { 
    font-weight: 700; font-size: 0.85rem; color: var(--dark);
    white-space: nowrap;       /* Alt satıra geçme */
    overflow: hidden;          /* Taşan kısmı gizle */
    text-overflow: ellipsis;   /* Üç nokta (...) koy */
    display: block;
    width: 100%;
}

/* SAĞ KISIM (FİYAT/ADET) */
.list-item > div:last-child {
    flex-shrink: 0; /* Asla küçülme */
    text-align: right;
}

.model-stat { font-family: 'Teko'; font-size: 1.4rem; font-weight: 600; color: var(--dark); }

.arb-badge {
    background: #DCFCE7; color: #166534; padding: 3px 8px;
    border-radius: 6px; font-size: 0.65rem; font-weight: 800; 
    display: inline-block; margin-bottom: 2px; white-space: nowrap;
}

/* GRAFİK ALANI */
.chart-container { height: auto; }
.canvas-wrapper { 
    padding: 15px; 
    height: 300px; 
    width: 100%;
    position: relative; 
}
canvas { width: 100% !important; height: 100% !important; }

/* SNIPER BOX */
.sniper-box { border: 2px solid var(--p-red); }
.sniper-list .list-item { background: #FEF2F2; }

/* AUTH LOCK (KİLİT) */
.city-lock-overlay {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(255, 255, 255, 0.4);
    backdrop-filter: blur(10px); z-index: 9999;
    display: flex; justify-content: center; align-items: center; padding: 20px;
}
.lock-box {
    background: #fff; padding: 30px; border: 2px solid var(--dark);
    text-align: center; max-width: 400px; width: 100%;
    box-shadow: 0 20px 50px rgba(0,0,0,0.2); border-radius: 16px;
}
.unlock-btn {
    background: var(--dark); color: #fff; text-decoration: none;
    padding: 15px 20px; font-family: 'Orbitron'; font-weight: 900;
    display: inline-block; margin-top: 20px; border-radius: 8px; width: 100%;
}

/* =========================================
   6. MOBİL RESPONSIVE (FİNAL DÜZELTME)
   ========================================= */
@media (max-width: 900px) {
    
    /* GÖVDE VE KAPŞAYICI */
    html, body {
        overflow-x: hidden !important; /* Sağa sola oynamayı engelle */
        width: 100%;
        position: relative;
    }

    .city-dashboard {
        padding: 10px !important; /* Kenar boşluklarını azalttım */
        padding-bottom: 90px !important; /* Nav payı */
        padding-left: 10px !important; 
        width: 100% !important;
        max-width: 100vw !important;
        overflow-x: hidden !important;
    }

    /* HEADER */
    .city-header {
        padding: 15px;
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
        width: 100%; /* Kart dışına taşmasın */
    }
    .city-header h1 { font-size: 1.5rem; word-break: break-word; }

    /* KPI GRID (YANA KAYDIRMALI SWIPE) - İSTEĞİN ÜZERİNE */
    .kpi-grid {
        display: flex !important; /* Grid yerine Flex */
        overflow-x: auto !important; /* Yana kaydırma açık */
        gap: 10px;
        padding-bottom: 10px; /* Scroll bar payı */
        scroll-snap-type: x mandatory; /* Kartlar yapışsın */
        width: 100%;
    }

    .kpi-card {
        min-width: 85%; /* Ekranın %85'ini kaplasın, yanındaki görünsün */
        flex: 0 0 auto; /* Küçülmesin */
        scroll-snap-align: start;
        padding: 15px;
        border-right: 4px solid var(--p-red); /* Mobilde sağa çizgi şık durur */
    }

    .kpi-info strong { font-size: 1.8rem; }

    /* ANALİZ GRID (TEK KOLON) */
    .analysis-grid {
        display: flex;
        flex-direction: column;
        gap: 15px;
        width: 100%;
    }

    .data-card {
        width: 100%;
        margin-bottom: 10px;
    }

    /* LİSTELER (TAŞMAYI ÖNLEME) */
    .list-item {
        padding: 10px;
        width: 100%;
    }
    
    .model-name {
        font-size: 0.75rem;
        max-width: 140px; /* İsim çok uzarsa kes */
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }
    
    .model-stat { font-size: 1.1rem; }

    /* GRAFİK ALANI */
    .canvas-wrapper {
        height: 250px;
        padding: 5px;
        width: 100%;
    }

    /* NAVIGASYON */
    .nav-rail {
        width: 100% !important;
        height: 60px !important;
        bottom: 0 !important; top: auto !important; left: 0 !important;
        flex-direction: row !important;
        padding: 0 !important;
        border-top: 1px solid var(--border) !important;
        z-index: 9999 !important;
    }
    .desktop-logo { display: none !important; }
    .nav-links { flex-direction: row !important; width: 100%; justify-content: space-around; }
    .nav-item { width: 100% !important; height: 100%; border-radius: 0; }
    .nav-item.active { border-top: 3px solid var(--p-red); background: transparent !important; }
}