/*
Theme Name: RingVip Theme (Tích hợp RPD Plugin)
Author: Custom Theme
Version: 1.3.0
Description: WordPress Theme chia sẻ nhạc chuông kết hợp chuẩn với plugin Ringtones Player & Downloader (Đã tối ưu Mobile).
*/

:root {
  --primary-color: #ff4757;
  --primary-hover: #e02847;
  --blue-color: #1e88e5;
  --bg-light: #f8f9fa;
  --text-color: #333;
  --border-radius: 12px;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
  background-color: #f4f6f9;
  color: var(--text-color);
  line-height: 1.5;
}

a {
  text-decoration: none;
  color: inherit;
}

.container {
  max-width: 1140px;
  margin: 0 auto;
  padding: 0 15px;
}

/* Header */
.site-header {
  background: #fff;
  border-bottom: 1px solid #eee;
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 70px;
}

.logo {
  font-size: 24px;
  font-weight: 800;
  color: var(--primary-color);
  display: flex;
  align-items: center;
  gap: 8px;
}

.main-navigation ul {
  display: flex;
  list-style: none;
  gap: 20px;
}

.main-navigation a {
  font-size: 14px;
  font-weight: 600;
  color: #555;
}

.btn-buy {
  background-color: var(--primary-color);
  color: #fff !important;
  padding: 8px 16px;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 600;
}

