/* ===== MOBILE RESPONSIVE CSS ===== */

/* ===== MOBILE BREAKPOINTS ===== */
/* Tablet: 768px - 1024px */
/* Mobile: < 768px */

/* ===== MOBILE NAVIGATION ===== */
.mobile-nav {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 60px;
    background: var(--bg-secondary);
    border-top: 1px solid var(--border-color);
    z-index: 1000;
    padding: 0 var(--spacing-sm);
}

.mobile-nav-items {
    display: flex;
    align-items: center;
    justify-content: space-around;
    height: 100%;
}

.mobile-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: var(--spacing-xs) var(--spacing-md);
    background: transparent;
    border: none;
    color: var(--text-tertiary);
    font-size: 10px;
    cursor: pointer;
    transition: all var(--transition-fast);
    border-radius: var(--radius-md);
}

.mobile-nav-item .nav-icon {
    font-size: 20px;
}

.mobile-nav-item.active {
    color: var(--accent-primary);
    background: rgba(0, 212, 255, 0.1);
}

.mobile-nav-item:active {
    transform: scale(0.95);
}

/* ===== MOBILE HEADER ===== */
.mobile-header {
    display: none;
}

/* ===== MOBILE FLOATING BUTTONS ===== */
.mobile-fab-container {
    display: none;
    position: fixed;
    right: var(--spacing-md);
    bottom: 80px;
    flex-direction: column;
    gap: var(--spacing-sm);
    z-index: 500;
}

.mobile-fab {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    cursor: pointer;
    box-shadow: var(--shadow-lg);
    transition: all var(--transition-normal);
}

.mobile-fab.primary {
    background: var(--accent-gradient);
    color: white;
}

.mobile-fab.secondary {
    background: var(--bg-card);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.mobile-fab:active {
    transform: scale(0.9);
}

.mobile-fab.primary:hover {
    box-shadow: var(--shadow-glow);
}

/* ===== MOBILE BOTTOM SHEET ===== */
.mobile-bottom-sheet {
    display: none;
    position: fixed;
    bottom: 60px;
    left: 0;
    right: 0;
    background: var(--bg-secondary);
    border-radius: var(--radius-xl) var(--radius-xl) 0 0;
    z-index: 900;
    max-height: 70vh;
    transform: translateY(calc(100% - 48px));
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 -4px 30px rgba(0, 0, 0, 0.3);
}

.mobile-bottom-sheet.expanded {
    transform: translateY(0);
}

.sheet-handle-area {
    display: flex;
    justify-content: center;
    padding: var(--spacing-sm) 0;
    cursor: grab;
}

.sheet-handle {
    width: 40px;
    height: 4px;
    background: var(--text-muted);
    border-radius: var(--radius-full);
}

.sheet-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 var(--spacing-md) var(--spacing-sm);
    border-bottom: 1px solid var(--border-color);
}

.sheet-header h3 {
    font-size: var(--font-size-md);
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
}

.sheet-tabs {
    display: flex;
    gap: var(--spacing-xs);
    padding: var(--spacing-sm) var(--spacing-md);
    background: var(--bg-tertiary);
}

