/* ==========================================================================
   ANISHIFT - WATCH HISTORY PAGE STYLES (MATCHING HOME.HTML COLOR & ICONS)
   ========================================================================== */

/* 1. Header Bar */
.history-header-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
  gap: 16px;
  flex-wrap: wrap;
}

.history-header-left {
  display: flex;
  flex-direction: column;
}

.history-page-title {
  font-size: 26px;
  font-weight: 800;
  color: var(--text-main);
  letter-spacing: -0.4px;
  line-height: 1.2;
  margin: 0;
}

.history-page-sub {
  font-size: 13.5px;
  color: var(--text-muted);
  margin-top: 4px;
  font-weight: 500;
}

.history-header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.history-head-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 36px;
  padding: 0 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  background: var(--bg-card);
  color: var(--text-main);
  font-size: 12.5px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.15s ease;
  user-select: none;
}

.history-head-btn:hover {
  border-color: var(--text-dim);
  background: var(--bg-hover);
}

.history-head-btn.danger {
  color: var(--text-muted);
}

.history-head-btn.danger:hover {
  color: #ef4444;
  border-color: rgba(239, 68, 68, 0.4);
  background: rgba(239, 68, 68, 0.08);
}

.history-head-btn.is-paused {
  background: var(--accent-primary);
  color: #ffffff;
  border-color: var(--accent-primary);
}

.history-head-btn.is-paused:hover {
  background: var(--accent-primary-hover);
  border-color: var(--accent-primary-hover);
  color: #ffffff;
}

/* 2. Main Two-Column Layout */
.history-layout {
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr);
  gap: 26px;
  margin-bottom: 50px;
  align-items: start;
}

/* Left Sidebar Controls */
.history-sidebar {
  display: flex;
  flex-direction: column;
  gap: 12px;
  position: sticky;
  top: 76px;
}

/* Search Box */
.history-search-box {
  position: relative;
  display: flex;
  align-items: center;
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 0 8px 0 34px;
  height: 38px;
  transition: border-color 0.15s, background-color 0.15s;
}

.history-search-box:focus-within {
  border-color: var(--accent-primary);
  background-color: var(--bg-surface);
}

.history-search-box .search-icon-left {
  position: absolute;
  left: 11px;
  color: var(--text-dim);
  font-size: 12.5px;
  pointer-events: none;
}

.history-search-box input {
  width: 100%;
  border: none;
  background: transparent;
  color: var(--text-main);
  font-size: 13px;
  font-family: inherit;
  outline: none;
}

.history-search-box input::placeholder {
  color: var(--text-dim);
}

.history-search-box .search-clear-btn {
  background: none;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  padding: 4px;
  font-size: 11px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.15s;
}

.history-search-box .search-clear-btn:hover {
  color: var(--text-main);
}

/* ===================================================
   CUSTOM DROPDOWN UI (MATCHING MOCKUP & TRENDING SELECT)
   =================================================== */
.history-custom-dropdown {
  position: relative;
  width: 100%;
}

.history-dropdown-trigger {
  width: 100%;
  height: 38px;
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-main);
  font-size: 13px;
  font-weight: 500;
  font-family: inherit;
  padding: 0 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  outline: none;
  transition: all 0.15s ease;
  user-select: none;
}

.history-dropdown-trigger:hover,
.history-custom-dropdown.open .history-dropdown-trigger {
  border-color: var(--text-dim);
  background-color: var(--bg-hover);
}

.history-dropdown-trigger .select-arrow {
  font-size: 10px;
  color: var(--text-dim);
  transition: transform 0.2s ease;
}

.history-custom-dropdown.open .history-dropdown-trigger .select-arrow {
  transform: rotate(180deg);
}

.history-dropdown-menu {
  position: absolute;
  top: calc(100% + 5px);
  left: 0;
  width: 100%;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.12);
  z-index: 100;
  display: none;
  flex-direction: column;
  padding: 4px;
  gap: 2px;
  animation: dropdownPop 0.12s ease;
}

[data-theme="dark"] .history-dropdown-menu,
[data-theme="oled"] .history-dropdown-menu,
[data-theme="navy"] .history-dropdown-menu {
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
}

