/**
 * ==============================================================================
 * KBTECH - HỆ THỐNG THIẾT KẾ ĐÁP ỨNG TOÀN DIỆN (RESPONSIVE SYSTEM)
 * Tệp: responsive.css
 * Mô tả: Quy định toàn bộ truy vấn media (media queries) và hành vi co giãn giao diện
 * ==============================================================================
 */

/* ==============================================================================
   1. ĐIỂM NGẮT MÁY TÍNH BẢNG - TABLET (max-width: 991.98px)
   ============================================================================== */
@media (max-width: 991.98px) {
    /* Điều chỉnh bố cục trang quản trị */
    .navbar-custom {
        left: 0 !important;
        padding: 0 1.25rem;
    }

    .sidebar {
        margin-left: calc(var(--sidebar-width, 280px) * -1);
        z-index: 1050;
        box-shadow: 4px 0 30px rgba(0, 0, 0, 0.15);
    }

    .main-wrapper {
        margin-left: 0 !important;
    }

    /* Trạng thái mở thanh điều hướng bên (Sidebar) trên thiết bị di động */
    body.sidebar-toggled .sidebar {
        margin-left: 0 !important;
    }

    /* Lớp phủ mờ nền khi mở menu (Backdrop Overlay) */
    body.sidebar-toggled::before {
        content: '';
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(15, 23, 42, 0.45);
        backdrop-filter: blur(4px);
        -webkit-backdrop-filter: blur(4px);
        z-index: 1045;
        animation: fadeInOverlay 0.25s ease forwards;
    }

    @keyframes fadeInOverlay {
        from { opacity: 0; }
        to { opacity: 1; }
    }

    /* Vùng chứa nội dung chính */
    .content-container {
        padding: 1.5rem 1.25rem;
    }

    /* Chiều cao biểu đồ trên máy tính bảng */
    .chart-area {
        height: 280px !important;
    }

    /* Ẩn chữ trạng thái hệ thống để tiết kiệm không gian */
    .system-status-indicator span {
        display: none;
    }
    .system-status-indicator {
        padding: 8px;
    }
}

/* ==============================================================================
   2. ĐIỂM NGẮT ĐIỆN THOẠI DI ĐỘNG - MOBILE (max-width: 767.98px)
   ============================================================================== */
