/* Mobile Optimization Enhancements */

/* Mobil cihazlarda hamburger butonu için */
@media (max-width: 768px) {
    .hamburger-menu-btn {
        top: 140px;
        left: 15px;
        width: 48px;
        height: 48px;
    }
    
    .hamburger-menu-btn.active {
        left: 320px;
    }
    
    .sidebar {
        width: 300px;
        left: -320px;
    }
    
    /* Switch'leri küçült */
    .switch {
        width: 44px;
        height: 24px;
    }
    
    .switch input:checked + .slider:before {
        transform: translateX(20px);
    }
    
    .slider:before {
        height: 18px;
        width: 18px;
        left: 3px;
        bottom: 3px;
    }
    
    /* Yazı boyutlarını küçült */
    .sidebar-accordion-header {
        padding: 12px;
        font-size: 13px;
    }
    
    .section-title {
        font-size: 14px;
    }
    
    .item-name {
        font-size: 13px;
    }
    
    .item-count {
        font-size: 11px;
    }
    
    .search-box input {
        padding: 10px 12px;
        font-size: 13px;
    }
    
    .toggle-all-btn {
        font-size: 11px;
        padding: 5px 10px;
    }
}

@media (max-width: 480px) {
    .hamburger-menu-btn {
        top: 130px;
        left: 10px;
        width: 45px;
        height: 45px;
        gap: 5px;
    }
    
    .hamburger-menu-btn span {
        width: 22px;
        height: 2.5px;
    }
    
    .hamburger-menu-btn.active {
        left: 280px;
    }
    
    .sidebar {
        width: 270px;
        left: -290px;
        padding: 15px;
    }
    
    /* Switch'leri daha küçült */
    .switch {
        width: 40px;
        height: 22px;
    }
    
    .switch input:checked + .slider:before {
        transform: translateX(18px);
    }
    
    .slider:before {
        height: 16px;
        width: 16px;
        left: 3px;
        bottom: 3px;
    }
    
    /* Küçük ekranlarda yazıları daha da küçült */
    .sidebar-accordion-header {
        padding: 10px;
        font-size: 12px;
    }
    
    .section-title {
        font-size: 13px;
    }
    
    .item-name {
        font-size: 12px;
    }
    
    .item-count {
        font-size: 10px;
    }
    
    .search-box input {
        padding: 9px 11px;
        font-size: 12px;
    }
    
    .toggle-all-btn {
        font-size: 10px;
        padding: 4px 8px;
    }
    
    .accordion-arrow {
        font-size: 12px !important;
    }
    
    /* Item spacing'i küçült */
    .item-with-switch {
        padding: 10px;
        gap: 10px;
    }
}

/* Better touch feedback */
button, a, .item, .item-with-switch, .icon-btn, .map-btn, 
.toggle-all-btn, .day-btn, .basemap-btn {
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    user-select: none;
    -webkit-user-select: none;
}

/* Better form controls on mobile */
input, select, textarea {
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
}