@keyframes dropdownPop {
  from {
    opacity: 0;
    transform: translateY(-4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.history-custom-dropdown.open .history-dropdown-menu {
  display: flex;
}

.history-dropdown-option {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 7px 10px;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text-muted);
  border-radius: 4px;
  cursor: pointer;
  background: transparent;
  border: none;
  width: 100%;
  font-family: inherit;
  transition: all 0.12s ease;
  text-align: left;
}

.history-dropdown-option:hover {
  background-color: var(--bg-hover);
  color: var(--text-main);
}

.history-dropdown-option.active {
  background-color: var(--bg-hover);
  color: var(--text-main);
  font-weight: 600;
}

.history-dropdown-option .check-mark {
  font-size: 10px;
  color: var(--text-main);
  opacity: 0;
}

.history-dropdown-option.active .check-mark {
  opacity: 1;
}

/* Sort Row */
.history-sort-row {
  display: flex;
  gap: 8px;
  width: 100%;
}

.history-sort-row .sort-dropdown-wrap {
  flex: 1;
  min-width: 0;
}

.history-dir-btn {
  width: 38px;
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  background-color: var(--bg-card);
  color: var(--text-main);
  cursor: pointer;
  flex-shrink: 0;
  font-size: 13px;
  transition: background-color 0.15s, border-color 0.15s, color 0.15s;
}

.history-dir-btn:hover {
  background-color: var(--bg-hover);
  border-color: var(--text-dim);
}

/* 3. Right Content Area: Cards Grid Layout */
.history-content-area {
  min-width: 0;
  width: 100%;
}

.history-content-area .trending-cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(360px, 1fr));
  gap: 16px;
  margin-bottom: 32px;
}

@media (min-width: 1400px) {
  .history-content-area .trending-cards-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 899px) {
  .history-content-area .trending-cards-grid {
    grid-template-columns: 1fr;
  }
}

/* History Badges & Styling on Trending Card */
.trending-card.history-trending-card {
  min-height: 140px;
}

/* 16:9 Original Widescreen Episode Poster */
.history-trending-card .trending-card-poster {
  width: 220px !important;
  min-width: 220px !important;
  height: 124px !important;
  aspect-ratio: 16 / 9 !important;
  border-radius: 8px !important;
  overflow: hidden;
  position: relative;
  background: var(--bg-hover);
  flex-shrink: 0;
}

.history-trending-card .trending-card-poster img {
  width: 100% !important;
  height: 100% !important;
  object-fit: cover !important;
  object-position: center !important;
  display: block;
}

@media (max-width: 768px) {
  .history-trending-card .trending-card-poster {
    width: 150px !important;
    min-width: 150px !important;
    height: 84px !important;
  }
}

@media (max-width: 480px) {
  .history-trending-card .trending-card-poster {
    width: 100% !important;
    min-width: 100% !important;
    height: auto !important;
    aspect-ratio: 16 / 9 !important;
  }
}

/* Subtle Ambient Background */
.history-trending-card .trending-card-bg {
  opacity: 0.05 !important;
  filter: grayscale(100%) !important;
}

[data-theme="dark"] .history-trending-card .trending-card-bg,
[data-theme="oled"] .history-trending-card .trending-card-bg,
[data-theme="navy"] .history-trending-card .trending-card-bg {
  opacity: 0.08 !important;
  filter: grayscale(100%) brightness(0.7) !important;
}

.trending-card .history-ep-tag {
  position: absolute;
  top: 6px;
  left: 6px;
  background: rgba(0, 0, 0, 0.78);
  backdrop-filter: blur(4px);
  color: #ffffff;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 4px;
  letter-spacing: 0.3px;
  line-height: 1;
  z-index: 2;
}

.trending-card .history-all-completed-tag {
  position: absolute;
  top: 6px;
  left: 6px;
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.95), rgba(5, 150, 105, 0.95));
  backdrop-filter: blur(4px);
  color: #ffffff;
  font-size: 9.5px;
  font-weight: 700;
  padding: 2.5px 7px;
  border-radius: 4px;
  letter-spacing: 0.3px;
  line-height: 1.1;
  z-index: 2;
  display: inline-flex;
  align-items: center;
  gap: 3.5px;
  box-shadow: 0 2px 6px rgba(16, 185, 129, 0.35);
}

.trending-card .history-all-completed-tag i {
  font-size: 8.5px;
}

.trending-card .history-thumb-prog-track {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 3.5px;
  background: rgba(0, 0, 0, 0.5);
  z-index: 2;
}

.trending-card .history-thumb-prog-fill {
  height: 100%;
  background: #ef4444;
  transition: width 0.3s ease;
}

.trending-card .history-thumb-prog-fill.completed-fill {
  background: #10b981;
}

.history-meta-row .meta-tag.meta-tag-all-completed {
  background: rgba(16, 185, 129, 0.15);
  border-color: rgba(16, 185, 129, 0.4);
  color: #10b981;
  font-weight: 700;
}

.history-meta-row .meta-tag.meta-tag-all-completed i {
  color: #10b981;
}

.history-meta-row .meta-tag.meta-tag-done {
  color: #10b981;
  border-color: rgba(16, 185, 129, 0.3);
}

