/* ==========================================
   Admin Catalog Styles
   ========================================== */

/* Tabs */
.admin-tabs {
  display: flex;
  gap: 0.25rem;
  background: rgba(0, 0, 0, 0.2);
  border-radius: 9999px;
  padding: 0.25rem;
}

.tab-btn {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  padding: 0.5rem 1rem;
  border-radius: 9999px;
  cursor: pointer;
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 500;
  transition: all 0.2s ease;
}

.tab-btn.active {
  background: var(--accent-color);
  color: #fff;
}

.tab-btn:hover:not(.active) {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-primary);
}

.tab-content {
  display: none;
  width: 100%;
}

.tab-content.active {
  display: block;
}

/* Catalog Header */
.catalog-header {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 2rem;
  flex-wrap: wrap;
}

.catalog-type-toggle {
  display: flex;
  gap: 0.25rem;
  background: rgba(0, 0, 0, 0.25);
  border-radius: 9999px;
  padding: 0.25rem;
}

.type-btn {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  padding: 0.5rem 1rem;
  border-radius: 9999px;
  cursor: pointer;
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 500;
  transition: all 0.2s ease;
}

.type-btn.active {
  background: rgba(255, 255, 255, 0.12);
  color: var(--text-primary);
}

.catalog-search {
  display: flex;
  gap: 0.5rem;
  flex: 1;
  min-width: 280px;
  align-items: stretch; /* Force same height */
}

.catalog-search input[type="text"] {
  flex: 1;
  min-width: 0;
  width: auto;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 0.75rem 1rem; /* Matched to global button padding */
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.9rem;
  outline: none;
  transition: border-color 0.2s ease;
  height: 100%; /* Ensure it fills the flex container height */
  box-sizing: border-box;
}

.catalog-search input[type="text"]:focus {
  border-color: var(--accent-color);
  background: rgba(0, 0, 0, 0.4);
}

.catalog-search button {
  white-space: nowrap;
  flex-shrink: 0;
  width: auto; /* Reset global width: 100% */
  padding: 0.75rem 1.5rem;
  height: 100%;
  box-sizing: border-box;
}

.glass-input {
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 0.6rem 1rem;
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.9rem;
  outline: none;
  transition: all 0.2s ease;
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'%3E%3C/path%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.75rem center;
  padding-right: 2.5rem;
}

.glass-input:focus {
  border-color: var(--accent-color);
  background-color: rgba(0, 0, 0, 0.4);
}

.glass-input option {
  background: #111;
  color: #fff;
}

.pagination-controls button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  filter: grayscale(1);
}

.catalog-status {
  text-align: center;
  padding: 2rem;
  color: var(--text-secondary);
  font-style: italic;
}

/* Grid */
.catalog-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 1.25rem;
}

.catalog-card {
  cursor: pointer;
  border-radius: var(--radius-md);
  overflow: hidden;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid transparent;
  position: relative;
}

.catalog-card:hover {
  transform: translateY(-4px) scale(1.03);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5);
  border-color: var(--accent-color);
}

.catalog-card img {
  width: 100%;
  aspect-ratio: 2 / 3;
  object-fit: cover;
  display: block;
}

.catalog-card-info {
  padding: 0.5rem 0.6rem;
}

.catalog-card-title {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.catalog-card-year {
  font-size: 0.7rem;
  color: var(--text-secondary);
}

.catalog-card-rating {
  position: absolute;
  top: 0.4rem;
  right: 0.4rem;
  background: rgba(0, 0, 0, 0.7);
  padding: 0.15rem 0.4rem;
  border-radius: var(--radius-sm);
  font-size: 0.7rem;
  font-weight: 600;
  color: #fbbf24;
  backdrop-filter: blur(4px);
}

/* ==========================================
   Details Modal
   ========================================== */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.8);
  backdrop-filter: blur(8px);
  z-index: 1000;
  display: none;
  justify-content: center;
  align-items: flex-start;
  padding: 3rem 1rem;
  overflow-y: auto;
}

.modal-overlay.active {
  display: flex;
}

.modal-content {
  width: 100%;
  max-width: 900px;
  background: var(--bg-secondary);
  border-radius: var(--radius-lg);
  overflow: hidden;
  border: 1px solid var(--border-color);
  position: relative;
  box-shadow: 0 25px 50px rgba(0, 0, 0, 0.5);
}

