/* Mobile Responsive Styles */

/* Mobile Menu Toggle Button */
.mobile-menu-toggle {
    display: none;
    position: fixed;
    top: 1rem;
    left: 1rem;
    z-index: 101;
    background: var(--primary-dark);
    color: white;
    border: none;
    border-radius: 8px;
    width: 44px;
    height: 44px;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: var(--shadow-md);
}

.mobile-menu-toggle span {
    display: block;
    width: 24px;
    height: 2px;
    background: white;
    margin: 5px 0;
    transition: 0.3s;
    position: relative;
}

.mobile-menu-toggle.active span:nth-child(1) {
    transform: rotate(-45deg) translate(-5px, 6px);
}

.mobile-menu-toggle.active span:nth-child(2) {
    opacity: 0;
}

.mobile-menu-toggle.active span:nth-child(3) {
    transform: rotate(45deg) translate(-5px, -6px);
}

/* Overlay for mobile menu */
.mobile-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 99;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.mobile-overlay.active {
    opacity: 1;
}

/* Tablet and Mobile Styles */
@media screen and (max-width: 1024px) {
    .mobile-menu-toggle { display: flex; flex-direction: column; }
    .mobile-overlay { display: block; pointer-events: none; }
    .mobile-overlay.active { pointer-events: auto; }
    .top-bar { padding-left: 4rem; }
}

/* Mobile Styles */
@media screen and (max-width: 768px) {
    /* Typography adjustments */
    body {
        font-size: 14px;
    }
    
    h1 {
        font-size: 1.75rem;
    }
    
    h2 {
        font-size: 1.5rem;
    }
    
    h3 {
        font-size: 1.25rem;
    }
    
    /* Page content adjustments */
    .page-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
        padding: 1rem;
    }
    
    .page-actions {
        width: 100%;
        justify-content: stretch;
    }
    
    .page-actions .btn {
        flex: 1;
    }
    
    /* Cards and containers */
    .dashboard-content {
        padding: 1rem;
    }
    
    .dashboard-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
    
    .stats-grid {
        grid-template-columns: 1fr;
    }
    
    .card {
        padding: 1rem;
    }
    
    /* Tables - Horizontal scrolling */
    .table-container {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        margin: 0 -1rem;
        padding: 0 1rem;
    }
    
    table {
        min-width: 600px;
    }
    
    /* Mobile-optimized table (stacked view) */
    @media screen and (max-width: 480px) {
        .mobile-table table,
        .mobile-table thead,
        .mobile-table tbody,
        .mobile-table th,
        .mobile-table td,
        .mobile-table tr {
            display: block;
        }
        
        .mobile-table thead tr {
            position: absolute;
            top: -9999px;
            left: -9999px;
        }
        
        .mobile-table tr {
            border: 1px solid var(--border-color);
            margin-bottom: 10px;
            border-radius: 8px;
            overflow: hidden;
        }
        
        .mobile-table td {
            border: none;
            position: relative;
            padding-left: 50%;
            padding-top: 0.5rem;
            padding-bottom: 0.5rem;
        }
        
        .mobile-table td:before {
            content: attr(data-label);
            position: absolute;
            left: 1rem;
            width: 45%;
            padding-right: 10px;
            white-space: nowrap;
            font-weight: 600;
            color: var(--text-gray);
        }
    }
    
    /* Forms */
    .form-grid {
        grid-template-columns: 1fr;
    }
    
    .form-group {
        margin-bottom: 1rem;
    }
    
    .form-group label {
        font-size: 0.875rem;
        margin-bottom: 0.5rem;
    }
    
    .form-control,
    .form-select,
    .form-textarea {
        font-size: 16px; /* Prevents zoom on iOS */
        padding: 0.75rem;
    }
    
    /* Modals */
    .modal {
        padding: 1rem;
    }
    
    .modal-content {
        width: 100%;
        max-width: none;
        margin: 0;
        max-height: 100vh;
        border-radius: 0;
    }
    
    .modal-header {
        padding: 1rem;
    }
    
    .modal-body {
        padding: 1rem;
        max-height: calc(100vh - 140px);
    }
    
    .modal-footer {
        padding: 1rem;
        flex-direction: column;
        gap: 0.5rem;
    }
    
    .modal-footer .btn {
        width: 100%;
    }
    
    /* Navigation tabs */
    .tabs {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        margin: 0 -1rem;
        padding: 0 1rem;
    }
    /* New name used for Projects-style button tabs */
    .tabbar {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        margin: 0 -1rem;
        padding: 0 1rem;
    }
    
    .tabs-list {
        min-width: max-content;
    }
    
    /* Dropdown menus */
    .dropdown-menu {
        position: fixed;
        left: 1rem !important;
        right: 1rem !important;
        width: auto !important;
    }
    
    /* Search bars */
    .search-box {
        width: 100%;
    }
    
    /* Filters */
    .filters-section {
        flex-direction: column;
        gap: 1rem;
    }
    
    .filter-group {
        width: 100%;
    }
    
    /* Sidebar width when explicitly expanded on mobile */
    .app-container.sidebar-expanded .sidebar {
        width: 85%;
        max-width: 280px;
    }
    
    /* Top bar adjustments */
    .top-bar {
        padding: 0.75rem 1rem;
        padding-left: 4rem;
    }
    
    .top-bar-content {
        gap: 0.5rem;
    }
    
    .user-menu {
        position: relative;
    }
    
    .user-dropdown {
        right: 0;
        left: auto;
    }
    
    /* Notification panel */
    .notifications-panel {
        position: fixed;
        top: 0;
        right: 0;
        left: 0;
        bottom: 0;
        width: 100%;
        max-width: none;
        border-radius: 0;
    }
    
    /* Charts and visualizations */
    .chart-container {
        height: 250px;
    }
    
    /* Buttons and actions */
    .btn-group {
        flex-direction: column;
        width: 100%;
    }
    
    .btn-group .btn {
        width: 100%;
        border-radius: 4px;
    }
    
    /* Timeline and activity feed */
    .timeline-item {
        padding-left: 2rem;
    }
    
    .timeline-item::before {
        left: 0.5rem;
    }
    
    /* Status badges */
    .status-badge {
        font-size: 0.75rem;
        padding: 0.25rem 0.5rem;
    }
    
    /* Pagination */
    .pagination {
        flex-wrap: wrap;
        justify-content: center;
    }
    
    /* Loading states */
    .skeleton {
        height: 60px;
    }
}

