/* =========================================
   MUHASEBEM - SADECE MOBİL İYİLEŞTİRMELERİ
   Desktop tasarımı ETKİLENMEZ
   Version: 2.5 - All Fixes
   ========================================= */

/* =========================================
   1. DESKTOP İÇİN GİZLEME
   ========================================= */

.mobile-fab-container,
.mobile-only-nav,
#page-transactions,
.mobile-budget-section {
    display: none;
}


/* =========================================
   2. MOBİL ANA DEĞİŞİKLİKLER
   ========================================= */

@media (max-width: 768px) {

    /* -----------------------------------------
       A. TOP BAR GENİŞLİĞİ %30 AZALTMA
       ----------------------------------------- */
    .header {
        padding: 12px 12px 35px !important;
    }

    .top-row {
        margin-bottom: 8px !important;
    }

    .market-center-bar {
        padding: 4px 0 !important;
        gap: 10px !important;
        flex-wrap: nowrap !important;
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch;
    }

    .market-center-bar>div {
        flex-shrink: 0 !important;
    }

    .header-asset-summary {
        padding: 8px 12px !important;
        margin-top: 8px !important;
    }

    .header-asset-summary .big-value {
        font-size: 24px !important;
    }

    .summary-row {
        gap: 8px !important;
    }

    .summary-row>div {
        padding: 6px 8px !important;
    }

    .summary-row .label {
        font-size: 9px !important;
    }

    .summary-row .value {
        font-size: 12px !important;
    }


    /* -----------------------------------------
       B. HOME - BÜTÇE VE BİRİKİM TABLOLARI GİZLE
       ----------------------------------------- */
    #page-home .stats-grid-row {
        display: none !important;
    }

    /* Dashboard grid içindeki Son İşlemler kartı - 
       GÖRÜNMEZleştir ama DOM'da tut (App.js render edebilsin) */
    #page-home .dashboard-grid>.card:first-child {
        position: absolute !important;
        left: -9999px !important;
        visibility: hidden !important;
        pointer-events: none !important;
    }

    /* Form kartı görünsün */
    #page-home .form-card {
        display: block !important;
    }

    .top-section {
        display: flex !important;
        flex-direction: column !important;
        gap: 12px !important;
        margin-top: -25px !important;
    }


    /* -----------------------------------------
       C. SON İŞLEMLER - YENİ SEKME
       ----------------------------------------- */
    .mobile-only-nav {
        display: flex !important;
    }

    #page-transactions {
        display: none;
    }

    #page-transactions.active {
        display: block !important;
    }


    /* -----------------------------------------
       D. LİSTELER SAYFASI - BÜTÇE/BİRİKİM
       ----------------------------------------- */
    .mobile-budget-section {
        display: flex !important;
        flex-direction: column !important;
        gap: 15px !important;
        margin-bottom: 20px !important;
    }

    .mobile-budget-section .card {
        height: fit-content !important;
        margin-bottom: 0 !important;
        padding: 15px !important;
    }


    /* -----------------------------------------
       E. GRAFİK EKRANI - FİLTRELER AŞAĞIDA
       + NAVBAR ALTI İÇİN PADDING
       ----------------------------------------- */

    /* Stats sayfasına alt padding ekle (navbar için) */
    #page-stats {
        padding-bottom: calc(70px + env(safe-area-inset-bottom)) !important;
    }

    .stats-container {
        display: flex !important;
        flex-direction: column !important;
        gap: 15px !important;
    }

    /* Grafik içeriği ÖNCE */
    .stats-content {
        order: 1 !important;
        width: 100% !important;
    }

    /* Filtreler SONRA (aşağıda) */
    .stats-sidebar {
        order: 2 !important;
        width: 100% !important;
        max-width: 100% !important;
        padding: 12px !important;
        background: var(--glass) !important;
        border-radius: 12px !important;
        border: 1px solid var(--border) !important;
        margin-bottom: 20px !important;
    }

    .stats-sidebar>div:first-child {
        font-size: 10px !important;
        margin-bottom: 10px !important;
    }

    .advanced-filter-bar {
        gap: 8px !important;
    }

    .filter-row {
        gap: 6px !important;
    }

    .filter-group {
        display: flex !important;
        flex-wrap: wrap !important;
        gap: 6px !important;
    }

    .filter-group .filter-chip {
        padding: 6px 10px !important;
        font-size: 10px !important;
        min-height: 30px !important;
    }

    .date-picker-group {
        display: flex !important;
        gap: 6px !important;
        flex-wrap: wrap !important;
    }

    .date-picker-group input[type="date"] {
        flex: 1 !important;
        min-width: 120px !important;
        padding: 6px 8px !important;
        font-size: 11px !important;
    }

    .stats-sidebar .glass-btn {
        padding: 8px 12px !important;
        font-size: 11px !important;
    }


    /* -----------------------------------------
       F. FAB KONUMU - AI BOT ÜST ÜSTE BİNMESİN
       Chat FAB sağda, bizim FAB solda
       ----------------------------------------- */
    .mobile-fab-container {
        display: block;
        position: fixed;
        bottom: calc(90px + env(safe-area-inset-bottom, 0px));
        left: 16px;
        /* SOLDA */
        right: auto;
        z-index: 999;
    }

    /* Chat FAB'ı sağda tut */
    .chat-fab {
        right: 16px !important;
        left: auto !important;
    }

    .fab-main {
        width: 52px;
        height: 52px;
        border-radius: 50%;
        background: linear-gradient(135deg, var(--primary) 0%, #4f46e5 100%);
        border: none;
        color: white;
        font-size: 20px;
        display: flex;
        align-items: center;
        justify-content: center;
        cursor: pointer;
        box-shadow: 0 4px 15px rgba(99, 102, 241, 0.4);
        transition: all 0.3s ease;
    }

    .fab-main:active {
        transform: scale(0.95);
    }

    .fab-main.open {
        transform: rotate(45deg);
        background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
    }

    .fab-actions {
        position: absolute;
        bottom: 60px;
        left: 2px;
        /* Soldan açılsın */
        right: auto;
        display: flex;
        flex-direction: column;
        gap: 8px;
        opacity: 0;
        visibility: hidden;
        transform: translateY(20px);
        transition: all 0.25s ease;
    }

    .mobile-fab-container.open .fab-actions {
        opacity: 1;
        visibility: visible;
        transform: translateY(0);
    }

    .fab-action {
        width: 40px;
        height: 40px;
        border-radius: 50%;
        border: none;
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: 14px;
        color: white;
        cursor: pointer;
        box-shadow: 0 3px 10px rgba(0, 0, 0, 0.2);
    }

    .fab-action.income {
        background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    }

    .fab-action.expense {
        background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
    }

    .fab-action.debt {
        background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
    }


    /* -----------------------------------------
       G. GENEL MOBİL OPTİMİZASYONLAR
       ----------------------------------------- */

    .invest-card {
        flex-direction: column !important;
        gap: 12px !important;
        padding: 14px !important;
    }

    .invest-card>div {
        min-width: 100% !important;
        width: 100% !important;
    }

    .form-card {
        padding: 14px !important;
    }

    .chip-btn {
        min-height: 40px;
        padding: 8px 14px;
        font-size: 12px;
    }

    .amt-tag {
        min-height: 40px;
        padding: 8px 12px;
        font-size: 13px;
    }

    .home-filter-bar {
        flex-wrap: nowrap !important;
        overflow-x: auto !important;
        gap: 6px !important;
        -webkit-overflow-scrolling: touch;
    }

    .home-filter-bar .h-filter-chip {
        flex-shrink: 0 !important;
        white-space: nowrap !important;
        padding: 6px 12px !important;
        font-size: 11px !important;
    }

    .bottom-nav {
        justify-content: space-around !important;
    }

    .nav-item {
        padding: 10px 16px !important;
    }

    /* Tüm sayfalara alt padding (navbar için) */
    .page {
        padding-bottom: calc(70px + env(safe-area-inset-bottom)) !important;
    }

    /* Scrollbar gizle */
    *::-webkit-scrollbar {
        width: 0;
        height: 0;
    }

    * {
        scrollbar-width: none;
    }
}


