/* ========================================================
   RESPONSIVE.CSS — Mobile / Tablet / Desktop
   Tối ưu cho người lớn tuổi: touch target lớn, chữ dễ đọc
======================================================== */

/* --------------------------------------------------------
   SIDEBAR TOGGLE — Hamburger Menu (hiện trên mobile/tablet)
-------------------------------------------------------- */
.sidebar-toggle {
    display: none; /* Ẩn mặc định trên desktop */
    position: fixed;
    top: 1rem;
    right: 1rem;
    z-index: calc(var(--z-sidebar) + 5);
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-md);
    width: var(--touch-target-min);
    height: var(--touch-target-min);
    font-size: 1.25rem;
    color: var(--text-main);
    cursor: pointer;
    box-shadow: var(--box-shadow);
    transition: var(--transition);
    align-items: center;
    justify-content: center;
}
.sidebar-toggle:hover {
    background-color: var(--primary-color);
    color: #fff;
}

/* Overlay đen mờ khi sidebar mở trên mobile */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    z-index: calc(var(--z-sidebar) - 1);
    backdrop-filter: blur(2px);
}
.sidebar-overlay.active {
    display: block;
}


/* ========================================================
   TABLET — ≤ 1024px
   Sidebar thu gọn, layout 2 cột giảm
======================================================== */
@media (max-width: 1024px) {
    .sidebar-toggle {
        display: flex;
    }

    .sidebar {
        position: fixed;
        left: 0;
        top: 0;
        height: 100vh;
        transform: translateX(-100%);
        transition: transform 0.3s ease;
        z-index: var(--z-sidebar);
        box-shadow: 4px 0 15px rgba(0, 0, 0, 0.1);
    }
    
    .sidebar.open {
        transform: translateX(0);
    }

    .content-body {
        padding: 1.5rem !important;
    }
    
    .main-content {
        margin-left: 0;
        width: 100%;
    }

    /* Header có chỗ cho hamburger */
    .page-header {
        padding-top: 0.5rem;
    }
}


/* ========================================================
   MOBILE — ≤ 768px
   1 cột, stack tất cả, nút bấm lớn hơn
======================================================== */
@media (max-width: 768px) {
    .content-body {
        padding: 1rem !important;
    }

    /* --- Page Header: Stack dọc --- */
    .page-title-row {
        flex-direction: column;
        align-items: flex-start !important;
        gap: 0.75rem;
    }
    
    .page-title-row h1 {
        font-size: 1.5rem;
    }

    .header-actions {
        width: 100%;
        flex-wrap: wrap;
    }
    
    .header-actions .btn {
        flex: 1;
        min-width: 0;
        justify-content: center;
    }

    /* --- Breadcrumb nhỏ hơn --- */
    .breadcrumb {
        font-size: var(--font-size-xs);
    }

    /* --- Toolbar: Stack dọc --- */
    .toolbar-row {
        flex-direction: column;
        gap: 1rem;
        align-items: stretch;
    }
    
    .search-input-wrapper {
        width: 100% !important;
    }
    
    .summary-stats {
        flex-wrap: wrap;
        gap: 0.75rem 1.5rem;
        font-size: var(--font-size-xs);
    }

    /* --- Stat Cards: 1 cột trên mobile --- */
    .stat-cards {
        grid-template-columns: 1fr !important;
    }
    
    .stat-cards-wrapper {
        grid-template-columns: 1fr !important;
    }

    /* --- Dashboard Grid: 1 cột --- */
    .dashboard-grid {
        grid-template-columns: 1fr !important;
    }

    /* --- Chart Row: Stack --- */
    .chart-container-row {
        grid-template-columns: 1fr !important;
    }


    /* --- Tables: compact --- */
    .table-custom th,
    .table-custom td {
        padding: 0.75rem 0.5rem;
    }
    
    /* Ẩn cột ít quan trọng trên mobile */
    .table-custom .hide-mobile {
        display: none;
    }

    /* --- Form Row: Stack dọc --- */
    .form-row {
        flex-direction: column;
    }

    /* --- Modal: Full width mobile --- */
    .modal-content {
        max-width: calc(100vw - 1.5rem) !important;
        margin: 0.75rem;
        max-height: 90vh;
    }
    
    .modal-lg .modal-content {
        max-width: calc(100vw - 1.5rem) !important;
    }
    
    .modal-lg .modal-body {
        max-height: 70vh;
    }

    /* --- Product Info Card meta: wrap --- */
    .product-info-card .product-info-meta {
        flex-wrap: wrap;
        gap: 0.5rem 1rem;
    }

    /* --- Report Filter Form: Wrap --- */
    .header-actions form {
        flex-wrap: wrap;
        gap: 0.5rem;
        width: 100%;
    }
    
    .header-actions form .form-control {
        min-width: 100px;
    }

    /* --- Pagination: bigger touch targets --- */
    .pagination .page-link {
        min-width: var(--touch-target-min);
        min-height: var(--touch-target-min);
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }

    /* --- Live Total bar responsive --- */
    .live-total-bar {
        flex-direction: column;
        gap: 0.5rem;
        text-align: center;
    }
}


/* ========================================================
   SMALL MOBILE — ≤ 480px
   Cực nhỏ, tối giản
======================================================== */
@media (max-width: 480px) {
    .content-body {
        padding: 0.75rem !important;
    }

    .stat-card {
        padding: 1rem;
    }
    
    .stat-card .val,
    .stat-number {
        font-size: 1.5rem;
    }

    .box-panel {
        padding: 1rem;
    }

    /* Buttons full width */
    .header-actions .btn {
        font-size: var(--font-size-sm);
        padding: 0.625rem 0.75rem;
    }

    /* Tối ưu UI Form cho màn hình nhỏ */
    .modal-body {
        padding: 1rem;
    }
    .modal-header {
        padding: 1rem;
    }
    .modal-header h3 {
        font-size: 1.1rem;
    }
}


/* ========================================================
   ELDERLY-FRIENDLY TOUCH TARGETS
   Áp dụng mọi breakpoint
======================================================== */

/* Tất cả nút bấm phải đủ lớn để bấm bằng ngón tay */
.btn {
    min-height: var(--touch-target-min);
    padding: 0.625rem 1.25rem;
}

/* Sidebar menu links */
.sidebar-menu a {
    min-height: var(--touch-target-min);
    padding: 0.75rem 1.25rem;
    font-size: var(--font-size-base);
}

/* Pagination */
.pagination .page-link {
    min-height: 40px;
    min-width: 40px;
}

/* Icon buttons */
.btn-icon-only {
    min-width: 40px;
    min-height: 40px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
}

/* Close button in modal — lớn hơn cho dễ bấm */
.close-btn {
    min-width: var(--touch-target-min);
    min-height: var(--touch-target-min);
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

/* Select / Input height */
.form-control {
    min-height: var(--touch-target-min);
}
