/* ═══════════════════════════════════════════════
   INTERFILM — CAST SYSTEM v3.0
   Multi-protocol: Google Cast · WebRTC · Remote
   ═══════════════════════════════════════════════ */

/* ─── Variables ─────────────────────────────────── */
:root {
  --cast-orange: #f77f00;
  --cast-orange2: #ff9500;
  --cast-orange-glow: rgba(247, 127, 0, 0.4);
  --cast-bg: rgba(10, 10, 14, 0.97);
  --cast-surface: rgba(255, 255, 255, 0.06);
  --cast-border: rgba(255, 255, 255, 0.1);
  --cast-border-active: rgba(247, 127, 0, 0.45);
  --cast-radius: 14px;
  --cast-ease: cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* ─── Cast Button ────────────────────────────────── */
#castBtn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: 10px;
  border: 1px solid var(--cast-border);
  background: var(--cast-surface);
  color: #fff;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .04em;
  text-transform: uppercase;
  cursor: pointer;
  transition: background .2s, border-color .2s, color .2s, transform .15s;
  font-family: var(--ff-head, 'Outfit', sans-serif);
  position: relative;
  overflow: hidden;
}

#castBtn:hover {
  background: rgba(247, 127, 0, 0.18);
  border-color: var(--cast-border-active);
  color: var(--cast-orange2);
  transform: translateY(-1px);
}

#castBtn.cast--active {
  background: rgba(247, 127, 0, 0.16);
  border-color: var(--cast-border-active);
  color: var(--cast-orange);
}

#castBtn.cast--active .cast-icon-svg {
  animation: castPulse 2s ease-in-out infinite;
  filter: drop-shadow(0 0 4px var(--cast-orange));
}

#castBtn.cast--scanning .cast-icon-svg {
  animation: castScan 1.2s ease-in-out infinite;
}

#castBtnLabel {
  transition: opacity .2s;
}

.cast-icon-svg {
  flex-shrink: 0;
  transition: color .2s;
}

/* ─── Animations ─────────────────────────────────── */
@keyframes castPulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: .65; transform: scale(1.12); }
}

@keyframes castScan {
  0% { opacity: 1; }
  50% { opacity: .4; }
  100% { opacity: 1; }
}

@keyframes castModalIn {
  from { opacity: 0; transform: translateY(12px) scale(.96); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes castBackdropIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

@keyframes castSpinRing {
  to { transform: rotate(360deg); }
}

@keyframes castDeviceIn {
  from { opacity: 0; transform: translateX(-8px); }
  to   { opacity: 1; transform: translateX(0); }
}

@keyframes castToastIn {
  from { opacity: 0; transform: translateX(20px); }
  to   { opacity: 1; transform: translateX(0); }
}

@keyframes castToastOut {
  to { opacity: 0; transform: translateX(20px); }
}

/* ─── Backdrop ───────────────────────────────────── */
#castBackdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 100000050;
  animation: castBackdropIn .2s ease;
}

#castBackdrop.cast-open { display: block; }

/* ─── Modal ──────────────────────────────────────── */
#castModal {
  display: none;
  position: fixed;
  bottom: 90px;
  right: 24px;
  width: 320px;
  max-height: 480px;
  background: var(--cast-bg);
  border: 1px solid rgba(247, 127, 0, 0.25);
  border-radius: var(--cast-radius);
  box-shadow:
    0 24px 64px rgba(0, 0, 0, 0.85),
    0 0 0 1px rgba(255,255,255,.04),
    0 0 40px rgba(247,127,0,.08);
  z-index: 100000060;
  overflow: hidden;
  flex-direction: column;
}

#castModal.cast-open {
  display: flex;
  animation: castModalIn .3s var(--cast-ease) both;
}

/* ─── Modal Header ───────────────────────────────── */
.cast-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 18px 14px;
  border-bottom: 1px solid rgba(255,255,255,.07);
}

.cast-modal-title {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  font-weight: 800;
  color: #fff;
  letter-spacing: .04em;
  text-transform: uppercase;
  font-family: var(--ff-head, 'Outfit', sans-serif);
}

.cast-modal-title svg {
  color: var(--cast-orange);
}

