/* ============================================================
   MEG@ Video Streaming — Player CSS
   Estilos del motor HLS y del player standalone.
   ============================================================ */

/* ── Variables (hereda de style.css cuando sea posible) ───── */
.mega-player {
  --mp-bg:      #060c19;
  --mp-border:  #1a2d48;
  --mp-muted:   #7a91b0;
  --mp-accent:  #37d7fb;
  --mp-on:      #ff3333;
  --mp-radius:  8px;
  background: var(--mp-bg);
  border: 1px solid var(--mp-border);
  border-radius: var(--mp-radius);
  overflow: hidden;
  width: 100%;
  max-width: 100%;
  font-size: 13px;
  color: white;
  font-family: inherit;
}

/* ── Head bar ────────────────────────────────────────────── */
.mp-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 14px;
  background: #030810;
  border-bottom: 1px solid var(--mp-border);
  gap: 10px;
  min-height: 38px;
}
.mp-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .06em;
  color: #a6b4cb;
}
.mp-logo {
  max-width: 42px;
  height: 32px;
  object-fit: contain;
}
.mp-indicator {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .1em;
  color: var(--mp-muted);
  background: #0f1c31;
  padding: 3px 9px;
  border-radius: 3px;
  border: 1px solid var(--mp-border);
}

/* ── Stage (video area) ──────────────────────────────────── */
.mp-stage {
  position: relative;
  aspect-ratio: 16 / 9;
  background: #000;
  overflow: hidden;
}
.mp-stage video {
  width: 100%;
  height: 100%;
  max-height: none;
  display: block;
  object-fit: contain;
}

/* ── Overlay (state messages) ────────────────────────────── */
.mp-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  background: rgba(4, 9, 22, .92);
  backdrop-filter: blur(2px);
  padding: 20px;
  text-align: center;
}
.mp-ol-logo {
  width: clamp(120px, 22vw, 260px);
  max-height: 40vh;
  object-fit: contain;
  margin-bottom: 20px;
  opacity: 0.9;
}
.mp-ol-title {
  font-size: 14px;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: white;
}
.mp-ol-detail {
  font-size: 12px;
  color: var(--mp-muted);
  max-width: 280px;
}
.mp-ol-retry {
  margin-top: 6px;
  padding: 9px 22px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .04em;
}

/* ── Spinner ─────────────────────────────────────────────── */
.mp-spinner {
  width: 32px;
  height: 32px;
  border: 3px solid rgba(55, 215, 251, .15);
  border-top-color: var(--mp-accent);
  border-radius: 50%;
  animation: mp-spin .7s linear infinite;
}
@keyframes mp-spin { to { transform: rotate(360deg); } }

/* ── Controls bar ────────────────────────────────────────── */
.mp-controls {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  background: rgba(3, 8, 16, 0.75);
  backdrop-filter: blur(16px);
  border-top: 1px solid rgba(55, 215, 251, 0.15);
  min-height: 54px;
}
.mp-ctrl-btn {
  background: transparent;
  border: 0;
  color: #a0aec0;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: 8px;
  padding: 0;
  flex-shrink: 0;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}
.mp-ctrl-btn:hover { color: #fff; background: rgba(55, 215, 251, 0.15); transform: scale(1.05); }
.mp-ctrl-btn:focus-visible { outline: 2px solid var(--mp-accent); outline-offset: 2px; }

/* Live badge */
.mp-live-pill {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .08em;
  padding: 3px 8px;
  border-radius: 4px;
  background: transparent;
  color: var(--mp-muted);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 5px;
  transition: color .3s;
}
.mp-live-pill .mp-live-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: transparent;
  display: inline-block;
}
.mp-live-on {
  color: white;
}
.mp-live-on .mp-live-dot {
  background: #ff2d2d;
  animation: mp-blink 1.6s ease-in-out infinite;
}
@keyframes mp-blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

.mp-ctrl-spacer { flex: 1; }

/* Volume slider */
.mp-vol {
  width: 72px;
  accent-color: var(--mp-accent);
  cursor: pointer;
  height: 3px;
  vertical-align: middle;
}

