/* ======================= RESET & ROOT ======================= */
:root {
  --primary: #7d0230;
  --primary-hover: #53002e;
  --bg: #f9f9f9;
  --bg-light: #ffffff;
  --border: #ddd;
  --text: #333;
  --text-muted: #777;
  --radius: 6px;
  --font: 'Segoe UI', 'Open Sans', sans-serif;
  --transition: 0.2s ease;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

/* ======================= CSS IMG VIDEO AUDIO ======================= */


/* Video gốc */
video {
  max-width: 100%;
  height: auto;
  display: block;
  margin: 10px auto;
  border-radius: 4px;
}

/* Audio */
audio {
  width: 100%;
  margin: 10px 0;
  display: block;
}

/* YouTube iframe nhúng */
iframe {
  max-width: 100%;
  height: auto;
  display: block;
  margin: 10px auto;
  aspect-ratio: 16 / 9; /* giữ tỉ lệ 16:9 */
  border-radius: 4px;
  border: none;
}


/* ======================= STYLE CHO INDEX PAGE ======================= */
body {
  font-family: 'Segoe UI', 'Open Sans', sans-serif;
}
.site-header .header-container {
  display: flex;
  justify-content: space-between; /* Logo trái, nút phải */
  align-items: center;
  padding: 10px 16px;
}

.auth-link a {
  text-decoration: none;
  color: #333;
  font-weight: 500;
  padding: 6px 10px;
  border-radius: 6px;
  transition: background 0.3s;
}

.auth-link a:hover {
  background: #f0f0f0;
}

.logout {
  color: #d9534f;
}


/* ===== NUMBER GRID ===== */
.number-grid-container {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 20px 0;
}

.number-grid {
  display: grid;
  grid-template-columns: repeat(10, 1fr);
  gap: 8px;
  max-width: 600px;
}

.number-grid div {
  width: 48px;
  height: 48px;
  background-color: #fff9e6;
  border: 1px solid #ccc;
  border-radius: 8px;
  font-weight: bold;
  font-size: 14px;
  font-family: monospace;
  color: #333;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  transition: all 0.2s ease;
  cursor: default;
}

.number-grid div.top {
  background-color: #ffeaa7;
  border-color: #fdcb6e;
  color: #000;
  box-shadow: 0 8px 5px rgba(0,0,0,0.1);
}

.number-grid div:hover {
  background-color: #f1f2f6;
  transform: scale(1.05);
  box-shadow: 0 4px 8px rgba(0,0,0,0.15);
}

.number-grid div:hover::after {
  content: attr(data-rank);
  position: absolute;
  top: -28px;
  left: 50%;
  transform: translateX(-50%);
  background: #2d3436;
  color: #fff;
  padding: 4px 8px;
  font-size: 12px;
  border-radius: 6px;
  white-space: nowrap;
  box-shadow: 0 2px 6px rgba(0,0,0,0.3);
}

/* Mobile Responsive */
@media (max-width: 600px) {
  .number-grid {
    display: grid;
    grid-template-columns: repeat(10, minmax(0, 1fr)); /* Chia đều mà không bị lố */
    gap: 2px; /* Rất quan trọng: giảm gap để tiết kiệm chiều rộng */
    padding: 0; 
    margin: 0 auto; /* Căn giữa nguyên grid */
    max-width: 100%; /* Chống tràn */
    box-sizing: border-box; /* Bắt buộc */
  }

  .number-grid div {
    width: 100%;            /* Mỗi ô chiếm đúng phần của cột */
    aspect-ratio: 1 / 1;     /* Tự động vuông theo chiều ngang */
    font-size: 11px;         /* Nhỏ lại cho vừa */
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;              /* Không cần padding để tránh lố */
    box-sizing: border-box;
  }
}



/* ===== TEXTAREA ===== */
textarea {
  width: 100%;
  height: 100px;
  padding: 10px;
  font-size: 15px;
  border-radius: 6px;
  border: 1px solid #ccc;
  margin-top: 10px;
  resize: vertical;
}

/* ===== BUTTON ===== */
button {
  margin-top: 12px;
  padding: 10px 20px;
  font-size: 16px;
  background: #0984e3;
  color: #fff;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.3s;
}
button:hover {
  background: #74b9ff;
}

/* ===== RANK BOX ===== */
.rank-box1 {
  background: var(--bg-light);
  padding: 16px;
  border-radius: 8px;
  margin-top: 20px;
  box-shadow: 0 2px 6px rgba(0,0,0,0.05);
  border: 1px solid var(--border);
}
.rank-box1 h4, .rank-box h5 {
  margin-bottom: 8px;
}
.rank-box1 p {
  white-space: normal;
  word-wrap: break-word;
  font-family: monospace;
  font-size: 15px;
  margin-bottom: 20px; /* thêm khoảng cách */
}
#top90Part1 {
  margin-bottom: 20px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
}


