/* xAIDRA - Responsive Design Improvements */

@media (max-width: 992px) {
    .xaidra-sidebar {
        position: fixed;
        left: -280px;
        top: 64px;
        height: calc(100vh - 64px);
        width: 280px;
        z-index: 1000;
        transition: left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        box-shadow: 4px 0 10px rgba(0,0,0,0.1);
    }

    .xaidra-sidebar.open {
        left: 0;
    }

    .xaidra-main {
        width: 100%;
    }

    .header-center {
        display: none !important;
    }

    .logo-text {
        font-size: 1.25rem;
    }

    .user-section {
        padding: 0.25rem 0.5rem;
    }

    .user-info-mini {
        display: none;
    }
}

@media (max-width: 576px) {
    .xaidra-header {
        padding: 0 1rem;
    }

    .logo-section img {
        width: 24px;
        height: 24px;
    }

    .version-badge {
        display: none;
    }

    .content-wrapper {
        padding: 1rem;
    }

    .page-header h1 {
        font-size: 1.5rem;
    }

    .stat-card {
        padding: 1rem;
    }

    .stat-icon {
        width: 40px;
        height: 40px;
        font-size: 1.25rem;
    }

    .stat-content h3 {
        font-size: 1.5rem;
    }

    .agents-grid {
        grid-template-columns: 1fr;
    }

    .modal-dialog {
        margin: 0.5rem;
    }
}

/* Burger Menu Button */
.mobile-toggle {
    display: none;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 1.25rem;
    cursor: pointer;
    margin-right: 1rem;
    padding: 0.5rem;
}

@media (max-width: 992px) {
    .mobile-toggle {
        display: block;
    }
}

.mobile-sidebar-header {
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 1rem;
    background: var(--bg-secondary);
}

/* Sidebar Overlay */
.sidebar-overlay {
    display: none;
    position: fixed;
    top: 64px;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    z-index: 999;
}

.sidebar-overlay.show {
    display: block;
}

/* Card Optimizations */
@media (max-width: 768px) {
    .card-header {
        padding: 0.75rem 1rem;
    }
    
    .card-body {
        padding: 1rem;
    }
}

/* Table Responsiveness */
@media (max-width: 768px) {
    .table-responsive {
        border: 0;
    }
    
    /* Optional: Stack tables on very small screens */
    /* .table-stack-mobile tbody tr { display: block; margin-bottom: 1rem; border: 1px solid var(--border-color); } */
}

/* Dashboard Fixes */
.stats-row {
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
}

@media (max-width: 480px) {
    .stats-row {
        grid-template-columns: 1fr;
    }
}

/* Page Specific Optimizations */
@media (max-width: 768px) {
    /* Alerts Page */
    .alerts-page .row > [class*="col-"] {
        margin-bottom: 1rem;
    }
    
    .alerts-page .list-group-item {
        padding: 1rem;
    }

    /* Jobs Page */
    .jobs-container .row > [class*="col-"] {
        margin-bottom: 1rem;
    }
    
    .nav-tabs {
        display: flex;
        flex-wrap: nowrap;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    .nav-tabs .nav-link {
        white-space: nowrap;
    }

    /* AI Assistant */
    .ai-chat-container {
        height: calc(100vh - 200px) !important;
    }
}

/* General Mobile Polish */
@media (max-width: 576px) {
    .btn-sm-block {
        width: 100%;
        display: block;
        margin-bottom: 0.5rem;
    }
    
    .card-header {
        flex-direction: column;
        align-items: flex-start !important;
        gap: 0.5rem;
    }
    
    .card-header .btn-group,
    .card-header .btn {
        width: 100%;
    }
}

/* Fix for horizontal scroll issues */
.xaidra-shell {
    overflow-x: hidden;
}

.xaidra-main {
    width: 100%;
    max-width: 100vw;
}
