/* Reset và thiết lập cơ bản cho toàn bộ website */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: Arial, sans-serif;
}

/* Body và container chính */
body {
    margin: 0;
    padding: 0;
    font-family: Arial, sans-serif;
    background: linear-gradient(45deg, rgba(76, 175, 80, 0.4), rgba(30, 136, 229, 0.4), rgba(103, 58, 183, 0.4), rgba(30, 136, 229, 0.4));
    background-size: 400% 400%;
    animation: gradient 15s ease infinite;
    color: #fff;
    background-color: #121212;
    background-blend-mode: overlay;
    display: flex; /* Thêm flex để quản lý chiều cao footer */
    flex-direction: column; /* Sắp xếp các phần tử theo chiều dọc */
    min-height: 100vh; /* Đảm bảo body luôn chiếm ít nhất toàn bộ chiều cao viewport */
}

@keyframes gradient {
    0% {
        background-position: 0% 50%;
    }
    50% {
        background-position: 100% 50%;
    }
    100% {
        background-position: 0% 50%;
    }
}

body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: radial-gradient(circle, rgba(255, 255, 255, 0.1), transparent);
    pointer-events: none;
}

.container {
    display: flex;
    flex-direction: column;
    justify-content: flex-start; /* căn chỉnh nội dung từ trên xuống */
    align-items: center;      /* căn giữa theo chiều ngang */
    text-align: center;
    padding: 20px; /* Giảm padding tổng */
    animation: fadeIn 1s ease-out;
    max-width: 1200px;
    margin: 0 auto;
    box-sizing: border-box;
    flex-grow: 1; /* Cho phép container chính chiếm không gian còn lại */
}

/* Tiêu đề chính */
h1 {
    text-align: center; /* Căn giữa chữ */
    font-size: 2.5em; /* Giảm kích thước font */
    font-weight: 700;
    background: linear-gradient(90deg, #f39c12, #e74c3c, #9b59b6, #3498db, #2ecc71);
    background-size: 300% 300%;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    animation: gradientTitle 8s linear infinite;
    text-shadow: 2px 2px 6px rgba(0, 0, 0, 0.4);
    letter-spacing: 1px; /* Giảm letter-spacing */
    margin-bottom: 20px; /* Giảm margin bottom */
    position: relative;
    padding-bottom: 10px; /* Giảm padding bottom */
}

h1::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 120px; /* Giảm độ dài gạch ngang */
    height: 2px; /* Giảm độ dày gạch ngang */
    background: linear-gradient(90deg, transparent, #ffffff80, transparent);
    animation: lineWidth 3.5s ease-in-out infinite;
}

@keyframes gradientTitle {
    0% {
        background-position: 0% 50%;
    }
    50% {
        background-position: 100% 50%;
    }
    100% {
        background-position: 0% 50%;
    }
}

@keyframes lineWidth {
    0% {
        width: 0;
        opacity: 0;
    }
    50% {
        width: 120px; /* Giảm độ dài gạch ngang */
        opacity: 1;
    }
    100% {
        width: 0;
        opacity: 0;
    }
}

/* Thanh tìm kiếm */
#search-section {
    text-align: center;
    margin-bottom: 15px; /* Giảm margin bottom */
}

#search-input, #filter-select, #search-button {
    padding: 6px; /* Giảm padding */
    margin: 3px; /* Giảm margin */
    font-size: 12px;  /* Giảm kích thước font */
    border: 1px solid #ccc;
    border-radius: 4px;
    outline: none;
}

#search-input:focus, #filter-select:focus, #search-button:focus {
    border-color: #007bff;
}

#search-button {
    background-color: #007bff;
    color: #fff;
    cursor: pointer;
    transition: background-color 0.3s ease;
}

#search-button:hover {
    background-color: #0056b3;
}

/* Grid để hiển thị scripts */
.scripts-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); /* Điều chỉnh kích thước card */
    gap: 15px; /* Giảm gap */
    margin-top: 15px; /* Giảm margin top */
    transition: transform 0.3s ease-in-out;
}

@media (min-width: 1000px) { /* Thêm điều kiện màn hình lớn hơn */
    .scripts-grid {
        grid-template-columns: repeat(4, 1fr); /* Luôn có 4 cột */
    }
}

@media (max-width: 900px) {
    .scripts-grid {
        grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); /* Điều chỉnh cho màn hình nhỏ hơn */
    }
}

@media (max-width: 600px) {
    .scripts-grid {
        grid-template-columns: 1fr;
    }
}