.modal-close {
  position: absolute;
  top: 1rem;
  right: 1rem;
  z-index: 10;
  background: rgba(0, 0, 0, 0.5);
  border: none;
  color: #fff;
  font-size: 1.25rem;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background-color 0.2s;
}

.modal-close:hover {
  background: rgba(255, 0, 0, 0.5);
}

.modal-backdrop {
  width: 100%;
  height: 300px;
  background-size: cover;
  background-position: center top;
  position: relative;
}

.modal-backdrop::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(to top, var(--bg-secondary) 0%, transparent 60%);
}

.modal-body {
  padding: 0 2rem 2rem;
  margin-top: -4rem;
  position: relative;
  z-index: 2;
}

.modal-info {
  display: flex;
  gap: 1.5rem;
  margin-bottom: 2rem;
}

.modal-poster {
  width: 150px;
  border-radius: var(--radius-md);
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.5);
  flex-shrink: 0;
  aspect-ratio: 2 / 3;
  object-fit: cover;
}

.modal-meta {
  flex: 1;
}

.modal-meta h2 {
  font-size: 1.5rem;
  margin-bottom: 0.5rem;
}

.modal-tags {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
  flex-wrap: wrap;
}

.tag {
  background: rgba(255, 255, 255, 0.1);
  padding: 0.25rem 0.6rem;
  border-radius: 9999px;
  font-size: 0.75rem;
  color: var(--text-secondary);
  font-weight: 500;
}

.modal-genres {
  font-size: 0.85rem;
  color: var(--accent-color);
  margin-bottom: 0.75rem;
}

.modal-description {
  font-size: 0.9rem;
  color: var(--text-secondary);
  line-height: 1.5;
  max-height: 6rem;
  overflow: hidden;
}

.modal-streams h3 {
  margin-bottom: 1rem;
  font-size: 1.1rem;
}

.stream-status {
  text-align: center;
  color: var(--text-secondary);
  padding: 1rem;
  font-style: italic;
}

.stream-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  max-height: 350px;
  overflow-y: auto;
}

.stream-card {
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 0.75rem 1rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  transition: border-color 0.2s, background 0.2s;
  cursor: pointer;
}

.stream-card:hover {
  border-color: var(--accent-color);
  background: rgba(99, 102, 241, 0.1);
}

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

.stream-card-title {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-primary);
  word-break: break-all;
}

.stream-card-meta {
  font-size: 0.75rem;
  color: var(--text-secondary);
  margin-top: 0.25rem;
}

.stream-card-source {
  font-size: 0.7rem;
  font-weight: 600;
  background: rgba(99, 102, 241, 0.2);
  color: var(--accent-color);
  padding: 0.2rem 0.5rem;
  border-radius: 9999px;
  white-space: nowrap;
  margin-left: 0.75rem;
}

.stream-card .btn-primary {
  padding: 0.4rem 0.8rem;
  font-size: 0.8rem;
  width: auto;
  white-space: nowrap;
  margin-left: 0.75rem;
  flex-shrink: 0;
}

/* Dolby Vision Warnings */
.dv-badge {
    background: #fbbf24;
    color: #000;
    font-size: 0.65rem;
    font-weight: 800;
    padding: 0.1rem 0.3rem;
    border-radius: 4px;
    margin-right: 0.5rem;
    vertical-align: middle;
}

