/* ============================================
   EK MOBİL OPTİMİZASYONLAR
   ============================================ */

/* 1. PERFORMANS OPTİMİZASYONLARI */

/* Image Optimization */
@media (max-width: 768px) {
    /* Lazy loading için placeholder */
    img[data-src] {
        background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
        background-size: 200% 100%;
        animation: loading 1.5s infinite;
    }
    
    @keyframes loading {
        0% { background-position: 200% 0; }
        100% { background-position: -200% 0; }
    }
    
    /* Image aspect ratio koruma */
    img {
        max-width: 100%;
        height: auto;
        display: block;
    }
    
    /* Responsive images için */
    picture img {
        width: 100%;
        height: auto;
    }
}

/* 2. SCROLL OPTİMİZASYONLARI */

@media (max-width: 768px) {
    /* Smooth scroll */
    html {
        scroll-behavior: smooth;
    }
    
    /* Scroll snap (iOS için) */
    .scroll-container {
        -webkit-overflow-scrolling: touch;
        scroll-snap-type: y proximity;
    }
    
    .scroll-item {
        scroll-snap-align: start;
    }
    
    /* Scroll bar gizleme (iOS Safari) */
    ::-webkit-scrollbar {
        width: 0px;
        background: transparent;
    }
}

/* 3. TOUCH İYİLEŞTİRMELERİ */

@media (max-width: 768px) {
    /* Long press önleme (yanlışlıkla text seçimi) */
    * {
        -webkit-tap-highlight-color: transparent;
        -webkit-touch-callout: none;
        -webkit-user-select: none;
        user-select: none;
    }
    
    /* Text seçimi gereken yerler */
    p, span, h1, h2, h3, h4, h5, h6, a, input, textarea {
        -webkit-user-select: text;
        user-select: text;
    }
    
    /* Touch delay kaldırma */
    a, button, .btn, .nav-link, .dropdown-item {
        touch-action: manipulation;
    }
    
    /* Active state feedback */
    .btn:active, button:active, a:active {
        transform: scale(0.97);
        transition: transform 0.1s;
    }
}

/* 4. FORM İYİLEŞTİRMELERİ */

@media (max-width: 768px) {
    /* Input focus için daha iyi görünüm */
    input:focus, textarea:focus, select:focus {
        outline: 2px solid var(--primary-color);
        outline-offset: 2px;
    }
    
    /* Autocomplete için */
    input:-webkit-autofill,
    input:-webkit-autofill:hover,
    input:-webkit-autofill:focus {
        -webkit-box-shadow: 0 0 0 30px white inset !important;
        -webkit-text-fill-color: var(--text-color) !important;
    }
    
    /* Number input için spinner gizleme */
    input[type="number"]::-webkit-inner-spin-button,
    input[type="number"]::-webkit-outer-spin-button {
        -webkit-appearance: none;
        margin: 0;
    }
    
    /* Date picker için */
    input[type="date"]::-webkit-calendar-picker-indicator {
        opacity: 0.6;
        cursor: pointer;
    }
}

/* 5. MODAL İYİLEŞTİRMELERİ */

@media (max-width: 768px) {
    .modal-dialog {
        margin: 0;
        max-width: 100%;
        height: 100%;
    }
    
    .modal-content {
        height: 100%;
        border-radius: 0;
        border: none;
    }
    
    .modal-header {
        position: sticky;
        top: 0;
        z-index: 10;
        background: white;
    }
    
    .modal-body {
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        padding: 20px;
    }
    
    /* Modal kapatma butonu */
    .modal-header .btn-close {
        padding: 10px;
        margin: -10px;
    }
}

/* 6. CARD İYİLEŞTİRMELERİ */

@media (max-width: 768px) {
    .card {
        margin-bottom: 15px;
        box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    }
    
    .card-body {
        padding: 15px;
    }
    
    /* Card hover efekti kaldır (mobilde gereksiz) */
    .card:hover {
        transform: none;
    }
}

/* 7. BUTTON İYİLEŞTİRMELERİ */

@media (max-width: 768px) {
    /* Button group mobilde dikey */
    .btn-group-vertical {
        width: 100%;
    }
    
    .btn-group-vertical > .btn {
        width: 100%;
        margin-bottom: 10px;
    }
    
    /* Loading state */
    .btn.loading {
        position: relative;
        color: transparent;
        pointer-events: none;
    }
    
    .btn.loading::after {
        content: '';
        position: absolute;
        width: 16px;
        height: 16px;
        top: 50%;
        left: 50%;
        margin-left: -8px;
        margin-top: -8px;
        border: 2px solid #fff;
        border-radius: 50%;
        border-top-color: transparent;
        animation: spinner 0.6s linear infinite;
    }
    
    @keyframes spinner {
        to { transform: rotate(360deg); }
    }
}

/* 8. NAVIGATION İYİLEŞTİRMELERİ */

@media (max-width: 768px) {
    /* Breadcrumb */
    .breadcrumb {
        font-size: 0.85rem;
        flex-wrap: wrap;
    }
    
    .breadcrumb-item {
        white-space: nowrap;
    }
    
    /* Pagination */
    .pagination {
        flex-wrap: wrap;
        justify-content: center;
    }
    
    .pagination .page-link {
        padding: 8px 12px;
        min-width: 44px;
    }
}

/* 9. TAB İYİLEŞTİRMELERİ */

