/* Các quy tắc cơ bản cho HTML và Body */
html, body {
  width: 100%;
  font-family: "Roboto", "Noto Sans", sans-serif;
  margin: 0;
  padding: 0;
  background: #f1f1f1; /* Nền xám nhạt cho toàn bộ trang */
}

/* Banner Xổ Số */
.xoso-banner {
  background: url('/images/banner-bg.jpg') no-repeat center center;
  background-size: cover;
  padding: 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  box-sizing: border-box;
  flex-wrap: wrap;
  overflow: hidden;
}
@media (max-width: 1200px) {
  .xoso-banner {
    padding: 0px;
  }
}
.xoso-logo img {
  height: 80px;
  max-width: 100%;
  display: block;
}
.xoso-site-name {
  font-size: 24px;
  color: white;
  font-weight: 600;
  white-space: nowrap;
  line-height: 1.2;
}
@media (max-width: 600px) {
  .xoso-site-name {
    font-size: 18px;
  }
}
.xoso-date {
  display: flex;
  align-items: center;
  gap: 8px;
  color: white; /* Đảm bảo màu chữ trắng như bạn đã có trong HTML */
  font-size: 16px; /* Đảm bảo kích thước chữ như bạn đã có trong HTML */
}

/* Nút bật/tắt lịch trên header (hiển thị trên mobile) */
#headerCalendarToggleBtn {
  background: none;
  border: none;
  padding: 2px;
  margin: 0;  
  cursor: pointer;
  color: white;
  display: inline-flex; /* Mặc định là inline-flex khi được hiển thị */
  display: none; /* Mặc định ẩn trên màn hình lớn */
}
#headerCalendarToggleBtn svg {
  width: 36px;
  height: 36px;
  margin-left: 12px;
  fill: currentColor;
}
#headerCalendarToggleBtn:hover svg {
  opacity: 0.8;
}

/* Dải màu nền cho cột trái (kéo dài toàn màn hình) */
.left-column-bg-wrapper {
  background-color: #c62828; /* Màu đỏ cho nền cột trái */
}

/* Wrapper chính chứa các cột (trái, giữa, phải) */
.xoso-wrapper {
  display: flex;
  flex-wrap: nowrap;
  gap: 20px;
  max-width: 1200px; /* Giới hạn chiều rộng nội dung chính */
  margin: 0 auto; /* Căn giữa wrapper trong left-column-bg-wrapper */
  /* border-top: 1px solid #ddd;  <--- Bỏ */
}

/* Cột trái */
.xoso-left {
  flex: 0 0 220px; /* Giữ kích thước cố định */
  color: white;
  padding: 15px;
  /* border-right: 1px solid #a00;  <--- Bỏ */
  margin: 0;
  min-height: 100vh; /* Quan trọng để màu nền kéo dài xuống */
}

/* Cột giữa */
.xoso-center {
  flex: 1 1 0;
  min-width: 0;
  background: #fff;
  padding: 15px 15px 30px 15px;
  border: 1px solid #ddd;
}

/* Cột phải */
.xoso-right {
  width: 250px;
  flex-shrink: 0;
  background: #f9f9f9;
  padding: 15px;
  border: 1px solid #ddd;
}

.xoso-right img {
  width: 100%;
  margin-bottom: 10px;
  display: block;
  border-radius: 4px;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

/* Tiêu đề trong cột trái và phải */
.xoso-left h3,
.xoso-right h3 {
  font-size: 16px;
  margin: 0;
  color: white; /* Giữ nguyên màu trắng cho cột trái */
  /* Cần chỉnh màu riêng cho cột phải nếu muốn */
  /* .xoso-right h3 { color: #333; } */
}

/* Danh sách trong cột trái */
.xoso-left ul {
  list-style: none;
  padding-left: 0;
  margin: 0 0 10px 0;
}

.xoso-left li {
  background-color: rgba(255, 255, 255, 0.25);
  padding: 6px 10px;
  margin: 2px 0;
  border-radius: 4px;
  transition: background 0.2s;
}

.xoso-left li:hover {
  background-color: rgba(255, 255, 255, 0.35);
}

.xoso-left li a {
  color: #fff;
  text-decoration: none;
  display: block;
  font-size: 14px;
}

/* Các phần toggle miền trong cột trái */
.mien-toggle {
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
  padding: 6px 0;
  user-select: none;
}

.mien-toggle h3 {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  font-size: 16px;
  margin: 0;
  color: #fff;
}

.toggle-arrow {
  font-size: 14px;
  margin-left: 8px;
  transition: transform 0.2s ease;
}

.mien-toggle.collapsed .toggle-arrow {
  transform: rotate(-90deg);
}

.toggle-list {
  margin-bottom: 15px;
}

/* Các bảng kết quả */
.bang-kq-wrapper {
  overflow-x: auto;
}

.result-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 18px;
  text-align: center;
}
.result-table td:first-child {
  font-size: 14px !important; /* <--- KÍCH THƯỚC FONT MỚI CHO TÊN GIẢI (ví dụ: 14px) */
  font-weight: normal !important; /* <--- BỎ IN ĐẬM CHO TÊN GIẢI */
  vertical-align: middle; /* Đảm bảo tên giải căn giữa theo chiều dọc */
  max-width: 360px;
}
.result-table th,
.result-table td {
  border: 1px solid #333;
  padding: 8px 6px;
  font-weight: normal;
}