@media (max-width: 767.98px) {
    /* Kích thước khung bố cục */
    :root {
        --header-height: 64px;
    }

    .content-container {
        padding: 1rem 0.85rem;
    }

    /* Tiêu đề trang & các nút thao tác */
    .border-bottom.d-flex.justify-content-between {
        flex-direction: column;
        align-items: flex-start !important;
        gap: 0.75rem;
    }

    .border-bottom.d-flex.justify-content-between .d-flex {
        width: 100%;
        justify-content: flex-start;
        flex-wrap: wrap;
    }

    /* Khoảng đệm thẻ Card & Tiêu đề */
    .card-body, .tech-card .card-body {
        padding: 1.15rem;
    }

    .card-header, .tech-header {
        padding: 0.85rem 1.15rem;
    }

    /* Thẻ thống kê chỉ số (KPI Stat Cards) */
    .kpi-card {
        padding: 1.15rem;
        margin-bottom: 0.75rem;
    }

    .kpi-value {
        font-size: 1.5rem;
    }

    .kpi-icon-wrapper {
        width: 44px;
        height: 44px;
        font-size: 1.15rem;
    }

    /* Nút tab điều hướng trên màn hình di động */
    .nav-pills-tech {
        display: flex;
        overflow-x: auto;
        white-space: nowrap;
        width: 100%;
        padding: 4px;
        scrollbar-width: none;
    }
    .nav-pills-tech::-webkit-scrollbar {
        display: none;
    }
    .nav-pills-tech .nav-link {
        padding: 9px 16px;
        font-size: 16px !important;
    }

    /* ==========================================
       Giao diện bảng dữ liệu dạng thẻ trên di động
       ========================================== */
    .table-modern {
        background: transparent !important;
    }

    .table-modern thead {
        display: none;
    }

    .table-modern tbody {
        display: block;
    }

    .table-modern tbody tr {
        display: flex;
        flex-wrap: wrap;
        margin-bottom: 0.75rem;
        background: #ffffff;
        border-radius: var(--border-radius-md, 12px);
        box-shadow: 0 2px 10px rgba(0, 0, 0, 0.04);
        border: 1px solid var(--border-color, #e2e8f0);
        overflow: hidden;
        transition: transform 0.2s ease;
    }

    .table-modern tbody tr:active {
        transform: scale(0.99);
    }

    .table-modern tbody td {
        display: block;
        width: 50%;
        text-align: left;
        padding: 8px 12px;
        border-bottom: 1px dashed #f1f5f9;
        border-right: 1px dashed #f1f5f9;
        font-size: 16px !important;
        line-height: 1.4;
    }

    .table-modern tbody td:nth-child(even) {
        text-align: left;
        border-right: 1px dashed #f1f5f9;
    }

    .table-modern tbody td:nth-child(odd) {
        text-align: right;
        border-right: none;
    }

    /* Cột đầu tiên = Tiêu đề dòng = Toàn bộ chiều rộng */
    .table-modern tbody td:first-child {
        width: 100% !important;
        text-align: left !important;
        font-weight: 700;
        color: var(--primary-color, #4f46e5);
        font-size: 17px !important;
        padding: 10px 14px;
        border-bottom: 2px solid #f1f5f9;
        border-right: none;
        background: linear-gradient(to right, #f8fafc, #ffffff);
    }

    /* Cột cuối cùng = Cột nút hành động / Chân dòng = Toàn bộ chiều rộng */
    .table-modern tbody td:last-child {
        width: 100% !important;
        border-bottom: none;
        border-right: none;
        background: #fafafa;
        padding: 8px 14px;
        text-align: right;
        display: flex;
        justify-content: flex-end;
        align-items: center;
        gap: 6px;
    }

    /* Nút thao tác tối ưu bấm chạm ngón tay trên di động */
    .btn-action-icon {
        width: 38px;
        height: 38px;
        font-size: 0.95rem;
    }

    /* Thẻ chỉ số siêu nhỏ trên màn hình điện thoại */
    .mobile-tiny-card .card-body {
        padding: 8px !important;
    }

    .mobile-tiny-card .mobile-icon-wrapper {
        width: 24px !important;
        height: 24px !important;
        padding: 4px !important;
    }

    .mobile-tiny-card .mobile-icon {
        font-size: 0.7rem !important;
    }

    .mobile-tiny-card .mobile-label {
        font-size: 0.65rem !important;
        margin-bottom: 2px !important;
        white-space: nowrap;
    }

    .mobile-tiny-card .mobile-value {
        font-size: 0.85rem !important;
    }

    /* ==========================================
       Tối ưu giao diện người dùng công khai trên di động
       ========================================== */
    .tech-header {
        padding: 12px 0 !important;
    }

    .search-results-container {
        position: fixed;
        top: var(--header-height, 64px);
        left: 10px;
        right: 10px;
        max-height: 70vh;
    }

    .post-card {
        margin-bottom: 1rem;
    }
}

/* ==============================================================================
   3. ĐIỆN THOẠI MÀN HÌNH NHỎ (max-width: 480px)
   ============================================================================== */
@media (max-width: 480px) {
    .content-container {
        padding: 0.75rem 0.5rem;
    }

    .sidebar {
        width: 85vw;
        max-width: 320px;
    }

    .navbar-custom {
        padding: 0 0.85rem;
    }

    .kpi-value {
        font-size: 1.35rem;
    }

    .btn {
        padding: 0.55rem 0.95rem;
        font-size: 16px !important;
    }
}
