/* ============================================================
   cai.css - 预测推荐页 (cai.html)
   Uses CSS variables from public.css:
     --primary, --gold, --orange, --red, --bg-light, --text-dark,
     --text-muted, --border-light, --radius-md, --radius-lg,
     --shadow-sm, --shadow-md
   ============================================================ */

/* ----------------------------------------------------------
   1. Filter Section
   ---------------------------------------------------------- */
.cxz-filter-box {
  background: var(--white, #ffffff);
  border-radius: var(--radius-lg, 12px);
  padding: 24px;
  margin-bottom: 20px;
  box-shadow: var(--shadow-sm, 0 2px 8px rgba(0, 0, 0, 0.06));
}

.cxz-filter-row {
  display: flex;
  align-items: flex-start;
  margin-bottom: 16px;
  gap: 12px;
}

.cxz-filter-row:last-child {
  margin-bottom: 0;
}

.cxz-filter-label {
  font-size: 14px;
  font-weight: 600;
  color: var(--primary, #102b6a);
  flex-shrink: 0;
  min-width: 56px;
  line-height: 32px;
  text-align: right;
}

.cxz-filter-options {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  flex: 1;
  min-width: 0;
}

/* Filter option tags (rendered as <button> in JS) */
.cxz-filter-options .cxz-filter-btn,
.cxz-filter-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 5px 16px;
  border-radius: 16px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-dark, #1a1a2e);
  background: var(--white, #ffffff);
  border: 1px solid var(--border-light, #e5e7eb);
  cursor: pointer;
  transition: all 0.25s ease;
  white-space: nowrap;
  line-height: 1.5;
  outline: none;
  -webkit-tap-highlight-color: transparent;
}

.cxz-filter-options .cxz-filter-btn:hover,
.cxz-filter-btn:hover {
  color: var(--primary, #102b6a);
  border-color: var(--primary, #102b6a);
  background: var(--bg-light, #f4f6fb);
}

.cxz-filter-options .cxz-filter-btn.active,
.cxz-filter-btn.active {
  color: #ffffff;
  background: var(--primary, #102b6a);
  border-color: var(--primary, #102b6a);
  box-shadow: 0 2px 8px rgba(16, 43, 106, 0.25);
}

/* Filter option links (fallback <a> style) */
.cxz-filter-options a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 5px 16px;
  border-radius: 16px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-dark, #1a1a2e);
  text-decoration: none;
  background: var(--white, #ffffff);
  border: 1px solid var(--border-light, #e5e7eb);
  transition: all 0.25s ease;
  white-space: nowrap;
}

.cxz-filter-options a:hover,
.cxz-filter-options a.active {
  color: #ffffff;
  background: var(--primary, #102b6a);
  border-color: var(--primary, #102b6a);
}

/* ----------------------------------------------------------
   2. Period Select Bar
   ---------------------------------------------------------- */
.cxz-period-bar {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.cxz-period-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--primary, #102b6a);
  padding-left: 14px;
  border-left: 4px solid var(--gold, #fdb933);
  line-height: 1.4;
}

.cxz-period-select {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}

.cxz-period-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 6px 18px;
  border-radius: 16px;
  font-size: 13px;
  font-weight: 500;
  border: 1px solid var(--primary, #102b6a);
  color: var(--primary, #102b6a);
  background: var(--white, #ffffff);
  cursor: pointer;
  transition: all 0.25s ease;
  white-space: nowrap;
  outline: none;
  -webkit-tap-highlight-color: transparent;
}

.cxz-period-btn:hover {
  background: var(--bg-light, #f4f6fb);
  box-shadow: 0 2px 6px rgba(16, 43, 106, 0.12);
}

.cxz-period-btn.active {
  color: #ffffff;
  background: var(--primary, #102b6a);
  border-color: var(--primary, #102b6a);
  box-shadow: 0 2px 8px rgba(16, 43, 106, 0.25);
}

/* ----------------------------------------------------------
   3. Table Section (overrides / extensions to public.css)
   ---------------------------------------------------------- */
.cxz-table-box {
  background: var(--white, #ffffff);
  border-radius: var(--radius-lg, 12px);
  box-shadow: var(--shadow-sm, 0 2px 8px rgba(0, 0, 0, 0.06));
  overflow: hidden;
  margin-bottom: 20px;
}

.cxz-table-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-light, #e5e7eb);
}

.cxz-table-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-dark, #1a1a2e);
}

.cxz-data-table {
  width: 100%;
  border-collapse: collapse;
}

.cxz-data-table thead {
  background: var(--bg-light, #f4f6fb);
}

.cxz-data-table th {
  padding: 12px 16px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted, #6b7280);
  text-align: center;
  white-space: nowrap;
  border-bottom: 1px solid var(--border-light, #e5e7eb);
}

.cxz-data-table td {
  padding: 14px 16px;
  font-size: 14px;
  color: var(--text-dark, #1a1a2e);
  text-align: center;
  border-bottom: 1px solid var(--border-light, #e5e7eb);
  vertical-align: middle;
}

.cxz-data-table tbody tr {
  transition: background 0.2s ease;
}

.cxz-data-table tbody tr:hover {
  background: var(--bg-light, #f4f6fb);
}

.cxz-data-table tbody tr:last-child td {
  border-bottom: none;
}

/* Table ball container - prevent overflow */
.cxz-data-table td .red-q,
.cxz-data-table td .bule-q {
  margin: 2px 1px;
}

/* Status tags in table */
.cxz-data-table td .status-hit {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 10px;
  border-radius: 10px;
  font-size: 12px;
  font-weight: 600;
}

/* ----------------------------------------------------------
   4. Pagination (extension to public.css)
   ---------------------------------------------------------- */
.cxz-pagination {
  padding: 20px;
  text-align: center;
}

.cxz-pagination .layui-laypage {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 4px;
}

.cxz-pagination .layui-laypage a,
.cxz-pagination .layui-laypage span {
  border-radius: var(--radius-md, 8px) !important;
  font-size: 13px !important;
  min-width: 32px;
  height: 32px;
  line-height: 32px !important;
  margin: 0 !important;
  border-color: var(--border-light, #e5e7eb) !important;
  transition: all 0.2s ease;
}

.cxz-pagination .layui-laypage a:hover {
  color: var(--primary, #102b6a) !important;
  border-color: var(--primary, #102b6a) !important;
}

.cxz-pagination .layui-laypage .layui-laypage-curr .layui-laypage-em {
  background: var(--primary, #102b6a) !important;
  border-radius: var(--radius-md, 8px) !important;
}

/* ----------------------------------------------------------
   5. Ranking Box
   ---------------------------------------------------------- */
.cxz-ranking-box {
  background: var(--white, #ffffff);
  border-radius: var(--radius-lg, 12px);
  overflow: hidden;
  box-shadow: var(--shadow-md, 0 4px 16px rgba(0, 0, 0, 0.08));
  margin-bottom: 20px;
  border: 1px solid var(--border-light, #e5e7eb);
}

.cxz-ranking-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 2px solid var(--gold, #fdb933);
  background: linear-gradient(135deg, var(--bg-light, #f4f6fb), #ffffff);
}

.cxz-ranking-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--primary, #102b6a);
  padding-left: 14px;
  border-left: 4px solid var(--gold, #fdb933);
  line-height: 1.4;
}

.cxz-rank-table {
  width: 100%;
  border-collapse: collapse;
}

.cxz-rank-table thead {
  background: var(--bg-light, #f4f6fb);
}

.cxz-rank-table th {
  padding: 12px 16px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted, #6b7280);
  text-align: center;
  white-space: nowrap;
  border-bottom: 1px solid var(--border-light, #e5e7eb);
}

.cxz-rank-table td {
  padding: 14px 16px;
  font-size: 14px;
  text-align: center;
  border-bottom: 1px solid var(--border-light, #e5e7eb);
  color: var(--text-dark, #1a1a2e);
  vertical-align: middle;
}

.cxz-rank-table tbody tr {
  transition: background 0.2s ease;
}

.cxz-rank-table tbody tr:hover {
  background: var(--bg-light, #f4f6fb);
}

.cxz-rank-table tbody tr:last-child td {
  border-bottom: none;
}

/* Highlight top-3 rows */
.cxz-rank-table tbody tr:nth-child(1) {
  background: rgba(253, 185, 51, 0.04);
}

.cxz-rank-table tbody tr:nth-child(2) {
  background: rgba(192, 192, 192, 0.04);
}

.cxz-rank-table tbody tr:nth-child(3) {
  background: rgba(205, 127, 50, 0.04);
}

/* ----------------------------------------------------------
   6. Rank Badges
   ---------------------------------------------------------- */
.cxz-rank-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  font-size: 13px;
  font-weight: 700;
  color: #ffffff;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.15);
  flex-shrink: 0;
}

/* 1st place - Gold */
.cxz-rank-1 {
  background: linear-gradient(135deg, #fdb933, #f5a623);
  box-shadow: 0 2px 8px rgba(253, 185, 51, 0.45);
}

/* 2nd place - Silver */
.cxz-rank-2 {
  background: linear-gradient(135deg, #c0c0c0, #a8a8a8);
  box-shadow: 0 2px 8px rgba(192, 192, 192, 0.45);
}

/* 3rd place - Bronze */
.cxz-rank-3 {
  background: linear-gradient(135deg, #cd7f32, #b5651d);
  box-shadow: 0 2px 8px rgba(205, 127, 50, 0.45);
}

/* 4th and beyond - Muted */
.cxz-rank-n {
  background: var(--text-muted, #6b7280);
  box-shadow: 0 1px 4px rgba(107, 114, 128, 0.3);
}

.cxz-expert-cell {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  font-weight: 600;
}

.cxz-expert-avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--navy), var(--primary-light));
  color: var(--white);
  font-size: 13px;
  font-weight: 700;
  flex-shrink: 0;
}

.cxz-rate {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 999px;
  font-weight: 700;
  font-size: 13px;
}

/* ----------------------------------------------------------
   7. Expert Link
   ---------------------------------------------------------- */
.cxz-expert-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--primary, #102b6a);
  text-decoration: none;
  font-weight: 600;
  font-size: 14px;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.cxz-expert-link:hover {
  color: var(--orange, #f15a22);
}

.cxz-expert-link::before {
  content: "";
  display: inline-block;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--primary, #102b6a);
  flex-shrink: 0;
  transition: background 0.2s ease;
}

.cxz-expert-link:hover::before {
  background: var(--orange, #f15a22);
}

/* ----------------------------------------------------------
   8. Buy / Action Button
   ---------------------------------------------------------- */
.cxz-btn-buy {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 5px 18px;
  border-radius: 14px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  background: linear-gradient(135deg, var(--orange, #f15a22), #e04e1a);
  color: #ffffff;
  text-decoration: none;
  transition: all 0.3s ease;
  white-space: nowrap;
  line-height: 1.5;
  outline: none;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.15);
  box-shadow: 0 2px 6px rgba(241, 90, 34, 0.3);
}

.cxz-btn-buy:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 14px rgba(241, 90, 34, 0.45);
  background: linear-gradient(135deg, #ff6b2b, #f15a22);
  color: #ffffff;
  text-decoration: none;
}

.cxz-btn-buy:active {
  transform: translateY(0);
  box-shadow: 0 2px 6px rgba(241, 90, 34, 0.3);
}

/* ----------------------------------------------------------
   9. Empty State
   ---------------------------------------------------------- */
.cxz-empty-row td {
  padding: 48px 20px !important;
  text-align: center !important;
  color: var(--text-muted, #6b7280);
  font-size: 14px;
}

.cxz-empty-row td::before {
  content: "";
  display: block;
  width: 48px;
  height: 48px;
  margin: 0 auto 12px;
  background: var(--bg-light, #f4f6fb);
  border-radius: 50%;
  border: 2px dashed var(--border-light, #e5e7eb);
}

/* ----------------------------------------------------------
   10. Page Layout (two-column on desktop)
   ---------------------------------------------------------- */
.cxz-cai-layout {
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: 20px;
  align-items: start;
}

.cxz-cai-main {
  min-width: 0;
}

.cxz-cai-sidebar {
  min-width: 0;
}

/* ----------------------------------------------------------
   11. Responsive - Tablet (1024px and below)
   ---------------------------------------------------------- */
@media (max-width: 1024px) {
  .cxz-filter-box {
    padding: 20px;
  }

  .cxz-filter-label {
    min-width: 50px;
    font-size: 13px;
  }

  .cxz-filter-btn {
    padding: 4px 14px;
    font-size: 12px;
  }

  .cxz-period-title {
    font-size: 16px;
  }

  .cxz-period-btn {
    padding: 5px 14px;
    font-size: 12px;
  }

  .cxz-ranking-box {
    margin-bottom: 16px;
  }

  .cxz-cai-layout {
    grid-template-columns: 1fr;
  }

  .cxz-cai-sidebar {
    order: -1;
  }
}

/* ----------------------------------------------------------
   12. Responsive - Mobile (768px and below)
   ---------------------------------------------------------- */
@media (max-width: 768px) {
  /* Filter */
  .cxz-filter-box {
    padding: 16px;
    border-radius: var(--radius-md, 8px);
    margin-bottom: 16px;
  }

  .cxz-filter-row {
    flex-direction: column;
    gap: 8px;
    margin-bottom: 12px;
  }

  .cxz-filter-label {
    min-width: auto;
    text-align: left;
    line-height: 1.4;
    font-size: 13px;
    padding-bottom: 2px;
    border-bottom: 1px solid var(--border-light, #e5e7eb);
  }

  .cxz-filter-options {
    gap: 6px;
  }

  .cxz-filter-btn {
    padding: 4px 12px;
    font-size: 12px;
  }

  /* Period bar */
  .cxz-period-bar {
    gap: 10px;
    margin-bottom: 12px;
  }

  .cxz-period-title {
    font-size: 15px;
    padding-left: 10px;
    border-left-width: 3px;
  }

  .cxz-period-select {
    margin-left: 0;
    width: 100%;
    justify-content: flex-start;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 4px;
  }

  .cxz-period-btn {
    padding: 5px 12px;
    font-size: 12px;
  }

  /* Table */
  .cxz-table-box {
    border-radius: var(--radius-md, 8px);
    margin-bottom: 16px;
  }

  .cxz-table-header {
    padding: 12px 14px;
  }

  .cxz-table-title {
    font-size: 14px;
  }

  .cxz-data-table th {
    padding: 10px 6px;
    font-size: 12px;
  }

  .cxz-data-table td {
    padding: 10px 6px;
    font-size: 12px;
  }

  /* Make table horizontally scrollable on mobile */
  .cxz-table-box {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .cxz-data-table {
    min-width: 560px;
  }

  /* Ranking */
  .cxz-ranking-box {
    border-radius: var(--radius-md, 8px);
    margin-bottom: 16px;
  }

  .cxz-ranking-header {
    padding: 12px 14px;
  }

  .cxz-ranking-title {
    font-size: 14px;
    padding-left: 10px;
    border-left-width: 3px;
  }

  .cxz-rank-table th {
    padding: 10px 6px;
    font-size: 12px;
  }

  .cxz-rank-table td {
    padding: 10px 6px;
    font-size: 12px;
  }

  .cxz-ranking-box {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .cxz-rank-table {
    min-width: 420px;
  }

  /* Rank badges - slightly smaller on mobile */
  .cxz-rank-badge {
    width: 24px;
    height: 24px;
    font-size: 12px;
  }

  /* Expert link */
  .cxz-expert-link {
    font-size: 13px;
  }

  /* Buy button */
  .cxz-btn-buy {
    padding: 4px 14px;
    font-size: 11px;
    border-radius: 12px;
  }

  /* Pagination */
  .cxz-pagination {
    padding: 16px 10px;
  }

  /* Balls in table - smaller */
  .cxz-data-table td .red-q,
  .cxz-data-table td .bule-q {
    width: 22px;
    height: 22px;
    font-size: 11px;
    margin: 1px;
  }
}

/* ----------------------------------------------------------
   13. Responsive - Small Mobile (480px and below)
   ---------------------------------------------------------- */
@media (max-width: 480px) {
  .cxz-filter-box {
    padding: 12px;
    margin-bottom: 12px;
  }

  .cxz-filter-row {
    margin-bottom: 10px;
  }

  .cxz-filter-label {
    font-size: 12px;
  }

  .cxz-filter-btn {
    padding: 3px 10px;
    font-size: 11px;
    border-radius: 12px;
  }

  .cxz-period-bar {
    gap: 8px;
  }

  .cxz-period-title {
    font-size: 14px;
  }

  .cxz-period-btn {
    padding: 4px 10px;
    font-size: 11px;
  }

  .cxz-data-table {
    min-width: 480px;
  }

  .cxz-data-table th {
    padding: 8px 4px;
    font-size: 11px;
  }

  .cxz-data-table td {
    padding: 8px 4px;
    font-size: 11px;
  }

  .cxz-data-table td .red-q,
  .cxz-data-table td .bule-q {
    width: 20px;
    height: 20px;
    font-size: 10px;
    margin: 1px 0;
  }

  .cxz-rank-table {
    min-width: 360px;
  }

  .cxz-rank-badge {
    width: 22px;
    height: 22px;
    font-size: 11px;
  }

  .cxz-btn-buy {
    padding: 3px 10px;
    font-size: 10px;
    border-radius: 10px;
  }

  .cxz-expert-link {
    font-size: 12px;
    gap: 4px;
  }

  .cxz-expert-link::before {
    width: 3px;
    height: 3px;
  }

  .cxz-pagination {
    padding: 12px 6px;
  }

  .cxz-pagination .layui-laypage a,
  .cxz-pagination .layui-laypage span {
    min-width: 28px !important;
    height: 28px !important;
    line-height: 28px !important;
    font-size: 12px !important;
  }
}

/* ----------------------------------------------------------
   14. Animations
   ---------------------------------------------------------- */
@keyframes cxz-fade-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.cxz-filter-box {
  animation: cxz-fade-in 0.3s ease-out;
}

.cxz-table-box {
  animation: cxz-fade-in 0.4s ease-out;
}

.cxz-ranking-box {
  animation: cxz-fade-in 0.5s ease-out;
}

/* Badge pulse animation for 1st place */
@keyframes cxz-badge-pulse {
  0%, 100% {
    box-shadow: 0 2px 8px rgba(253, 185, 51, 0.45);
  }
  50% {
    box-shadow: 0 2px 14px rgba(253, 185, 51, 0.7);
  }
}

.cxz-rank-1 {
  animation: cxz-badge-pulse 2s ease-in-out infinite;
}

/* ----------------------------------------------------------
   15. Print Styles
   ---------------------------------------------------------- */
@media print {
  .cxz-filter-box,
  .cxz-period-bar,
  .cxz-btn-buy,
  .cxz-pagination {
    display: none !important;
  }

  .cxz-ranking-box,
  .cxz-table-box {
    box-shadow: none;
    border: 1px solid #ccc;
  }

  .cxz-data-table th,
  .cxz-data-table td,
  .cxz-rank-table th,
  .cxz-rank-table td {
    padding: 6px 8px;
    font-size: 11px;
  }
}