/* Script box (trong card - ẩn ban đầu) */
.code-container {
    background-color: #1e1e1e;
    color: #00ffb7;
    padding: 10px; /* Giảm padding */
    border-radius: 6px;
    white-space: pre-wrap; /* Đảm bảo text sẽ xuống dòng khi cần thiết */
    word-wrap: break-word; /* Đảm bảo từ dài không bị tràn ra ngoài */
    font-family: monospace;
    overflow-x: auto;
    margin-top: 5px; /* Giảm margin top */
    font-size: 12px; /* Giảm kích thước font */
    line-height: 1.4; /* Giảm khoảng cách dòng */
    max-height: 200px; /* Giảm chiều cao tối đa */
    overflow-y: auto; /* Cho phép cuộn khi cần */
    flex-grow: 1; /* Cho phép phần này giãn nở */
}

/* Card */
.card {
    background: #1e1e1e; /* Nền tối phù hợp */
    color: #fff;
    border-radius: 8px; /* Giảm bo tròn góc */
    overflow: hidden;
    box-shadow: 0 1px 6px rgba(0, 0, 0, 0.3); /* Giảm độ đậm bóng */
    display: flex;
    flex-direction: column;
    text-align: center;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.card:hover {
    transform: translateY(-3px); /* Giảm độ nổi khi hover */
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.4); /* Giảm độ đậm bóng khi hover */
}

.card-game {
    font-size: 14px; /* Giảm kích thước font */
    font-weight: bold;
    padding: 8px 10px 0; /* Giảm padding */
    color: #7fc8ff;
    text-align: left;
}

.card-game::before {
    content: "Game: ";
    font-weight: bold;
    color: #ccc;
}

.card hr.card-divider {
    border: none;
    height: 1px;
    background-color: #333;
    margin: 5px 0; /* Giảm margin */
}

.card img {
    width: 100%;
    height: 120px; /* Giảm chiều cao ảnh */
    object-fit: cover;
    border-top: 1px solid #333;
    border-bottom: 1px solid #333;
    margin-top: 8px; /* Giảm margin top */
}

/* Phần nội dung */
.card-content {
    padding: 10px; /* Giảm padding */
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

/* Tên script */
.card-title {
    font-size: 16px; /* Giảm kích thước font */
    font-weight: bold;
    margin: 8px 0; /* Giảm margin */
    color: #f1f1f1;
}

/* Nút View Script */
.view-button {
    background-color: #007bff;
    color: white;
    padding: 8px 12px; /* Giảm padding */
    font-size: 12px; /* Giảm kích thước font */
    font-weight: 600;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    margin-top: 8px; /* Giảm margin top */
    transition: background-color 0.3s ease;
}

.view-button:hover {
    background-color: #0056b3;
}

/* Modal nền tối */
#script-details-modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100vw;
    height: 100vh;
    background-color: rgba(0, 0, 0, 0.8);
    justify-content: center;
    align-items: center;
    padding: 15px; /* Giảm padding modal */
    opacity: 0; /* Thêm thuộc tính opacity */
    transition: opacity 0.3s ease-in-out; /* Thêm transition cho hiệu ứng mờ dần */
}

#script-details-modal.show {
    display: flex; /* Hiển thị modal khi có class 'show' */
    opacity: 1; /* Hiển thị hoàn toàn khi có class 'show' */
}

/* Phần nội dung modal */
#modal-content {
    background-color: #1e1e1e;
    padding: 15px; /* Giảm padding nội dung modal */
    border-radius: 8px;
    max-width: 500px; /* Giảm kích thước tối đa */
    width: 90%;
    max-height: 70vh; /* Giảm chiều cao tối đa */
    display: flex;
    flex-direction: column;
    position: relative;
    transform: translateY(-20px); /* Thêm thuộc tính transform để tạo hiệu ứng trượt lên */
    transition: transform 0.3s ease-out, opacity 0.3s ease-out; /* Thêm transition cho hiệu ứng trượt và mờ dần */
    opacity: 0; /* Thêm thuộc tính opacity */
}

#script-details-modal.show #modal-content {
    transform: translateY(0); /* Đưa nội dung về vị trí ban đầu khi hiển thị */
    opacity: 1; /* Hiển thị hoàn toàn khi có class 'show' */
}

/* Tiêu đề modal */
#modal-title {
    color: #f1f1f1;
    font-size: 1.2em;
    font-weight: bold;
    margin-bottom: 10px;
    text-align: center;
}

/* Chi tiết tối giản card trong modal */
.minimal-details-card {
    display: flex;
    flex-direction: column;
    gap: 10px; /* Giảm gap trong card chi tiết */
}

/* Header chi tiết */
.details-header {
    display: flex;
    align-items: center;
    gap: 10px; /* Giảm gap header */
    margin-bottom: 8px; /* Giảm margin bottom header */
}

