/* ============================================
   ULTRA RESPONSIVE BULLETPROOF (V3)
   ============================================ */

/* 1. Global Reset & Overflow Prevention */
* {
    box-sizing: border-box !important;
}

html, body {
    overflow-x: hidden !important;
    width: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
    position: relative;
    -webkit-text-size-adjust: 100%;
}

/* Fix Flex Layout on Mobile */
body {
    display: block !important; /* Switch from flex to block on mobile */
}

@media (min-width: 1025px) {
    body {
        display: flex !important;
    }
}

/* 2. Sidebar Overhaul */
@media (max-width: 1024px) {
    .sidebar {
        position: fixed !important;
        top: 0 !important;
        left: 0 !important;
        bottom: 0 !important;
        width: 280px !important;
        min-width: 280px !important;
        transform: translateX(-105%) !important;
        z-index: 10000 !important;
        transition: transform 0.4s cubic-bezier(0.165, 0.84, 0.44, 1) !important;
        box-shadow: none !important;
        background: var(--bg-sidebar) !important;
        display: flex !important;
    }

    .sidebar.show {
        transform: translateX(0) !important;
        box-shadow: 20px 0 50px rgba(0, 0, 0, 0.8) !important;
    }

    .sidebar-overlay {
        position: fixed !important;
        inset: 0 !important;
        background: rgba(0, 0, 0, 0.7) !important;
        backdrop-filter: blur(5px) !important;
        z-index: 9999 !important;
        display: none;
        opacity: 0;
        transition: opacity 0.3s;
    }

    .sidebar-overlay.show {
        display: block !important;
        opacity: 1 !important;
    }

    .main {
        width: 100% !important;
        min-width: 100% !important;
        margin-left: 0 !important;
        display: block !important;
        overflow-x: hidden !important;
    }
}

/* 3. Topbar Cleanup */
@media (max-width: 1024px) {
    .topbar {
        padding: 0 15px !important;
        height: 70px !important;
        justify-content: space-between !important;
        width: 100% !important;
    }

    .search-bar-wrap {
        display: none !important;
    }

    .sys-badge {
        display: none !important;
    }

    .topbar-right {
        gap: 5px !important;
    }

    #topbar-name {
        display: none !important;
    }

    .topbar-breadcrumb {
        padding: 5px 12px !important;
        max-width: 120px !important;
        overflow: hidden;
        white-space: nowrap;
        text-overflow: ellipsis;
        display: flex !important;
    }
    
    .topbar-breadcrumb span, .topbar-breadcrumb i:not(:first-child) {
        display: none !important;
    }

    .btn-menu-toggle {
        display: flex !important;
        width: 42px !important;
        height: 42px !important;
        background: rgba(255, 255, 255, 0.08) !important;
        border: 1px solid var(--border-light) !important;
        border-radius: 12px !important;
        color: #fff !important;
        align-items: center;
        justify-content: center;
        font-size: 1.1rem !important;
        cursor: pointer;
        backdrop-filter: blur(10px);
    }
}

/* 4. Content & Grid */
@media (max-width: 768px) {
    .container {
        padding: 15px !important;
        width: 100% !important;
    }

    .grid-4, .grid-3, .grid-2, .db-grid-main {
        grid-template-columns: 1fr !important;
        display: grid !important;
        gap: 15px !important;
    }

    .stat-card {
        padding: 15px !important;
        width: 100% !important;
    }

    .stat-icon {
        width: 45px !important;
        height: 45px !important;
        font-size: 1.1rem !important;
    }

    .stat-content h4 {
        font-size: 1.3rem !important;
    }

    .welcome-banner {
        flex-direction: column !important;
        padding: 20px !important;
        text-align: center !important;
    }

    .welcome-banner h2 {
        font-size: 1.4rem !important;
        margin-bottom: 10px !important;
    }

    .user-avatar-big {
        margin: 0 auto 15px !important;
        width: 60px !important;
        height: 60px !important;
        font-size: 1.2rem !important;
    }

    .welcome-actions {
        flex-direction: column !important;
        gap: 8px !important;
    }

    .welcome-actions .btn {
        width: 100% !important;
    }

    /* Table Fix */
    .p-body {
        overflow-x: auto !important;
        padding: 10px !important;
    }

    table {
        min-width: 500px !important;
    }

    /* Modal Fix */
    .modal-content {
        width: 95% !important;
        padding: 20px !important;
    }

    /* Activity Feed Fix */
    .activity-item {
        flex-direction: column !important;
        align-items: flex-start !important;
        gap: 5px !important;
    }
}

/* 5. Terminal Mobile Fix */
@media (max-width: 768px) {
    #terminal .card {
        height: 400px !important;
    }
    
    #term-output {
        font-size: 0.7rem !important;
        line-height: 1.4 !important;
    }
    
    #term-output br {
        display: block !important;
        margin-bottom: 5px !important;
    }
}

/* Custom Scrollbar for Tabs */
.tabs {
    overflow-x: auto !important;
    display: flex !important;
    flex-wrap: nowrap !important;
    -webkit-overflow-scrolling: touch !important;
    scrollbar-width: none !important;
}

.tabs::-webkit-scrollbar {
    display: none !important;
}

.tab-btn {
    flex: 0 0 auto !important;
}