.cast-close-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 8px;
  border: 1px solid var(--cast-border);
  background: var(--cast-surface);
  color: rgba(255,255,255,.5);
  cursor: pointer;
  transition: .15s;
  font-size: 16px;
  line-height: 1;
}

.cast-close-btn:hover {
  background: rgba(255,255,255,.1);
  color: #fff;
}

/* ─── Modal Body ─────────────────────────────────── */
.cast-modal-body {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
  scrollbar-width: thin;
  scrollbar-color: rgba(247,127,0,.3) transparent;
}

.cast-modal-body::-webkit-scrollbar { width: 4px; }
.cast-modal-body::-webkit-scrollbar-track { background: transparent; }
.cast-modal-body::-webkit-scrollbar-thumb {
  background: rgba(247,127,0,.3);
  border-radius: 4px;
}

/* ─── Section Labels ─────────────────────────────── */
.cast-section-label {
  padding: 6px 8px 8px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: rgba(255,255,255,.3);
  font-family: var(--ff-head, 'Outfit', sans-serif);
}

/* ─── Scanning State ─────────────────────────────── */
.cast-scanning-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 12px;
  border-radius: 10px;
  background: var(--cast-surface);
  border: 1px solid var(--cast-border);
  margin-bottom: 8px;
}

.cast-spin {
  width: 18px;
  height: 18px;
  border: 2px solid rgba(247,127,0,.25);
  border-top-color: var(--cast-orange);
  border-radius: 50%;
  animation: castSpinRing .8s linear infinite;
  flex-shrink: 0;
}

.cast-scanning-txt {
  font-size: 12px;
  color: rgba(255,255,255,.6);
}

/* ─── Device List ────────────────────────────────── */
.cast-device-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.cast-device {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-radius: 10px;
  border: 1px solid var(--cast-border);
  background: var(--cast-surface);
  cursor: pointer;
  transition: background .15s, border-color .15s, transform .15s;
  animation: castDeviceIn .25s ease both;
  text-align: left;
  width: 100%;
}

.cast-device:nth-child(1) { animation-delay: .04s; }
.cast-device:nth-child(2) { animation-delay: .08s; }
.cast-device:nth-child(3) { animation-delay: .12s; }
.cast-device:nth-child(4) { animation-delay: .16s; }

.cast-device:hover {
  background: rgba(247, 127, 0, 0.1);
  border-color: rgba(247, 127, 0, 0.3);
  transform: translateX(3px);
}

.cast-device.cast-device--active {
  background: rgba(247, 127, 0, 0.14);
  border-color: var(--cast-border-active);
}

.cast-device.cast-device--connecting {
  pointer-events: none;
  opacity: .75;
}

.cast-device-icon {
  width: 36px;
  height: 36px;
  border-radius: 9px;
  background: rgba(247, 127, 0, 0.12);
  border: 1px solid rgba(247, 127, 0, 0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: var(--cast-orange);
}

.cast-device--active .cast-device-icon {
  background: rgba(247, 127, 0, 0.2);
}

.cast-device-info {
  flex: 1;
  min-width: 0;
}

.cast-device-name {
  font-size: 13px;
  font-weight: 700;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cast-device-type {
  font-size: 11px;
  color: rgba(255,255,255,.4);
  margin-top: 2px;
}

.cast-device-status {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .05em;
  text-transform: uppercase;
}

.cast-device-status.status-ready { color: rgba(255,255,255,.3); }
.cast-device-status.status-connecting { color: var(--cast-orange); }
.cast-device-status.status-active { color: var(--cast-orange2); }

.cast-device-status-dot {
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  margin-right: 4px;
  background: currentColor;
}

.status-active .cast-device-status-dot {
  animation: castPulse 1.5s infinite;
}

/* ─── Device Spinner (during connect) ─────────────── */
.cast-device-spinner {
  width: 16px;
  height: 16px;
  border: 2px solid rgba(247,127,0,.25);
  border-top-color: var(--cast-orange);
  border-radius: 50%;
  animation: castSpinRing .7s linear infinite;
}

/* ─── Empty State ────────────────────────────────── */
.cast-empty {
  padding: 28px 16px;
  text-align: center;
}

.cast-empty-icon {
  width: 48px;
  height: 48px;
  margin: 0 auto 12px;
  border-radius: 14px;
  background: rgba(255,255,255,.05);
  border: 1px solid rgba(255,255,255,.08);
  display: flex;
  align-items: center;
  justify-content: center;
  color: rgba(255,255,255,.25);
}

.cast-empty-title {
  font-size: 13px;
  font-weight: 700;
  color: rgba(255,255,255,.7);
  margin-bottom: 6px;
}

.cast-empty-sub {
  font-size: 11.5px;
  color: rgba(255,255,255,.35);
  line-height: 1.5;
}

/* ─── Active Session Bar ─────────────────────────── */
.cast-active-bar {
  margin: 8px 0 4px;
  padding: 10px 12px;
  background: rgba(247, 127, 0, 0.08);
  border: 1px solid rgba(247, 127, 0, 0.2);
  border-radius: 10px;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  color: rgba(255,255,255,.6);
}

.cast-active-bar-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--cast-orange);
  animation: castPulse 1.5s infinite;
  flex-shrink: 0;
}

