/* ============================================
   ISP CRM - Global Responsive Design System
   ============================================ */

/* Base Responsive Utilities */
* {
    box-sizing: border-box;
}

/* ============================================
   Tablet & Desktop (1200px and below)
   ============================================ */
@media (max-width: 1200px) {
    /* Page Headers */
    .page-header {
        flex-direction: column !important;
        align-items: flex-start !important;
        gap: 16px !important;
    }
    
    .page-actions {
        width: 100%;
        flex-wrap: wrap;
    }
    
    /* Grid Layouts - 4 columns to 2 columns */
    div[style*="grid-template-columns: repeat(4, 1fr)"],
    .dashboard-stats-grid,
    .stats-grid-4 {
        grid-template-columns: repeat(2, 1fr) !important;
    }
    
    /* Auto-fit grids */
    div[style*="grid-template-columns: auto 1fr"] {
        grid-template-columns: 1fr !important;
    }
}

/* ============================================
   Tablet (768px and below)
   ============================================ */
@media (max-width: 768px) {
    /* Container Padding - Removed as main-content now has proper padding */
    
    /* Page Headers */
    .page-header {
        flex-direction: column !important;
        align-items: flex-start !important;
        gap: 12px !important;
    }
    
    .page-actions {
        width: 100%;
        flex-wrap: wrap;
        gap: 8px !important;
    }
    
    .page-actions > * {
        flex: 1;
        min-width: 100px;
    }
    
    /* Typography */
    .page-title,
    h1[style*="font-size: 28px"] {
        font-size: 22px !important;
    }
    
    .page-subtitle,
    p[style*="font-size: 14px"] {
        font-size: 12px !important;
    }
    
    h2[style*="font-size: 32px"] {
        font-size: 24px !important;
    }
    
    h3[style*="font-size: 24px"] {
        font-size: 20px !important;
    }
    
    /* Buttons */
    .btn-modern,
    button[class*="btn-"] {
        padding: 8px 16px !important;
        font-size: 13px !important;
    }
    
    /* Grid Layouts - 4 or 2 columns to 2 columns */
    div[style*="grid-template-columns: repeat(4, 1fr)"],
    div[style*="grid-template-columns: repeat(3, 1fr)"],
    .dashboard-stats-grid,
    .stats-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 10px !important;
    }
    
    /* Auto-fit grids */
    div[style*="grid-template-columns: repeat(auto-fit, minmax(200px, 1fr))"] {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 12px !important;
    }
    
    /* Cards & Stats */
    .dashboard-stats-grid > div,
    div[style*="padding: 14px 16px"] {
        padding: 12px !important;
    }
    
    .dashboard-stats-grid h3,
    div[style*="font-size: 24px"] h3 {
        font-size: 20px !important;
    }
    
    .dashboard-stats-grid p,
    div[style*="font-size: 12px"] p {
        font-size: 11px !important;
    }
    
    /* Forms */
    #filterForm,
    form[style*="display: flex"] {
        flex-direction: column !important;
    }
    
    #filterForm > div,
    form > div[style*="flex: 1"] {
        width: 100% !important;
        min-width: 100% !important;
        flex: none !important;
    }
    
    /* Tables */
    .table-responsive {
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch !important;
    }
    
    table {
        min-width: 800px !important;
    }
    
    /* Modals */
    .modal-dialog {
        margin: 10px !important;
    }
    
    /* Flex Containers */
    div[style*="display: flex"][style*="flex-wrap: wrap"] {
        gap: 8px !important;
    }
}

/* ============================================
   Mobile (480px and below)
   ============================================ */
@media (max-width: 480px) {
    /* Container Padding - Removed as main-content now has proper padding */
    
    /* Typography */
    .page-title,
    h1 {
        font-size: 20px !important;
    }
    
    .page-subtitle {
        font-size: 11px !important;
    }
    
    h2 {
        font-size: 20px !important;
    }
    
    h3 {
        font-size: 18px !important;
    }
    
    /* Buttons */
    .btn-modern,
    .btn-action,
    button[class*="btn-"] {
        padding: 6px 12px !important;
        font-size: 12px !important;
    }
    
    .page-actions button,
    .page-actions a {
        min-width: 80px !important;
    }
    
    /* Grid Layouts - All to single column */
    div[style*="grid-template-columns: repeat(4, 1fr)"],
    div[style*="grid-template-columns: repeat(3, 1fr)"],
    div[style*="grid-template-columns: repeat(2, 1fr)"],
    div[style*="grid-template-columns: repeat(auto-fit"],
    .dashboard-stats-grid,
    .stats-grid {
        grid-template-columns: 1fr !important;
        gap: 8px !important;
    }
    
    /* Cards */
    .card {
        margin-bottom: 12px !important;
    }
    
    /* Tables */
    table {
        min-width: 600px !important;
        font-size: 12px !important;
    }
    
    table th,
    table td {
        padding: 8px 6px !important;
        font-size: 11px !important;
    }
    
    /* Action Buttons in Tables */
    .btn-action {
        padding: 4px 8px !important;
        font-size: 10px !important;
    }
    
    /* Icons */
    div[style*="width: 48px; height: 48px"] {
        width: 40px !important;
        height: 40px !important;
        font-size: 20px !important;
    }
    
    /* Modals */
    .modal-content {
        margin: 5px !important;
    }
    
    .modal-body {
        padding: 16px !important;
    }
    
    /* Forms */
    input[type="text"],
    input[type="email"],
    input[type="number"],
    input[type="date"],
    select,
    textarea {
        font-size: 14px !important;
    }
}

/* ============================================
   Specific Component Overrides
   ============================================ */

/* Sidebar Responsive */
@media (max-width: 992px) {
    .sidebar {
        transform: translateX(-100%);
        transition: transform 0.3s ease;
    }
    
    .sidebar.show {
        transform: translateX(0);
    }
}

/* Stats Cards */
@media (max-width: 768px) {
    .stat-card,
    .client-stat-card {
        min-height: auto !important;
    }
}

/* Filter Panels */
@media (max-width: 768px) {
    .filter-panel {
        position: fixed !important;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        z-index: 1000;
        background: white;
        overflow-y: auto;
    }
}

/* ============================================
   Utility Classes
   ============================================ */

/* Hide on Mobile */
.hide-mobile {
    display: block;
}

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

/* Show only on Mobile */
.show-mobile {
    display: none;
}

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

/* Responsive Text Alignment */
@media (max-width: 768px) {
    .text-center-mobile {
        text-align: center !important;
    }
}

/* Responsive Spacing */
@media (max-width: 768px) {
    .mb-mobile-2 {
        margin-bottom: 8px !important;
    }
    
    .mb-mobile-3 {
        margin-bottom: 12px !important;
    }
    
    .mb-mobile-4 {
        margin-bottom: 16px !important;
    }
}

/* ============================================
   Print Styles
   ============================================ */
@media print {
    .page-actions,
    .btn-modern,
    .sidebar,
    .no-print {
        display: none !important;
    }
    
    .page-header {
        margin-bottom: 20px !important;
    }
    
    table {
        page-break-inside: auto;
    }
    
    tr {
        page-break-inside: avoid;
        page-break-after: auto;
    }
}
