/* =====================================================
   CinePlayer — Core CSS
   Modern, tema destekli video oynatıcı stilleri
   ===================================================== */

/* ── Tema Değişkenleri (Varsayılan: Koyu) ───────────── */
:root {
  --cp-primary:         #6C63FF;
  --cp-primary-light:   #9D97FF;
  --cp-bg:              #0d0d0d;
  --cp-surface:         rgba(255, 255, 255, 0.06);
  --cp-surface-hover:   rgba(255, 255, 255, 0.12);
  --cp-border:          rgba(255, 255, 255, 0.1);
  --cp-text:            #ffffff;
  --cp-text-muted:      rgba(255, 255, 255, 0.6);
  --cp-icon:            rgba(255, 255, 255, 0.88);
  --cp-icon-hover:      #ffffff;
  --cp-controls-bg:     linear-gradient(to top, rgba(0,0,0,0.85) 0%, transparent 100%);
  --cp-progress-bg:     rgba(255, 255, 255, 0.2);
  --cp-progress-buffer: rgba(255, 255, 255, 0.3);
  --cp-progress-fill:   var(--cp-primary);
  --cp-radius:          14px;
  --cp-radius-sm:       6px;
  --cp-font:            -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --cp-transition:      0.18s ease;
  --cp-menu-bg:         rgba(18, 18, 28, 0.96);
  --cp-menu-border:     rgba(255, 255, 255, 0.08);
  --cp-menu-hover:      rgba(255, 255, 255, 0.07);
  --cp-menu-active:     rgba(108, 99, 255, 0.2);
  --cp-subtitle-bg:     rgba(0, 0, 0, 0.78);
  --cp-subtitle-text:   #ffffff;
  /* Altyazı stil değişkenleri — JS ile güncellenir */
  --cp-sub-font:        -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --cp-sub-size:        clamp(13px, 2.5vw, 20px);
  --cp-sub-color:       #ffffff;
  --cp-sub-bg-r:        0;
  --cp-sub-bg-g:        0;
  --cp-sub-bg-b:        0;
  --cp-sub-bg-a:        0.78;
}

/* ── Açık Tema ─────────────────────────────────────── */
.cp-theme-light {
  --cp-bg:              #1a1a1a;
  --cp-surface:         rgba(0, 0, 0, 0.05);
  --cp-surface-hover:   rgba(0, 0, 0, 0.1);
  --cp-border:          rgba(0, 0, 0, 0.12);
  --cp-text:            #111111;
  --cp-text-muted:      rgba(0, 0, 0, 0.55);
  --cp-icon:            rgba(255,255,255,0.9);
  --cp-menu-bg:         rgba(255, 255, 255, 0.97);
  --cp-menu-border:     rgba(0, 0, 0, 0.08);
  --cp-menu-hover:      rgba(0, 0, 0, 0.05);
  --cp-menu-active:     rgba(108, 99, 255, 0.12);
}

/* ── Ana Yapı ───────────────────────────────────────── */
.cp-container {
  position: relative;
  display: block;
  width: 100%;
  background: var(--cp-bg);
  border-radius: var(--cp-radius);
  /* overflow: hidden — KALDIRILDI: menü kutuları container dışına taşabilsin */
  overflow: visible;
  font-family: var(--cp-font);
  outline: none;
  -webkit-user-select: none;
  user-select: none;
}

