/**
 * ==============================================================================
 * PLAYRADARX V2 — RESPONSIVE & CROSS-DEVICE DESIGN SYSTEM (responsive.css)
 * ==============================================================================
 * Kiến trúc Mobile-First lũy tiến chuẩn W3C:
 *   - Base Mobile: 320px - 575px (Mặc định không dùng @media)
 *   - Phablet:     min-width: 576px (Màn hình điện thoại lớn / Phablet)
 *   - Tablet:      min-width: 768px (Máy tính bảng dọc - iPad 10.2, Mini)
 *   - Laptop:      min-width: 1024px (Laptop & Desktop tiêu chuẩn, chuyển đổi Navbar)
 *   - Desktop:     min-width: 1280px (Màn hình lớn Full HD 1080p, Container 1240px)
 *   - Ultra-Wide:  min-width: 1600px (Màn hình đồ họa 2K/4K, Container 1360px)
 * ==============================================================================
 */

/* ==============================================================================
   TẦNG 0: NỀN TẢNG MOBILE TOÀN CỤC & CHỐNG TRÀN LAYOUT (BASE SHIELD)
   ============================================================================== */
html {
  box-sizing: border-box;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-behavior: smooth;
  width: 100%;
}

*,
*::before,
*::after {
  box-sizing: inherit;
}