.stream-warning {
    font-size: 0.7rem;
    color: #fbbf24;
    margin-top: 0.25rem;
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.stream-filter-toggle {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 1rem;
    font-size: 0.85rem;
    color: var(--text-secondary);
    padding: 0.5rem 1rem;
    background: rgba(0,0,0,0.2);
    border-radius: var(--radius-md);
    cursor: pointer;
}

.stream-filter-toggle input {
    accent-color: var(--accent-color);
}

/* Mode Selector Button Group */
.mode-selector {
    display: flex;
    gap: 0.5rem;
    background: rgba(0,0,0,0.2);
    padding: 0.25rem;
    border-radius: var(--radius-md);
    width: fit-content;
}

.mode-btn {
    padding: 0.5rem 0.75rem;
    font-size: 0.8rem;
    white-space: nowrap;
    border-radius: 6px;
    background: transparent;
    color: var(--text-secondary);
    border: none;
    cursor: pointer;
    transition: all 0.2s;
    width: auto;
}

.mode-btn:hover {
    background: rgba(255,255,255,0.05);
    color: #fff;
}

.mode-btn.active {
    background: var(--accent-color);
    color: #fff;
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

/* ==========================================
   Addon Cards
   ========================================== */
.addon-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 0.75rem 1rem;
}

.addon-card-info h4 {
  font-size: 0.95rem;
  margin-bottom: 0.15rem;
}

.addon-card-info p {
  font-size: 0.75rem;
  color: var(--text-secondary);
}

.addon-remove-btn {
  background: rgba(239, 68, 68, 0.2);
  border: 1px solid rgba(239, 68, 68, 0.3);
  color: #ef4444;
  padding: 0.4rem 0.8rem;
  border-radius: var(--radius-md);
  cursor: pointer;
  font-family: inherit;
  font-size: 0.8rem;
  font-weight: 500;
  transition: background 0.2s;
}

.addon-remove-btn:hover {
  background: rgba(239, 68, 68, 0.4);
}

/* ==========================================
   Recommendation System (Viewer)
   ========================================== */

.rec-vote-controls {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.1rem;
  margin-right: 0.25rem;
  min-width: 32px;
}

.vote-btn {
  background: transparent;
  border: none !important;
  color: var(--text-secondary);
  padding: 2px !important;
  cursor: pointer;
  border-radius: 4px;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px !important;
  height: 28px !important;
  box-shadow: none !important;
}

.vote-btn:hover {
  background: rgba(255, 255, 255, 0.08) !important;
  color: var(--text-primary);
}

.vote-btn.up.active {
  color: var(--success-color) !important;
  background: rgba(16, 185, 129, 0.15) !important;
}

.vote-btn.down.active {
  color: var(--error-color) !important;
  background: rgba(239, 68, 68, 0.15) !important;
}

.vote-count {
  font-size: 0.7rem;
  font-weight: 800;
  color: var(--text-secondary);
  min-width: 1.2rem;
  text-align: center;
}

.vote-count.positive {
  color: var(--success-color);
}

.vote-count.negative {
  color: var(--error-color);
}

.recommendations-section {
  width: 100%;
  max-width: 1000px;
  margin-top: 1.5rem;
}

.rec-search-panel {
  margin-bottom: 1rem;
}

.rec-search-panel h2 {
  font-size: 1.15rem;
  margin-bottom: 0.25rem;
}

.rec-search-results {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-top: 1rem;
  max-height: 350px;
  overflow-y: auto;
}

.rec-result-card,
.rec-card,
.admin-rec-card {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.5rem 0.75rem;
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  transition: all 0.2s ease;
  width: 100%;
}

.rec-result-card:hover,
.rec-card:hover,
.admin-rec-card:hover {
  border-color: var(--accent-color);
  background: rgba(99, 102, 241, 0.05);
}

.rec-result-card img,
.rec-card img,
.admin-rec-card img {
  width: 40px;
  height: 60px;
  object-fit: cover;
  border-radius: 4px;
  flex-shrink: 0;
}

/* Info container shared typography */
.rec-result-info,
.rec-card-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.rec-result-title,
.rec-card-title {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 0.15rem;
}

.rec-result-year,
.rec-card-year {
  font-size: 0.75rem;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Buttons inside admin / result */
.rec-submit-btn,
.admin-rec-card button {
  padding: 0.4rem 0.8rem !important;
  font-size: 0.8rem !important;
  width: auto !important;
  white-space: nowrap;
  flex-shrink: 0;
  margin: 0;
}

.admin-rec-card .admin-rec-remove {
  padding: 0.4rem 0.6rem !important;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px !important;
  height: 32px;
}

/* Recommendation List (both viewer and admin) */
.rec-list-panel {
  margin-top: 1rem;
}

.rec-list-panel h3 {
  font-size: 1rem;
  margin-bottom: 0.75rem;
}

.rec-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.rec-empty {
  color: var(--text-secondary);
  font-style: italic;
  font-size: 0.85rem;
}

/* YouTube Recommendation overrides */
.youtube-rec-card {
  position: relative;
  border-left: 3px solid #ef4444 !important;
  box-shadow: 0 4px 15px rgba(239, 68, 68, 0.1);
}

.youtube-rec-card:hover {
  border-color: #ef4444 !important;
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(239, 68, 68, 0.2);
}

.youtube-rec-card img {
  width: 106px !important;
  height: 60px !important;
  object-fit: cover !important;
  border-radius: 4px;
  flex-shrink: 0;
}

.youtube-rec-play-icon {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  color: white;
  background: rgba(239, 68, 68, 0.9);
  border-radius: 50%;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0.9;
  pointer-events: none;
  box-shadow: 0 2px 8px rgba(0,0,0,0.5);
}
