/* ── Watch Together Plugin ── */

.wt-container {
  height: 100%;
  overflow-y: auto;
  padding: 16px;
}

/* ── Top Bar ── */
.wt-topbar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.wt-input {
  padding: 10px 14px;
  border: 1px solid var(--bg-tertiary);
  border-radius: var(--radius);
  background: var(--bg-secondary);
  color: var(--text-normal);
  font-size: 14px;
  outline: none;
  transition: border-color var(--transition);
  min-width: 0;
}
.wt-input:focus { border-color: var(--accent); }
.wt-input::placeholder { color: var(--text-faint); }
.wt-input-name { width: 150px; }
.wt-input-room { flex: 1; min-width: 180px; }
.wt-input-password { width: 170px; }

.wt-btn {
  padding: 10px 20px;
  border: none;
  border-radius: var(--radius);
  background: var(--accent);
  color: #fff;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  transition: background var(--transition);
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 6px;
}
.wt-btn:hover { background: var(--accent-hover); }
.wt-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ── Grid ── */
.wt-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}

/* ── Tile ── */
.wt-tile {
  background: var(--bg-secondary);
  border-radius: var(--radius-lg);
  overflow: hidden;
  cursor: pointer;
  transition: transform var(--transition), box-shadow var(--transition);
  position: relative;
}
.wt-tile:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
}

/* Preview area (16:9) */
.wt-tile-preview {
  position: relative;
  width: 100%;
  padding-top: 56.25%;
  background: var(--bg-deep);
  overflow: hidden;
}
.wt-tile-icon {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 48px;
  opacity: 0.3;
}

/* Member count on tile */
.wt-tile-members {
  position: absolute;
  top: 8px;
  right: 8px;
  background: rgba(0, 0, 0, 0.6);
  color: #fff;
  font-size: 12px;
  padding: 2px 8px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  gap: 4px;
}

/* Lock icon on tile */
.wt-tile-lock {
  position: absolute;
  bottom: 8px;
  right: 8px;
  font-size: 16px;
  opacity: 0.6;
}

/* Playing indicator on tile */
.wt-tile-playing {
  position: absolute;
  top: 8px;
  left: 8px;
  background: var(--accent);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  gap: 4px;
}

/* Info bar below preview */
.wt-tile-info {
  padding: 10px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.wt-tile-meta {
  min-width: 0;
  flex: 1;
}
.wt-tile-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-normal);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.wt-tile-host {
  font-size: 12px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ── Empty state ── */
.wt-empty {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}
.wt-empty-icon {
  font-size: 48px;
  margin-bottom: 12px;
  opacity: 0.4;
}
.wt-empty h3 {
  font-size: 18px;
  font-weight: 600;
  color: var(--text-normal);
  margin-bottom: 6px;
}
.wt-empty p {
  font-size: 14px;
}

/* ── Error ── */
.wt-error {
  background: rgba(237, 66, 69, 0.12);
  color: var(--danger);
  padding: 10px 14px;
  border-radius: var(--radius);
  font-size: 14px;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.wt-error-dismiss {
  background: none;
  border: none;
  color: var(--danger);
  cursor: pointer;
  margin-left: auto;
  font-size: 16px;
  padding: 0 4px;
}

/* ── Password / Join Modal ── */
.wt-modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
}
.wt-modal {
  background: var(--bg-secondary);
  border-radius: var(--radius-lg);
  padding: 24px;
  width: 340px;
  max-width: 90vw;
}
.wt-modal h3 {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 4px;
}
.wt-modal p {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 16px;
}
.wt-modal .wt-input {
  width: 100%;
  margin-bottom: 12px;
}
.wt-modal-error {
  color: var(--danger);
  font-size: 13px;
  margin-bottom: 8px;
}
.wt-modal-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}
.wt-modal-cancel {
  padding: 8px 16px;
  border: 1px solid var(--bg-tertiary);
  border-radius: var(--radius);
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 14px;
}
.wt-modal-cancel:hover {
  color: var(--text-normal);
  border-color: var(--text-faint);
}

/* ══════════════════════════════════════
   ROOM VIEW (Fullscreen Overlay)
   ══════════════════════════════════════ */

.wt-room-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: #000;
  display: flex;
  flex-direction: column;
}