/* Meta Tags Matching home.html */
.history-meta-row {
  display: flex;
  align-items: center;
  gap: 5px;
  flex-wrap: wrap;
  margin-bottom: 6px;
}

.history-meta-row .meta-tag {
  background: var(--bg-badge);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 10.5px;
  font-weight: 600;
  color: var(--text-muted);
  display: inline-flex;
  align-items: center;
  gap: 3.5px;
  border: 1px solid var(--border-color);
  line-height: 1.2;
}

.history-meta-row .meta-tag i {
  font-size: 8px;
  color: var(--text-muted);
}

.history-meta-row .meta-tag.format-tag {
  color: var(--text-main);
  text-transform: uppercase;
}

.history-trending-card .trending-card-body {
  padding-right: 36px;
  display: flex;
  flex-direction: column;
  flex: 1;
  min-width: 0;
  gap: 3px;
}

.history-ep-info-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 4px;
}

.history-ep-line {
  font-size: 11.5px;
  color: var(--text-main);
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.history-time-line {
  font-size: 11px;
  color: var(--text-dim);
  font-variant-numeric: tabular-nums;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.history-time-line i {
  font-size: 7.5px;
  color: var(--accent-primary);
}

.history-desc-snippet {
  font-size: 11.5px;
  color: var(--text-muted);
  line-height: 1.45;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 6px;
  flex: 1;
}

.history-genres-row {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
  margin-top: 2px;
}

.history-genre-pill {
  font-size: 9.5px;
  font-weight: 600;
  padding: 1.5px 6px;
  border-radius: 3px;
  background: var(--bg-hover);
  color: var(--text-dim);
  border: 1px solid var(--border-color);
  letter-spacing: 0.2px;
}

/* History Card Dismiss/Delete Button (Top Right) */
.history-card-remove-btn {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--bg-hover);
  border: 1px solid var(--border-color);
  color: var(--text-dim);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10.5px;
  cursor: pointer;
  transition: all 0.15s ease;
  z-index: 3;
}

.history-card-remove-btn:hover {
  background: rgba(239, 68, 68, 0.12);
  border-color: rgba(239, 68, 68, 0.35);
  color: #ef4444;
  transform: scale(1.08);
}

/* History Card Add/Bookmark Button (Bottom Right) */
.history-trending-card .trending-card-add-btn {
  position: absolute;
  bottom: 12px;
  right: 12px;
  width: 26px;
  height: 26px;
  border-radius: 6px;
  background: var(--bg-hover);
  border: 1px solid var(--border-color);
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  cursor: pointer;
  transition: all 0.15s ease;
  z-index: 2;
}

.history-trending-card .trending-card-add-btn:hover {
  background: var(--text-main);
  color: var(--bg-surface);
  transform: scale(1.08);
}

.history-trending-card .trending-card-add-btn.bookmarked {
  background: var(--accent-primary);
  color: #ffffff;
  border-color: var(--accent-primary);
}

/* 4. Empty State Box */
.history-empty-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 60px 20px;
  background-color: var(--bg-card);
  border: 1px dashed var(--border-color);
  border-radius: var(--radius-lg);
}

.history-empty-box > i.empty-main-icon,
.history-empty-box > i:first-child {
  font-size: 36px;
  color: var(--text-dim);
  margin-bottom: 14px;
  opacity: 0.65;
}

.history-empty-box .empty-head-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-main);
  margin-bottom: 6px;
}

.history-empty-box .empty-sub-desc {
  font-size: 13px;
  color: var(--text-muted);
  max-width: 420px;
  line-height: 1.5;
  margin-bottom: 20px;
}

.history-empty-box .btn-empty-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 36px;
  padding: 0 18px;
  background-color: var(--accent-primary);
  color: #ffffff;
  font-size: 13px;
  font-weight: 600;
  border-radius: var(--radius-sm);
  text-decoration: none;
  transition: all 0.15s ease;
}

.history-empty-box .btn-empty-link:hover {
  background-color: var(--accent-primary-hover);
  transform: translateY(-1px);
}

/* 5. Responsive Breakpoints */
@media (max-width: 1024px) {
  .history-layout {
    grid-template-columns: 210px minmax(0, 1fr);
    gap: 18px;
  }
}

@media (max-width: 860px) {
  .history-layout {
    grid-template-columns: 1fr;
  }
  .history-sidebar {
    position: static;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
  }
  .history-search-box {
    grid-column: 1 / -1;
  }
}

@media (max-width: 540px) {
  .history-sidebar {
    grid-template-columns: 1fr;
  }
  .history-header-bar {
    flex-direction: column;
    align-items: flex-start;
  }
  .history-header-actions {
    width: 100%;
    justify-content: flex-start;
  }
}