body {
  width: 100%;
  min-width: 320px;
  position: relative;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Quy tắc cốt lõi chống tràn: Cho phép mọi Flex/Grid item co lại tự nhiên */
.content-area,
.sidebar,
.flex-child,
.grid-child,
.main-grid > *,
.container {
  min-width: 0;
}

/* Chống tràn ảnh, video, iframe, bảng biểu */
img,
svg,
video,
canvas,
audio,
iframe,
embed,
object {
  max-width: 100%;
  height: auto;
}

iframe {
  border: 0;
}

/* Tự động ngắt dòng văn bản dài, link dài, tiêu đề dài */
h1,
h2,
h3,
h4,
h5,
h6,
p,
span,
a,
label,
li,
td,
th {
  overflow-wrap: break-word;
  word-wrap: break-word;
}

pre,
code {
  white-space: pre-wrap;
  word-break: break-all;
  max-width: 100%;
}

/* Chống tự động phóng to (Auto-Zoom) trên iPhone/iOS Safari */
input[type="text"],
input[type="password"],
input[type="email"],
input[type="number"],
input[type="tel"],
input[type="url"],
input[type="search"],
select,
textarea {
  font-size: 16px;
}

/* Khung chứa nội dung (Container) cơ sở */
.container {
  width: 100%;
  margin-left: auto;
  margin-right: auto;
  padding-left: 12px;
  padding-right: 12px;
}

/* Bố cục nội dung chính mặc định trên mobile */
.main-grid {
  display: flex;
  flex-direction: column;
  gap: 16px;
  width: 100%;
}

.content-area {
  width: 100%;
}

.sidebar {
  width: 100%;
}

/* Mặc định ẩn banner nổi trôi 2 bên (Skyscraper Float Ads) */
.ad-float,
.ad-float-left,
.ad-float-right {
  display: none !important;
}

/* ==============================================================================
   TẦNG 1: ĐIỆN THOẠI DI ĐỘNG & MOBILE COMPACT (MAX-WIDTH: 768px)
   ============================================================================== */
@media (max-width: 768px) {
  .container {
    max-width: 100% !important;
    padding-left: 12px !important;
    padding-right: 12px !important;
  }

  .main-grid {
    display: flex !important;
    flex-direction: column !important;
    gap: 14px !important;
  }

  .content-area,
  .sidebar {
    width: 100% !important;
  }

  /* 7.1. TOPBAR & THÔNG BÁO TỐI GIẢN MOBILE */
  .topbar {
    padding: 3px 0 !important;
  }

  .topbar-text {
    font-size: 0.65rem !important;
  }

  /* 7.2. HEADER CHÍNH & BRANDING GAMING MOBILE */
  .site-header {
    position: sticky !important;
    top: 0 !important;
    z-index: 1000 !important;
    padding: 6px 0 !important;
    background: rgba(10, 14, 26, 0.95) !important;
    backdrop-filter: blur(16px) !important;
    -webkit-backdrop-filter: blur(16px) !important;
    border-bottom: 1px solid rgba(139, 25, 255, 0.3) !important;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.6) !important;
  }

  .header-main-row {
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    gap: 6px !important;
    width: 100% !important;
  }

  .logo-wrapper {
    flex: 0 0 auto !important;
    display: flex !important;
    align-items: center !important;
    gap: 5px !important;
    max-width: 58% !important;
  }

  .logo-img {
    width: 26px !important;
    height: 26px !important;
    min-width: 26px !important;
    border-radius: 6px !important;
    box-shadow: 0 0 10px rgba(139, 25, 255, 0.6) !important;
  }

  .site-title {
    font-size: 0.88rem !important;
    font-weight: 800 !important;
    letter-spacing: -0.2px !important;
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    max-width: 115px !important;
  }

  .site-tagline {
    display: none !important;
  }

  /* 7.3. CỤM TIỆN ÍCH MOBILE BÊN PHẢI (AUTH + THEME + LANG + BURGER) */
  .mobile-header-right {
    display: flex !important;
    align-items: center !important;
    gap: 4px !important;
    margin-left: auto !important;
  }

  .btn-mobile-auth {
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 4px !important;
    padding: 4px 7px !important;
    font-size: 0.68rem !important;
    font-weight: 700 !important;
    border-radius: 5px !important;
    white-space: nowrap !important;
  }

  .btn-mobile-login {
    background: rgba(255, 255, 255, 0.08) !important;
    color: #e2e8f0 !important;
    border: 1px solid rgba(255, 255, 255, 0.15) !important;
  }

  .btn-mobile-register {
    background: linear-gradient(135deg, #8B19FF 0%, #00F0FF 100%) !important;
    color: #ffffff !important;
    border: none !important;
    box-shadow: 0 0 10px rgba(139, 25, 255, 0.5) !important;
  }

  .mobile-theme-btn,
  .mobile-lang-btn {
    width: 28px !important;
    height: 28px !important;
    min-width: 28px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    border-radius: 6px !important;
    background: rgba(255, 255, 255, 0.06) !important;
    border: 1px solid rgba(255, 255, 255, 0.12) !important;
    color: #cbd5e1 !important;
    font-size: 0.75rem !important;
    cursor: pointer !important;
  }

  .mobile-menu-toggle {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    width: 32px !important;
    height: 32px !important;
    min-width: 32px !important;
    border-radius: 6px !important;
    background: rgba(139, 25, 255, 0.18) !important;
    border: 1px solid rgba(139, 25, 255, 0.45) !important;
    color: #00F0FF !important;
    font-size: 0.9rem !important;
    cursor: pointer !important;
    box-shadow: 0 0 10px rgba(139, 25, 255, 0.3) !important;
  }

  /* 7.4. THANH ĐIỀU HƯỚNG DESKTOP ẨN TRÊN MOBILE */
  .desktop-nav,
  .header-nav {
    display: none !important;
  }

  /* 7.5. MOBILE DRAWER NAVIGATION MENU */
  .mobile-drawer {
    position: fixed !important;
    top: 0 !important;
    right: -100% !important;
    width: 280px !important;
    max-width: 85vw !important;
    height: 100vh !important;
    background: rgba(10, 14, 26, 0.98) !important;
    backdrop-filter: blur(20px) !important;
    -webkit-backdrop-filter: blur(20px) !important;
    border-left: 1px solid rgba(139, 25, 255, 0.4) !important;
    box-shadow: -10px 0 30px rgba(0, 0, 0, 0.8) !important;
    z-index: 2000 !important;
    transition: right 0.3s cubic-bezier(0.4, 0, 0.2, 1) !important;
    display: flex !important;
    flex-direction: column !important;
    padding: 16px !important;
    overflow-y: auto !important;
  }

  .mobile-drawer.open {
    right: 0 !important;
  }

  .drawer-backdrop {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    background: rgba(0, 0, 0, 0.7) !important;
    backdrop-filter: blur(4px) !important;
    -webkit-backdrop-filter: blur(4px) !important;
    z-index: 1999 !important;
    opacity: 0 !important;
    pointer-events: none !important;
    transition: opacity 0.3s ease !important;
  }

  .drawer-backdrop.open {
    opacity: 1 !important;
    pointer-events: auto !important;
  }

  /* 7.6. HERO COMPACT & THỐNG KÊ MOBILE */
  .hero-compact {
    padding: 14px 0 10px !important;
  }

  .hero-stats {
    display: flex !important;
    flex-wrap: wrap !important;
    gap: 6px !important;
  }

  .stat-badge {
    padding: 3px 8px !important;
    font-size: 0.68rem !important;
  }

  /* 7.7. SERVER CARD COMPACT MOBILE */
  .server-card {
    padding: 10px 12px !important;
    border-radius: 8px !important;
  }

  .server-title {
    font-size: 0.88rem !important;
  }

  .server-meta {
    font-size: 0.7rem !important;
    gap: 6px !important;
  }

  /* 7.8. MODALS & POPUPS MOBILE */
  .modal-dialog {
    margin: 12px !important;
    max-width: calc(100vw - 24px) !important;
  }

  /* 7.9. TABLES TRÊN MOBILE */
  .table-responsive {
    display: block !important;
    width: 100% !important;
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch !important;
  }

  /* 7.10. CHÍNH SÁCH VÀ QUY TRÌNH QUẢNG CÁO MOBILE */
  .ad-policy-grid {
    grid-template-columns: repeat(3, 1fr) !important;
    gap: 6px !important;
  }

  .ad-policy-box {
    padding: 6px 5px !important;
    border-radius: 6px !important;
  }

  .ad-step-grid {
    grid-template-columns: repeat(3, 1fr) !important;
    gap: 6px !important;
  }

  .ad-step-grid > .ad-step-card:nth-child(4) {
    grid-column: 1 / -1 !important;
  }

  .ad-positions-grid {
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)) !important;
    gap: 10px !important;
  }
}

