/* ==================== */
/* MOBILE OPTIMIZATION  */
/* ==================== */

/* Mobile Viewport Fix */
html {
    height: -webkit-fill-available;
}

body {
    min-height: 100vh;
    min-height: -webkit-fill-available;
}

/* Mobile Container */
@media (max-width: 768px) {
    .container-fluid {
        padding-left: 0.75rem;
        padding-right: 0.75rem;
        overflow-x: hidden;
    }
    
    /* Navbar Mobile */
    .navbar {
        padding: 0.5rem 0 !important;
        height: 60px;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        z-index: 1030;
    }
    
    .navbar-brand {
        font-size: 1rem;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        max-width: 150px;
    }
    
    .navbar-toggler {
        padding: 0.25rem 0.5rem;
        font-size: 1rem;
    }
    
    /* Mobile Overlay */
    .mobile-overlay {
        position: fixed;
        top: 60px;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0, 0, 0, 0.5);
        z-index: 1040;
        opacity: 0;
        visibility: hidden;
        transition: opacity 0.3s ease;
    }
    
    .mobile-overlay.show {
        opacity: 1;
        visibility: visible;
    }
    
    /* Sidebar Mobile */
    .sidebar {
        position: fixed;
        top: 60px;
        left: -280px;
        width: 280px;
        height: calc(100vh - 60px);
        z-index: 1050;
        background: var(--sidebar-bg);
        transition: left 0.3s ease;
        overflow-y: auto;
        box-shadow: 2px 0 10px rgba(0,0,0,0.1);
    }
    
    .sidebar.show {
        left: 0;
    }
    
    .sidebar-header {
        padding: 1rem;
        background: var(--bg-secondary);
    }
    
    /* Main Content */
    main {
        margin-top: 60px !important;
        padding: 1rem !important;
        min-height: calc(100vh - 60px);
    }
    
    /* Cards Mobile */
    .card {
        margin-bottom: 1rem;
        border-radius: 12px;
        border: 1px solid var(--border-color);
    }
    
    .card-body {
        padding: 1rem !important;
    }
    
    /* Stat Cards */
    .stats-grid {
        display: grid;
        grid-template-columns: 1fr;
        gap: 1rem;
    }
    
    .stat-card {
        margin-bottom: 0;
    }
    
    .stat-value {
        font-size: 1.5rem !important;
    }
    
    /* Forms Mobile */
    .form-control, .form-select {
        font-size: 16px !important;
        padding: 0.75rem !important;
        min-height: 44px;
    }
    
    .form-label {
        font-weight: 500;
        margin-bottom: 0.5rem;
    }
    
    /* Buttons Mobile */
    .btn {
        padding: 0.75rem 1rem !important;
        min-height: 44px;
        font-size: 1rem;
        border-radius: 8px;
    }
    
    /* Alerts Mobile */
    .alert-fixed-mobile {
        position: fixed;
        top: 80px;
        left: 1rem;
        right: 1rem;
        z-index: 1060;
        border-radius: 12px;
        padding: 1rem;
        box-shadow: 0 4px 12px rgba(0,0,0,0.15);
        animation: slideDown 0.3s ease;
    }
    
    @keyframes slideDown {
        from {
            transform: translateY(-20px);
            opacity: 0;
        }
        to {
            transform: translateY(0);
            opacity: 1;
        }
    }
    
    /* Tables Mobile */
    .table-responsive {
        margin: 0 -1rem;
        padding: 0 1rem;
    }
    
    .table {
        font-size: 0.875rem;
    }
    
    /* Hide desktop elements on mobile */
    .d-desktop-only {
        display: none !important;
    }
}

/* Small Phones */
@media (max-width: 480px) {
    .container-fluid {
        padding-left: 0.5rem;
        padding-right: 0.5rem;
    }
    
    main {
        padding: 0.75rem !important;
    }
    
    .card-body {
        padding: 0.75rem !important;
    }
    
    .btn {
        padding: 0.625rem 0.875rem !important;
    }
    
    h1 { font-size: 1.5rem !important; }
    h2 { font-size: 1.25rem !important; }
    h3 { font-size: 1.125rem !important; }
}

/* Tablet */
@media (min-width: 769px) and (max-width: 1024px) {
    .sidebar {
        width: 220px;
    }
    
    main {
        padding-left: 1.5rem !important;
        padding-right: 1.5rem !important;
    }
    
    .stats-grid {
        grid-template-columns: repeat(2, 1fr) !important;
    }
}

/* Touch Device Optimizations */
@media (hover: none) and (pointer: coarse) {
    /* Better touch targets */
    .btn, .nav-link, .form-check-label {
        min-height: 44px;
        display: inline-flex;
        align-items: center;
    }
    
    /* Remove hover effects */
    .btn:hover, .nav-link:hover {
        transform: none !important;
    }
    
    /* Better scrolling */
    * {
        -webkit-overflow-scrolling: touch;
    }
}

/* Dark Theme Mobile */
[data-theme="dark"] .mobile-overlay {
    background: rgba(0, 0, 0, 0.7);
}