.cast-active-bar-label {
  flex: 1;
  font-size: 11px;
  font-weight: 600;
  color: rgba(255,255,255,.7);
}

.cast-active-bar-time {
  font-size: 11px;
  color: var(--cast-orange);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

/* ─── Footer ─────────────────────────────────────── */
.cast-modal-footer {
  padding: 12px;
  border-top: 1px solid rgba(255,255,255,.07);
  display: flex;
  gap: 8px;
}

.cast-btn {
  flex: 1;
  padding: 10px 14px;
  border-radius: 9px;
  border: none;
  font-size: 11.5px;
  font-weight: 700;
  cursor: pointer;
  transition: .15s;
  font-family: var(--ff-head, 'Outfit', sans-serif);
  letter-spacing: .04em;
  text-transform: uppercase;
}

.cast-btn--secondary {
  background: rgba(255,255,255,.06);
  border: 1px solid rgba(255,255,255,.1);
  color: rgba(255,255,255,.6);
}
.cast-btn--secondary:hover {
  background: rgba(255,255,255,.1);
  color: #fff;
}

.cast-btn--danger {
  background: rgba(239, 68, 68, 0.12);
  border: 1px solid rgba(239, 68, 68, 0.35);
  color: #f87171;
}
.cast-btn--danger:hover {
  background: rgba(239, 68, 68, 0.22);
  color: #fca5a5;
}

.cast-btn--rescan {
  background: rgba(247, 127, 0, 0.12);
  border: 1px solid rgba(247, 127, 0, 0.3);
  color: var(--cast-orange);
}
.cast-btn--rescan:hover {
  background: rgba(247, 127, 0, 0.2);
}

/* ─── Protocol Tabs ──────────────────────────────── */
.cast-proto-tabs {
  display: flex;
  gap: 4px;
  padding: 10px 12px 0;
}

.cast-proto-tab {
  flex: 1;
  padding: 7px 8px;
  border-radius: 8px;
  border: 1px solid var(--cast-border);
  background: transparent;
  color: rgba(255,255,255,.4);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
  cursor: pointer;
  transition: .15s;
  font-family: var(--ff-head, 'Outfit', sans-serif);
  text-align: center;
}

.cast-proto-tab:hover {
  color: rgba(255,255,255,.7);
  background: var(--cast-surface);
}

.cast-proto-tab.active {
  background: rgba(247, 127, 0, 0.14);
  border-color: rgba(247, 127, 0, 0.4);
  color: var(--cast-orange2);
}

/* ─── QR Code Section ────────────────────────────── */
.cast-qr-section {
  padding: 16px 12px;
  text-align: center;
}

.cast-qr-wrap {
  display: inline-block;
  padding: 12px;
  background: #fff;
  border-radius: 12px;
  margin-bottom: 12px;
}

#castQRCanvas {
  display: block;
}

.cast-qr-url {
  font-size: 10.5px;
  color: rgba(255,255,255,.4);
  word-break: break-all;
  line-height: 1.5;
  padding: 0 8px;
}

.cast-qr-hint {
  font-size: 11.5px;
  color: rgba(255,255,255,.6);
  margin-bottom: 10px;
  line-height: 1.5;
}

/* ─── WebRTC Section ─────────────────────────────── */
.cast-webrtc-info {
  padding: 14px 12px;
  font-size: 12px;
  color: rgba(255,255,255,.55);
  line-height: 1.6;
  text-align: center;
}

