/* ========================================
   RESPONSIVE DESIGN GLOBAL FIXES
   ======================================== */

/* Mobile First Approach - Base Styles */
@media (max-width: 480px) {
    /* Typography */
    html {
        font-size: 14px;
    }
    
    h1 { font-size: 1.75rem; }
    h2 { font-size: 1.5rem; }
    h3 { font-size: 1.25rem; }
    h4 { font-size: 1.1rem; }
    
    /* Layout */
    .container,
    .content {
        padding: 0.75rem;
        max-width: 100%;
    }
    
    /* Navigation */
    .navbar {
        padding: 0.5rem 1rem;
        height: auto;
        min-height: 60px;
    }
    
    .navbar-brand h1 {
        font-size: 1.2rem;
    }
    
    .navbar-actions {
        gap: 0.5rem;
        margin-right: 1rem;
    }
    
    .btn {
        padding: 0.5rem 1rem;
        font-size: 0.9rem;
    }
    
    .btn-sm {
        padding: 0.4rem 0.8rem;
        font-size: 0.8rem;
    }
    
    /* Sidebar */
    .sidebar {
        width: 100%;
        max-width: 280px;
        transform: translateX(-100%);
        position: fixed;
        top: 0;
        left: 0;
        height: 100vh;
        z-index: 9999;
        box-shadow: 2px 0 10px rgba(0,0,0,0.1);
    }
    
    .sidebar.open {
        transform: translateX(0);
    }
    
    .sidebar-toggle {
        display: block !important;
        position: fixed;
        top: 15px;
        left: 15px;
        z-index: 10000;
        background: var(--primary-color);
        color: white;
        border: none;
        padding: 0.5rem;
        border-radius: 4px;
        cursor: pointer;
    }
    
    /* Main Content */
    .main-content {
        margin-left: 0;
        width: 100%;
    }
    
    .content {
        padding: 1rem 0.75rem;
        margin-top: 60px;
    }
    
    /* Grids */
    .stats-grid,
    .dashboard-grid,
    .features-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
    
    .grid-2 { grid-template-columns: 1fr; }
    .grid-3 { grid-template-columns: 1fr; }
    .grid-4 { grid-template-columns: repeat(2, 1fr); }
    
    /* Cards */
    .card,
    .stat-card {
        padding: 1rem;
        margin-bottom: 1rem;
    }
    
    .stat-value {
        font-size: 1.5rem;
    }
    
    /* Forms */
    .form-group {
        margin-bottom: 1rem;
    }
    
    .form-row {
        flex-direction: column;
        gap: 1rem;
    }
    
    .form-control {
        font-size: 16px; /* Prevent zoom on iOS */
        padding: 0.75rem;
    }
    
    /* Tables */
    .table-responsive {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    table {
        font-size: 0.9rem;
    }
    
    th, td {
        padding: 0.5rem;
        white-space: nowrap;
    }
    
    /* Modals */
    .modal {
        padding: 1rem;
    }
    
    .modal-content {
        margin: 0;
        max-width: 100%;
        max-height: 100vh;
        border-radius: 0;
    }
    
    .modal-header {
        padding: 1rem;
    }
    
    .modal-body {
        padding: 1rem;
        max-height: calc(100vh - 120px);
        overflow-y: auto;
    }
    
    /* Notifications */
    .notification,
    .alert {
        padding: 0.75rem;
        margin: 0.5rem;
        font-size: 0.9rem;
    }
    
    /* Buttons */
    .btn-group {
        flex-direction: column;
        gap: 0.5rem;
    }
    
    .btn-group .btn {
        width: 100%;
    }
    
    /* Hide elements on mobile */
    .hide-mobile,
    .desktop-only {
        display: none !important;
    }
    
    /* Show mobile elements */
    .mobile-only {
        display: block !important;
    }
    
    /* Specific component fixes */
    .dashboard-header {
        flex-direction: column;
        gap: 1rem;
        text-align: center;
    }
    
    .dashboard-header-left {
        text-align: center;
    }
    
    .filter-tabs {
        flex-wrap: wrap;
        gap: 0.25rem;
    }
    
    .filter-tab {
        font-size: 0.8rem;
        padding: 0.4rem 0.8rem;
    }
    
    /* Chat and messaging */
    .chat-container {
        height: calc(100vh - 120px);
    }
    
    .message-bubble {
        max-width: 85%;
    }
    
    /* Profile sections */
    .profile-header {
        text-align: center;
    }
    
    .profile-avatar {
        width: 80px;
        height: 80px;
        margin: 0 auto 1rem;
    }
}

/* Tablet Styles */
@media (min-width: 481px) and (max-width: 768px) {
    /* Navigation */
    .navbar {
        padding: 0.75rem 1.5rem;
    }
    
    .navbar-brand h1 {
        font-size: 1.3rem;
    }
    
    /* Sidebar */
    .sidebar {
        width: 280px;
    }
    
    /* Main Content */
    .content {
        padding: 1.5rem;
        margin-top: 70px;
    }
    
    /* Grids */
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .dashboard-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .grid-3 {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .grid-4 {
        grid-template-columns: repeat(3, 1fr);
    }
    
    /* Cards */
    .stat-value {
        font-size: 1.75rem;
    }
    
    /* Forms */
    .form-row {
        gap: 1rem;
    }
    
    /* Show/hide elements */
    .hide-tablet {
        display: none !important;
    }
    
    .tablet-only {
        display: block !important;
    }
}

/* Small Desktop */
@media (min-width: 769px) and (max-width: 992px) {
    /* Navigation */
    .navbar {
        padding: 1rem 2rem;
    }
    
    /* Sidebar */
    .sidebar {
        width: 260px;
    }
    
    .main-content {
        margin-left: 260px;
        width: calc(100% - 260px);
    }
    
    /* Content */
    .content {
        padding: 2rem;
    }
    
    /* Grids */
    .stats-grid {
        grid-template-columns: repeat(3, 1fr);
    }
    
    .dashboard-grid {
        grid-template-columns: repeat(3, 1fr);
    }
    
    /* Hide/show elements */
    .hide-small-desktop {
        display: none !important;
    }
    
    .small-desktop-only {
        display: block !important;
    }
}

/* Large Desktop */
@media (min-width: 993px) and (max-width: 1200px) {
    /* Sidebar */
    .sidebar {
        width: 270px;
    }
    
    .main-content {
        margin-left: 270px;
        width: calc(100% - 270px);
    }
    
    /* Hide/show elements */
    .hide-medium-desktop {
        display: none !important;
    }
    
    .medium-desktop-only {
        display: block !important;
    }
}

/* Extra Large Desktop */
@media (min-width: 1201px) {
    /* Sidebar */
    .sidebar {
        width: 280px;
    }
    
    .main-content {
        margin-left: 280px;
        width: calc(100% - 280px);
    }
    
    .content {
        padding: 2.5rem;
        max-width: 1400px;
        margin: 70px auto 0;
    }
    
    /* Hide/show elements */
    .hide-large-desktop {
        display: none !important;
    }
    
    .large-desktop-only {
        display: block !important;
    }
}

/* Landscape Mobile */
@media (max-width: 768px) and (orientation: landscape) {
    .navbar {
        min-height: 50px;
    }
    
    .content {
        margin-top: 50px;
    }
    
    .modal-content {
        margin: 0.5rem;
        max-height: 90vh;
    }
}

/* High DPI Displays */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    /* Improve readability on high DPI screens */
    body {
        -webkit-font-smoothing: antialiased;
        -moz-osx-font-smoothing: grayscale;
    }
}

/* Dark Mode Support */
@media (prefers-color-scheme: dark) {
    /* Add dark mode overrides if needed */
    .dark-mode {
        background-color: #1a1a1a;
        color: #ffffff;
    }
}

/* Reduced Motion */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Print Styles */
@media print {
    .sidebar,
    .navbar,
    .btn,
    .no-print {
        display: none !important;
    }
    
    .content {
        margin: 0;
        padding: 0;
        width: 100%;
    }
    
    body {
        font-size: 12pt;
        line-height: 1.4;
    }
}

/* ========================================
   UTILITY CLASSES FOR RESPONSIVE
   ======================================== */

.visible-mobile { display: none !important; }
.visible-tablet { display: none !important; }
.visible-desktop { display: none !important; }

@media (max-width: 480px) {
    .visible-mobile { display: block !important; }
    .hidden-mobile { display: none !important; }
}

@media (min-width: 481px) and (max-width: 768px) {
    .visible-tablet { display: block !important; }
    .hidden-tablet { display: none !important; }
}

@media (min-width: 769px) {
    .visible-desktop { display: block !important; }
    .hidden-desktop { display: none !important; }
}

/* ========================================
   SPECIFIC COMPONENT FIXES
   ======================================== */

/* Dashboard specific fixes */
@media (max-width: 768px) {
    .dashboard-section {
        padding: 1rem;
    }
    
    .section-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
    }
    
    .section-header h2 {
        font-size: 1.5rem;
    }
    
    .action-buttons {
        flex-direction: column;
        gap: 0.5rem;
    }
    
    .action-buttons .btn {
        width: 100%;
    }
}

/* Form specific fixes */
@media (max-width: 768px) {
    .demande-form {
        padding: 1rem;
    }
    
    .form-section {
        margin-bottom: 1.5rem;
    }
    
    .form-actions {
        flex-direction: column;
        gap: 1rem;
    }
    
    .form-actions .btn {
        width: 100%;
    }
}

/* Chat specific fixes */
@media (max-width: 768px) {
    .chat-messages {
        height: calc(100vh - 200px);
    }
    
    .chat-input {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        padding: 1rem;
        background: white;
        border-top: 1px solid #e0e0e0;
    }
    
    .chat-input-container {
        max-width: none;
    }
}