/* =========================================
   3. MOBİL MODAL
   ========================================= */

@media (max-width: 480px) {
    .custom-modal.active {
        align-items: flex-end;
        padding: 0;
    }

    .custom-modal .modal-content {
        max-width: 100%;
        width: 100%;
        border-radius: 20px 20px 0 0;
        max-height: 85vh;
        overflow-y: auto;
        animation: slideUpMobile 0.3s ease;
    }

    @keyframes slideUpMobile {
        from {
            transform: translateY(100%);
        }

        to {
            transform: translateY(0);
        }
    }

    .custom-modal .modal-header {
        position: relative;
        padding-top: 20px;
    }

    .custom-modal .modal-header::before {
        content: '';
        position: absolute;
        top: 8px;
        left: 50%;
        transform: translateX(-50%);
        width: 36px;
        height: 4px;
        background: rgba(255, 255, 255, 0.15);
        border-radius: 4px;
    }
}


/* =========================================
   4. SAFE AREA
   ========================================= */

@supports (padding: env(safe-area-inset-bottom)) {
    @media (max-width: 768px) {
        body {
            padding-bottom: env(safe-area-inset-bottom);
        }

        .bottom-nav {
            padding-bottom: calc(10px + env(safe-area-inset-bottom));
        }

        .page {
            padding-bottom: calc(70px + env(safe-area-inset-bottom)) !important;
        }
    }
}