.cp-container * {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

.cp-wrapper {
  position: relative;
  width: 100%;
  height: 100%;
  aspect-ratio: 16 / 9;
  background: #000;
  border-radius: var(--cp-radius);
  /* overflow: hidden — menüler cp-controls içinde absolute, wrapper dışına çıkabilmeli */
  overflow: visible;
  /* Video köşeleri kesmek için clip-path kullan, overflow yerine */
  clip-path: inset(0 round var(--cp-radius));
}

/* ── Video ──────────────────────────────────────────── */
.cp-video {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #000;
}

/* ── iframe (Platform) Katmanı ─────────────────────── */
.cp-iframe-layer {
  display: none;
  position: absolute;
  inset: 0;
  z-index: 3;     /* poster'ın (z-index:2) üstünde olmalı */
  background: #000;
}
.cp-iframe-layer.is-active {
  display: block;
}
.cp-iframe-layer iframe,
.cp-iframe-layer > div {
  width: 100% !important;
  height: 100% !important;
  border: none;
  display: block;
}

/* ── Poster ─────────────────────────────────────────── */
.cp-poster {
  display: none;
  position: absolute;
  inset: 0;
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  z-index: 2;
  cursor: pointer;
  transition: opacity var(--cp-transition);
}
.cp-poster.is-visible {
  display: block;
}

/* ── Spinner ────────────────────────────────────────── */
.cp-spinner {
  display: none;
  position: absolute;
  inset: 0;
  z-index: 10;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}
.cp-spinner.is-visible {
  display: flex;
}
.cp-spinner-ring {
  width: 44px;
  height: 44px;
  border: 3px solid rgba(255,255,255,0.12);
  border-top-color: var(--cp-primary);
  border-radius: 50%;
  animation: cp-spin 0.75s linear infinite;
}
@keyframes cp-spin {
  to { transform: rotate(360deg); }
}

/* ── Büyük Oynat Butonu ─────────────────────────────── */
.cp-big-play {
  display: none;
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.8);
  z-index: 8;
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: rgba(0,0,0,0.45);
  border: 2px solid rgba(255,255,255,0.25);
  cursor: pointer;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s cubic-bezier(.34,1.56,.64,1), background var(--cp-transition);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}
.cp-big-play.is-visible {
  display: flex;
}
.cp-big-play:hover {
  background: rgba(108, 99, 255, 0.6);
  border-color: var(--cp-primary);
  transform: translate(-50%, -50%) scale(1);
}
.cp-big-play svg {
  width: 30px;
  height: 30px;
  fill: #fff;
  margin-left: 4px;
}

/* ── Kontroller ─────────────────────────────────────── */
.cp-controls {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 25;    /* iframe(3), poster(2), spinner(10), bigPlay(8) hepsinin üstünde */
  padding: 8px 14px 12px;
  background: var(--cp-controls-bg);
  border-radius: 0 0 var(--cp-radius) var(--cp-radius);
  opacity: 0;
  transform: translateY(4px);
  transition: opacity 0.25s ease, transform 0.25s ease;
  pointer-events: none;
}
.cp-controls.is-visible {
  opacity: 1;
  transform: translateY(0);
  pointer-events: all;
}

/* ── Progress Bar ───────────────────────────────────── */
.cp-progress-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 6px;
}

.cp-progress-wrap {
  flex: 1;
  height: 4px;
  background: var(--cp-progress-bg);
  border-radius: 2px;
  position: relative;
  cursor: pointer;
  transition: height 0.15s ease;
  overflow: visible;   /* thumbnail preview'in dışına taşmasına izin ver */
}
.cp-progress-wrap:hover,
.cp-progress-wrap.is-dragging {
  height: 6px;
}

.cp-progress-buffered {
  position: absolute;
  left: 0; top: 0;
  height: 100%;
  background: var(--cp-progress-buffer);
  border-radius: 2px;
  pointer-events: none;
  transition: width 0.3s ease;
}

.cp-progress-fill {
  position: absolute;
  left: 0; top: 0;
  height: 100%;
  background: var(--cp-progress-fill);
  border-radius: 2px;
  pointer-events: none;
  transition: width 0.1s linear;
}

.cp-progress-thumb {
  position: absolute;
  right: -6px;
  top: 50%;
  transform: translateY(-50%) scale(0);
  width: 14px;
  height: 14px;
  background: #fff;
  border-radius: 50%;
  box-shadow: 0 0 0 3px rgba(108,99,255,0.4);
  transition: transform 0.15s ease;
  pointer-events: none;
}
.cp-progress-wrap:hover .cp-progress-thumb,
.cp-progress-wrap.is-dragging .cp-progress-thumb {
  transform: translateY(-50%) scale(1);
}

/* Zaman önizleme + thumbnail */
.cp-progress-preview {
  display: none;
  position: absolute;
  bottom: calc(100% + 10px);  /* progress bar yüksekliğinin üstünde */
  left: 0;
  transform: translateX(-50%);
  pointer-events: none;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  z-index: 30;
  filter: drop-shadow(0 4px 14px rgba(0,0,0,0.7));
}
.cp-progress-preview.is-visible {
  display: flex;
}
.cp-preview-thumb {
  display: none;
  background: #111 center/cover no-repeat;
  border-radius: 5px;
  border: 1.5px solid rgba(255,255,255,0.18);
  overflow: hidden;
  width: 160px;
  height: 90px;
  flex-shrink: 0;
}
.cp-preview-time {
  background: rgba(0,0,0,0.82);
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  padding: 3px 9px;
  border-radius: 4px;
  white-space: nowrap;
  letter-spacing: 0.04em;
}