/* ── Room Header ── */
.wt-room-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: rgba(0, 0, 0, 0.8);
  color: #fff;
  z-index: 1;
  flex-shrink: 0;
}
.wt-room-header-left {
  display: flex;
  align-items: center;
  gap: 12px;
}
.wt-room-name {
  font-weight: 600;
  font-size: 16px;
}
.wt-room-members {
  font-size: 13px;
  color: var(--text-muted);
}
.wt-host-badge {
  font-size: 11px;
  background: rgba(255, 255, 255, 0.1);
  padding: 2px 8px;
  border-radius: 4px;
  color: var(--accent);
  font-weight: 600;
}
.wt-room-header-right {
  display: flex;
  align-items: center;
  gap: 8px;
}
.wt-fullscreen-btn {
  background: rgba(255, 255, 255, 0.1);
  border: none;
  color: #fff;
  width: 36px;
  height: 36px;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background var(--transition);
}
.wt-fullscreen-btn:hover {
  background: rgba(255, 255, 255, 0.25);
}
.wt-leave-btn {
  background: rgba(255, 255, 255, 0.1);
  border: none;
  color: #fff;
  padding: 8px 16px;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 14px;
  transition: background var(--transition);
}
.wt-leave-btn:hover {
  background: rgba(255, 255, 255, 0.2);
}

/* ── Room Body ── */
.wt-room-body {
  display: flex;
  flex: 1;
  overflow: hidden;
}

/* ── Player Section ── */
.wt-player-section {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.wt-player-wrap {
  position: relative;
  width: 100%;
  flex: 1;
  background: #000;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.wt-yt-container {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}
.wt-yt-container iframe {
  width: 100%;
  height: 100%;
}
.wt-video-element {
  width: 100%;
  height: 100%;
  object-fit: contain;
}
.wt-dm-container {
  width: 100%;
  height: 100%;
  border: none;
  position: absolute;
  top: 0;
  left: 0;
}
.wt-player-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  color: var(--text-muted);
  font-size: 16px;
}
.wt-placeholder-icon {
  font-size: 48px;
  opacity: 0.3;
}

/* ── Controls ── */
.wt-controls {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: rgba(0, 0, 0, 0.8);
  flex-shrink: 0;
}
.wt-ctrl-btn {
  background: rgba(255, 255, 255, 0.1);
  border: none;
  color: #fff;
  width: 36px;
  height: 36px;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background var(--transition);
  flex-shrink: 0;
}
.wt-ctrl-btn:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.25);
}
.wt-ctrl-btn:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}
.wt-ctrl-status {
  color: var(--text-muted);
  font-size: 16px;
  width: 36px;
  text-align: center;
  flex-shrink: 0;
}

/* ── Seek Slider ── */
.wt-seek {
  -webkit-appearance: none;
  appearance: none;
  flex: 1;
  height: 4px;
  border-radius: 2px;
  background: var(--bg-tertiary);
  outline: none;
  cursor: pointer;
  min-width: 60px;
}
.wt-seek::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
  border: none;
  box-shadow: 0 0 4px rgba(0, 0, 0, 0.3);
}
.wt-seek::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
  border: none;
  box-shadow: 0 0 4px rgba(0, 0, 0, 0.3);
}
.wt-seek::-webkit-slider-runnable-track {
  height: 4px;
  border-radius: 2px;
}
.wt-seek::-moz-range-track {
  height: 4px;
  border-radius: 2px;
  background: var(--bg-tertiary);
}

/* Read-only seek for non-host */
.wt-seek-readonly {
  flex: 1;
  height: 4px;
  border-radius: 2px;
  background: var(--bg-tertiary);
  position: relative;
  overflow: hidden;
  min-width: 60px;
}
.wt-seek-progress {
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  background: var(--accent);
  border-radius: 2px;
  transition: width 0.3s linear;
}

/* ── Time Display ── */
.wt-time {
  font-variant-numeric: tabular-nums;
  color: #fff;
  font-size: 13px;
  white-space: nowrap;
  flex-shrink: 0;
}

/* ── Volume ── */
.wt-volume {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
  margin-left: auto;
}
.wt-volume-icon {
  font-size: 16px;
  width: 20px;
  text-align: center;
  cursor: default;
}
.wt-volume-slider {
  -webkit-appearance: none;
  appearance: none;
  width: 100px;
  height: 4px;
  border-radius: 2px;
  background: var(--bg-tertiary);
  outline: none;
  cursor: pointer;
}
.wt-volume-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
  border: none;
  box-shadow: 0 0 4px rgba(0, 0, 0, 0.3);
}
.wt-volume-slider::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
  border: none;
  box-shadow: 0 0 4px rgba(0, 0, 0, 0.3);
}