@media (max-width: 768px) {
    .nav-tabs {
        flex-wrap: wrap;
        border-bottom: 2px solid #dee2e6;
    }
    
    .nav-tabs .nav-link {
        flex: 1 1 auto;
        min-width: 100px;
        text-align: center;
        padding: 12px 8px;
    }
    
    .tab-content {
        padding-top: 15px;
    }
}

/* 10. ALERT İYİLEŞTİRMELERİ */

@media (max-width: 768px) {
    .alert {
        padding: 15px;
        margin-bottom: 15px;
        font-size: 0.95rem;
    }
    
    .alert-dismissible .btn-close {
        padding: 10px;
    }
}

/* 11. DROPDOWN İYİLEŞTİRMELERİ */

@media (max-width: 768px) {
    .dropdown-menu {
        max-height: 70vh;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    .dropdown-item {
        padding: 12px 20px;
        min-height: 44px;
    }
}

/* 12. TOOLTIP VE POPOVER */

@media (max-width: 768px) {
    /* Tooltip'leri mobilde devre dışı bırak (touch ile çalışmaz) */
    .tooltip {
        display: none !important;
    }
    
    /* Popover'ları mobilde daha büyük yap */
    .popover {
        max-width: 90vw;
    }
}

/* 13. TABLE İYİLEŞTİRMELERİ (Ek) */

@media (max-width: 768px) {
    /* Table card view için ek stiller */
    .table-card-view {
        display: block;
    }
    
    .table-card {
        background: white;
        border-radius: 8px;
        padding: 15px;
        margin-bottom: 15px;
        box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    }
    
    .table-card-row {
        display: flex;
        justify-content: space-between;
        padding: 8px 0;
        border-bottom: 1px solid #f0f0f0;
    }
    
    .table-card-row:last-child {
        border-bottom: none;
    }
    
    .table-card-label {
        font-weight: 600;
        color: var(--text-color);
        margin-right: 10px;
        flex: 0 0 40%;
    }
    
    .table-card-value {
        flex: 1;
        text-align: right;
        color: var(--text-color);
        opacity: 0.8;
    }
}

/* 14. LOADING STATES */

@media (max-width: 768px) {
    .loading-overlay {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0,0,0,0.5);
        display: flex;
        align-items: center;
        justify-content: center;
        z-index: 9999;
    }
    
    .spinner {
        width: 40px;
        height: 40px;
        border: 4px solid rgba(255,255,255,0.3);
        border-top-color: white;
        border-radius: 50%;
        animation: spin 0.8s linear infinite;
    }
    
    @keyframes spin {
        to { transform: rotate(360deg); }
    }
}

/* 15. SAFE AREA SUPPORT (iPhone X ve üzeri) */

@supports (padding: max(0px)) {
    @media (max-width: 768px) {
        /* Safe area için padding */
        .safe-area-top {
            padding-top: max(20px, env(safe-area-inset-top));
        }
        
        .safe-area-bottom {
            padding-bottom: max(20px, env(safe-area-inset-bottom));
        }
        
        .safe-area-left {
            padding-left: max(15px, env(safe-area-inset-left));
        }
        
        .safe-area-right {
            padding-right: max(15px, env(safe-area-inset-right));
        }
        
        /* Navbar için safe area */
        #mainNav {
            padding-top: max(0px, env(safe-area-inset-top));
        }
        
        /* Footer için safe area */
        footer {
            padding-bottom: max(20px, env(safe-area-inset-bottom));
        }
    }
}

/* 16. DARK MODE SUPPORT */

@media (max-width: 768px) {
    @media (prefers-color-scheme: dark) {
        /* Dark mode için ek stiller */
        .card {
            background: #1a1a1a;
            color: #fff;
        }
        
        .modal-content {
            background: #1a1a1a;
            color: #fff;
        }
    }
}

/* 17. ORIENTATION SUPPORT */

@media (max-width: 768px) {
    /* Landscape mode */
    @media (orientation: landscape) {
        .navbar-collapse {
            max-height: 80vh;
        }
        
        .modal-dialog {
            max-height: 90vh;
        }
    }
    
    /* Portrait mode */
    @media (orientation: portrait) {
        .hero-title {
            font-size: 2rem;
        }
    }
}

/* 18. NETWORK AWARENESS */

@media (max-width: 768px) {
    /* Slow connection için */
    .slow-connection img {
        filter: blur(5px);
        transition: filter 0.3s;
    }
    
    .slow-connection img.loaded {
        filter: blur(0);
    }
}

/* 19. ACCESSIBILITY İYİLEŞTİRMELERİ */

@media (max-width: 768px) {
    /* Focus visible */
    *:focus-visible {
        outline: 2px solid var(--primary-color);
        outline-offset: 2px;
    }
    
    /* Skip to content link - sadece focus'ta görünür */
    .skip-to-content {
        position: absolute;
        left: -9999px;
        z-index: 9999;
        background: var(--primary-color);
        color: white;
        padding: 10px 20px;
        text-decoration: none;
        border-radius: 4px;
    }
    
    .skip-to-content:focus {
        position: absolute;
        left: 50%;
        transform: translateX(-50%);
        top: 10px;
    }
}

/* 20. PERFORMANCE OPTIMIZATIONS */

@media (max-width: 768px) {
    /* GPU acceleration */
    .navbar-collapse,
    .modal,
    .dropdown-menu,
    .card {
        transform: translateZ(0);
        will-change: transform;
    }
    
    /* Reduce repaints */
    .fixed-element {
        position: fixed;
        backface-visibility: hidden;
    }
}