.cp-time-display {
  font-size: 11px;
  color: var(--cp-text-muted);
  white-space: nowrap;
  min-width: 80px;
  text-align: right;
  letter-spacing: 0.02em;
}

/* ── Buton Satırı ───────────────────────────────────── */
.cp-btn-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 2px;
}

.cp-btn-group {
  display: flex;
  align-items: center;
  gap: 2px;
}
.cp-btn-group--right {
  gap: 2px;
}

/* ── Butonlar ───────────────────────────────────────── */
.cp-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border: none;
  border-radius: var(--cp-radius-sm, 6px);
  background: transparent;
  color: var(--cp-icon, rgba(255,255,255,0.88));  /* fallback: beyaz */
  cursor: pointer;
  transition: background var(--cp-transition, 0.18s ease), color var(--cp-transition, 0.18s ease), transform 0.1s;
  position: relative;
  flex-shrink: 0;
}
.cp-btn:hover {
  background: var(--cp-surface-hover, rgba(255,255,255,0.12));
  color: var(--cp-icon-hover, #ffffff);
}
.cp-btn:active {
  transform: scale(0.9);
}
.cp-btn.is-active {
  color: var(--cp-primary-light, #9D97FF);
}
.cp-btn svg {
  width: 16px;
  height: 16px;
  fill: currentColor;
  display: block;          /* inline SVG'lerin hizalama sorunununu önler */
  flex-shrink: 0;
  pointer-events: none;
  overflow: visible;       /* path'ların kesilmemesi için */
}

/* Hız etiketi */
.cp-speed-label,
.cp-quality-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.02em;
  white-space: nowrap;
  padding: 0 6px;
  min-width: 28px;
  text-align: center;
}

/* ── Ses Kontrolü ───────────────────────────────────── */
.cp-vol-wrap {
  display: flex;
  align-items: center;
  gap: 4px;
}

.cp-vol-slider {
  width: 60px;
  height: 4px;
  background: var(--cp-progress-bg);
  border-radius: 2px;
  position: relative;
  cursor: pointer;
  transition: width var(--cp-transition);
  overflow: visible;
}

@media (max-width: 480px) {
  .cp-vol-slider { display: none; }
}

.cp-vol-fill {
  position: absolute;
  left: 0; top: 0;
  height: 100%;
  background: rgba(255,255,255,0.7);
  border-radius: 2px;
  pointer-events: none;
}

/* ── Altyazı Gösterimi ─────────────────────────────── */
.cp-subtitle-display {
  position: absolute;
  bottom: 70px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 20;
  text-align: center;
  pointer-events: none;
  max-width: 80%;
}

.cp-subtitle-text {
  display: inline-block;
  background: rgba(var(--cp-sub-bg-r), var(--cp-sub-bg-g), var(--cp-sub-bg-b), var(--cp-sub-bg-a));
  color: var(--cp-sub-color);
  font-family: var(--cp-sub-font);
  font-size: var(--cp-sub-size);
  line-height: 1.5;
  padding: 4px 12px;
  border-radius: 4px;
  white-space: pre-wrap;
  word-break: break-word;
  transition: background .2s, color .2s, font-size .15s;
}

/* ── Paylaş Paneli ───────────────────────────────── */
.cp-share-panel {
  min-width: 280px;
  max-width: 320px;
}
.cp-share-panel textarea {
  color: #9D97FF;
  font-family: 'Fira Code', 'Courier New', monospace;
}

/* ── Altyazı Stil Paneli ─────────────────────────────── */
.cp-sub-style-menu {
  min-width: 230px;
}

.cp-style-section {
  padding: 10px 14px 8px;
  border-top: 1px solid var(--cp-menu-border);
}

.cp-style-section-label {
  font-size: 10px;
  font-weight: 600;
  color: rgba(255,255,255,.35);
  text-transform: uppercase;
  letter-spacing: .1em;
  margin-bottom: 10px;
  display: block;
}

/* Font seçenekleri */
.cp-style-font-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 5px;
  margin-bottom: 2px;
}