.result-table td { 
  font-weight: bold;
}

.result-table th {
  background-color: #f2f2f2;
  font-size: 14px;
}

.result-table td {
  vertical-align: middle;
}
.result-table td .so {
  display: block;
  margin: 2px auto;
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 28px;
  font-weight: bold;
  background-color: #fafafa;
  max-width: fit-content;
  margin-bottom: 5px; /* Khoảng cách giữa các số khi chúng xuống dòng */
}
/* Đảm bảo số cuối cùng không có margin-bottom thừa */
.result-table td .so:last-child {
  margin-bottom: 0;
}
/* Trong style.css */

/* ... (các quy tắc khác) ... */

/* THÊM QUY TẮC MỚI CHO CONTAINER CỦA CÁC DÒNG SỐ */
.so-row-flex {
    display: flex;
    justify-content: center; /* Căn giữa các số trong dòng */
    gap: 55px; /* <--- KHOẢNG CÁCH MẶC ĐỊNH CHO MÀN HÌNH LỚN (PC) */
    flex-wrap: wrap; /* Cho phép các số xuống dòng nếu không đủ chỗ */
    margin-bottom: 5px; /* Khoảng cách giữa các dòng số (nếu có 2 dòng) */
}
.so-row-flex:last-child {
    margin-bottom: 0;
}
/* Các số riêng lẻ trong flex container này */
.so-row-flex .so-item {
    padding: 0 2px;
    white-space: nowrap; /* Giữ các số không bị ngắt giữa */
    font-size: 28px;
}

/* --- MEDIA QUERIES ĐỂ ĐIỀU CHỈNH GAP CHO MÀN HÌNH NHỎ HƠN --- */

/* Cho màn hình từ 901px đến 1200px (nếu bạn có breakpoint 1100px hoặc lớn hơn) */
/* Ví dụ, nếu layout của bạn thay đổi ở 1100px hoặc 900px, bạn có thể điều chỉnh ở đây */
@media (max-width: 1200px) {
    .so-row-flex {
        gap: 40px; /* Giảm gap cho các màn hình laptop nhỏ hơn */
    }
}

/* Cho màn hình từ 769px đến 900px (tablet hoặc laptop nhỏ) */
@media (max-width: 900px) { /* breakpoint này tương ứng với lúc xoso-wrapper max-width 900px */
    .so-row-flex {
        gap: 30px; /* Giảm gap thêm */
    }
}

/* Cho màn hình từ 601px đến 768px (máy tính bảng đứng hoặc điện thoại ngang) */
@media (max-width: 768px) {
    .so-row-flex {
        gap: 20px; /* Giảm gap đáng kể cho màn hình mobile */
    }
}

/* Cho màn hình dưới hoặc bằng 600px (điện thoại) */
@media (max-width: 600px) {
    .so-row-flex {
        gap: 15px; /* Giảm gap nữa để phù hợp với điện thoại */
    }
}

/* Cho màn hình rất nhỏ (dưới 400px) */
@media (max-width: 400px) {
    .so-row-flex {
        gap: 10px; /* Gap nhỏ nhất để các số không bị rớt quá nhiều */
    }
    /* Nếu bạn muốn font chữ nhỏ lại để vừa hơn trên màn hình rất nhỏ */
    /* .so-row-flex .so-item {
        font-size: 18px;
    } */
}

/* ... (các quy tắc khác) ... */

/* Thêm class này vào các ô td chứa các số inline */
.result-inline-cell {
    /* Đảm bảo text-align center nếu muốn */
    text-align: center;
    font-size: 28px;
}
.giai-dac-biet td .so {
  color: red;
  font-size: 28px;
  font-weight: 900;
}