/* Small Mobile Styles */
@media screen and (max-width: 375px) {
    /* Further adjustments for very small screens */
    body {
        font-size: 13px;
    }
    
    .page-header {
        padding: 0.75rem;
    }
    
    .card {
        padding: 0.75rem;
    }
    
    .btn {
        padding: 0.5rem 1rem;
        font-size: 0.875rem;
    }
    
    .form-control,
    .form-select,
    .form-textarea {
        padding: 0.625rem;
    }
}

/* Touch-friendly adjustments */
@media (hover: none) and (pointer: coarse) {
    /* Increase touch targets */
    .btn,
    .nav-link,
    .dropdown-item,
    .chip {
        min-height: 44px;
        display: flex;
        align-items: center;
    }
    
    /* Remove hover effects on touch devices */
    .btn:hover,
    .nav-link:hover {
        background-color: inherit;
    }
    
    /* Add active states for touch feedback */
    .btn:active,
    .nav-link:active {
        transform: scale(0.98);
        opacity: 0.9;
    }
}

/* Landscape mobile adjustments */
@media screen and (max-width: 812px) and (orientation: landscape) {
    .sidebar {
        width: 240px;
    }
    
    .modal-content {
        max-height: 90vh;
    }
    
    .modal-body {
        max-height: calc(90vh - 120px);
    }
}

/* Print styles */
@media print {
    .sidebar,
    .mobile-menu-toggle,
    .top-bar,
    .page-actions,
    .btn,
    .modal {
        display: none !important;
    }
    
    .main-content {
        margin-left: 0 !important;
        width: 100% !important;
    }
    
    .card {
        page-break-inside: avoid;
    }
}