/* ==============================================================================
   TẦNG 1.5: ĐIỆN THOẠI NHỎ (XS: <= 480px)
   ============================================================================== */
@media (max-width: 480px) {
  .container {
    padding-left: 10px !important;
    padding-right: 10px !important;
  }

  .site-header .logo-main {
    font-size: 15px !important;
  }

  .page-hero-title,
  .page-hero h1 {
    font-size: 1.05rem !important;
  }

  .btn,
  .btn-primary,
  .btn-game {
    min-height: 38px;
    font-size: 0.85rem;
  }

  .categories-grid {
    gap: 8px !important;
  }

  .cat-card {
    padding: 8px 10px !important;
  }

  .cat-icon {
    width: 28px !important;
    height: 28px !important;
    min-width: 28px !important;
    font-size: 12px !important;
  }

  .sidebar {
    gap: 8px !important;
  }
}

/* ==============================================================================
   TẦNG 2: PHABLET & MÀN HÌNH ĐIỆN THOẠI LỚN (MIN-WIDTH: 576px)
   ============================================================================== */
@media (min-width: 576px) {
  .container {
    padding-left: 16px;
    padding-right: 16px;
  }

  .categories-grid {
    grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  }
}

/* ==============================================================================
   TẦNG 3: MÁY TÍNH BẢNG DỌC (TABLET PORTRAIT: MIN-WIDTH: 768px)
   ============================================================================== */
@media (min-width: 768px) {
  .container {
    max-width: 720px;
    padding-left: 16px;
    padding-right: 16px;
  }

  /* Ẩn các nút điều hướng đặc thù mobile */
  .mobile-only-auth,
  .mobile-header-right,
  .mobile-menu-toggle,
  .mobile-guest-wrap,
  .mobile-theme-selector,
  .mobile-lang-selector,
  .mobile-user-profile-wrap {
    display: none !important;
  }

  .news-grid {
    grid-template-columns: 1fr 1fr;
  }

  .ad-positions-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
  }
}