/* Prevent text size adjustment on mobile */
body {
    -webkit-text-size-adjust: 100%;
    -moz-text-size-adjust: 100%;
    -ms-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

/* Safe area insets for notch devices */
@supports (padding: max(0px)) {
    .sidebar {
        padding-top: max(20px, env(safe-area-inset-top));
        padding-left: max(20px, env(safe-area-inset-left));
        padding-right: max(20px, env(safe-area-inset-right));
        padding-bottom: max(20px, env(safe-area-inset-bottom));
    }
    
    .map-container {
        padding-bottom: env(safe-area-inset-bottom);
    }
    
    .schedule-panel {
        padding-top: env(safe-area-inset-top);
        padding-bottom: env(safe-area-inset-bottom);
    }
}

/* Hardware acceleration for smooth animations */
.sidebar, .mobile-overlay, .schedule-panel,
.dropdown-menu, .accordion-content {
    transform: translateZ(0);
    -webkit-transform: translateZ(0);
    will-change: transform;
}

/* Better scrolling performance */
.item-list, .schedule-content, .accordion-content, .sidebar {
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    scroll-behavior: smooth;
}

/* Optimize leaflet map for mobile */
@media (max-width: 768px) {
    .leaflet-container {
        touch-action: pan-y pan-x;
    }
    
    .leaflet-touch .leaflet-control-layers,
    .leaflet-touch .leaflet-bar {
        border: 2px solid rgba(0,0,0,0.2);
    }
    
    .leaflet-touch .leaflet-control-attribution {
        font-size: 10px;
    }
    
    /* Larger touch targets for map controls */
    .leaflet-bar a {
        width: 40px;
        height: 40px;
        line-height: 40px;
        font-size: 20px;
    }
    
    .leaflet-touch .leaflet-bar a:first-child {
        border-radius: 8px 8px 0 0;
    }
    
    .leaflet-touch .leaflet-bar a:last-child {
        border-radius: 0 0 8px 8px;
    }
    
    /* Optimize marker clusters for mobile */
    .marker-cluster-small, .marker-cluster-medium, .marker-cluster-large {
        font-size: 14px !important;
    }
    
    .marker-cluster-small div, .marker-cluster-medium div, .marker-cluster-large div {
        width: 36px !important;
        height: 36px !important;
        margin-left: 5px !important;
        margin-top: 5px !important;
        line-height: 36px !important;
    }
}

/* Improve input focus states on mobile */
@media (max-width: 768px) {
    input:focus, select:focus, textarea:focus {
        font-size: 16px; /* Prevents zoom on iOS */
        outline: none;
        border-color: #667eea;
        box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.15);
    }
}

/* Better button active states */
@media (hover: none) and (pointer: coarse) {
    button:active, .icon-btn:active, .map-btn:active,
    .toggle-all-btn:active, .day-btn:active {
        transform: scale(0.95);
        opacity: 0.8;
    }
    
    .item:active, .item-with-switch:active {
        background: #f0f4ff;
    }
}

/* Optimize images for mobile */
img {
    max-width: 100%;
    height: auto;
    image-rendering: -webkit-optimize-contrast;
}

/* Better table/grid layouts on mobile */
@media (max-width: 768px) {
    table {
        display: block;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
}

/* Accessibility improvements for mobile */
@media (max-width: 768px) {
    /* Ensure minimum touch target size */
    button, a, input[type="checkbox"], input[type="radio"],
    .switch, .icon-btn, .toggle-all-btn {
        min-width: 44px;
        min-height: 44px;
    }
    
    /* Better focus indicators */
    *:focus-visible {
        outline: 3px solid #667eea;
        outline-offset: 2px;
    }
}

/* Reduce motion for users who prefer it */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

/* Dark mode support for mobile */
@media (prefers-color-scheme: dark) {
    /* Add dark mode styles here if needed in the future */
}

/* Print styles for mobile */
@media print {
    .mobile-menu-toggle,
    .mobile-overlay,
    .sidebar,
    .map-controls {
        display: none !important;
    }
    
    #map {
        height: 80vh !important;
    }
}

/* Landscape orientation optimizations */
@media (max-width: 900px) and (orientation: landscape) {
    .sidebar {
        max-width: 50vw;
    }
    
    .map-header {
        padding: 8px 12px;
    }
    
    .map-header-title {
        font-size: 12px;
    }
    
    .icon-btn {
        min-width: 36px;
        height: 36px;
    }
}

/* Very small devices (older phones) */
@media (max-width: 360px) {
    .sidebar {
        width: 95%;
        padding: 12px;
    }
    
    .icon-btn {
        min-width: 40px;
        height: 40px;
        padding: 8px;
        font-size: 14px;
    }
    
    .search-box input {
        padding: 12px;
        font-size: 15px;
    }
}

/* High DPI displays */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    .icon-btn, .map-btn, .toggle-all-btn {
        border-width: 0.5px;
    }
}
