/* Responsive Design Styles for Mobile and Tablet */

/* Mobile First Approach */

/* Prevent body scroll when mobile menu is open */
body.menu-open {
    overflow: hidden;
}

/* Mobile (max-width: 640px) */
@media (max-width: 640px) {
    /* Sidebar adjustments */
    #sidebar {
        width: 280px;
    }
    
    /* Header adjustments */
    header h1 {
        font-size: 1.125rem;
    }
    
    /* Content padding */
    #main-container {
        padding: 1rem;
    }
    
    /* Stats grid - 1 column on mobile */
    .stats-grid {
        grid-template-columns: 1fr !important;
    }
    
    /* Cards spacing */
    .card {
        margin-bottom: 1rem;
    }
    
    /* Tables - make scrollable */
    .table-responsive {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    .table-responsive table {
        min-width: 600px;
    }
    
    /* Form adjustments */
    .form-group {
        margin-bottom: 1rem;
    }
    
    /* Button groups */
    .btn-group {
        flex-direction: column;
        gap: 0.5rem;
    }
    
    .btn-group button,
    .btn-group a {
        width: 100%;
    }
    
    /* Filters - horizontal scroll */
    .filters-container {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        padding-bottom: 0.5rem;
    }
    
    /* Hide some elements on mobile */
    .hide-mobile {
        display: none !important;
    }
}

/* Tablet (641px - 1023px) */
@media (min-width: 641px) and (max-width: 1023px) {
    /* Sidebar can be toggled */
    #sidebar {
        width: 240px;
    }
    
    /* Stats grid - 2 columns on tablet */
    .stats-grid {
        grid-template-columns: repeat(2, 1fr) !important;
    }
    
    /* Tables - still scrollable but with more space */
    .table-responsive {
        overflow-x: auto;
    }
    
    /* Form adjustments */
    .form-row {
        flex-direction: column;
    }
    
    /* Show tablet-specific elements */
    .show-tablet {
        display: block !important;
    }
}

/* Desktop (min-width: 1024px) */
@media (min-width: 1024px) {
    /* Sidebar always visible */
    #sidebar {
        transform: translateX(0) !important;
    }
    
    /* Hide mobile menu overlay */
    #mobile-menu-overlay {
        display: none !important;
    }
    
    /* Show desktop-specific elements */
    .show-desktop {
        display: block !important;
    }
}

/* Table Responsive Styles */
@media (max-width: 768px) {
    /* Convert tables to card layout on mobile */
    .table-mobile-card {
        display: block;
        width: 100%;
    }
    
    .table-mobile-card thead {
        display: none;
    }
    
    .table-mobile-card tbody {
        display: block;
    }
    
    .table-mobile-card tr {
        display: block;
        margin-bottom: 1rem;
        border: 1px solid #e2e8f0;
        border-radius: 0.5rem;
        background: white;
        padding: 1rem;
        box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    }
    
    .table-mobile-card td {
        display: flex;
        justify-content: space-between;
        align-items: flex-start;
        padding: 0.75rem 0;
        border: none;
        text-align: right;
        flex-wrap: wrap;
    }
    
    .table-mobile-card td::before {
        content: attr(data-label);
        font-weight: 600;
        color: #64748b;
        text-align: left;
        margin-right: 1rem;
        flex: 1;
        min-width: 120px;
    }
    
    .table-mobile-card td:first-child {
        font-weight: 700;
        font-size: 1.125rem;
        color: #1e293b;
        border-bottom: 1px solid #e2e8f0;
        padding-bottom: 0.75rem;
        margin-bottom: 0.5rem;
        display: block;
        width: 100%;
    }
    
    .table-mobile-card td:first-child::before {
        display: none;
    }
    
    .table-mobile-card td:last-child {
        border-top: 1px solid #f1f5f9;
        padding-top: 0.75rem;
        margin-top: 0.5rem;
    }
    
    /* Action buttons in mobile cards */
    .table-mobile-card td[data-label="Action"],
    .table-mobile-card td[data-label="Actions"] {
        justify-content: center;
        gap: 0.5rem;
    }
    
    .table-mobile-card td[data-label="Action"]::before,
    .table-mobile-card td[data-label="Actions"]::before {
        display: none;
    }
}

/* Form Responsive Styles */
@media (max-width: 768px) {
    /* Form containers */
    .form-container {
        padding: 1rem;
    }
    
    /* Form rows stack on mobile */
    .form-row {
        flex-direction: column;
    }
    
    /* Form columns full width on mobile */
    .form-col,
    .col-md-6,
    .col-md-8,
    .col-md-4 {
        width: 100% !important;
        margin-bottom: 1rem;
    }
    
    /* Inputs full width */
    .form-control,
    .form-select {
        width: 100%;
    }
    
    /* Button groups stack */
    .form-actions {
        flex-direction: column;
        gap: 0.75rem;
    }
    
    .form-actions button,
    .form-actions a {
        width: 100%;
    }
    
    /* Crispy forms rows */
    .row {
        margin-left: 0;
        margin-right: 0;
    }
    
    .row > [class*="col-"] {
        padding-left: 0;
        padding-right: 0;
    }
}

/* Grid Responsive Adjustments */
@media (max-width: 640px) {
    /* Dashboard stats - 1 column */
    .dashboard-stats {
        grid-template-columns: 1fr !important;
    }
    
    /* Dashboard content - 1 column */
    .dashboard-content {
        grid-template-columns: 1fr !important;
    }
    
    /* Stats cards smaller padding on mobile */
    .dashboard-stats > div {
        padding: 1rem;
    }
    
    .dashboard-stats p.text-2xl {
        font-size: 1.5rem;
    }
}

@media (min-width: 641px) and (max-width: 1023px) {
    /* Dashboard stats - 2 columns */
    .dashboard-stats {
        grid-template-columns: repeat(2, 1fr) !important;
    }
}

/* Navigation Responsive */
@media (max-width: 1023px) {
    /* Sidebar navigation items */
    .nav-item {
        padding: 0.75rem 1rem;
        font-size: 0.875rem;
    }
    
    /* Sidebar logo */
    .sidebar-logo {
        padding: 1rem;
    }
    
    .sidebar-logo span {
        font-size: 1.125rem;
    }
    
    /* Ensure sidebar is above content */
    #sidebar {
        position: fixed;
        height: 100vh;
        z-index: 50;
    }
    
    /* Main content adjustment when sidebar is open */
    main {
        width: 100%;
    }
}

/* Modal Responsive */
@media (max-width: 768px) {
    .modal-content {
        width: 95%;
        max-width: 95%;
        margin: 1rem auto;
        max-height: 90vh;
    }
    
    .modal-header {
        padding: 1rem;
    }
    
    .modal-body {
        padding: 1rem;
    }
}

/* Utility Classes */
.mobile-only {
    display: block;
}

.desktop-only {
    display: none;
}

@media (min-width: 1024px) {
    .mobile-only {
        display: none;
    }
    
    .desktop-only {
        display: block;
    }
}

/* Touch-friendly elements */
@media (max-width: 1024px) {
    /* Larger touch targets */
    button,
    a,
    .clickable {
        min-height: 44px;
        min-width: 44px;
    }
    
    /* Better spacing for touch */
    .touch-spacing {
        padding: 0.75rem;
    }
}

/* Print styles */
@media print {
    #sidebar,
    header,
    .no-print {
        display: none !important;
    }
    
    #main-container {
        padding: 0;
        margin: 0;
    }
}

