@media screen and (max-width:600px) {
    h2 {
        font-size: 16px;
        padding: 10px;
    }

    h3 {
        font-size: 14px;
    }
    h4 {
        font-size: 18px;
        margin-bottom: 0px !important;
        font-weight: 0 !important;
    }
    .span {
        font-size: 10px !important;
    }
    .mb-2 {
        margin-bottom: 6px !important;
    }
    .font-large-1 {
        font-size: 1.5rem !important;
    }
    .text-right{
        text-align: left !important;
    }
    .popup-content {
        top: 5%;
        left: 2% !important;
        width: 96% !important;
        height: auto;
        max-height: 90vh;
        padding: 15px !important;
        border-radius: 8px !important;
        overflow-y: auto;
        /* Cố định chiều ngang, tránh di chuyển */
        min-width: 300px;
        max-width: 96vw;
        box-sizing: border-box;
    }
    
    /* CSS cho nút bảng dữ liệu trên mobile */
    .btn-data-table {
        width: 100%;
        min-width: 120px;
        white-space: nowrap;
        font-size: 14px !important;
        padding: 8px 12px !important;
    }
    
    /* CSS cho input group trên mobile */
    .input-group {
        width: 100%;
    }
    
    .input-group .btn {
        font-size: 12px !important;
        padding: 8px 10px !important;
        white-space: nowrap;
    }
    
    /* Đảm bảo form control không bị overflow */
    .form-control {
        font-size: 16px !important; /* Tránh zoom trên iOS */
        min-height: 38px;
    }
    
    /* Cải thiện layout cho row */
    .row {
        margin: 0 !important;
    }
    
    .col-12 {
        padding-left: 5px !important;
        padding-right: 5px !important;
    }
}

/* Thêm CSS cho input để tránh zoom */
.no-zoom {
    font-size: 16px !important; /* Tối thiểu 16px để tránh zoom trên iOS */
    transform-origin: left top;
    transform: scale(1);
}

/* CSS chung cho popup */
.daterangepicker {
    z-index: 99999 !important;
}

.popup-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 9999;
    overflow-y: auto; 
    overflow-x: hidden;
}

.popup-content {
    position: relative;
    top: 5%;
    left: 3%;
    width: 94%;
    margin-top: 30px;
    margin-bottom: 100px;
    background: rgba(255, 255, 255, 0.7); 
    padding: 20px 20px;
    border-radius: 8px;
    opacity: 0;
    transform: translateY(-50px);
    animation: slideDown 0.5s forwards;
    overflow-y: auto;
    z-index: 2001;
    backdrop-filter: blur(26px); 
    -webkit-backdrop-filter: blur(26px); 
    min-height: calc(100vh - 50px);
    box-sizing: border-box;
}

.popup-content.closing {
    animation: slideUp 0.5s forwards;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-50px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes slideUp {
    from {
        opacity: 1;
        transform: translateY(0);
    }
    to {
        opacity: 0;
        transform: translateY(-50px);
    }
}

.popup-close {
    position: absolute;
    top: 10px;
    right: 20px;
    font-size: 18px;
    cursor: pointer;
    color: red;
}

/* CSS bổ sung cho responsive buttons */
@media (max-width: 576px) {
    .btn {
        font-size: 14px;
        padding: 6px 12px;
    }
    
    .btn-sm {
        font-size: 12px;
        padding: 4px 8px;
    }
    
    /* Đảm bảo input group không bị break */
    .input-group-append .btn {
        border-top-left-radius: 0;
        border-bottom-left-radius: 0;
    }
}

@media (max-width: 768px) {
    .daterangepicker {
        z-index: 20010 !important;
        position: fixed !important;
        left: 50% !important;
        transform: translateX(-50%) !important;
        width: 95vw !important;
        max-width: 360px !important;
    }
}
/* Responsive button layout */
@media (max-width: 767.98px) {
    .btn-data-table {
        width: 100% !important;
        margin-top: 0 !important;
        margin-bottom: 20px !important;
    }
    
    /* Đảm bảo nút bảng dữ liệu xuống hàng mới trên mobile */
    .col-12.col-md-4 {
        margin-top: 10px !important;
    }
}

@media (min-width: 768px) {
    .btn-data-table {
        width: auto !important;
        min-width: 150px;
    }
    
    /* Đảm bảo nút nằm cùng hàng trên desktop */
    .col-12.col-md-4 {
        margin-top: 0 !important;
    }
    
    /* Căn chỉnh height để nút nằm cùng mức với input group */
    .align-items-end {
        align-items: flex-end !important;
    }
}

/* Cải thiện layout input group */
@media (max-width: 767.98px) {
    .input-group {
        width: 100%;
        margin-bottom: 0;
    }
    
    .form-group {
        margin-bottom: 10px !important;
    }
}
@media (max-width: 768px) {
    .daterangepicker {
        z-index: 999999 !important;
        position: fixed !important;
        left: 50% !important;
        transform: translateX(-50%) !important;
        width: 95vw !important;
        max-width: 360px !important;
        background: #fff !important;
        border: 1px solid #ddd !important;
        box-shadow: 0 10px 30px rgba(0,0,0,0.3) !important;
    }
    
    /* Đảm bảo popup-content có thể scroll được */
    .popup-content {
        z-index: 2001 !important;
        position: relative !important;
    }
    
    /* Khi daterangepicker hiển thị, giảm z-index của các element khác */
    .daterangepicker.show {
        z-index: 999999 !important;
    }
}

/* Cải thiện scroll behavior */
@media (max-width: 768px) {
    .popup-content {
        scroll-behavior: smooth;
        -webkit-overflow-scrolling: touch;
        overflow-scrolling: touch;
    }
    
    /* Đảm bảo chart không che daterangepicker */
    .chart_plotly {
        position: relative;
        z-index: 1;
    }
}