.rank-box {
  background: var(--bg-light);
  padding: 16px;
  border-radius: 8px;
  margin-top: 20px;
  box-shadow: 0 2px 6px rgba(0,0,0,0.05);
  border: 1px solid var(--border);
}
.rank-box h4, .rank-box h5 {
  margin-bottom: 8px;
}
.rank-box p {
  white-space: normal;
  word-wrap: break-word;
  font-family: monospace;
  font-size: 15px;
}
.rank-box {
  text-align: center;
}

.rank-box > div {
  display: inline-block;
}


/* ===== LOADING ===== */
#loading {
  color: gray;
  margin-top: 10px;
  display: none;
}

/* ===== FOOTER ===== */
footer {
  background-color: #dfe6e9;
  text-align: center;
  padding: 12px 0;
  font-size: 13px;
  color: #636e72;
  margin-top: 30px;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 600px) {
 

  header h1 {
    font-size: 18px;
  }

  textarea {
    font-size: 14px;
  }

  button {
    font-size: 15px;
  }
  
  #bbcode-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px; /* khoảng cách giữa các nút */
  justify-content: flex-start;
}

#bbcode-toolbar button {
  flex: 1 1 45%; /* mỗi nút chiếm tối thiểu 45% chiều ngang, có thể co giãn */
  max-width: 150px; /* giới hạn tối đa chiều rộng */
  font-size: 15px;
  padding: 8px 0;
  box-sizing: border-box;
}


  .rank-box p {
    font-size: 14px;
  }
}



/* ===== UTILS ===== */
.container {
  max-width: 960px;
  margin: auto;
  padding: 0 16px;
}
.center {
  text-align: center;
}
.mt-3 { margin-top: 24px; }
.mb-3 { margin-bottom: 24px; }

/* ===== HEADER ===== */
.site-header {
  background: #fff;
  border-bottom: 1px solid #ddd;
  box-shadow: 0 2px 5px rgba(0,0,0,0.05);
  position: fixed;
  top: 0;
  width: 100%;
  z-index: 999;
}

.header-container {
  max-width: 1200px;
  margin: auto;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.logo {
  display: flex;
  align-items: center;
  text-decoration: none;
}

.logo-img {
  width: 28px;
  height: 28px;
  margin-right: 8px;
}

.logo-text {
  font-weight: bold;
  font-size: 18px;
  color: #333;
}

.auth-link a {
  text-decoration: none;
  color: #555;
  font-weight: 500;
  padding: 6px 10px;
  border-radius: 6px;
  transition: background 0.3s;
}

.auth-link a:hover {
  background: #f0f0f0;
}

.logout {
  color: #d9534f;
}

/* Desktop mặc định hiển thị */
.desktop-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* Mobile mặc định ẩn */
.mobile-header {
  display: none;
}

/* Hiển thị mobile, ẩn desktop */
@media (max-width: 768px) {
  .desktop-header {
    display: none;
  }
  .mobile-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 16px;
  }
  .mobile-header .logo-img {
    width: 32px;
    height: 32px;
  }
}






/* Mobile Responsive */
@media (max-width: 768px) {
  .header-container {
    flex-direction: column;
    align-items: flex-start;
  }

  .nav {
    margin-top: 10px;
    flex-wrap: wrap;
  }

  .nav-link, .login-form button {
    font-size: 15px;
    padding: 6px 12px;
  }

  .login-form {
    flex-wrap: wrap;
  }
}


/* ===== FORM ===== */
form {
  margin-top: 24px;
}
textarea.form-control {
  width: 100%;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 16px;
  resize: vertical;
  background-color: #fff;
}
button.btn {
  background: var(--primary);
  color: #fff;
  border: none;
  padding: 10px 18px;
  border-radius: var(--radius);
  font-size: 16px;
  cursor: pointer;
  transition: background var(--transition);
}
button.btn:hover {
  background: var(--primary-hover);
}

/* ===== POSTS ===== */
.list-group {
  margin-top: 16px;
}
.post {
  background: var(--bg-light);
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}
.chat_message {
  display: block;
  font-family: 'Courier New', monospace;
  font-size: 15px;
  white-space: pre-wrap;
  word-break: break-word;
  margin-bottom: 8px;
}
.post p {
  font-size: 13px;
  color: var(--text-muted);
  margin: 0;
}
.post a {
  font-size: 14px;
  color: var(--primary);
  margin-right: 12px;
  text-decoration: none;
}
.post a:hover {
  text-decoration: underline;
}



