/* =====================================================
   BlueStream — Embed Player (iframe)
   تغطية كاملة + نفس ستايل الموقع
   ===================================================== */

   * { box-sizing: border-box; }

   /* ===== Overlay يغطي كل الشاشة ===== */
   .embed-overlay {
     position: fixed;
     top: 0;
     left: 0;
     right: 0;
     bottom: 0;
     width: 100vw;
     height: 100vh;
     z-index: 200;
     display: flex;
     flex-direction: column;
     background: var(--bg, #09090b);
     overflow: hidden;
     animation: fadeIn 0.25s ease;
   }
   
   @keyframes fadeIn {
     from { opacity: 0; }
     to { opacity: 1; }
   }
   
   /* ===== الشريط العلوي — نفس ستايل player-topbar ===== */
   .embed-topbar {
     position: absolute;
     top: 0;
     inset-inline: 0;
     z-index: 10;
     display: flex;
     align-items: center;
     gap: 18px;
     padding: 18px 28px;
     background: linear-gradient(180deg, rgba(9, 9, 11, 0.96) 0%, rgba(9, 9, 11, 0.72) 58%, transparent 100%);
     transition: opacity 0.4s ease;
     pointer-events: auto;
   }
   
   .embed-overlay.hide-chrome .embed-topbar {
     opacity: 0;
     pointer-events: none;
   }
   
   .embed-back {
     padding: 9px 20px;
     border: 1px solid var(--border-strong, #2a2a30);
     border-radius: var(--radius-sm, 8px);
     background: rgba(9, 9, 11, 0.6);
     color: var(--text, #f4f4f5);
     font-family: inherit;
     font-size: 0.92rem;
     font-weight: 700;
     cursor: pointer;
     transition: background 0.2s, border-color 0.2s;
   }
   .embed-back:hover {
     background: var(--surface-2, #1c1c22);
     border-color: var(--accent-border, #3b82f6);
   }
   
   .embed-title {
     flex: 1;
     font-size: 1.1rem;
     font-weight: 800;
     color: var(--text, #f4f4f5);
     white-space: nowrap;
     overflow: hidden;
     text-overflow: ellipsis;
     text-shadow: 0 2px 8px rgba(0, 0, 0, 0.8);
     margin: 0;
   }

   .embed-episode {
     min-width: 150px;
     padding: 9px 14px;
     border: 1px solid var(--border-strong, rgba(255, 255, 255, 0.14));
     border-radius: var(--radius-sm, 12px);
     background: var(--surface, #17171c);
     color: var(--text, #f4f4f5);
     font-family: inherit;
     font-size: 0.86rem;
     font-weight: 700;
     cursor: pointer;
     outline: none;
   }
   .embed-episode:focus {
     border-color: var(--accent-border, #3b82f6);
     box-shadow: 0 0 0 3px var(--accent-soft, rgba(59, 130, 246, 0.16));
   }
   
   /* ===== منطقة الـ iframe — تغطية كاملة ===== */
   .embed-stage {
     position: absolute;
     top: 0;
     left: 0;
     width: 100vw;
     height: 100vh;
     display: grid;
     place-items: center;
     padding: 76px 24px 24px;
     background:
       radial-gradient(circle at 50% 35%, var(--surface-2, #1c1c22), transparent 55%),
       var(--bg, #09090b);
     overflow: hidden;
     transition: padding 0.35s ease;
   }

   .embed-overlay.hide-chrome .embed-stage {
     padding-top: 24px;
   }
   
   .embed-frame {
     position: relative;
     width: min(100%, calc((100vh - 100px) * 16 / 9));
     height: auto;
     max-height: 100%;
     aspect-ratio: 16 / 9;
     background: #000;
     display: block;
     overflow: hidden;
     border: 1px solid var(--border-strong, rgba(255, 255, 255, 0.14));
     border-radius: 18px;
     box-shadow: 0 30px 90px rgba(0, 0, 0, 0.72);
     transition: width 0.35s ease, border-radius 0.35s ease;
   }

   .embed-overlay.hide-chrome .embed-frame {
     width: min(100%, calc((100vh - 48px) * 16 / 9));
   }
   
   .embed-frame iframe {
     position: absolute;
     top: 0;
     left: 0;
     width: 100%;
     height: 100%;
     border: none;
     display: block;
   }
   
   /* ===== Loading overlay (يظهر أثناء تجربة السيرفرات) ===== */
   .embed-loading {
     position: absolute;
     inset: 0;
     z-index: 5;
     display: flex;
     flex-direction: column;
     align-items: center;
     justify-content: center;
     background: rgba(0, 0, 0, 0.85);
     backdrop-filter: blur(8px);
     color: var(--text, #f4f4f5);
     font-family: inherit;
     gap: 18px;
   }
   
   .embed-loading-spinner {
     width: 50px;
     height: 50px;
     border: 3px solid rgba(255, 255, 255, 0.15);
     border-top-color: var(--accent-solid, #3b82f6);
     border-radius: 50%;
     animation: spin 0.9s linear infinite;
   }
   
   @keyframes spin {
     to { transform: rotate(360deg); }
   }
   
   .embed-loading-text {
     font-size: 1.05rem;
     font-weight: 700;
     color: var(--text, #f4f4f5);
     text-shadow: 0 2px 8px rgba(0, 0, 0, 0.8);
     margin: 0;
   }
   
   .embed-loading-server {
     font-size: 0.88rem;
     font-weight: 600;
     color: var(--text-secondary, #a0a0aa);
     margin: 0;
   }
   
   /* ===== رسالة الخطأ — نفس ستايل player-error ===== */
   .embed-error {
     position: absolute;
     inset: 0;
     z-index: 30;
     display: grid;
     place-items: center;
     padding: 24px;
     background: rgba(3, 6, 12, 0.92);
     backdrop-filter: blur(10px);
   }
   
   .embed-error-card {
     max-width: 460px;
     width: 100%;
     text-align: center;
     padding: 34px 30px;
     border-radius: 18px;
     background: var(--surface, #17171c);
     border: 1px solid var(--border-strong, #2a2a30);
     box-shadow: 0 24px 60px rgba(0, 0, 0, 0.7);
     animation: pop 0.28s cubic-bezier(0.2, 0.9, 0.3, 1.2);
   }
   
   @keyframes pop {
     from { opacity: 0; transform: scale(0.95); }
     to { opacity: 1; transform: scale(1); }
   }
   
   .embed-error-icon {
     width: 62px;
     height: 62px;
     margin: 0 auto 18px;
     display: grid;
     place-items: center;
     font-size: 1.9rem;
     border-radius: 50%;
     color: var(--text, #f4f4f5);
     background: var(--surface-2, #1c1c22);
     border: 1px solid var(--accent-border, #3b82f6);
     box-shadow: 0 0 20px rgba(59, 130, 246, 0.3);
   }
   
   .embed-error-card p {
     font-size: 1.02rem;
     line-height: 1.8;
     color: var(--text, #f4f4f5);
     margin-bottom: 24px;
   }
   
   .embed-error-actions {
     display: flex;
     gap: 12px;
     justify-content: center;
     flex-wrap: wrap;
   }
   
   .embed-error-actions button {
     padding: 11px 26px;
     font-size: 0.95rem;
     font-weight: 700;
     font-family: inherit;
     border-radius: var(--radius-sm, 8px);
     cursor: pointer;
     transition: background 0.2s, border-color 0.2s;
   }
   
   .embed-error-retry {
     background: var(--accent-solid, #3b82f6);
     color: #fff;
     border: none;
   }
   .embed-error-retry:hover { background: var(--accent-solid-hover, #2563eb); }
   
   .embed-error-skip {
     background: rgba(9, 9, 11, 0.6);
     color: var(--text, #f4f4f5);
     border: 1px solid var(--border-strong, #2a2a30);
   }
   .embed-error-skip:hover {
     background: var(--surface-2, #1c1c22);
     border-color: var(--accent-border, #3b82f6);
   }
   
   .embed-error-close {
     background: rgba(9, 9, 11, 0.6);
     color: var(--text, #f4f4f5);
     border: 1px solid var(--border-strong, #2a2a30);
   }
   .embed-error-close:hover {
     background: var(--surface-2, #1c1c22);
     border-color: var(--accent-border, #3b82f6);
   }
   
   /* ===== استجابة الجوال ===== */
   @media (max-width: 768px) {
     .embed-topbar {
       padding: 12px 14px;
       gap: 10px;
     }
   
     .embed-title {
       font-size: 0.95rem;
     }
   
     .embed-back {
       padding: 7px 14px;
       font-size: 0.85rem;
     }

     .embed-episode {
       min-width: 110px;
       max-width: 42vw;
       padding: 7px 10px;
       font-size: 0.78rem;
     }

     .embed-stage,
     .embed-overlay.hide-chrome .embed-stage {
       padding: 58px 0 0;
     }

     .embed-frame,
     .embed-overlay.hide-chrome .embed-frame {
       width: 100%;
       max-height: none;
       border-inline: 0;
       border-radius: 0;
     }
   }

/* =====================================================
   مساحة المشغل الجديدة: اختيار يدوي + حلقات داخل الإطار
   ===================================================== */
.embed-server-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  direction: rtl;
}
.embed-server-label {
  color: var(--text-faint, #6b7280);
  font-size: 0.7rem;
  font-weight: 800;
}
.embed-server,
.embed-season {
  min-width: 148px;
  padding: 9px 12px;
  border: 1px solid var(--border-strong, rgba(255, 255, 255, 0.14));
  border-radius: var(--radius-sm, 12px);
  outline: none;
  background: var(--surface, #17171c);
  color: var(--text, #f4f4f5);
  font-family: inherit;
  font-size: 0.76rem;
  font-weight: 700;
  cursor: pointer;
}
.embed-server:focus,
.embed-season:focus {
  border-color: var(--accent-border, #3b82f6);
  box-shadow: 0 0 0 3px var(--accent-soft, rgba(59, 130, 246, 0.16));
}
.embed-control-button {
  padding: 9px 13px;
  border: 1px solid var(--border-strong, rgba(255, 255, 255, 0.14));
  border-radius: var(--radius-sm, 12px);
  background: rgba(255, 255, 255, 0.055);
  color: var(--text, #f4f4f5);
  font-family: inherit;
  font-size: 0.72rem;
  font-weight: 800;
  white-space: nowrap;
  cursor: pointer;
}
.embed-control-button:hover {
  border-color: var(--accent-border, #3b82f6);
  background: var(--surface-2, #1c1c22);
}

.embed-stage,
.embed-overlay.hide-chrome .embed-stage {
  display: block;
  padding: 82px 20px 20px;
}
.embed-workspace {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-areas: "player";
  align-items: center;
  gap: 14px;
  width: min(100%, 1600px);
  height: 100%;
  margin: 0 auto;
  direction: ltr;
}
.embed-workspace.has-sidebar {
  grid-template-columns: minmax(238px, 292px) minmax(0, 1fr);
  grid-template-areas: "episodes player";
}
.embed-workspace .embed-frame,
.embed-overlay.hide-chrome .embed-workspace .embed-frame {
  grid-area: player;
  justify-self: center;
  width: min(100%, calc((100vh - 112px) * 16 / 9));
  max-height: 100%;
}
.embed-workspace.has-sidebar .embed-frame,
.embed-overlay.hide-chrome .embed-workspace.has-sidebar .embed-frame {
  width: 100%;
}

.embed-episodes-panel {
  grid-area: episodes;
  align-self: stretch;
  min-height: 0;
  max-height: 100%;
  padding: 14px;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: var(--bg-raised, #0f0f13);
  box-shadow: 0 22px 65px rgba(0, 0, 0, 0.45);
  direction: rtl;
}
.embed-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}
.embed-panel-head > div {
  display: flex;
  flex-direction: column;
}
.embed-panel-head span,
.embed-season-label {
  color: var(--text-faint, #6b7280);
  font-size: 0.63rem;
  font-weight: 700;
}
.embed-panel-head h4 {
  margin: 1px 0 0;
  color: var(--text, #f4f4f5);
  font-size: 1rem;
  font-weight: 900;
}
.embed-panel-head button {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: var(--surface, #17171c);
  color: var(--text-dim, #9ca3af);
  cursor: pointer;
}
.embed-season-label { display: block; margin-bottom: 6px; }
.embed-season { width: 100%; margin-bottom: 11px; }
.embed-episodes-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  height: calc(100% - 105px);
  padding-inline-end: 2px;
  overflow-y: auto;
}
.embed-episode-item {
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr);
  align-items: center;
  gap: 9px;
  width: 100%;
  padding: 9px;
  border: 1px solid transparent;
  border-radius: 12px;
  background: transparent;
  color: var(--text-dim, #9ca3af);
  font-family: inherit;
  text-align: start;
  cursor: pointer;
  transition: background var(--transition), border-color var(--transition);
}
.embed-episode-item:hover,
.embed-episode-item.active {
  border-color: var(--border-strong);
  background: var(--surface-2, #1c1c22);
  color: var(--text, #f4f4f5);
}
.embed-episode-item.active {
  box-shadow: inset 3px 0 0 var(--accent-solid, #3b82f6);
}
.embed-episode-number {
  position: relative;
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface, #17171c);
  color: var(--text-faint, #6b7280);
  font-size: 0.72rem;
  font-weight: 900;
}
.embed-episode-item.active .embed-episode-number {
  color: var(--accent-solid, #3b82f6);
}
.embed-episode-copy { min-width: 0; }
.embed-episode-copy strong,
.embed-episode-copy span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.embed-episode-copy strong { font-size: 0.72rem; font-weight: 800; }
.embed-episode-copy span {
  margin-top: 2px;
  color: var(--text-faint, #6b7280);
  font-size: 0.6rem;
}
.embed-episode-item.watched .embed-episode-number::after {
  content: "✓";
  position: absolute;
  margin: 26px 24px 0 0;
  color: var(--accent-solid, #3b82f6);
  font-size: 0.56rem;
}
.embed-panel-message {
  padding: 14px 10px;
  color: var(--text-faint, #6b7280);
  font-size: 0.7rem;
  line-height: 1.7;
  text-align: center;
}

.embed-verification {
  position: absolute;
  z-index: 18;
  inset-inline: 12px;
  bottom: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid var(--border-strong);
  border-radius: 13px;
  background: rgba(15, 15, 19, 0.94);
  color: var(--text-dim, #9ca3af);
  font-size: 0.68rem;
  font-weight: 600;
  backdrop-filter: blur(14px);
}
.embed-verification > div { display: flex; gap: 7px; flex-shrink: 0; }
.embed-verification button {
  padding: 7px 11px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-pill, 999px);
  background: var(--surface-2, #1c1c22);
  color: var(--text, #f4f4f5);
  font-family: inherit;
  font-size: 0.65rem;
  font-weight: 800;
  cursor: pointer;
}
#embed-confirm-working {
  border-color: var(--accent-border, #3b82f6);
}

.embed-error-next,
.embed-error-retry {
  border: 0;
  background: #fff;
  color: #09090b;
}

@media (max-width: 1100px) {
  .embed-workspace.has-sidebar {
    grid-template-columns: minmax(220px, 255px) minmax(0, 1fr);
  }
  .embed-topbar { gap: 10px; padding-inline: 18px; }
  .embed-server-label { display: none; }
  .embed-server { min-width: 125px; max-width: 170px; }
  .embed-control-button { padding-inline: 10px; }
}

@media (max-width: 820px) {
  .embed-topbar {
    align-items: center;
    flex-wrap: wrap;
    padding: 10px 12px;
  }
  .embed-title {
    min-width: 0;
    font-size: 0.82rem;
  }
  .embed-server-controls {
    order: 3;
    width: 100%;
  }
  .embed-server { flex: 1; max-width: none; min-width: 0; }
  .embed-stage,
  .embed-overlay.hide-chrome .embed-stage {
    padding: 112px 0 0;
  }
  .embed-workspace,
  .embed-workspace.has-sidebar {
    display: block;
    width: 100%;
  }
  .embed-workspace .embed-frame,
  .embed-workspace.has-sidebar .embed-frame,
  .embed-overlay.hide-chrome .embed-workspace .embed-frame,
  .embed-overlay.hide-chrome .embed-workspace.has-sidebar .embed-frame {
    width: 100%;
    border-inline: 0;
    border-radius: 0;
  }
  .embed-episodes-panel {
    position: absolute;
    z-index: 24;
    top: 0;
    bottom: 0;
    left: 0;
    width: min(88vw, 350px);
    max-height: none;
    border-block: 0;
    border-inline-start: 0;
    border-radius: 0 18px 18px 0;
  }
  .embed-verification {
    align-items: stretch;
    flex-direction: column;
  }
  .embed-verification > div { justify-content: stretch; }
  .embed-verification button { flex: 1; }
}

@media (max-width: 480px) {
  .embed-back { padding: 7px 10px; font-size: 0.74rem; }
  .embed-control-button { font-size: 0.64rem; }
  #embed-next-server { max-width: 104px; }
  .embed-verification { bottom: 7px; inset-inline: 7px; }
}
   