.cast-webrtc-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 13px 14px;
  border-radius: 10px;
  border: 1px solid rgba(247, 127, 0, 0.3);
  background: rgba(247, 127, 0, 0.1);
  color: var(--cast-orange2);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  transition: .15s;
  font-family: var(--ff-head, 'Outfit', sans-serif);
  text-transform: uppercase;
  letter-spacing: .04em;
  margin: 8px 12px;
  width: calc(100% - 24px);
}

.cast-webrtc-btn:hover {
  background: rgba(247, 127, 0, 0.18);
}

/* ─── Toast Notifications ────────────────────────── */
#castToastContainer {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 100000070;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.cast-toast {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-radius: 12px;
  background: rgba(14, 14, 20, 0.97);
  border: 1px solid rgba(255,255,255,.1);
  box-shadow: 0 8px 32px rgba(0,0,0,.7);
  font-size: 12.5px;
  font-weight: 600;
  color: #fff;
  min-width: 220px;
  max-width: 300px;
  backdrop-filter: blur(8px);
  pointer-events: none;
  animation: castToastIn .25s var(--cast-ease) both;
}

.cast-toast.toast-out {
  animation: castToastOut .25s ease both;
}

.cast-toast-icon {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 14px;
}

.cast-toast--success .cast-toast-icon { background: rgba(34,197,94,.15); color: #4ade80; }
.cast-toast--error   .cast-toast-icon { background: rgba(239,68,68,.15);  color: #f87171; }
.cast-toast--info    .cast-toast-icon { background: rgba(247,127,0,.15);  color: var(--cast-orange2); }
.cast-toast--warning .cast-toast-icon { background: rgba(234,179,8,.15);  color: #fbbf24; }

.cast-toast-text { flex: 1; line-height: 1.4; }
.cast-toast-title { font-weight: 700; color: #fff; }
.cast-toast-sub { font-size: 11px; color: rgba(255,255,255,.5); margin-top: 1px; }

/* ─── Responsive ─────────────────────────────────── */
@media (max-width: 600px) {
  #castModal {
    right: 8px;
    left: 8px;
    bottom: 80px;
    width: auto;
    max-height: 60vh;
  }

  #castToastContainer {
    right: 8px;
    left: 8px;
    bottom: 16px;
  }

  .cast-toast { min-width: unset; max-width: unset; }
}

/* ─── Onglet "Envoyer sur un appareil" ───────────── */
.cast-send-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 4px 0 8px;
}

.cast-send-hint {
  font-size: 12px;
  color: rgba(255,255,255,.55);
  text-align: center;
  line-height: 1.5;
  max-width: 280px;
}

.cast-send-hint strong { color: rgba(255,255,255,.85); }

.cast-qr-wrap {
  background: #fff;
  border-radius: 10px;
  padding: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 20px rgba(0,0,0,.4);
}

.cast-send-title {
  font-size: 13px;
  font-weight: 700;
  color: #fff;
  text-align: center;
  max-width: 260px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cast-send-url {
  font-size: 10px;
  color: rgba(255,255,255,.3);
  text-align: center;
  max-width: 260px;
  word-break: break-all;
  line-height: 1.4;
}

.cast-send-copy {
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(245,166,35,.12);
  border: 1px solid rgba(245,166,35,.3);
  color: var(--cast-orange2);
  font-size: 12px;
  font-weight: 600;
  padding: 7px 16px;
  border-radius: 8px;
  cursor: pointer;
  transition: background .15s, border-color .15s;
}

.cast-send-copy:hover {
  background: rgba(245,166,35,.22);
  border-color: rgba(245,166,35,.6);
}

.cast-send-apps {
  width: 100%;
  border-top: 1px solid rgba(255,255,255,.07);
  padding-top: 12px;
  margin-top: 2px;
}

.cast-send-apps-label {
  font-size: 10px;
  color: rgba(255,255,255,.3);
  text-align: center;
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: .04em;
}

.cast-send-apps-row {
  display: flex;
  justify-content: center;
  gap: 16px;
}

.cast-send-app {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  font-size: 20px;
}

.cast-send-app span {
  font-size: 9px;
  color: rgba(255,255,255,.35);
  font-weight: 600;
  letter-spacing: .03em;
}