/* Nhãn cho lịch */
.calendar-label {
  font-size: 16px;
  font-weight: bold;
  margin-bottom: 10px;
  color: #444;
  display: block;
}

.chon-ngay-wrapper {
  margin-bottom: 10px;
}


/* === CSS CHO CALENDAR POPUP VÀ SIDEBAR (TINH CHỈNH) === */

/* Style cho #calendar-popup KHI NÓ NẰM TRONG SIDEBAR (trên desktop) */
/* Đây là quy tắc áp dụng khi JS di chuyển lịch vào trong .xoso-right */
.xoso-right #calendar-popup {
  display: block; /* Đảm bảo lịch hiển thị trong cột phải */
  position: static; /* Quan trọng để nó nằm trong luồng tài liệu */
  margin-top: 10px;
  margin-bottom: 20px;
  background-color: transparent; /* Giả sử cột phải có background riêng */
  border: none;
  box-shadow: none;
  padding: 0;
  border-radius: 0;
  /* Lịch sẽ tự động chiếm chiều rộng của cột phải */
}

/* Style cho #calendar-popup KHI NÓ TRỞ THÀNH POPUP */
#calendar-popup.is-header-triggered {
  position: fixed; /* Bắt buộc để nó là popup */
  background-color: white;
  border: 1px solid #ccc;
  box-shadow: 0 5px 15px rgba(0,0,0,0.2);
  z-index: 1010; /* Đảm bảo nó nằm trên cùng */
  padding: 10px;
  border-radius: 4px;
  display: block; /* Đảm bảo hiển thị */
  /* Các thuộc tính top, left sẽ được JavaScript điều chỉnh */
}

/* Class 'hidden' để ẩn/hiện toàn bộ #calendar-popup */
#calendar-popup.hidden {
  display: none !important; /* Đảm bảo ẩn tuyệt đối */
}


/* === Responsive cho layout chính === */

/* MÀN HÌNH TỪ 801px ĐẾN 1100px (Layout 2 cột: Giữa, Phải) */
@media screen and (max-width: 1100px) {
  .xoso-left {
    display: none; /* Ẩn hoàn toàn cột trái */
  }

  .xoso-wrapper {
    max-width: 900px; /* Điều chỉnh max-width cho layout 2 cột */
    flex-direction: row; /* Giữ cột giữa và phải nằm ngang */
    gap: 20px;
  }

  .xoso-center {
    flex: 1 1 0; /* Cột giữa chiếm hết không gian còn lại */
    min-width: 0;
  }

  .xoso-right {
    width: 250px; /* Cột phải vẫn giữ chiều rộng cố định */
    flex-shrink: 0;
    display: block; /* Đảm bảo cột phải hiển thị ở đây */
  }

  /* Nút calendar header ẩn ở breakpoint này */
  #headerCalendarToggleBtn {
    display: none;
  }
}

/* MÀN HÌNH TỪ DƯỚI HOẶC BẰNG 800px (Layout 1 cột: Chỉ Giữa) */
@media screen and (max-width: 800px) {
  .xoso-left {
    display: none; /* Cột trái vẫn ẩn */
  }
  .xoso-right {
    display: none; /* Ẩn hoàn toàn cột phải */
  }

  /* Ẩn lịch khi không phải là popup header trên mobile */
  #calendar-popup:not(.is-header-triggered) {
    display: none !important;
  }

  /* Hiển thị nút calendar header */
  #headerCalendarToggleBtn {
    display: inline-flex;
  }

  .xoso-center {
    flex: 1 1 100%; /* Cột giữa chiếm toàn bộ chiều rộng có sẵn */
    max-width: none; /* Cho phép mở rộng tối đa */
    margin: 0 auto; /* Căn giữa */
    padding: 0px 5px 30px 5px;
  }

  .xoso-wrapper {
    flex-direction: column; /* Chuyển sang bố cục 1 cột */
    gap: 0; /* Loại bỏ gap khi chỉ có 1 cột chính */
    max-width: none; /* Cho phép wrapper mở rộng toàn bộ màn hình */
    padding: 0px 0px; /* Thêm padding cho wrapper để nội dung không dính sát rìa */
  }

  /* Kích thước font cho bảng 3 cột trên mobile nhỏ */
  .result-table-3cot td:first-child {
    font-size: 14px !important;
    font-weight: normal !important;
    width: 55px;
  }
  .result-table-3cot {
    font-size: 20px;
  }
  .result-table-3cot td {
    padding: 6px 4px;
  }
}

/* Kích thước font cho bảng 3 cột */
.result-table-3cot {
  width: 100%;
  border-collapse: collapse;
  text-align: center;
  table-layout: fixed;
}