/* ==============================================================================
   TẦNG 4: MÁY TÍNH XÁCH TAY & DESKTOP (LAPTOP & DESKTOP: MIN-WIDTH: 1024px)
   ============================================================================== */
@media (min-width: 1024px) {
  .container {
    max-width: 1140px;
    padding-left: 20px;
    padding-right: 20px;
  }

  /* Kích hoạt thanh điều hướng Desktop */
  .desktop-nav,
  .header-nav {
    display: flex !important;
    align-items: center;
    gap: 16px;
  }

  /* Bố cục 2 cột tiêu chuẩn: Nội dung chính + Cột Sidebar cố định */
  .main-grid {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) 300px !important;
    gap: 24px !important;
    align-items: start !important;
  }

  .content-area {
    min-width: 0;
    width: 100%;
  }

  .sidebar {
    min-width: 0;
    width: 300px !important;
  }

  /* Lưới máy chủ & thể loại desktop */
  .games-grid,
  .normal-servers-grid,
  .servers-grid {
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 16px;
  }

  /* Lưới Bảng Giá Quảng Cáo: 3-4 cột thoáng đãng */
  .ad-positions-grid {
    grid-template-columns: repeat(auto-fit, minmax(285px, 1fr)) !important;
    gap: 14px !important;
  }

  /* Lưới Chính Sách 3 Cột */
  .ad-policy-grid {
    grid-template-columns: repeat(3, 1fr) !important;
    gap: 16px !important;
  }

  .ad-policy-grid > .ad-policy-box:nth-child(7) {
    grid-column: 1 / -1 !important;
  }

  /* Lưới Quy Trình 4 Bước Thẳng Hàng */
  .ad-step-grid {
    grid-template-columns: repeat(4, 1fr) !important;
    gap: 14px !important;
  }
}

/* ==============================================================================
   TẦNG 5: MÀN HÌNH DESKTOP TIÊU CHUẨN (MIN-WIDTH: 1280px)
   ============================================================================== */
@media (min-width: 1280px) {
  .container {
    max-width: 1240px;
    padding-left: 20px;
    padding-right: 20px;
  }

  .main-grid {
    grid-template-columns: minmax(0, 1fr) 300px !important;
    gap: 24px !important;
  }
}

/* ==============================================================================
   TẦNG 5.5: BANNER NỔI SKYSCRAPER TRÔI 2 BÊN (MIN-WIDTH: 1540px)
   ============================================================================== */
@media (min-width: 1540px) {
  .ad-float {
    display: flex !important;
    position: fixed;
    top: 220px;
    z-index: 850;
    width: 160px;
    transition: top 0.15s ease-out;
  }

  .ad-float-left {
    left: calc((100vw - 1280px) / 2 - 175px);
  }

  .ad-float-right {
    right: calc((100vw - 1280px) / 2 - 175px);
  }
}

/* ==============================================================================
   TẦNG 6: MÀN HÌNH DESKTOP LỚN (MIN-WIDTH: 1600px)
   ============================================================================== */
@media (min-width: 1600px) {
  .container {
    max-width: 1360px !important;
    padding-left: 24px !important;
    padding-right: 24px !important;
  }

  .main-grid {
    grid-template-columns: minmax(0, 1fr) 320px !important;
    gap: 28px !important;
  }
}

/* ==============================================================================
   TẦNG 7: SMART TV & 2K GAMING MONITORS (MIN-WIDTH: 1920px)
   Tự động nâng tỷ lệ font để người xem TV ngồi từ xa vẫn đọc chữ sắc nét rõ ràng
   ============================================================================== */
@media (min-width: 1920px) {
  html {
    font-size: 17.5px !important;
  }

  .container {
    max-width: 1680px !important;
    padding-left: 32px !important;
    padding-right: 32px !important;
  }

  .main-grid {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) 350px !important;
    gap: 32px !important;
  }

  .sidebar {
    width: 350px !important;
  }

  /* Dàn đều 4 cột cho các danh mục máy chủ và tựa game trên Smart TV */
  .games-grid,
  .normal-servers-grid,
  .servers-grid,
  .news-grid {
    grid-template-columns: repeat(4, 1fr) !important;
    gap: 20px !important;
  }

  /* Định vị lại Skyscraper Ads 2 bên màn hình TV */
  .ad-float-left {
    left: calc((100vw - 1680px) / 2 - 185px) !important;
  }

  .ad-float-right {
    right: calc((100vw - 1680px) / 2 - 185px) !important;
  }
}