/* ===== PAGINATION ===== */
.pagination {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  margin-top: 20px;
  gap: 6px;
  padding: 10px;
}

.pagination a {
  padding: 6px 12px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: #fff;
  color: var(--primary);
  text-decoration: none;
  transition: background var(--transition);
  white-space: nowrap;
  font-size: 14px;
}

.pagination a.current {
  background: var(--primary);
  color: #fff;
  pointer-events: none;
}

.pagination a:hover:not(.current) {
  background: var(--primary-hover);
  color: #fff;
}

/* ===== Responsive (Mobile) ===== */
@media screen and (max-width: 480px) {
  .pagination a {
    font-size: 13px;
    padding: 5px 10px;
  }
}



/* ===== FOOTER ===== */
.site-footer {
  background: #f0f0f0;
  padding: 24px 0;
  text-align: center;
  font-size: 14px;
  color: var(--text-muted);
  border-top: 1px solid var(--border);
}
.site-footer a {
  color: var(--text-muted);
  margin: 0 6px;
  text-decoration: none;
}
.site-footer a:hover {
  color: var(--primary);
}

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
  body {
    font-size: 17px;
  }
  .site-header .container {
    flex-direction: column;
    align-items: flex-start;
    height: auto;
    padding: 12px 16px;
  }
  .nav {
    margin-top: 8px;
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
  }
  .nav a {
    margin: 0;
    margin-right: 16px;
  }
  .btn {
    width: 100%;
  }
  .chat_message {
    font-size: 14px;
  }
}


/* Chừa khoảng trống cho header */
  padding-bottom: 70px; /* Chừa khoảng trống cho footer */
  box-sizing: border-box;
}

.site-footer, footer {
  position: relative;
  bottom: 0;
  left: 0;
  width: 100%;
}


/* ===== LAYOUT: HEADER, FOOTER & BOTTOM-NAV ===== */
html, body {
  height: 100%;
  display: flex;
  flex-direction: column;
}

main {
  flex: 1;
  padding-top: 80px;    /* chừa khoảng trống cho header */
  padding-bottom: 60px; /* chừa khoảng trống cho footer hoặc bottom-nav */
  box-sizing: border-box;
}

/* Footer (desktop) luôn ở cuối trang */
.site-footer, footer {
  position: relative;
  bottom: 0;
  left: 0;
  width: 100%;
}

/* Điều chỉnh cho mobile */
@media (max-width: 768px) {
  main.container {
    padding-top: 60px;    /* chừa khoảng trống cho header mobile */
    padding-bottom: 60px; /* chừa chỗ cho bottom-nav */
  }
}


/* ===== FOOTER & BOTTOM-NAV (RESPONSIVE) ===== */

/* Ẩn footer trên mobile */
@media (max-width: 768px) {
  .hide-on-mobile {
    display: none !important;
  }
}

/* Bottom nav mặc định ẩn (desktop) */
.bottom-nav {
  display: none;
}

/* Bottom nav hiển thị trên mobile */
@media (max-width: 768px) {
  .bottom-nav {
    display: flex;
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    background: #fff;
    border-top: 1px solid #ddd;
    justify-content: space-around;
    padding: 6px 0;
    z-index: 1000;
    box-shadow: 0 -1px 4px rgba(0,0,0,0.05);
  }

  .bottom-nav a {
    flex: 1;
    text-align: center;
    text-decoration: none;
    color: #666;
    font-size: 13px;
    transition: color 0.3s;
  }

  .bottom-nav a i {
    font-size: 18px;
    display: block;
    margin-bottom: 2px;
  }

  .bottom-nav a.active,
  .bottom-nav a:hover {
    color: #007bff;
  }
}

.login-box {
  max-width: 400px;
  margin: 80px auto;
  padding: 30px;
  border-radius: 10px;
  background: #ffffff;
  box-shadow: 0 4px 20px rgba(0,0,0,0.1);
  text-align: center;
  font-family: 'Inter', sans-serif;
}

.login-box h2 {
  margin-bottom: 20px;
  color: #333;
}

.login-input {
  width: 100%;
  padding: 12px 15px;
  margin-bottom: 16px;
  font-size: 15px;
  border: 1px solid #ddd;
  border-radius: 6px;
}

.login-button {
  padding: 10px 18px;
  background: #007bff;
  color: white;
  font-size: 15px;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.3s ease;
}

.login-button:hover {
  background: #0056b3;
}

.error-msg {
  color: red;
  font-size: 14px;
  margin-bottom: 12px;
}