/* =========================================
   5. KÜÇÜK EKRAN
   ========================================= */

@media (max-width: 375px) {
    .container {
        padding: 0 10px;
    }

    .card {
        padding: 12px;
    }

    .header {
        padding: 10px 10px 30px !important;
    }

    .header-asset-summary .big-value {
        font-size: 22px !important;
    }

    .chip-btn {
        padding: 6px 10px;
        font-size: 11px;
    }

    .fab-main {
        width: 48px;
        height: 48px;
        font-size: 18px;
    }

    .fab-action {
        width: 36px;
        height: 36px;
        font-size: 12px;
    }
}


/* =========================================
   6. ERİŞİLEBİLİRLİK
   ========================================= */

@media (prefers-reduced-motion: reduce) {

    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}


/* =========================================
   7. SKELETON VE EMPTY STATE
   ========================================= */

@keyframes skeleton-pulse {
    0% {
        background-position: -200% 0;
    }

    100% {
        background-position: 200% 0;
    }
}

.skeleton {
    background: linear-gradient(90deg,
            rgba(255, 255, 255, 0.03) 25%,
            rgba(255, 255, 255, 0.06) 50%,
            rgba(255, 255, 255, 0.03) 75%);
    background-size: 200% 100%;
    animation: skeleton-pulse 1.5s ease-in-out infinite;
    border-radius: 8px;
}

.empty-state {
    text-align: center;
    padding: 40px 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
}

.empty-state-icon {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: rgba(99, 102, 241, 0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    color: var(--primary);
}


/* =========================================
   8. PULL TO REFRESH
   ========================================= */

.pull-indicator {
    display: none;
}

@media (max-width: 768px) {
    .pull-indicator {
        display: flex;
        position: fixed;
        top: 0;
        left: 50%;
        transform: translateX(-50%) translateY(-100%);
        background: var(--primary);
        color: white;
        padding: 8px 16px;
        border-radius: 0 0 12px 12px;
        font-size: 11px;
        font-weight: 600;
        align-items: center;
        gap: 6px;
        z-index: 9999;
        transition: transform 0.3s ease;
    }

    .pull-indicator.visible {
        transform: translateX(-50%) translateY(0);
    }

    .pull-indicator i {
        animation: spin 1s linear infinite;
    }

    @keyframes spin {
        from {
            transform: rotate(0deg);
        }

        to {
            transform: rotate(360deg);
        }
    }
}