/* Thiết lập tổng thể */
body {
    margin: 0;
    font-family: sans-serif;
}

/* NÚT BẬT/TẮT BẢNG ĐIỀU KHIỂN */
#toggle-controls-btn {
    position: fixed;
    top: 15px;
    right: 15px;
    z-index: 200;
    width: 45px;
    height: 45px;
    background-color: rgba(0, 0, 0, 0.6);
    color: white;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    
    @media (max-width: 480px) {
    #iframe-container {
        grid-template-rows: repeat(4, 1fr); /* Đảm bảo 4 hàng trên màn hình rất nhỏ */
    }
    .controls {
        width: 95%; /* Tăng độ rộng để phù hợp hơn */
        padding: 8px;
    }
    .controls input[type="number"] {
        width: 40px; /* Giảm độ rộng input */
        padding: 6px;
    }
    .controls button {
        padding: 6px 12px; /* Giảm padding nút */
        font-size: 14px;
    }
    #toggle-controls-btn {
        width: 35px;
        height: 35px;
        font-size: 18px;
    }
}

    align-items: center;
    font-size: 24px;
    cursor: pointer;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
    transition: transform 0.2s ease;
}
#toggle-controls-btn:hover {
    transform: scale(1.1) rotate(45deg);
}

/* BẢNG ĐIỀU KHIỂN NỔI */
.controls {
    position: fixed;
    top: 15px;
    left: 50%;
    transform: translate(-50%, -150%);
    opacity: 0;
    visibility: hidden;
    z-index: 100;
    background-color: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(8px);
    padding: 10px 20px;
    border-radius: 16px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
    transition: transform 0.4s ease, opacity 0.4s ease;
    display: flex;
    align-items: center;
    gap: 10px;
}

.controls.visible {
    transform: translate(-50%, 0);
    opacity: 1;
    visibility: visible;
}

.controls label {
    font-weight: bold;
    white-space: nowrap;
}
.controls input[type="number"] {
    width: 50px; /* Điều chỉnh lại độ rộng cho phù hợp */
    padding: 8px;
    border: 1px solid #ccc;
    border-radius: 6px;
    text-align: center;
}
.controls button {
    padding: 8px 16px;
    border: none;
    background-color: #007bff;
    color: white;
    border-radius: 6px;
    cursor: pointer;
    transition: background-color 0.2s;
    white-space: nowrap;
}
.controls button:hover {
    background-color: #0056b3;
}
#max-btn {
    background-color: #28a745;
}
#max-btn:hover {
    background-color: #218838;
}

/* Vùng chứa các iframes */
#iframe-container {
    display: grid; /* Chuyển sang sử dụng Grid Layout */
    width: 100vw;
    height: 100vh;
    overflow: hidden;
}
/* Viền nhẹ quanh mỗi iframe */
.panel {
    border: 0px transparent; /* Viền trong suốt để tránh ảnh hưởng đến bố cục */
    padding: 0;
}
iframe {
    width: 100%;
    height: 100%;
    border: none;
}/* Responsive Grid Layout */
@media (min-width: 1200px) {
    /* Màn hình lớn: 2x2 */
    #iframe-container {
        grid-template-columns: repeat(2, 1fr);
        grid-template-rows: repeat(2, 1fr);
    }
}

@media (min-width: 768px) and (max-width: 1199px) {
    /* Màn hình tablet ngang: 2x1 (2 cột, 1 hàng) hoặc 1x2 (1 cột, 2 hàng) tùy chiều cao */
    #iframe-container {
        grid-template-columns: repeat(2, 1fr);
        grid-template-rows: 1fr; /* Chỉ 1 hàng, các iframe sẽ tự co chiều cao */
    }
}

@media (max-width: 767px) {
    /* Màn hình điện thoại và tablet đứng: 1xN (1 cột, N hàng) */
    #iframe-container {
        grid-template-columns: 1fr;
        grid-template-rows: repeat(4, 1fr); /* Mỗi iframe một hàng */
    }
    .controls {
        flex-wrap: wrap; /* Cho phép các điều khiển xuống dòng */
        justify-content: center;
        width: 90%;
        left: 50%;
        transform: translate(-50%, -150%); /* Giữ nguyên vị trí ẩn */
        padding: 10px;
    }
    .controls.visible {
        transform: translate(-50%, 15px); /* Điều chỉnh vị trí hiển thị */
    }
    .controls label, .controls input, .controls button {
        margin: 5px 0; /* Thêm khoảng cách khi xuống dòng */
    }
    #toggle-controls-btn {
        top: 10px;
        right: 10px;
        width: 40px;
        height: 40px;
        font-size: 20px;
    }
}

/* BỘ ĐẾM TRUY CẬP */
.visit-counter {
    position: fixed;
    bottom: 15px;
    left: 15px;
    z-index: 200;
    background-color: rgba(0, 0, 0, 0.6);
    color: #fff;
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 14px;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 6px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    backdrop-filter: blur(4px);
    transition: opacity 0.3s;
    user-select: none;
}

.visit-counter .icon {
    font-size: 16px;
}

@media (max-width: 767px) {
    .visit-counter {
        bottom: 10px;
        left: 10px;
        font-size: 12px;
        padding: 4px 10px;
    }
}