.cp-style-font-btn {
  background: rgba(255,255,255,.05);
  border: 1px solid var(--cp-menu-border);
  border-radius: 5px;
  color: rgba(255,255,255,.65);
  font-size: 12px;
  padding: 6px 4px;
  cursor: pointer;
  transition: all .15s;
  text-align: center;
}
.cp-style-font-btn:hover {
  background: rgba(255,255,255,.1);
  color: #fff;
}
.cp-style-font-btn.is-active {
  background: var(--cp-menu-active);
  border-color: rgba(108,99,255,.4);
  color: var(--cp-primary-light);
}

/* Boyut seçenekleri */
.cp-style-size-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 5px;
}

.cp-style-size-btn {
  background: rgba(255,255,255,.05);
  border: 1px solid var(--cp-menu-border);
  border-radius: 5px;
  color: rgba(255,255,255,.65);
  cursor: pointer;
  padding: 5px 4px;
  transition: all .15s;
  text-align: center;
  line-height: 1;
}
.cp-style-size-btn:hover {
  background: rgba(255,255,255,.1);
  color: #fff;
}
.cp-style-size-btn.is-active {
  background: var(--cp-menu-active);
  border-color: rgba(108,99,255,.4);
  color: var(--cp-primary-light);
}

/* Renk seçenekleri */
.cp-style-color-row {
  display: flex;
  gap: 7px;
  flex-wrap: wrap;
}

.cp-color-swatch {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  cursor: pointer;
  border: 2px solid transparent;
  transition: border-color .15s, transform .1s;
  flex-shrink: 0;
}
.cp-color-swatch:hover {
  transform: scale(1.15);
}
.cp-color-swatch.is-active {
  border-color: #fff;
  box-shadow: 0 0 0 1px rgba(255,255,255,.3);
}

/* Opaklık slider */
.cp-style-slider-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.cp-style-slider {
  flex: 1;
  height: 4px;
  -webkit-appearance: none;
  appearance: none;
  background: rgba(255,255,255,.15);
  border-radius: 2px;
  outline: none;
  cursor: pointer;
}
.cp-style-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #fff;
  cursor: pointer;
  box-shadow: 0 0 0 2px rgba(108,99,255,.4);
}
.cp-style-slider::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #fff;
  cursor: pointer;
  border: none;
  box-shadow: 0 0 0 2px rgba(108,99,255,.4);
}
.cp-style-slider-val {
  font-size: 11px;
  color: rgba(255,255,255,.5);
  min-width: 32px;
  text-align: right;
}

/* Stil aç/kapat butonu altyazı menüsü altında */
.cp-menu-style-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 14px;
  font-size: 12px;
  color: rgba(255,255,255,.45);
  cursor: pointer;
  border-top: 1px solid var(--cp-menu-border);
  margin-top: 2px;
  transition: color .15s;
}
.cp-menu-style-toggle:hover {
  color: rgba(255,255,255,.8);
}
.cp-menu-style-toggle svg {
  width: 13px;
  height: 13px;
  fill: currentColor;
  flex-shrink: 0;
}

/* ── Menüler ────────────────────────────────────────── */
.cp-menu {
  display: none;
  position: absolute;
  bottom: 56px;
  right: 10px;
  z-index: 9999;   /* iframe + tüm katmanların üstünde */
  min-width: 190px;
  background: var(--cp-menu-bg);
  border: 1px solid var(--cp-menu-border);
  border-radius: 10px;
  overflow: visible;  /* iç scroll için alt elemanlar overflow:auto kullanır */
  overflow-y: auto;
  max-height: calc(100% - 70px);   /* container yüksekliğini aşmasın */
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  box-shadow: 0 8px 32px rgba(0,0,0,0.5);
  animation: cp-menu-in 0.15s ease;
}
.cp-menu.is-open {
  display: block;
}