/* Hero Search */
.hero-section {
  background: linear-gradient(135deg, #ff4757, #ff6b81);
  color: #fff;
  padding: 40px 0;
  text-align: center;
}

.hero-title {
  font-size: 28px;
  margin-bottom: 8px;
}

.hero-subtitle {
  font-size: 14px;
  opacity: 0.9;
  margin-bottom: 20px;
}

.search-box {
  max-width: 600px;
  margin: 0 auto;
  display: flex;
  background: #fff;
  border-radius: 30px;
  overflow: hidden;
  padding: 4px;
}

.search-box input {
  flex: 1;
  border: none;
  padding: 10px 20px;
  outline: none;
  font-size: 14px;
}

.search-box button {
  background: #2ed573;
  border: none;
  color: #fff;
  padding: 10px 25px;
  border-radius: 25px;
  cursor: pointer;
  font-weight: bold;
}

/* Ads Slot */
.ad-slot {
  background: #fff5c4;
  border: 1px dashed #d1b200;
  text-align: center;
  padding: 12px;
  margin: 20px auto;
  font-weight: bold;
  font-size: 13px;
  color: #8a6d0b;
  border-radius: 6px;
}

/* Section Title */
.section-title {
  font-size: 18px;
  font-weight: 700;
  margin: 25px 0 15px;
  border-left: 4px solid var(--primary-color);
  padding-left: 10px;
}

/* Track List Desktop */
.track-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.track-item {
  background: #fff;
  border-radius: var(--border-radius);
  padding: 12px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: 0 2px 5px rgba(0,0,0,0.03);
}

.track-left {
  display: flex;
  align-items: center;
  gap: 15px;
  flex: 1;
  min-width: 0;
}

.btn-play {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: #ffebee;
  border: none;
  color: var(--primary-color);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  flex-shrink: 0;
}

.track-info {
  flex: 1;
  min-width: 0;
}

.track-info .track-name {
  font-size: 14px;
  font-weight: 700;
  color: #222;
  margin-bottom: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.track-info .track-name a:hover {
  color: var(--primary-color);
}

.track-meta {
  font-size: 12px;
  color: #888;
  display: flex;
  gap: 12px;
}

.track-right {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.btn-action {
  background: #f1f3f4;
  border: none;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  cursor: pointer;
  color: #666;
}

.btn-download {
  background: var(--blue-color);
  color: #fff;
  padding: 8px 18px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

/* Chart Grid (2 Columns Desktop) */
.chart-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 15px;
}

.chart-item {
  display: flex;
  align-items: center;
  gap: 10px;
}

.rank-badge {
  width: 32px;
  height: 32px;
  background: var(--primary-color);
  color: #fff;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 13px;
  flex-shrink: 0;
}

/* Rank Badge Colors */
.chart-grid .chart-item:nth-child(1) .rank-badge { background: #ff4757; }
.chart-grid .chart-item:nth-child(2) .rank-badge { background: #ff6b81; }
.chart-grid .chart-item:nth-child(3) .rank-badge { background: #ff7f50; }
.chart-grid .chart-item:nth-child(n+4) .rank-badge { background: #e0e0e0; color: #666; }

/* Categories Grid (4 Columns Desktop) */
.category-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 15px;
}

.category-card {
  background: #fff;
  border-radius: var(--border-radius);
  padding: 15px;
  display: flex;
  align-items: center;
  gap: 12px;
  box-shadow: 0 2px 5px rgba(0,0,0,0.03);
}

.category-icon {
  width: 40px;
  height: 40px;
  background: #ffebee;
  color: var(--primary-color);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.category-name {
  font-size: 14px;
  font-weight: 700;
  color: #222;
}

.category-count {
  font-size: 12px;
  color: #888;
}

/* Footer */
.site-footer {
  background: #263238;
  color: #b0bec5;
  padding: 40px 0 20px;
  margin-top: 50px;
  text-align: center;
  font-size: 12px;
}

.footer-links {
  display: flex;
  justify-content: center;
  gap: 20px;
  margin: 15px 0;
}

.footer-links a {
  color: #fff;
}

/* --- SINGLE PAGE LAYOUT --- */
.single-container {
  margin-top: 20px;
  margin-bottom: 40px;
}

.single-layout {
  display: flex;
  gap: 25px;
  margin-top: 15px;
}

.single-main {
  flex: 1;
  min-width: 0;
}

.single-sidebar {
  width: 320px;
  flex-shrink: 0;
}

.single-card {
  background: #fff;
  border-radius: var(--border-radius);
  padding: 25px;
  margin-bottom: 20px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.04);
}

.card-title {
  font-size: 16px;
  font-weight: 700;
  color: #222;
  margin-bottom: 15px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.card-title i {
  color: var(--primary-color);
}

.card-divider {
  border: 0;
  border-top: 1px solid #eee;
  margin: 15px 0;
}

.single-description {
  font-size: 14px;
  color: #555;
  line-height: 1.6;
}

.copyright-note {
  font-size: 12px;
  color: #888;
}

.copyright-note a {
  color: var(--blue-color);
}

/* --- CATEGORY / ARCHIVE PAGE --- */
.category-ringtone-container {
  max-width: 850px;
  margin: 30px auto 50px;
  padding: 0 15px;
}

.cat-title {
  font-size: 22px;
  font-weight: 700;
  color: #1a1a1a;
  display: flex;
  align-items: center;
  margin-bottom: 25px;
}

.cat-title .red-line {
  width: 4px;
  height: 22px;
  background-color: var(--primary-color);
  display: inline-block;
  margin-right: 10px;
  border-radius: 2px;
}

.ringtone-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.ringtone-item {
  background: #ffffff;
  border-radius: 16px;
  padding: 12px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: 0 2px 8px rgba(0,0,0,0.03);
}

.ringtone-info {
  flex-grow: 1;
  margin: 0 15px;
  overflow: hidden;
}

.song-title {
  margin: 0 0 6px 0;
  font-size: 15px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.song-title a {
  color: #222;
}

.song-meta {
  display: flex;
  gap: 15px;
  font-size: 12px;
  color: #777;
}

.ringtone-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

/* Pagination Style */
.pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  margin-top: 30px;
}

.pagination .page-numbers {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  background: #fff;
  color: #444;
  font-size: 14px;
  border: 1px solid #eaeaea;
}

.pagination .page-numbers.current {
  background-color: var(--primary-color);
  color: #fff;
  border-color: var(--primary-color);
}


/* ==========================================================================
   MOBILE RESPONSIVE (TỐI ƯU GIAO DIỆN CHUẨN 3 ẢNH MẪU)
   ========================================================================== */
@media (max-width: 768px) {
  
  .container {
    padding: 0 12px;
  }

  /* 1. Category Grid trên Mobile: Chia làm 2 Cột chuẩn theo ảnh 1 */
  .category-grid {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 12px !important;
  }

  .category-card {
    padding: 12px;
    border-radius: 14px;
  }

  .category-icon {
    width: 36px;
    height: 36px;
    font-size: 14px;
  }

  .category-name {
    font-size: 13px;
    line-height: 1.3;
  }

  .category-count {
    font-size: 11px;
  }

  /* 2. Chart Grid & Track List trên Mobile: Chuyển về 1 cột */
  .chart-grid {
    grid-template-columns: 1fr !important;
    gap: 10px !important;
  }

  .track-item, .ringtone-item {
    padding: 10px 12px !important;
    border-radius: 14px !important;
    gap: 8px !important;
  }

  .track-left {
    gap: 10px !important;
  }

  /* 3. Chuyển nút "Tải về" chữ dài thành nút TRÒN Icon Download chuẩn theo ảnh 2 & 3 */
  .btn-download, .download-btn, .action-btn.download-btn {
    width: 40px !important;
    height: 40px !important;
    padding: 0 !important;
    border-radius: 50% !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    font-size: 15px !important;
    flex-shrink: 0 !important;
  }

  /* Ẩn bớt chữ "Tải về" / "Tải MP3" trên mobile chỉ giữ lại Icon download */
  .btn-download span, 
  .download-btn text,
  .btn-download:after {
    display: none !important;
  }

  /* Ẩn nút Share trên Mobile để tiết kiệm diện tích */
  .btn-action, .share-btn {
    display: none !important;
  }

  /* Căn chỉnh lại Font size & ellipsis bài hát trên mobile */
  .track-info .track-name, .song-title {
    font-size: 13.5px !important;
    max-width: 180px;
  }

  .track-meta, .song-meta {
    font-size: 11px !important;
    gap: 8px !important;
  }

  /* Single Layout Mobile */
  .single-layout {
    flex-direction: column !important;
  }

  .single-sidebar {
    width: 100% !important;
  }
}

/* ==========================================================================
   FIX DỨT ĐIỂM LỖI VỠ NÚT & TÙ GIAO DIỆN MOBILE
   ========================================================================== */
@media (max-width: 768px) {
  
  .container {
    padding: 0 10px !important;
  }

  /* 1. Khung bài hát gọn gàng */
  .track-item, .ringtone-item {
    padding: 10px 12px !important;
    border-radius: 14px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    gap: 8px !important;
  }

  /* 2. Căn chỉnh cụm icon play và tiêu đề */
  .track-left {
    gap: 10px !important;
    flex: 1 !important;
    min-width: 0 !important;
  }

  .btn-play, .btn-play-archive, .btn-play-search {
    width: 36px !important;
    height: 36px !important;
    font-size: 13px !important;
    flex-shrink: 0 !important;
  }

  /* 3. Xử lý Tiêu đề bài hát không bị đè hay tràn dòng */
  .track-info, .ringtone-info {
    flex: 1 !important;
    min-width: 0 !important;
    margin: 0 !important;
  }

  .track-info .track-name, .song-title, .song-title a {
    font-size: 13px !important;
    font-weight: 600 !important;
    line-height: 1.3 !important;
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    display: block !important;
  }

  .track-meta, .song-meta {
    font-size: 11px !important;
    gap: 8px !important;
    margin-top: 3px !important;
  }

  /* 4. CHUYỂN NÚT TẢI VỀ THÀNH NÚT TRÒN CHIỀU CAO ĐẦY ĐỦ (ÉP ẨN CHỮ 'TẢI VỀ') */
  .btn-download, 
  .download-btn, 
  a.btn-download, 
  a.action-btn.download-btn {
    width: 38px !important;
    height: 38px !important;
    min-width: 38px !important;
    padding: 0 !important;
    border-radius: 50% !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    font-size: 0 !important; /* Bỏ chữ thừa */
    background-color: var(--blue-color) !important;
    color: #ffffff !important;
    flex-shrink: 0 !important;
    text-indent: -9999px; /* Đẩy chữ ra ngoài */
    position: relative;
  }

  /* Hiện Icon Download chuẩn giữa nút tròn */
  .btn-download::before, 
  .download-btn::before,
  a.btn-download::before {
    content: "\f019" !important; /* Mã Unicode icon Download FontAwesome */
    font-family: "Font Awesome 6 Free" !important;
    font-weight: 900 !important;
    font-size: 14px !important;
    color: #ffffff !important;
    text-indent: 0 !important;
    position: absolute;
  }

  /* 5. Ẩn Nút Share trên Mobile để nhường không gian */
  .btn-action, .share-btn, .ringtone-actions .share-btn {
    display: none !important;
  }

  /* 6. Thể loại chia 2 cột chuẩn */
  .category-grid {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 10px !important;
  }

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

/* --- STYLE PHÂN TRANG (PAGINATION) --- */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    margin: 25px 0 35px;
}

.pagination .page-numbers {
    width: 38px;
    height: 38px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    background: #fff;
    color: #444;
    text-decoration: none;
    font-size: 14px;
    font-weight: 600;
    border: 1px solid #eaeaea;
    transition: all 0.2s ease;
}

.pagination .page-numbers.current {
    background-color: var(--primary-color);
    color: #fff;
    border-color: var(--primary-color);
}

.pagination .page-numbers:hover:not(.current) {
    background-color: #f0f0f0;
}

/* ==========================================================================
   MOBILE RESPONSIVE (TỐI ƯU CỰC NÉT CHO MÀN HÌNH NHỎ < 768px)
   ========================================================================== */
@media (max-width: 768px) {
  
  .container {
    padding: 0 10px !important;
  }

  .hero-section {
    padding: 25px 10px !important;
  }

  .hero-title {
    font-size: 20px !important;
  }

  .hero-subtitle {
    font-size: 12px !important;
    margin-bottom: 15px !important;
  }

  /* 1. Đưa Danh sách & Bảng xếp hạng về 1 cột gọn gàng */
  .chart-grid {
    grid-template-columns: 1fr !important;
    gap: 10px !important;
  }

  .track-item {
    padding: 10px 12px !important;
    border-radius: 12px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    gap: 8px !important;
  }

  .track-left {
    gap: 10px !important;
    flex: 1 !important;
    min-width: 0 !important;
  }

  .btn-play {
    width: 36px !important;
    height: 36px !important;
    font-size: 13px !important;
    flex-shrink: 0 !important;
  }

  .rank-badge {
    width: 28px !important;
    height: 28px !important;
    font-size: 12px !important;
    border-radius: 6px !important;
    flex-shrink: 0 !important;
  }

  /* 2. Tiêu đề cắt gọn 1 dòng không bao giờ vỡ chữ */
  .track-info {
    flex: 1 !important;
    min-width: 0 !important;
  }

  .track-info .track-name, 
  .track-info .track-name a {
    font-size: 13px !important;
    font-weight: 600 !important;
    line-height: 1.3 !important;
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    display: block !important;
  }

  .track-meta {
    font-size: 11px !important;
    gap: 8px !important;
    margin-top: 2px !important;
  }

  /* 3. CHUYỂN NÚT TẢI VỀ THÀNH NÚT TRÒN XANH ICON DOWNLOAD (ẨN DẠNG CHỮ DÀI) */
  .btn-download {
    width: 38px !important;
    height: 38px !important;
    min-width: 38px !important;
    padding: 0 !important;
    border-radius: 50% !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    background-color: var(--blue-color) !important;
    color: #ffffff !important;
    flex-shrink: 0 !important;
  }

  .btn-download span {
    display: none !important; /* Ẩn chữ "Tải về" / "Tải MP3" */
  }

  .btn-download i {
    font-size: 15px !important;
    margin: 0 !important;
  }

  /* Ẩn nút Share để tiết kiệm diện tích */
  .btn-action {
    display: none !important;
  }

  /* 4. Thể loại hiển thị 2 cột chuẩn Mobile */
  .category-grid {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 10px !important;
  }

  .category-card {
    padding: 10px !important;
    gap: 8px !important;
    border-radius: 12px !important;
  }

  .category-icon {
    width: 34px !important;
    height: 34px !important;
    font-size: 13px !important;
  }

  .category-name {
    font-size: 12.5px !important;
    line-height: 1.2 !important;
  }

  .category-count {
    font-size: 10.5px !important;
  }
}

/* ==========================================================================
   FIX DỨT ĐIỂM VỠ KHUNG BẢNG XẾP HẠNG (CHART GRID)
   ========================================================================== */
.chart-grid {
    display: grid !important;
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 15px !important;
}

.chart-grid .chart-item {
    background: #ffffff !important;
    border-radius: 16px !important;
    padding: 12px 16px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    box-shadow: 0 2px 8px rgba(0,0,0,0.03) !important;
    gap: 12px !important;
    min-width: 0 !important; /* Bắt buộc để không bị tràn khung */
    box-sizing: border-box !important;
}

/* Badge số thứ tự #1, #2... */
.chart-grid .rank-badge {
    width: 34px !important;
    height: 34px !important;
    border-radius: 8px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    font-weight: 700 !important;
    font-size: 13px !important;
    flex-shrink: 0 !important;
}

/* Màu sắc chuẩn cho Rank */
.chart-grid .chart-item:nth-child(1) .rank-badge { background: #ff3555 !important; color: #fff !important; }
.chart-grid .chart-item:nth-child(2) .rank-badge { background: #ff5e78 !important; color: #fff !important; }
.chart-grid .chart-item:nth-child(3) .rank-badge { background: #ff8597 !important; color: #fff !important; }
.chart-grid .chart-item:nth-child(n+4) .rank-badge { background: #f0f0f2 !important; color: #777 !important; }

/* Nút Play tròn */
.chart-grid .btn-play {
    width: 36px !important;
    height: 36px !important;
    border-radius: 50% !important;
    background-color: #ffebee !important;
    border: none !important;
    color: #ff3555 !important;
    font-size: 13px !important;
    cursor: pointer !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    flex-shrink: 0 !important;
}

/* Cụm Tiêu Đề Bài Hát - Cắt 1 dòng tự động */
.chart-grid .track-info {
    flex: 1 !important;
    min-width: 0 !important;
    overflow: hidden !important;
    margin: 0 !important;
}

.chart-grid .track-name,
.chart-grid .track-name a {
    font-size: 14px !important;
    font-weight: 700 !important;
    color: #222 !important;
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    display: block !important;
    text-decoration: none !important;
}

.chart-grid .track-name a:hover {
    color: #ff3555 !important;
}

.chart-grid .track-meta {
    font-size: 12px !important;
    color: #888 !important;
    margin-top: 2px !important;
}

/* Cụm Nút Tải MP3 bên phải */
.chart-grid .track-right {
    flex-shrink: 0 !important;
}

.chart-grid .btn-download {
    height: 36px !important;
    padding: 0 16px !important;
    background-color: #1e88e5 !important;
    color: #fff !important;
    border-radius: 20px !important;
    font-size: 13px !important;
    font-weight: 600 !important;
    display: inline-flex !important;
    align-items: center !important;
    gap: 6px !important;
    text-decoration: none !important;
}

/* Responsive cho Màn hình Điện thoại (< 768px) */
@media (max-width: 768px) {
    .chart-grid {
        grid-template-columns: 1fr !important;
    }
}