.wt-quality-select {
  background: var(--bg-secondary, #2a2620);
  color: var(--text-primary, #e0e0e0);
  border: 1px solid var(--border-color, #322d26);
  border-radius: 6px;
  padding: 2px 6px;
  font-size: 12px;
  cursor: pointer;
  outline: none;
  margin-left: 4px;
}
.wt-quality-select:hover {
  border-color: var(--accent, #7c5cff);
}

/* ══════════════════════════════════════
   QUEUE PANEL
   ══════════════════════════════════════ */

.wt-queue-panel {
  width: 280px;
  background: var(--bg-secondary);
  border-left: 1px solid var(--bg-tertiary);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}
.wt-queue-header {
  padding: 14px 16px;
  font-weight: 600;
  font-size: 14px;
  color: var(--text-normal);
  border-bottom: 1px solid var(--bg-tertiary);
  flex-shrink: 0;
}
.wt-queue-list {
  flex: 1;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--bg-tertiary) transparent;
}
.wt-queue-list::-webkit-scrollbar {
  width: 4px;
}
.wt-queue-list::-webkit-scrollbar-thumb {
  background: var(--bg-tertiary);
  border-radius: 2px;
}
.wt-queue-empty {
  padding: 24px 16px;
  text-align: center;
  color: var(--text-faint);
  font-size: 13px;
}
.wt-queue-item {
  padding: 10px 12px;
  border-bottom: 1px solid var(--bg-tertiary);
  display: flex;
  align-items: center;
  gap: 8px;
  transition: background var(--transition);
}
.wt-queue-item:hover {
  background: var(--bg-tertiary);
}
.wt-queue-item.playing {
  border-left: 3px solid var(--accent);
  background: rgba(230, 126, 34, 0.08);
}
.wt-queue-item-info {
  flex: 1;
  min-width: 0;
}
.wt-queue-item-title {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-normal);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.wt-queue-item-by {
  font-size: 11px;
  color: var(--text-faint);
  margin-top: 2px;
}
.wt-queue-item-remove {
  background: none;
  border: none;
  color: var(--text-faint);
  cursor: pointer;
  font-size: 18px;
  padding: 2px 6px;
  border-radius: 4px;
  transition: all var(--transition);
  flex-shrink: 0;
}
.wt-queue-item-remove:hover {
  color: var(--danger);
  background: rgba(237, 66, 69, 0.12);
}

/* ── Queue Add ── */
.wt-queue-add {
  padding: 12px;
  display: flex;
  gap: 8px;
  border-top: 1px solid var(--bg-tertiary);
  flex-shrink: 0;
}
.wt-queue-input {
  flex: 1;
  font-size: 13px;
  padding: 8px 10px;
}
.wt-queue-add-btn {
  padding: 8px 12px;
  font-size: 13px;
  flex-shrink: 0;
}

/* ── Player Error Overlay ── */
.wt-player-error {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    background: rgba(0, 0, 0, 0.85);
    color: #fff;
    z-index: 2;
    text-align: center;
    padding: 20px;
}
.wt-error-icon {
    font-size: 48px;
}
.wt-player-error p {
    font-size: 15px;
    color: var(--text-muted);
    margin: 0;
}
.wt-yt-link {
    display: inline-block;
    padding: 8px 20px;
    background: #ff0000;
    color: #fff;
    border-radius: var(--radius);
    text-decoration: none;
    font-weight: 600;
    font-size: 14px;
    transition: background var(--transition);
}
.wt-yt-link:hover {
    background: #cc0000;
}
.wt-skip-info {
    font-size: 12px !important;
    color: var(--text-faint) !important;
    font-style: italic;
}

/* ── Clickable Queue Items ── */
.wt-queue-item.clickable {
    cursor: pointer;
}
.wt-queue-item.clickable:hover {
    background: rgba(230, 126, 34, 0.12);
}

/* ══════════════════════════════════════
   RESPONSIVE
   ══════════════════════════════════════ */

@media (max-width: 768px) {
  .wt-room-body {
    flex-direction: column;
  }

  .wt-queue-panel {
    width: 100%;
    max-height: 40vh;
    border-left: none;
    border-top: 1px solid var(--bg-tertiary);
  }

  .wt-player-wrap {
    min-height: 200px;
  }

  .wt-controls {
    flex-wrap: wrap;
    gap: 8px;
    padding: 10px 12px;
  }

  .wt-volume {
    margin-left: 0;
  }

  .wt-volume-slider {
    width: 80px;
  }

  .wt-room-header {
    padding: 10px 12px;
  }

  .wt-room-name {
    font-size: 14px;
  }

  .wt-room-members,
  .wt-host-badge {
    font-size: 11px;
  }
}

@media (max-width: 480px) {
  .wt-topbar {
    gap: 8px;
  }

  .wt-input-name {
    width: 100%;
  }

  .wt-input-room {
    min-width: 0;
  }

  .wt-input-password {
    width: 100%;
  }

  .wt-volume-slider {
    width: 60px;
  }

  .wt-time {
    font-size: 12px;
  }

  .wt-host-badge {
    display: none;
  }
}

/* ── Watched Queue Items ── */
.wt-queue-item.watched {
  opacity: 0.55;
  transition: opacity var(--transition), background var(--transition);
}
.wt-queue-item.watched:hover {
  opacity: 0.85;
}

.wt-queue-item-check {
  color: #2ecc71;
  font-size: 16px;
  font-weight: 700;
  flex-shrink: 0;
  line-height: 1;
}

/* ── Queue Thumbnail ── */
.wt-queue-item-info {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  flex: 1;
}

.wt-queue-thumb {
  width: 48px;
  height: 36px;
  object-fit: cover;
  border-radius: 4px;
  flex-shrink: 0;
}

.wt-queue-item-text {
  min-width: 0;
  flex: 1;
}

/* ── Next Button ── */
.wt-next-btn {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 13px;
  padding: 6px 12px;
  white-space: nowrap;
}

/* ══════════════════════════════════════
   SYNC INDICATOR
   ══════════════════════════════════════ */

.wt-sync-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}
.wt-sync-synced { background: #2ecc71; }
.wt-sync-drifting { background: #f1c40f; }
.wt-sync-desynced { background: #e74c3c; }

/* ══════════════════════════════════════
   VOTE BUTTONS
   ══════════════════════════════════════ */

.wt-vote-btn {
  background: rgba(255, 255, 255, 0.08) !important;
  border: 1px solid rgba(255, 255, 255, 0.15) !important;
}
.wt-vote-btn:hover:not(:disabled) {
  background: rgba(230, 126, 34, 0.2) !important;
  border-color: var(--accent) !important;
}
.wt-vote-count {
  font-size: 12px;
  color: var(--accent);
  font-weight: 600;
  white-space: nowrap;
  padding: 2px 8px;
  background: rgba(230, 126, 34, 0.12);
  border-radius: 4px;
}

/* ══════════════════════════════════════
   HEADER BUTTONS
   ══════════════════════════════════════ */

.wt-header-btn {
  background: rgba(255, 255, 255, 0.1);
  border: none;
  color: #fff;
  padding: 8px 14px;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 13px;
  transition: background var(--transition);
}
.wt-header-btn:hover {
  background: rgba(255, 255, 255, 0.2);
}

/* ══════════════════════════════════════
   CHAT PANEL
   ══════════════════════════════════════ */

.wt-chat-panel {
  width: 260px;
  background: var(--bg-secondary);
  border-left: 1px solid var(--bg-tertiary);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}
.wt-chat-header {
  padding: 14px 16px;
  font-weight: 600;
  font-size: 14px;
  color: var(--text-normal);
  border-bottom: 1px solid var(--bg-tertiary);
  flex-shrink: 0;
}
.wt-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 8px 12px;
  scrollbar-width: thin;
  scrollbar-color: var(--bg-tertiary) transparent;
}
.wt-chat-messages::-webkit-scrollbar { width: 4px; }
.wt-chat-messages::-webkit-scrollbar-thumb { background: var(--bg-tertiary); border-radius: 2px; }
.wt-chat-empty {
  padding: 24px 8px;
  text-align: center;
  color: var(--text-faint);
  font-size: 13px;
}
.wt-chat-msg {
  margin-bottom: 6px;
  font-size: 13px;
  line-height: 1.4;
  word-break: break-word;
}
.wt-chat-sender {
  font-weight: 600;
  color: var(--accent);
  margin-right: 6px;
}
.wt-chat-text {
  color: var(--text-normal);
}
.wt-chat-input-row {
  padding: 10px 12px;
  display: flex;
  gap: 6px;
  border-top: 1px solid var(--bg-tertiary);
  flex-shrink: 0;
}
.wt-chat-input {
  flex: 1;
  font-size: 13px;
  padding: 8px 10px;
}
.wt-chat-send-btn {
  padding: 8px 12px;
  font-size: 13px;
  flex-shrink: 0;
}

/* ══════════════════════════════════════
   QUEUE HEADER CLEAR BUTTON
   ══════════════════════════════════════ */

.wt-queue-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.wt-queue-clear-btn {
  background: none;
  border: none;
  color: var(--text-faint);
  font-size: 11px;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 4px;
  transition: all var(--transition);
}
.wt-queue-clear-btn:hover {
  color: var(--danger);
  background: rgba(237, 66, 69, 0.12);
}

/* ══════════════════════════════════════
   TILE MEMBER NAMES
   ══════════════════════════════════════ */

.wt-tile-members-list {
  font-size: 11px;
  color: var(--text-faint);
  padding: 0 12px 8px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ══════════════════════════════════════
   RESPONSIVE CHAT
   ══════════════════════════════════════ */

@media (max-width: 768px) {
  .wt-chat-panel {
    width: 100%;
    max-height: 30vh;
    border-left: none;
    border-top: 1px solid var(--bg-tertiary);
  }
}