@keyframes cp-menu-in {
  from { opacity: 0; transform: translateY(6px) scale(0.97); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.cp-menu-header {
  padding: 10px 14px 8px;
  font-size: 11px;
  font-weight: 600;
  color: var(--cp-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  border-bottom: 1px solid var(--cp-menu-border);
}

.cp-menu-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 9px 14px;
  font-size: 13px;
  color: var(--cp-text);
  cursor: pointer;
  transition: background var(--cp-transition);
  gap: 10px;
}
.cp-menu-item:hover {
  background: var(--cp-menu-hover);
}
.cp-menu-item.is-active {
  background: var(--cp-menu-active);
  color: var(--cp-primary-light);
}
.cp-menu-item.is-active::after {
  content: '✓';
  font-size: 12px;
  color: var(--cp-primary-light);
  margin-left: auto;
}

.cp-menu-label {
  font-weight: 400;
}
.cp-menu-value {
  font-size: 12px;
  color: var(--cp-text-muted);
}

.cp-menu-divider {
  height: 1px;
  background: var(--cp-menu-border);
  margin: 4px 0;
}

/* Toggle switch */
.cp-toggle {
  width: 34px;
  height: 18px;
  background: rgba(255,255,255,0.2);
  border-radius: 9px;
  position: relative;
  cursor: pointer;
  transition: background var(--cp-transition);
  flex-shrink: 0;
}
.cp-toggle.is-on {
  background: var(--cp-primary);
}
.cp-toggle-thumb {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 14px;
  height: 14px;
  background: #fff;
  border-radius: 50%;
  transition: transform var(--cp-transition);
  box-shadow: 0 1px 3px rgba(0,0,0,0.3);
}
.cp-toggle.is-on .cp-toggle-thumb {
  transform: translateX(16px);
}

/* ── Tooltip ────────────────────────────────────────── */
.cp-tooltip {
  display: none;
  position: absolute;
  z-index: 50;
  background: rgba(0,0,0,0.8);
  color: #fff;
  font-size: 11px;
  padding: 4px 8px;
  border-radius: 4px;
  pointer-events: none;
  white-space: nowrap;
}

/* ── Tam Ekran ──────────────────────────────────────── */
.cp-container:fullscreen,
.cp-container:-webkit-full-screen {
  border-radius: 0;
  width: 100vw;
  height: 100vh;
}
.cp-container:fullscreen .cp-wrapper,
.cp-container:-webkit-full-screen .cp-wrapper {
  border-radius: 0;
  aspect-ratio: unset;
  height: 100vh;
}
.cp-container:fullscreen .cp-subtitle-text,
.cp-container:-webkit-full-screen .cp-subtitle-text {
  font-size: clamp(18px, 3vw, 28px);
}

/* ── Mobil ──────────────────────────────────────────── */
@media (max-width: 560px) {
  .cp-btn {
    width: 28px;
    height: 28px;
  }
  .cp-btn svg {
    width: 14px;
    height: 14px;
  }
  .cp-btn--audio,
  .cp-btn--cast { display: none; }
  .cp-menu { min-width: 160px; right: 4px; }
  .cp-time-display { font-size: 10px; min-width: 64px; }
}

/* Stop butonu — hafif kırmızı tonu ile ayrışır */
.cp-btn--stop:hover {
  background: rgba(255, 80, 80, 0.15);
  color: rgba(255, 140, 140, 0.95);
}

/* Chromecast bağlı durumu */
.cp-btn--cast.cast-connecting {
  animation: cp-cast-pulse 1s ease-in-out infinite;
}
.cp-btn--cast.cast-connected {
  color: var(--cp-primary-light);
}
@keyframes cp-cast-pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.4; }
}
.cp-container:focus-visible {
  outline: 2px solid var(--cp-primary);
  outline-offset: 2px;
}
.cp-btn:focus-visible,
.cp-progress-wrap:focus-visible,
.cp-vol-slider:focus-visible {
  outline: 2px solid var(--cp-primary-light);
  outline-offset: 2px;
}

/* Hareket azaltma */
@media (prefers-reduced-motion: reduce) {
  .cp-spinner-ring { animation: none; border-top-color: var(--cp-primary); }
  .cp-controls { transition: none; }
  .cp-big-play { transition: none; }
  .cp-menu { animation: none; }
}

/* ── RTL Desteği ────────────────────────────────────── */
[dir="rtl"] .cp-btn-group--right {
  margin-left: 0;
  margin-right: auto;
}
[dir="rtl"] .cp-menu {
  right: auto;
  left: 10px;
}

/* ── Yükleniyor Durumu ──────────────────────────────── */
.cp-container.is-loading .cp-video {
  opacity: 0.3;
}

/* ── Hata Durumu ────────────────────────────────────── */
.cp-error-overlay {
  display: none;
  position: absolute;
  inset: 0;
  z-index: 40;
  background: rgba(0,0,0,0.7);
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 12px;
  text-align: center;
  padding: 20px;
}
.cp-container.has-error .cp-error-overlay {
  display: flex;
}
.cp-error-icon {
  width: 48px;
  height: 48px;
  fill: rgba(255,100,100,0.8);
}
.cp-error-message {
  color: rgba(255,255,255,0.8);
  font-size: 14px;
}