.result-table-3cot th {
  border: 1px solid #333;
  padding: 10px 6px;
  font-size: 18px;
  word-break: break-word;
  font-weight: normal;
  background-color: #f0f0f0;
}

.result-table-3cot td {
  border: 1px solid #333;
  padding: 10px 6px;
  word-break: break-word;
  font-weight: bold;
  font-size: 28px;
}
@media screen and (max-width: 900px) {
  .result-table-3cot td {
    font-size: 28px;
  }
}
.result-table th:first-child {
  width: 40px;
}
.result-table-3cot td:first-child {
  white-space: nowrap;
  color: #333;
  font-size: 28px;
  font-size: 14px !important; /* Đặt lại 14px và giữ !important nếu cần */
  font-weight: normal !important; /* Giữ normal và !important nếu cần */
}

.result-table-3cot tbody tr:first-child td:not(:first-child) {
  color: #d32f2f;
  max-width: 30px;
}
.result-table-3cot th:first-child,
.result-table-3cot td:first-child {
  width: 40px;  
  text-align: center;
  white-space: nowrap;  
}
.result-table-3cot th {
  font-size: 14px !important;
}
/* --- GIẢI ĐẶC BIỆT --- */
/* Áp dụng màu đỏ và font-weight cho toàn bộ ô kết quả Giải Đặc biệt */
.giai-dac-biet td {  
  font-weight: bold; /* Đảm bảo chữ in đậm */
}
/* Giữ nguyên style riêng cho các con số bên trong giải đặc biệt (nếu có) */
.giai-dac-biet td .so {
  color: #d32f2f;
  font-size: 28px; /* Giữ nguyên kích thước lớn hơn */
  font-weight: 900; /* Giữ nguyên độ đậm cao nhất */
  background-color: #fafafa;
}


/* --- GIẢI TÁM NỔI BẬT (cho miền Trung/Nam) --- */
/* Thêm class này cho dòng Giải 8 nếu muốn nổi bật */
.giai-tam-noi-bat td {
  color: #d32f2f;
  font-weight: bold;
}

/* --- GIẢI BẢY NỔI BẬT (cho miền Bắc) --- */
/* Thêm class này cho dòng Giải 7 nếu muốn nổi bật */
.giai-bay-noi-bat td {  
  font-weight: bold;
}
.giai-bay-noi-bat .so-row-flex .so-item {
    color: #d32f2f; /* <--- Đảm bảo các con số của Giải 7 MB có màu đỏ */
}
/* === Toolbar === */
.xoso-toolbar {
  display: flex;
  justify-content: flex-start;
  gap: 10px;
  padding: 10px 20px;
  background-color: #c62828;
  border-bottom: 2px solid #b71c1c;
  position: relative;
  z-index: 999;
}

.xoso-tab {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 6px 10px;
  margin: 2px;
  background-color: #f2f2f2;
  border: none;
  border-radius: 6px;
  color: #333;
  text-decoration: none;
  font-weight: 500;
  transition: background-color 0.2s, color 0.2s;
  line-height: 1.2;
}

.xoso-tab svg {
  display: block;
  width: 20px;
  height: 20px;
  fill: currentColor;
}

.xoso-tab:hover {
  background-color: #ddd;
  color: black;
}

.xoso-tab.active {
  background-color: #f5b400;
  color: white;
}

.xoso-tab-toggle {
  cursor: pointer;
  background-color: #eee;
}

.xoso-tab-toggle.active-dropdown {
  background-color: #f5b400;
  color: white;
}

/* === Dropdown CHUNG === */
.xoso-tab-dropdown {
  position: relative;
  display: inline-block;
}

.xoso-dropdown-list {
  position: absolute;
  top: 100%;
  left: 0;
  background: white;
  border: 1px solid #ccc;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
  min-width: 340px;
  padding: 10px;
  margin: 0;
  z-index: 1000;
  box-sizing: border-box;
  display: none;
}

.xoso-dropdown-list li {
  list-style: none;
  box-sizing: border-box;
}

.xoso-dropdown-list li:first-child {
  flex-basis: 100%;
  width: 100%;
  margin-bottom: 8px;
}

.xoso-dropdown-list li:first-child a {
  text-align: center;
  background-color: #f0f0f0;
  font-weight: bold;
  padding: 8px 10px;
}

.xoso-dropdown-list li a {
  display: block;
  padding: 8px 10px;
  text-decoration: none;
  color: #333;
  border-radius: 4px;
  transition: background-color 0.2s;
  overflow-wrap: break-word;
  word-break: break-word;
}