/* ── Status bar ──────────────────────────────────────────── */
.mp-status-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: #020710;
  border-top: 1px solid #0b1527;
  padding: 5px 14px;
}
.mp-status {
  font-size: 10px;
  color: #3d5470;
  margin: 0;
  letter-spacing: .04em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.mp-watermark {
  font-size: 10px;
  color: #273950;
  text-decoration: none;
  letter-spacing: .02em;
  transition: color 0.2s;
  flex-shrink: 0;
}
.mp-watermark:hover {
  color: #435b7a;
}

/* ── Standalone wrapper (player/index.php) ───────────────── */
.standalone-body {
  margin: 0;
  padding: 0;
  background: #040b1a;
  color: white;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.mega-standalone-wrap {
  display: flex;
  flex-direction: column;
  width: min(1060px, 100%);
  margin: 0 auto;
  padding: 16px 16px 24px;
  flex: 1;
  box-sizing: border-box;
}

/* ── Topbar (above player) ───────────────────────────────── */
.ms-topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}
.ms-brand-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}
.ms-topbar-logo {
  width: 30px;
  height: 32px;
  object-fit: contain;
  flex-shrink: 0;
}
.ms-brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.3;
}
.ms-brand-name {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .05em;
  color: var(--mp-accent);
  text-transform: uppercase;
}
.ms-channel-name {
  font-size: 14px;
  font-weight: 600;
  color: white;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ms-theater-btn {
  display: flex;
  align-items: center;
  gap: 7px;
  background: #0f1c31;
  border: 1px solid var(--mp-border);
  border-radius: 5px;
  color: var(--mp-muted);
  cursor: pointer;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .06em;
  padding: 7px 13px;
  white-space: nowrap;
  transition: border-color .2s, color .2s;
}
.ms-theater-btn:hover { border-color: var(--mp-accent); color: white; }
.ms-theater-btn:focus-visible { outline: 2px solid var(--mp-accent); }

/* ── Theater mode ────────────────────────────────────────── */
.theater-body        { overflow: hidden; }
.theater-active {
  position: fixed;
  inset: 0;
  z-index: 500;
  width: 100% !important;
  max-width: 100% !important;
  margin: 0;
  padding: 10px;
  background: #000;
  box-sizing: border-box;
}
.theater-active .ms-topbar  { margin-bottom: 8px; }
.theater-active .mega-player { flex: 1; display: flex; flex-direction: column; }
.theater-active .mp-stage    { flex: 1; aspect-ratio: unset; }
.theater-active .mp-stage video { height: 100%; }

/* ── Share section (admin/player-edit.php) ───────────────── */
.share-section {
  margin-top: 32px;
  padding-top: 24px;
  border-top: 1px solid var(--line, #1a2d48);
}
.share-section h2 { font-size: 18px; margin-bottom: 16px; }
.share-group { margin-bottom: 18px; display: grid; gap: 6px; font-size: 13px; }
.share-row   { display: flex; gap: 8px; align-items: flex-start; }
.share-input {
  flex: 1;
  background: #111e32;
  border: 1px solid #43506a;
  border-radius: 5px;
  color: #a6b4cb;
  font: inherit;
  font-size: 12px;
  font-family: monospace;
  padding: 9px 12px;
  resize: none;
  min-width: 0;
}
.share-input:focus-visible { outline: 2px solid var(--cyan, #37d7fb); }

/* ── Responsive ──────────────────────────────────────────── */
@media (max-width: 480px) {
  .mp-vol { display: none; }
  .mp-ctrl-btn { width: 44px; height: 44px; }
  .mp-controls { padding: 8px 12px; gap: 8px; }
  .mp-head    { padding: 8px 12px; }
  .mega-standalone-wrap { padding: 10px 10px 16px; }
  .ms-topbar  { gap: 8px; }
  .ms-channel-name { font-size: 13px; }
  .ms-theater-btn { display: none; }
  .share-row { flex-direction: column; }
  .share-row .button { align-self: flex-start; }
}
  .mp-ctrl-btn { width: 36px; height: 36px; }
  .mp-head    { padding: 6px 10px; }
  .mega-standalone-wrap { padding: 10px 10px 16px; }
  .ms-topbar  { gap: 8px; }
  .ms-channel-name { font-size: 13px; }
  .ms-theater-btn { display: none; }
  .share-row { flex-direction: column; }
  .share-row .button { align-self: flex-start; }
}

/* 📱 Backward compat: standalone-player class (old layout) 📱 */
.standalone-player {
  width: min(1920px, calc(100% - 32px));
  margin: 40px auto;
}
.standalone-player > h1 { font-size: 24px; }
.standalone-player > p  { margin-top: 18px; font-size: 13px; }
/* Fullscreen overlays */
.mega-player:fullscreen, .mega-player:-webkit-full-screen, .mega-player:-moz-full-screen {
  width: 100% !important;
  height: 100% !important;
    height: 100dvh !important;
  max-width: none !important;
  max-height: none !important;
  border: none !important;
  border-radius: 0 !important;
  display: flex !important;
  flex-direction: column !important;
  background: #000 !important;
  position: relative !important;
}

.mega-player:fullscreen .mp-stage, .mega-player:-webkit-full-screen .mp-stage, .mega-player:-moz-full-screen .mp-stage {
  flex: 1 !important;
    min-height: 0 !important;
  aspect-ratio: unset !important;
  height: 100% !important;
  background: #000;
}

.mega-player:fullscreen video, .mega-player:-webkit-full-screen video, .mega-player:-moz-full-screen video {
  height: 100% !important;
  object-fit: contain !important;
}

.mega-player:fullscreen .mp-head, .mega-player:-webkit-full-screen .mp-head, .mega-player:-moz-full-screen .mp-head {
  position: absolute !important;
  top: 0; left: 0; right: 0;
  z-index: 40 !important;
  background: linear-gradient(to bottom, rgba(0,0,0,0.8), transparent) !important;
  border: none !important;
  padding: 15px 20px !important;
  transition: opacity 0.3s ease;
}

.mega-player:fullscreen .mp-controls, .mega-player:-webkit-full-screen .mp-controls, .mega-player:-moz-full-screen .mp-controls {
    position: absolute !important;
    bottom: 0 !important;
    left: 0 !important;
    right: 0 !important;
    z-index: 30 !important;
    background: rgba(3, 8, 16, 0.8) !important;
    backdrop-filter: blur(8px);
    border: none !important;
    border-top: 1px solid rgba(255,255,255,0.1) !important;
    border-radius: 0 !important;
    padding: 10px 15px !important;
    padding-bottom: max(15px, env(safe-area-inset-bottom)) !important;
    padding-left: max(15px, env(safe-area-inset-left)) !important;
    padding-right: max(15px, env(safe-area-inset-right)) !important;
    transition: opacity 0.3s ease;
  }

.mega-player:fullscreen .mp-status-bar, .mega-player:-webkit-full-screen .mp-status-bar, .mega-player:-moz-full-screen .mp-status-bar {
  display: none !important;
}

.mega-player.fs-hide-ui .mp-head,
.mega-player.fs-hide-ui .mp-controls {
  opacity: 0 !important;
  pointer-events: none !important;
}

.mega-player.fs-hide-ui {
  cursor: none !important;
}
.mp-head-actions { display: flex; align-items: center; gap: 8px; }
.mp-close-btn { background: transparent; border: none; color: #fff; cursor: pointer; display: flex; align-items: center; justify-content: center; width: 36px; height: 36px; border-radius: 50%; background: rgba(255,255,255,0.1); transition: all 0.2s; }
.mp-close-btn:hover { background: rgba(255,0,0,0.6); transform: scale(1.1); }
/* LIVE controls remain reachable on notched phones and standalone fullscreen. */
.mp-controls { padding-bottom:calc(6px + env(safe-area-inset-bottom)); padding-left:calc(10px + env(safe-area-inset-left)); padding-right:calc(10px + env(safe-area-inset-right)); }
.mp-ctrl-btn { min-width:38px; min-height:38px; }
.mp-controls .mp-cast-btn[hidden] { display:none; }
@media (max-width:480px) {
  .mp-controls { gap:5px; }
  .mp-ctrl-btn { min-width:40px; min-height:40px; }
  .mp-vol { display:none; }
}
@supports (height:100dvh) {
  .mega-player:fullscreen, .mega-standalone-wrap:fullscreen { min-height:100dvh; }
  .mega-player:fullscreen .mp-stage, .mega-standalone-wrap:fullscreen .mp-stage { min-height:calc(100dvh - 112px); }
}