.header-image {
    width: 50px; /* Giảm kích thước ảnh header */
    height: 50px; /* Giảm kích thước ảnh header */
    border-radius: 5px;
    overflow: hidden;
}

.header-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.header-info h3 {
    color: #7fc8ff;
    font-size: 1em;
    margin: 0;
}

/* Khung chứa script code trong modal */
.script-box {
    display: flex;
    flex-direction: column; /* Sắp xếp các phần tử con theo chiều dọc */
    gap: 8px; /* Khoảng cách giữa tiêu đề script và khung code */
    position: relative; /* Để định vị tuyệt đối nút copy bên trong */
    padding-bottom: 45px; /* Thêm padding-bottom để tạo khoảng trống cho nút copy */
}

.script-box h4 {
    color: #bbb;
    margin: 0;
    font-size: 0.9em;
}

/* Phần bạn đã sửa */
.code-container {
    background-color: #2c2c2c;
    padding: 8px;
    border-radius: 6px;
    overflow-x: auto;
    font-family: monospace;
    color: #f1f1f1;
    white-space: pre-wrap;
    word-wrap: break-word;
    max-height: 150px;
    overflow-y: auto;
    font-size: 0.8em;
    line-height: 1.3;
    margin-bottom: 10px; /* Thêm margin-bottom để tạo khoảng cách với nút copy */
}

/* Phần bạn đã sửa */
#modal-copy-button {
    position: absolute; /* Đặt vị trí tuyệt đối */
    bottom: 10px; /* Khoảng cách từ đáy của .script-box */
    left: 50%; /* Căn giữa theo chiều ngang */
    transform: translateX(-50%); /* Dịch chuyển để căn giữa chính xác */
    width: 90%;
    box-sizing: border-box;
    background-color: #f39c12;
    color: black;
    padding: 8px 16px;
    font-size: 1em;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-weight: bold;
    transition: background-color 0.3s ease;
    align-self: flex-start; /* Loại bỏ align-self không cần thiết khi đã dùng position absolute */
    margin-top: 0; /* Loại bỏ margin-top không cần thiết */
}

#modal-copy-button.copied {
    background-color: #008CBA; /* Màu xanh dương khi đã copy */
    font-size: 0.9em;
    padding: 6px 12px;
}

/* Nút đóng */
#close-modal {
    background-color: #444;
    color: white;
    border: none;
    padding: 8px 16px; /* Giữ nguyên padding nút đóng hoặc giảm nhẹ */
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9em; /* Giảm kích thước font nút đóng */
    margin-top: 10px; /* Giảm margin top nút đóng */
    align-self: center;
}

#close-modal:hover {
    background-color: #666;
}

/* Phần nút sang trang */
.pagination {
    display: flex; /* Sử dụng flexbox để các nút nằm trên cùng một dòng */
    justify-content: center; /* Căn giữa các nút */
    align-items: center; /* Căn giữa theo chiều dọc (tùy chọn) */
    margin-top: 20px; /* Khoảng cách phía trên */
    padding: 10px 20px; /* Thêm padding */
}

.pagination button {
    padding: 8px 15px;
    margin: 0 10px; /* Khoảng cách giữa các nút */
    border: 1px solid #ccc;
    border-radius: 5px;
    background-color: #f9f9f9;
    color: #333;
    cursor: pointer;
    font-size: 0.9rem;
}

.pagination button:disabled {
    background-color: #eee;
    color: #777;
    cursor: not-allowed;
    border-color: #ddd;
}

#pagination-numbers {
    margin: 0 15px; /* Khoảng cách với các nút */
    font-size: 0.9rem;
    color: #555;
}

/* Nút đóng modal (X trong khung tròn) */
#close-modal-button {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 25px;
    height: 25px;
    border-radius: 50%;
    background-color: #333;
    color: #fff;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
    border: none;
    padding: 0;
    transition: background-color 0.3s ease;
}

#close-modal-button:hover {
    background-color: #555;
}

/* Hamburger icon */
.hamburger {
    font-size: 24px; /* Giảm kích thước icon */
    cursor: pointer;
    position: fixed;
    top: 15px; /* Giảm vị trí top */
    left: 15px; /* Giảm vị trí left */
    z-index: 1001;
    color: #fff;
    background-color: #1f1f1f;
    padding: 8px 10px; /* Giảm padding icon */
    border-radius: 6px;
    transition: background 0.3s;
}

.hamburger:hover {
    background-color: #333;
}

