/**
 * Dark theme — activated via html[data-theme="dark"]
 * Toggle: localStorage.theme = system | light | dark
 */

[data-theme="dark"] {
  color-scheme: dark;
  --color-page: #111827;
  --color-text: #e5e7eb;
  --color-text-secondary: #9ca3af;
  --color-font-gray: #9ca3af;
  --color-gray: #9ca3af;
  --color-light-blue: #1f2937;
  --color-light: #1f2937;
  --dx-main-bg-color: #0f1419;
  --dx-subtitle-color: #d1d5db;
  --color-border: rgba(255, 255, 255, 0.1);
  --color-input-border: #374151;
  --color-input-text: #e5e7eb;
  --color-input-background: rgba(255, 255, 255, 0.06);
  --color-input-placeholder: #6b7280;
  --color-popover-bg: #1f2937;
  --color-image-placeholder: #374151;
  --dx-box-shadow: 0 0 10px rgba(0, 0, 0, 0.35);
  --color-breadcrumb-text: #9ca3af;
  --color-breadcrumb-active-text: #e5e7eb;
  --dx-scrollbar-thumb-color: #6b7280;
  --dx-scrollbar-thumb-hover-color: #9ca3af;
  --swiper-pagination-bullet-inactive-color: #374151;
  --backdrop-blur-bg: rgba(15, 20, 25, 0.85);
}

[data-theme="dark"] body {
  background-color: var(--color-page);
  color: var(--color-text);
}