.sheet-tab {
    flex: 1;
    padding: var(--spacing-sm) var(--spacing-md);
    border: none;
    background: transparent;
    color: var(--text-tertiary);
    font-size: var(--font-size-sm);
    font-weight: 500;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.sheet-tab.active {
    background: var(--accent-gradient);
    color: white;
}

.sheet-content {
    padding: var(--spacing-md);
    overflow-y: auto;
    max-height: calc(70vh - 120px);
}

.sheet-section {
    margin-bottom: var(--spacing-lg);
}

.sheet-section-title {
    font-size: var(--font-size-sm);
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: var(--spacing-sm);
    display: flex;
    align-items: center;
    gap: var(--spacing-xs);
}

/* ===== MOBILE QUICK ACTIONS ===== */
.mobile-quick-actions {
    display: none;
    position: fixed;
    top: 70px;
    left: var(--spacing-sm);
    right: var(--spacing-sm);
    z-index: 400;
}

.quick-action-row {
    display: flex;
    gap: var(--spacing-xs);
    overflow-x: auto;
    padding: var(--spacing-xs) 0;
    scrollbar-width: none;
}

.quick-action-row::-webkit-scrollbar {
    display: none;
}

.quick-action-chip {
    display: flex;
    align-items: center;
    gap: var(--spacing-xs);
    padding: var(--spacing-sm) var(--spacing-md);
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-full);
    color: var(--text-secondary);
    font-size: var(--font-size-sm);
    white-space: nowrap;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.quick-action-chip:active {
    background: var(--accent-primary);
    color: white;
    border-color: var(--accent-primary);
}

.quick-action-chip.active {
    background: rgba(0, 212, 255, 0.15);
    border-color: var(--accent-primary);
    color: var(--accent-primary);
}

/* ===== MOBILE STATS OVERLAY ===== */
.mobile-stats-bar {
    display: none;
    position: fixed;
    top: 60px;
    left: 0;
    right: 0;
    padding: var(--spacing-sm) var(--spacing-md);
    background: var(--bg-glass);
    backdrop-filter: blur(10px);
    z-index: 300;
    border-bottom: 1px solid var(--border-color);
}

.mobile-stats-row {
    display: flex;
    justify-content: space-around;
}

.mobile-stat {
    text-align: center;
}

.mobile-stat-value {
    font-size: var(--font-size-md);
    font-weight: 700;
    color: var(--text-primary);
}

.mobile-stat-label {
    font-size: 10px;
    color: var(--text-tertiary);
}

/* ===== MOBILE MAP CONTROLS ===== */
@media (max-width: 768px) {
    .map-controls {
        bottom: 140px;
        right: var(--spacing-sm);
    }

    .map-control-btn {
        width: 44px;
        height: 44px;
        font-size: 18px;
    }

    .map-legend {
        left: var(--spacing-sm);
        bottom: 140px;
        max-width: calc(100% - 80px);
        font-size: var(--font-size-xs);
    }
}

/* ===== MOBILE STORE POPUP ===== */
@media (max-width: 768px) {
    .leaflet-popup-content-wrapper {
        max-width: calc(100vw - 40px) !important;
    }

    .store-popup {
        min-width: 240px;
    }

    .popup-actions {
        flex-direction: column;
    }

    .popup-actions button {
        width: 100%;
    }
}

/* ===== TABLET STYLES (768px - 1024px) ===== */
@media (max-width: 1024px) and (min-width: 769px) {
    :root {
        --sidebar-width: 280px;
        --stats-width: 260px;
    }

    .stats-panel {
        display: none;
    }

    .control-panel {
        width: var(--sidebar-width);
    }
}

/* ===== MOBILE STYLES (< 768px) ===== */
@media (max-width: 768px) {

    /* Hide desktop elements */
    .app-header .header-center,
    .control-panel,
    .stats-panel {
        display: none !important;
    }

    /* Show mobile elements */
    .mobile-nav,
    .mobile-fab-container,
    .mobile-bottom-sheet,
    .mobile-quick-actions,
    .mobile-stats-bar {
        display: flex;
    }

    .mobile-bottom-sheet {
        display: block;
    }

    /* Mobile header */
    .app-header {
        padding: 0 var(--spacing-sm);
    }

    .logo-text {
        font-size: var(--font-size-base);
    }

    .logo-icon {
        font-size: 22px;
    }

    .header-btn {
        width: 36px;
        height: 36px;
        font-size: 16px;
    }

    /* Map container */
    .map-wrapper {
        width: 100%;
        height: calc(100vh - var(--header-height));
    }

    .app-main {
        flex-direction: column;
    }

    /* Adjust for bottom nav */
    .map-container {
        height: calc(100vh - var(--header-height) - 60px);
    }

    /* Loading overlay */
    .loading-overlay {
        bottom: 60px;
    }

    /* Toast positioning */
    .toast-container {
        bottom: 130px;
        left: var(--spacing-sm);
        right: var(--spacing-sm);
    }

    .toast {
        width: 100%;
        min-width: auto;
    }
}

/* ===== SMALL MOBILE (< 375px) ===== */
@media (max-width: 375px) {
    .mobile-nav-item {
        padding: var(--spacing-xs);
    }

    .mobile-nav-item .nav-icon {
        font-size: 18px;
    }

    .mobile-fab {
        width: 48px;
        height: 48px;
        font-size: 20px;
    }

    .quick-action-chip {
        padding: 6px 10px;
        font-size: 12px;
    }
}

/* ===== LANDSCAPE MOBILE ===== */
@media (max-width: 768px) and (orientation: landscape) {
    .mobile-bottom-sheet {
        max-height: 60vh;
    }

    .mobile-stats-bar {
        display: none;
    }

    .mobile-quick-actions {
        top: 60px;
    }

    .map-controls {
        bottom: 80px;
    }
}

/* ===== TOUCH OPTIMIZATIONS ===== */
@media (hover: none) and (pointer: coarse) {

    /* Larger touch targets */
    .btn-small {
        padding: 10px 14px;
        font-size: var(--font-size-sm);
    }

    .checkbox-item,
    .store-item {
        padding: 12px;
    }

    .slider-modern::-webkit-slider-thumb {
        width: 24px;
        height: 24px;
    }

    /* Remove hover effects */
    .btn-primary:hover,
    .btn-secondary:hover,
    .header-btn:hover {
        transform: none;
    }

    /* Active states instead */
    .btn-primary:active {
        transform: scale(0.98);
        opacity: 0.9;
    }
}

/* ===== DARK MODE SAFE AREA (for notched phones) ===== */
@supports (padding-top: env(safe-area-inset-top)) {
    .app-header {
        padding-top: env(safe-area-inset-top);
        height: calc(var(--header-height) + env(safe-area-inset-top));
    }

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

    .mobile-bottom-sheet {
        bottom: calc(60px + env(safe-area-inset-bottom));
    }
}

/* ===== ANIMATIONS FOR MOBILE ===== */
@keyframes slideUp {
    from {
        transform: translateY(100%);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

@keyframes fadeSlideUp {
    from {
        transform: translateY(20px);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.mobile-nav {
    animation: slideUp 0.3s ease-out;
}

.mobile-fab-container {
    animation: fadeSlideUp 0.4s ease-out 0.2s both;
}