/* Sidebar style */
.sidebar {
    position: fixed;
    top: 0;
    left: -200px; /* Giảm độ rộng sidebar */
    width: 200px; /* Giảm độ rộng sidebar */
    height: 100%;
    background-color: #181818;
    box-shadow: 2px 0 8px rgba(0, 0, 0, 0.4);
    padding-top: 50px; /* Giảm padding top sidebar */
    transition: 0.3s ease-in-out;
    z-index: 1002;
    overflow-y: auto;
}

.sidebar.open {
    left: 0;
}

.sidebar a {
    display: block;
    padding: 10px 15px; /* Giảm padding link sidebar */
    text-decoration: none;
    color: #eee;
    transition: background 0.3s;
    font-size: 16px; /* Giảm kích thước font link sidebar */
}

.sidebar a:hover {
    background-color: #222;
}

.sidebar .sidebar-header {
    padding: 15px; /* Giảm padding header sidebar */
    text-align: center;
    border-bottom: 1px solid #222;
    margin-bottom: 10px; /* Giảm margin bottom header sidebar */
}

.sidebar .sidebar-header h3 {
    color: #f1f1f1;
    margin: 0;
    font-size: 1.2em; /* Giảm kích thước font header sidebar */
}

/* Error message */
#error-message {
    color: #ff4d4d;
    text-align: center;
    margin-top: 15px;
    font-size: 0.9em;
}

/* Responsive adjustments */
@media screen and (max-width: 768px) {
    h1 {
        font-size: 2em;
        margin-bottom: 15px;
        padding-bottom: 8px;
    }

    h1::after {
        width: 100px;
        height: 1.5px;
    }

    #search-input, #filter-select, #search-button {
        padding: 8px;
        font-size: 14px;
    }

    .card-title {
        font-size: 14px;
        margin: 6px 0;
    }

    .view-button {
        padding: 6px 10px;
        font-size: 10px;
        margin-top: 6px;
    }

    #modal-content {
        max-width: 95%;
    }

    #modal-title {
        font-size: 1.1em;
        margin-bottom: 8px;
    }

    .script-box h4 {
        font-size: 0.8em;
    }

    .code-container {
        font-size: 0.7em;
        max-height: 120px;
        padding: 6px;
        margin-bottom: 8px;
    }

    #modal-copy-button {
        padding: 6px 12px;
        font-size: 0.9em;
    }

    .pagination button {
        padding: 6px 12px;
        margin: 0 3px;
        font-size: 12px;
    }

    .hamburger {
        font-size: 20px;
        top: 10px;
        left: 10px;
        padding: 6px 8px;
    }

    .sidebar a {
        font-size: 14px;
        padding: 8px 12px;
    }

    .sidebar .sidebar-header h3 {
        font-size: 1em;
    }
}

@media screen and (max-width: 480px) {
    h1 {
        font-size: 1.8em;
    }

    #search-input, #filter-select, #search-button {
        font-size: 12px;
    }

    .card-title {
        font-size: 12px;
    }

    .view-button {
        font-size: 9px;
        padding: 5px 8px;
    }

    #modal-title {
        font-size: 1em;
    }

    .script-box h4 {
        font-size: 0.7em;
    }

    .code-container {
        font-size: 0.6em;
        max-height: 100px;
        padding: 5px;
        margin-bottom: 6px;
    }

    #modal-copy-button {
        font-size: 0.8em;
        padding: 5px 10px;
    }

    .pagination button {
        font-size: 10px;
        padding: 5px 10px;
    }

    .hamburger {
        font-size: 18px;
        top: 8px;
        left: 8px;
        padding: 5px 7px;
    }

    .sidebar {
        width: 150px;
        left: -150px;
        padding-top: 40px;
    }

    .sidebar a {
        font-size: 12px;
        padding: 8px 10px;
    }

    .sidebar .sidebar-header h3 {
        font-size: 0.9em;
    }
}

footer {
    background-color: #1e1e1e;
    color: #f0f0f0;
    padding: 15px 20px;
    font-size: 0.9rem;
    border-top: 1px solid #333;
    margin-top: auto; /* Đẩy footer xuống cuối */
}

.footer-container {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.footer-left p {
    margin: 0;
}

.footer-right {
    display: flex;
    align-items: center;
}

.social-icons-simple {
    margin-right: 20px;
}

.social-icons-simple a {
    color: #ccc;
    font-size: 1.5rem;
    margin: 0 10px;
    text-decoration: none;
}

.social-icons-simple a:hover {
    color: #eee;
}

.footer-right p {
    margin: 0;
}

/* Responsive cho footer (tùy chọn) */
@media (max-width: 600px) {
    .footer-container {
        flex-direction: column;
        text-align: center;
    }

    .footer-right {
        flex-direction: column;
        margin-top: 10px;
    }

    .social-icons-simple {
        margin-right: 0;
        margin-bottom: 10px;
    }
}