/* --- Tailwind arbitrary color overrides (views) --- */
[data-theme="dark"] .text-\[\#374151\],
[data-theme="dark"] .\!text-\[\#374151\] {
  color: #e5e7eb !important;
}
[data-theme="dark"] .text-\[\#111827\],
[data-theme="dark"] .text-\[\#333\] {
  color: #f3f4f6 !important;
}
[data-theme="dark"] .text-\[\#4B5563\],
[data-theme="dark"] .text-\[\#6B7280\],
[data-theme="dark"] .text-\[\#6D798C\],
[data-theme="dark"] .text-\[\#666\],
[data-theme="dark"] .text-\[\#999\],
[data-theme="dark"] .text-\[\#9CA3AF\] {
  color: #9ca3af !important;
}
[data-theme="dark"] .bg-\[\#EDF0F5\],
[data-theme="dark"] .bg-\[\#E6E8EC\],
[data-theme="dark"] .bg-\[\#eaf4fb\],
[data-theme="dark"] .bg-\[\#e6f0ff\],
[data-theme="dark"] .bg-slate-50\/50 {
  background-color: #1f2937 !important;
}
[data-theme="dark"] .bg-white,
[data-theme="dark"] .bg-white\/60 {
  background-color: #1f2937 !important;
}
[data-theme="dark"] .border-\[\#E6E8EC\],
[data-theme="dark"] .border-\[\#E6E8EC4D\],
[data-theme="dark"] .border-\[\#dcdfe6\],
[data-theme="dark"] .border-\[\#dde0e4\],
[data-theme="dark"] .border-\[\#ccc\] {
  border-color: #374151 !important;
}
[data-theme="dark"] .hover\:bg-\[\#e6f0ff\]:hover {
  background-color: #374151 !important;
}
[data-theme="dark"] .hover\:text-\[\#333\]:hover {
  color: #e5e7eb !important;
}
[data-theme="dark"] .placeholder-\[\#9CA3AF\]::placeholder,
[data-theme="dark"] .placeholder\:text-\[\#9CA3AF\]::placeholder {
  color: #6b7280 !important;
}

/* Semantic helpers (Phase 2 partials) */
.text-dx-primary { color: var(--color-text); }
.text-dx-muted { color: var(--color-text-secondary); }
.bg-dx-surface { background-color: var(--color-light-blue); }
.border-dx { border-color: var(--color-border); }

/* --- Header search panels --- */
[data-theme="dark"] .search-wrapper .hot-search-container,
[data-theme="dark"] .search-wrapper .pc-search-panel {
  background-color: #1f2937;
  color: var(--color-text);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
}
[data-theme="dark"] .search-wrapper .pc-search-tab {
  color: #9ca3af;
}
[data-theme="dark"] .search-wrapper .pc-search-hot-title {
  color: #f3f4f6;
}
[data-theme="dark"] .search-wrapper .pc-search-divider {
  background: #374151;
}
[data-theme="dark"] .h5-search-panel {
  background: rgba(17, 24, 39, 0.95);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
}
[data-theme="dark"] .h5-search-title,
[data-theme="dark"] .h5-search-tab.is-active {
  color: #f3f4f6;
}
[data-theme="dark"] .h5-search-tab {
  color: #9ca3af;
}
[data-theme="dark"] .h5-search-input {
  color: #e5e7eb;
}
[data-theme="dark"] .h5-search-input-box {
  background: rgba(255, 255, 255, 0.08);
  border-color: #374151;
}
[data-theme="dark"] .h5-search-divider {
  background: #374151;
}

/* --- Aside / filter / tags --- */
[data-theme="dark"] .app-aside {
  background-color: #1f2937;
}
[data-theme="dark"] .app-aside .is-active {
  background: linear-gradient(to right, rgba(58, 166, 255, 0.2), transparent);
}
[data-theme="dark"] .dx-filter-tag {
  background-color: #374151;
  color: #d1d5db;
}
[data-theme="dark"] .dx-border-title.has-bg {
  background-color: #1f2937;
}
[data-theme="dark"] .dx-tab.dx-button-tab {
  background-color: #374151;
  color: #d1d5db;
}

/* --- Popup / modal / overlay --- */
[data-theme="dark"] .dx-popup {
  background-color: #1f2937;
  color: var(--color-text);
}
[data-theme="dark"] .modal-dialog .modal-content {
  background-color: #1f2937;
  color: var(--color-text);
}
[data-theme="dark"] .modal-dialog .modal-header,
[data-theme="dark"] .modal-dialog .modal-footer {
  border-color: var(--color-border);
}
[data-theme="dark"] .form-control {
  background-color: var(--color-input-background);
  border-color: var(--color-input-border);
  color: var(--color-input-text);
}
[data-theme="dark"] .dx-textarea {
  background-color: #1f2937;
  border-color: var(--color-input-border);
}
[data-theme="dark"] .interaction-action-label {
  color: var(--color-text);
}

/* --- Pager --- */
[data-theme="dark"] .dx-pager .form-control.pager-goto-input {
  background-color: var(--color-input-background);
  color: var(--color-text);
  border-color: var(--color-input-border);
}

/* --- Scrollbar track (PC) --- */
@media (min-width: 768px) {
  [data-theme="dark"] ::-webkit-scrollbar-track:vertical,
  [data-theme="dark"] ::-webkit-scrollbar-track:horizontal {
    background-color: #111827;
  }
}

/* --- index.css --- */
[data-theme="dark"] .movie-cat-tab {
  background-color: #374151;
  color: #d1d5db;
}
[data-theme="dark"] .movie-cat-tab.is-active {
  background-color: #0066ff;
  color: #fff;
}
[data-theme="dark"] .index-swiper .linear-bg {
  background: linear-gradient(to top, var(--color-page), transparent);
}
[data-theme="dark"] .index-swiper .left-linear-bg {
  background: linear-gradient(to right, var(--color-page), transparent);
}
[data-theme="dark"] .dx-home-platform-name {
  color: #e5e7eb;
}
[data-theme="dark"] .dx-home-pcbox-banners__link,
[data-theme="dark"] .dx-home-pcbox-banners__img {
  background: #374151;
}
[data-theme="dark"] .dx-home-popup-layer__card {
  background: #1f2937;
  border-color: rgba(0, 102, 255, 0.35);
}
[data-theme="dark"] .dx-home-popup-layer__title {
  color: #f3f4f6;
}
[data-theme="dark"] .dx-home-popup-layer__desc {
  color: #9ca3af;
}

/* --- post.css --- */
[data-theme="dark"] .dx-article-sub-cate-wrap {
  background: linear-gradient(135deg, #1f2937 0%, #111827 100%);
  border-color: #374151;
}
[data-theme="dark"] .dx-article-sub-cate-arrow {
  background: linear-gradient(135deg, #1f2937, #111827);
  border-color: #374151;
}
[data-theme="dark"] .dx-article-sub-cate-item {
  color: #d1d5db !important;
  background: #374151 !important;
  border-color: #4b5563 !important;
}

/* --- page.css mobile topbar --- */
@media (max-width: 768px) {
  [data-theme="dark"] #app-header .app-topbar {
    background: linear-gradient(135deg, #192132 0%, #111827 100%);
  }
}
[data-theme="dark"] .btn-like svg {
  stroke: #9ca3af;
}

/* --- video.css --- */
[data-theme="dark"] .tab-item {
  color: #9ca3af !important;
}
[data-theme="dark"] .tab-item.is-show {
  color: #5d9eff !important;
}
[data-theme="dark"] .video-detail-actor-name {
  color: #e5e7eb;
}

/* --- search.css --- */
[data-theme="dark"] .associative-words {
  background-color: var(--color-page);
}
[data-theme="dark"] .app-search-header .app-search-container {
  background-color: #374151;
  color: #e5e7eb;
}
[data-theme="dark"] #filter_modal,
[data-theme="dark"] #filter_modal_pc {
  background: rgba(17, 24, 39, 0.95);
  border-color: rgba(255, 255, 255, 0.1);
}

/* --- contact / about / message --- */
[data-theme="dark"] .dx-placeholder-tip {
  color: #6b7280;
}

/* --- actress-page.css --- */
[data-theme="dark"] .actress-detail-name {
  color: #f3f4f6;
}
[data-theme="dark"] .actress-detail-works {
  color: #9ca3af;
}
[data-theme="dark"] .actress-detail-bio,
[data-theme="dark"] .actress-detail-bio-text {
  color: #d1d5db;
}

/* --- custom pagination (layout/pagination.phtml) --- */
[data-theme="dark"] .cus-pagination a,
[data-theme="dark"] .preBtn,
[data-theme="dark"] .nextBtn,
[data-theme="dark"] .jump-page-container span {
  color: #d1d5db;
}
[data-theme="dark"] .jumpInput {
  background: #374151;
  border-color: #4b5563;
  color: #e5e7eb;
}
[data-theme="dark"] .jumpBtn {
  background: #0066ff;
  color: #fff;
}

/* --- about.css --- */
[data-theme="dark"] .main {
  background-color: var(--color-page);
}
[data-theme="dark"] .stat-item {
  background: linear-gradient(180deg, #1f2937 0%, rgba(31, 41, 55, 0) 100%);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25);
}
[data-theme="dark"] .milestone-year,
[data-theme="dark"] .milestone-title,
[data-theme="dark"] .milestone-year-unit,
[data-theme="dark"] .milestone-desc,
[data-theme="dark"] .milestone-subtitle {
  color: #d1d5db;
}
[data-theme="dark"] .about-bg-2 {
  background-color: #111827;
}

/* --- message-page.css --- */
[data-theme="dark"] .message-card {
  background: #1f2937;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
}
[data-theme="dark"] .message-card-img {
  border-bottom-color: #374151;
}
[data-theme="dark"] .message-card-title {
  color: #e5e7eb;
}
[data-theme="dark"] .message-detail-img {
  background: #374151;
}
[data-theme="dark"] .message-detail-text {
  color: #d1d5db;
}

/* --- xgplayer (minimal) --- */
[data-theme="dark"] .xgplayer {
  background-color: #000;
}

/* --- ZUI overrides --- */
[data-theme="dark"] .messager,
[data-theme="dark"] .alert {
  background-color: #1f2937;
  color: #e5e7eb;
  border-color: #374151;
}

/* --- Swiper --- */
[data-theme="dark"] .movie-banner-swiper,
[data-theme="dark"] .ad-swiper {
  --swiper-pagination-bullet-inactive-color: #4b5563;
}

/* --- Theme switcher (显示模式) --- */
.h5-sidebar {
  display: flex;
  flex-direction: column;
}

.dx-theme-switcher {
  position: relative;
  flex-shrink: 0;
  color: #fff;
  overflow: visible;
}

/* 单按钮循环：仅显示当前模式 */
.dx-theme-cycle {
  display: block;
  padding: 0;
  margin: 0;
  border: 0;
  background: transparent;
  color: inherit;
  cursor: pointer;
  line-height: 1;
  font: inherit;
}

.dx-theme-cycle:hover .dx-theme-cycle__track {
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.35);
}

.dx-theme-cycle:focus-visible {
  outline: 2px solid rgba(93, 158, 255, 0.85);
  outline-offset: 2px;
  border-radius: 12px;
}

.dx-theme-cycle__track {
  display: inline-grid;
  grid-template-columns: 1fr;
  grid-template-rows: 1fr;
  align-items: center;
  justify-items: center;
  padding: 6px 12px;
  min-height: 36px;
  min-width: 72px;
  border-radius: 10px;
  background: linear-gradient(180deg, #3b82f6 0%, #2563eb 100%);
  border: 1px solid rgba(147, 197, 253, 0.45);
  box-shadow: 0 2px 8px rgba(37, 99, 235, 0.35);
  transition: background 0.2s, border-color 0.2s;
}

.dx-theme-cycle__slot {
  grid-column: 1;
  grid-row: 1;
  display: none;
  flex-direction: row;
  align-items: center;
  justify-content: center;
  gap: 6px;
  color: #fff;
  pointer-events: none;
  white-space: nowrap;
}

.dx-theme-cycle__slot.is-active,
html[data-theme-mode="system"] .dx-theme-cycle__slot[data-theme-slot="system"],
html[data-theme-mode="light"] .dx-theme-cycle__slot[data-theme-slot="light"],
html[data-theme-mode="dark"] .dx-theme-cycle__slot[data-theme-slot="dark"] {
  display: inline-flex;
}

.dx-theme-cycle__icon {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

.dx-theme-cycle__label {
  font-size: 11px;
  font-weight: 600;
  line-height: 1.15;
  white-space: nowrap;
}

/* 主题切换指引（关闭后不再显示，见 theme.js localStorage） */
.dx-theme-guide {
  position: absolute;
  right: 0;
  top: calc(100% + 10px);
  z-index: 260;
  box-sizing: border-box;
  width: 260px;
  max-width: min(260px, calc(100vw - 24px));
  min-width: 0;
  padding: 10px 36px 10px 12px;
  border-radius: 10px;
  background: rgba(30, 41, 59, 0.82);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid rgba(255, 255, 255, 0.18);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.28);
  color: rgba(255, 255, 255, 0.95);
  white-space: normal;
  pointer-events: auto;
  overflow: visible;
  animation: dx-theme-guide-in 0.35s ease;
}

.dx-theme-guide[hidden] {
  display: none !important;
}

/* 气泡箭头指向模式按钮（PC 在下方，箭头朝上） */
.dx-theme-switcher--pc .dx-theme-guide::before,
.dx-theme-switcher--pc .dx-theme-guide::after {
  content: '';
  position: absolute;
  right: 28px;
  width: 0;
  height: 0;
  border-left: 8px solid transparent;
  border-right: 8px solid transparent;
  pointer-events: none;
}

.dx-theme-switcher--pc .dx-theme-guide::before {
  top: -8px;
  border-bottom: 8px solid rgba(255, 255, 255, 0.18);
}

.dx-theme-switcher--pc .dx-theme-guide::after {
  top: -6px;
  border-bottom: 7px solid rgba(30, 41, 59, 0.88);
}

/* 移动端气泡在按钮上方，箭头朝下 */
.dx-theme-switcher--mobile .dx-theme-guide::before,
.dx-theme-switcher--mobile .dx-theme-guide::after {
  content: '';
  position: absolute;
  right: 24px;
  width: 0;
  height: 0;
  border-left: 8px solid transparent;
  border-right: 8px solid transparent;
  pointer-events: none;
}

.dx-theme-switcher--mobile .dx-theme-guide::before {
  bottom: -8px;
  border-top: 8px solid rgba(255, 255, 255, 0.18);
}

.dx-theme-switcher--mobile .dx-theme-guide::after {
  bottom: -6px;
  border-top: 7px solid rgba(30, 41, 59, 0.88);
}

@keyframes dx-theme-guide-in {
  from {
    opacity: 0;
    transform: translateY(-6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.dx-theme-guide__text {
  margin: 0;
  min-width: 0;
  font-size: 12px;
  line-height: 1.5;
  font-weight: 500;
  white-space: normal;
  overflow-wrap: break-word;
  word-break: break-word;
}

.dx-theme-guide__close {
  position: absolute;
  top: 8px;
  right: 8px;
  z-index: 2;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  padding: 0;
  margin: 0;
  border: 0;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.16);
  color: rgba(255, 255, 255, 0.95);
  cursor: pointer;
  transition: background 0.2s;
  flex-shrink: 0;
}

.dx-theme-guide__close:hover {
  background: rgba(255, 255, 255, 0.22);
}

.dx-theme-switcher--pc {
  display: none;
}

.dx-theme-switcher-mobile {
  display: none;
  flex-shrink: 0;
  margin-left: 4px;
}

.dx-theme-switcher--mobile {
  display: block;
}

.dx-theme-switcher--mobile .dx-theme-cycle__track {
  min-height: 32px;
  min-width: 64px;
  padding: 5px 10px;
}

.dx-theme-switcher--mobile .dx-theme-cycle__icon {
  width: 14px;
  height: 14px;
}

.dx-theme-switcher--mobile .dx-theme-cycle__label {
  font-size: 10px;
}

.dx-theme-switcher--mobile .dx-theme-guide {
  top: auto;
  bottom: calc(100% + 10px);
  right: 0;
  width: min(220px, calc(100vw - 32px));
  max-width: min(220px, calc(100vw - 32px));
  padding-right: 34px;
  animation-name: dx-theme-guide-in-mobile;
}

/* 顶栏右侧 nowrap 会继承到指引，需显式覆盖 */
.app-header .group .dx-theme-guide,
.app-header .group .dx-theme-guide__text,
.dx-theme-switcher-mobile .dx-theme-guide,
.dx-theme-switcher-mobile .dx-theme-guide__text {
  white-space: normal;
}

@keyframes dx-theme-guide-in-mobile {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* H5 侧栏底部（与顶栏同步，打开菜单时也可用） */
.h5-sidebar-menu {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.h5-sidebar-theme {
  padding: 10px 14px 16px;
  margin-top: auto;
  flex-shrink: 0;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.dx-theme-switcher--h5 .dx-theme-cycle {
  width: 100%;
}

.dx-theme-switcher--h5 .dx-theme-cycle__track {
  width: 100%;
}

@media (min-width: 769px) {
  .dx-theme-switcher--pc {
    display: block;
  }

  .dx-theme-switcher-mobile {
    display: none !important;
  }

  .h5-sidebar-theme {
    display: none !important;
  }
}

@media (max-width: 768px) {
  .dx-theme-switcher-mobile {
    display: block;
  }

  .dx-theme-switcher--pc {
    display: none !important;
  }

  .h5-sidebar-theme {
    display: none !important;
  }
}

/* Legacy single-button toggle (if any remain) */
.dx-theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  cursor: pointer;
}