/* ==============================================================================
   TẦNG 8: SMART TV 4K & MÀN HÌNH ĐỒ HỌA SIÊU RỘNG (MIN-WIDTH: 2560px)
   Chuẩn rạp hát 4K: Chữ và nút bấm tự phóng to tỉ lệ vàng, không bị li ti
   ============================================================================== */
@media (min-width: 2560px) {
  html {
    font-size: 19.5px !important;
  }

  .container {
    max-width: 2040px !important;
    padding-left: 40px !important;
    padding-right: 40px !important;
  }

  .main-grid {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) 400px !important;
    gap: 36px !important;
  }

  .sidebar {
    width: 400px !important;
  }

  /* Dàn đều 5 cột tuyệt đẹp trên màn hình 4K TV */
  .games-grid,
  .normal-servers-grid,
  .servers-grid,
  .news-grid {
    grid-template-columns: repeat(5, 1fr) !important;
    gap: 24px !important;
  }

  /* Định vị lại Skyscraper Ads trên 4K */
  .ad-float-left {
    left: calc((100vw - 2040px) / 2 - 200px) !important;
  }

  .ad-float-right {
    right: calc((100vw - 2040px) / 2 - 200px) !important;
  }
}

/* ==============================================================================
   TẦNG 9: ĐỒNG HÓA THẺ (CARDS), PAGE HERO & BỐ CỤC TOÀN BỘ CÁC TRANG
   Bảo đảm từ Trang Chủ, Kho Game, Tựa Game, Tin Tức tới Chi Tiết Server đều đồng nhất
   ============================================================================== */
.page-hero {
  padding: clamp(16px, 2.5vw, 36px) 0 !important;
  margin-bottom: clamp(14px, 2vw, 24px) !important;
  background: linear-gradient(135deg, rgba(14, 18, 30, 0.95) 0%, rgba(139, 25, 255, 0.12) 50%, rgba(14, 18, 30, 0.95) 100%) !important;
  border-bottom: 1px solid rgba(139, 25, 255, 0.25) !important;
}

.page-hero h1 {
  font-size: var(--prx-fs-hero) !important;
  font-weight: 800 !important;
  line-height: 1.25 !important;
  letter-spacing: -0.3px !important;
}

.page-hero-icon {
  width: clamp(40px, 4vw, 56px) !important;
  height: clamp(40px, 4vw, 56px) !important;
  min-width: clamp(40px, 4vw, 56px) !important;
  border-radius: var(--prx-card-radius) !important;
  background: linear-gradient(135deg, rgba(139, 25, 255, 0.3) 0%, rgba(0, 240, 255, 0.15) 100%) !important;
  border: 1px solid rgba(139, 25, 255, 0.4) !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  box-shadow: 0 0 15px rgba(139, 25, 255, 0.35) !important;
}

/* Đồng hóa thẻ Máy Chủ, Tựa Game, Tin Tức */
.server-card,
.game-card,
.news-card,
.cat-card,
.ad-position-card,
.ad-step-card {
  border-radius: var(--prx-card-radius) !important;
  border: var(--prx-card-border) !important;
  background: var(--prx-card-bg) !important;
  transition: transform var(--transition-normal), box-shadow var(--transition-normal), border-color var(--transition-normal) !important;
}

.server-card:hover,
.game-card:hover,
.news-card:hover,
.cat-card:hover,
.ad-position-card:hover {
  transform: translateY(-4px) !important;
  border: var(--prx-card-hover-border) !important;
  box-shadow: var(--prx-card-hover-shadow) !important;
}

.server-title,
.game-title,
.news-title {
  font-size: var(--prx-fs-card-title) !important;
  font-weight: 700 !important;
  line-height: 1.35 !important;
}