.xoso-dropdown-list li a:hover {
  background: #f2f2f2;
}

/* --- DESKTOP HOVER BEHAVIOR --- */
@media (min-width: 769px) {
  .xoso-tab-dropdown:hover > .xoso-dropdown-list {
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    gap: 6px;
    align-content: flex-start;
  }

  .xoso-tab-dropdown:hover > .xoso-dropdown-list li:not(:first-child) {
    flex-basis: calc(50% - 3px);
    width: calc(50% - 3px);
  }

  .xoso-toolbar .xoso-tab-dropdown:last-child:hover > .xoso-dropdown-list {
    left: auto;
    right: 0;
  }
}


/* Nút close mặc định ẩn (cho desktop) */
.close-mobile-popup {
  display: none;
}

@media (max-width: 768px) {
  .xoso-toolbar {
    padding: 5px;
  }
}
/* === POPUP CHO MÀN HÌNH NHỎ (MOBILE) === */
@media (max-width: 768px) {
  .xoso-toolbar .xoso-dropdown-list.open {
    position: fixed;
    left: 0;
    width: 100%;
    bottom: 0;
    background-color: white;
    border-top: 1px solid #e0e0e0;
    z-index: 1001;
    padding: 10px;
    box-sizing: border-box;
    overflow-y: auto;
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    gap: 10px;
    align-items: flex-start;
  }

  /* --- LI CHỨA HÀNG TIÊU ĐỀ (LINK "XEM TẤT CẢ" VÀ NÚT "CLOSE") --- */
  .xoso-toolbar .xoso-dropdown-list.open li.mobile-popup-header {
    flex-basis: 100%;
    width: 100%;
    display: flex;
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
    padding: 0;
    margin: 0 0 5px 0;
    list-style: none;
    box-sizing: border-box;
  }

  .xoso-toolbar .xoso-dropdown-list.open li.mobile-popup-header .view-all-region-link {
    flex-grow: 1;
    flex-shrink: 1;
    min-width: 0;
    text-align: left;
    font-weight: bold;
    color: #333;
    text-decoration: none;
    background-color: #e8f0fe;
    border-radius: 4px;
    padding: 8px 10px;
    line-height: 1.4;
    overflow-wrap: break-word;
    word-break: break-word;
  }

  .xoso-toolbar .xoso-dropdown-list.open li.mobile-popup-header .close-mobile-popup {
    flex-shrink: 0;
    margin-left: 10px;
    width: 30px;
    height: 30px;
    line-height: 30px;
    text-align: center;
    background-color: #f0f0f0;
    border: 1px solid #ccc;
    border-radius: 50%;
    font-size: 14px;
    font-weight: bold;
    color: #333;
    cursor: pointer;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
  }

  /* --- CÁC TỈNH (2 cột) - là các li KHÔNG PHẢI mobile-popup-header --- */
  .xoso-toolbar .xoso-dropdown-list.open li:not(.mobile-popup-header) {
    box-sizing: border-box;
    flex-basis: calc(50% - 5px);
    width: calc(50% - 5px);
    list-style: none;
  }

  .xoso-toolbar .xoso-dropdown-list.open li:not(.mobile-popup-header) a {
    display: block;
    padding: 10px 8px;
    background-color: #f9f9f9;
    border-radius: 4px;
    text-align: center;
    color: #333;
    text-decoration: none;
    transition: background-color 0.2s;
  }

  .xoso-toolbar .xoso-dropdown-list.open li a:hover {
    background-color: #e0e0e0;
  }

  body.mobile-popup-is-open {
    overflow: hidden;
  }
}

/* === Footer Styles === */
.xoso-footer {
  background-color: #424242;
  color: #e0e0e0;
  padding: 25px 0;
  font-size: 13px;
  text-align: center;
  border-top: 3px solid #c62828;
  width: 100%;
  box-sizing: border-box;
}

.xoso-footer .footer-content {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 20px;
  text-align: justify;
}

.xoso-footer p {
  margin: 0;
  line-height: 1.6;
}

@media (max-width: 768px) {
  .xoso-footer {
    padding: 20px 0;
  }
  .xoso-footer .footer-content {
    padding: 0 15px;
    text-align: left;
  }
  .xoso-footer p {
    font-size: 12px;
  }
}

.xoso-footer .footer-content p:first-child {
  text-align: justify;
  margin-bottom: 10px;
}

.xoso-footer p.copyright-text {
  text-align: center;
  margin-top: 15px;
  font-size: 0.9em;
  color: #cccccc;
}