/* Nexus CRM - Mobile Responsive Styles */

/* ========== Base Mobile Styles ========== */
@media (max-width: 768px) {
    /* Hide sidebar on mobile */
    .sidebar {
        position: fixed;
        left: -100%;
        top: 0;
        bottom: 0;
        width: 280px;
        z-index: 1000;
        transition: left 0.3s ease;
    }
    
    .sidebar.open {
        left: 0;
    }
    
    /* Main content full width */
    main {
        width: 100%;
    }
    
    /* Mobile header */
    .mobile-header {
        display: flex !important;
        align-items: center;
        justify-content: space-between;
        padding: 12px 16px;
        background: rgba(15, 23, 42, 0.95);
        backdrop-filter: blur(10px);
        border-bottom: 1px solid rgba(56, 189, 248, 0.2);
        position: sticky;
        top: 0;
        z-index: 100;
    }
    
    .desktop-header {
        display: none;
    }
    
    /* Menu button */
    .menu-button {
        display: flex !important;
        align-items: center;
        justify-content: center;
        width: 40px;
        height: 40px;
        border-radius: 8px;
        background: rgba(56, 189, 248, 0.1);
        border: none;
        cursor: pointer;
    }
    
    .menu-button:active {
        background: rgba(56, 189, 248, 0.2);
    }
    
    /* Overlay */
    .sidebar-overlay {
        display: none;
        position: fixed;
        inset: 0;
        background: rgba(0, 0, 0, 0.5);
        z-index: 999;
        opacity: 0;
        transition: opacity 0.3s ease;
    }
    
    .sidebar-overlay.show {
        display: block;
        opacity: 1;
    }
    
    /* Content padding */
    .p-8 {
        padding: 16px !important;
    }
    
    /* Cards */
    .glass-card {
        border-radius: 12px !important;
        padding: 16px !important;
    }
    
    /* Stats cards */
    .metric-card, .stat-card {
        padding: 16px !important;
    }
    
    /* Tables - make scrollable */
    .overflow-x-auto {
        -webkit-overflow-scrolling: touch;
    }
    
    table {
        min-width: 600px;
    }
    
    /* Buttons */
    .btn-primary, button {
        min-height: 44px; /* Touch target size */
    }
    
    /* Form inputs */
    input, select, textarea {
        min-height: 44px;
        font-size: 16px; /* Prevent zoom on iOS */
    }
    
    /* Modal adjustments */
    .modal-overlay {
        padding: 16px;
    }
    
    .modal-content {
        max-height: 90vh;
        overflow-y: auto;
    }
    
    /* Hide desktop-only elements */
    .hidden-mobile {
        display: none !important;
    }
}

/* ========== Tablet Styles ========== */
@media (min-width: 769px) and (max-width: 1024px) {
    .p-8 {
        padding: 24px !important;
    }
    
    .grid-cols-4 {
        grid-template-columns: repeat(2, 1fr) !important;
    }
    
    .grid-cols-3 {
        grid-template-columns: repeat(2, 1fr) !important;
    }
}

/* ========== Mobile Navigation ========== */
@media (max-width: 768px) {
    /* Bottom navigation for mobile */
    .mobile-nav {
        display: flex !important;
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        background: rgba(15, 23, 42, 0.95);
        backdrop-filter: blur(10px);
        border-top: 1px solid rgba(56, 189, 248, 0.2);
        z-index: 100;
        padding: 8px 0;
        padding-bottom: env(safe-area-inset-bottom);
    }
    
    .mobile-nav-item {
        flex: 1;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        padding: 8px 4px;
        color: #94a3b8;
        text-decoration: none;
        font-size: 11px;
        gap: 4px;
    }
    
    .mobile-nav-item.active {
        color: #38bdf8;
    }
    
    .mobile-nav-item i {
        width: 24px;
        height: 24px;
    }
    
    .desktop-nav {
        display: none !important;
    }
}

/* ========== Mobile Optimizations ========== */
@media (max-width: 768px) {
    /* Typography */
    h1 { font-size: 20px !important; }
    h2 { font-size: 18px !important; }
    h3 { font-size: 16px !important; }
    
    /* Search bar */
    .search-input {
        font-size: 16px;
    }
    
    /* Cards in grid */
    .grid-cols-2, .grid-cols-3, .grid-cols-4 {
        grid-template-columns: 1fr !important;
        gap: 12px !important;
    }
    
    /* Action buttons */
    .action-buttons {
        display: flex;
        gap: 8px;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        padding-bottom: 8px;
    }
    
    .action-buttons button {
        flex-shrink: 0;
        white-space: nowrap;
    }
    
    /* Filter dropdowns */
    select {
        max-width: 100%;
    }
    
    /* Pagination */
    .pagination {
        display: flex;
        justify-content: center;
        gap: 4px;
    }
    
    .pagination button {
        min-width: 36px;
        padding: 8px;
    }
    
    /* Toast notifications */
    .toast {
        left: 16px;
        right: 16px;
        bottom: 80px; /* Above mobile nav */
        text-align: center;
    }
    
    /* Loading states */
    .loading-skeleton {
        border-radius: 8px;
    }
    
    /* Empty states */
    .empty-state {
        padding: 40px 20px !important;
    }
}

/* ========== Touch Optimizations ========== */
@media (max-width: 768px) {
    /* Larger touch targets */
    a, button, input, select, textarea {
        min-height: 44px;
        min-width: 44px;
    }
    
    /* Remove hover effects on mobile */
    .hover\:bg-gray-800:hover {
        background: transparent;
    }
    
    /* Active states instead */
    .active-state:active {
        background: rgba(56, 189, 248, 0.1);
    }
    
    /* Swipeable cards */
    .swipe-card {
        touch-action: pan-y;
    }
    
    /* Pull to refresh indicator */
    .ptr-indicator {
        position: absolute;
        top: -60px;
        left: 0;
        right: 0;
        text-align: center;
        padding: 10px;
        color: #94a3b8;
    }
}

/* ========== Safe Area Insets (iPhone X+) ========== */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
    .mobile-nav {
        padding-bottom: env(safe-area-inset-bottom);
    }
    
    .toast {
        bottom: calc(80px + env(safe-area-inset-bottom));
    }
}

/* ========== Landscape Mode ========== */
@media (max-width: 768px) and (orientation: landscape) {
    .mobile-nav {
        display: none !important;
    }
    
    .sidebar {
        width: 200px;
    }
}

/* ========== Print Styles ========== */
@media print {
    .sidebar, .mobile-header, .mobile-nav, .action-buttons {
        display: none !important;
    }
    
    main {
        padding: 0 !important;
    }
    
    .glass-card {
        border: 1px solid #ccc !important;
        box-shadow: none !important;
    }
}

/* ========== Utility Classes ========== */
.show-mobile { display: none; }
.hide-mobile { display: block; }

@media (max-width: 768px) {
    .show-mobile { display: block !important; }
    .hide-mobile { display: none !important; }
}

/* Flex utilities for mobile */
@media (max-width: 768px) {
    .flex-mobile-col {
        flex-direction: column !important;
    }
    
    .gap-mobile-sm {
        gap: 8px !important;
    }
    
    .gap-mobile-md {
        gap: 12px !important;
    }
}
