@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=Outfit:wght@500;600;700;800&display=swap');

:root {
  --bg-main: #090a10;
  --bg-card: rgba(18, 20, 32, 0.75);
  --bg-card-hover: rgba(26, 29, 48, 0.85);
  --border-subtle: rgba(255, 255, 255, 0.08);
  --border-accent: rgba(244, 63, 94, 0.35);
  --text-primary: #f1f3fa;
  --text-secondary: #9499b8;
  --text-muted: #5e6382;
  --accent-pink: #f43f5e;
  --accent-pink-glow: rgba(244, 63, 94, 0.4);
  --accent-blue: #3b82f6;
  --accent-green: #10b981;
  --accent-amber: #f59e0b;
}

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

body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background-color: var(--bg-main);
  background-image: 
    radial-gradient(circle at 50% 0%, rgba(244, 63, 94, 0.08) 0%, transparent 60%),
    radial-gradient(circle at 100% 100%, rgba(59, 130, 246, 0.05) 0%, transparent 50%);
  color: var(--text-primary);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 2rem 1.5rem;
  overflow-x: hidden;
}

#app {
  width: 100%;
  max-width: 960px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2rem;
}

/* Header & Navigation */
.header {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  text-align: center;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  text-decoration: none;
}

.brand-icon {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: linear-gradient(135deg, #f43f5e 0%, #be123c 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 20px var(--accent-pink-glow);
}

.brand-icon svg {
  width: 22px;
  height: 22px;
  stroke: #ffffff;
}

.brand h1 {
  font-family: 'Outfit', sans-serif;
  font-size: 1.6rem;
  font-weight: 700;
  letter-spacing: -0.5px;
  color: #ffffff;
}

.brand h1 span {
  color: var(--accent-pink);
}

.header-badges {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  justify-content: center;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-subtle);
  backdrop-filter: blur(12px);
  padding: 0.35rem 0.85rem;
  border-radius: 9999px;
  font-size: 0.82rem;
  color: var(--text-secondary);
}

.badge-highlight {
  color: #ffffff;
  font-weight: 600;
}

.badge-btn {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.2rem 0.45rem;
  border-radius: 6px;
  font-size: 0.78rem;
  transition: all 0.2s;
}

.badge-btn:hover {
  color: #ffffff;
  background: rgba(255, 255, 255, 0.08);
}

/* Cards & Containers */
.glass-panel {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: 20px;
  backdrop-filter: blur(20px);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.4);
}

.main-card {
  width: 100%;
  max-width: 480px;
  padding: 2.75rem 2.25rem;
  text-align: center;
}

.icon-wrapper {
  width: 76px;
  height: 76px;
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 1.5rem;
}

.icon-wrapper svg {
  width: 36px;
  height: 36px;
  stroke: var(--accent-pink);
}

.main-card h2 {
  font-family: 'Outfit', sans-serif;
  font-size: 1.5rem;
  font-weight: 600;
  color: #ffffff;
  margin-bottom: 0.6rem;
}

.main-card p {
  font-size: 0.92rem;
  color: var(--text-secondary);
  line-height: 1.6;
  margin-bottom: 1.8rem;
}

/* Role Selection */
#role-select {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.25rem;
  width: 100%;
  max-width: 520px;
}

@media (max-width: 540px) {
  #role-select {
    grid-template-columns: 1fr;
  }
}

.role-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: 18px;
  padding: 1.75rem 1.25rem;
  cursor: pointer;
  text-align: center;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  flex-direction: column;
  align-items: center;
}

.role-card:hover {
  background: var(--bg-card-hover);
  border-color: var(--border-accent);
  transform: translateY(-4px);
  box-shadow: 0 12px 30px rgba(244, 63, 94, 0.15);
}

.role-icon {
  width: 54px;
  height: 54px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 1rem;
  transition: all 0.25s;
}

.role-icon svg {
  width: 26px;
  height: 26px;
  stroke: var(--text-secondary);
  transition: stroke 0.25s;
}

.role-card:hover .role-icon {
  background: rgba(244, 63, 94, 0.12);
  border-color: var(--accent-pink);
}

.role-card:hover .role-icon svg {
  stroke: var(--accent-pink);
}

.role-card .rc-title {
  font-family: 'Outfit', sans-serif;
  font-size: 1.1rem;
  font-weight: 600;
  color: #ffffff;
  margin-bottom: 0.4rem;
}

.role-card .rc-desc {
  font-size: 0.82rem;
  color: var(--text-muted);
  line-height: 1.4;
}

/* Video Containers */
#host-panel, #viewer-panel {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.5rem;
}

.video-box {
  width: 100%;
  background: #040507;
  border: 1px solid var(--border-subtle);
  border-radius: 18px;
  overflow: hidden;
  position: relative;
  aspect-ratio: 16/9;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.6);
}

.video-box video {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.live-indicator {
  position: absolute;
  top: 16px;
  left: 16px;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  background: rgba(10, 10, 15, 0.75);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(244, 63, 94, 0.3);
  padding: 0.35rem 0.75rem;
  border-radius: 8px;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.5px;
  color: #ffffff;
  z-index: 10;
}

.live-indicator .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent-pink);
  box-shadow: 0 0 10px var(--accent-pink);
  animation: live-pulse 1.5s infinite;
}

@keyframes live-pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.4; transform: scale(0.8); }
}

.video-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: rgba(9, 10, 16, 0.95);
  gap: 1rem;
  z-index: 5;
}

.video-overlay svg {
  width: 52px;
  height: 52px;
  stroke: var(--text-muted);
}

.video-overlay span {
  font-size: 0.95rem;
  color: var(--text-secondary);
  font-weight: 500;
}

/* Status & Controls */
.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  font-size: 0.86rem;
  color: var(--text-secondary);
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-subtle);
  border-radius: 12px;
  padding: 0.6rem 1.15rem;
}

.status-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--text-muted);
}

.status-dot.live {
  background: var(--accent-pink);
  box-shadow: 0 0 10px var(--accent-pink-glow);
  animation: live-pulse 1.5s infinite;
}

.status-dot.connecting {
  background: var(--accent-amber);
  animation: live-pulse 1s infinite;
}

.status-dot.ok {
  background: var(--accent-green);
  box-shadow: 0 0 10px rgba(16, 185, 129, 0.4);
}

.btn-group {
  display: flex;
  gap: 0.85rem;
  width: 100%;
  max-width: 440px;
  justify-content: center;
}

.btn-primary {
  background: linear-gradient(135deg, #f43f5e 0%, #e11d48 100%);
  color: #ffffff;
  border: none;
  border-radius: 12px;
  padding: 0.85rem 2rem;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  box-shadow: 0 4px 20px var(--accent-pink-glow);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
}

.btn-primary:hover {
  filter: brightness(1.1);
  transform: translateY(-1px);
  box-shadow: 0 6px 25px rgba(244, 63, 94, 0.5);
}

.btn-primary:active {
  transform: translateY(1px);
}

.btn-primary:disabled {
  background: #2a1520;
  color: #653245;
  box-shadow: none;
  cursor: not-allowed;
  transform: none;
}

.btn-danger {
  background: rgba(244, 63, 94, 0.12);
  color: #ff6b87;
  border: 1px solid rgba(244, 63, 94, 0.35);
  border-radius: 12px;
  padding: 0.8rem 1.6rem;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}

.btn-danger:hover {
  background: rgba(244, 63, 94, 0.22);
  border-color: var(--accent-pink);
  color: #ffffff;
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-secondary);
  border: 1px solid var(--border-subtle);
  border-radius: 12px;
  padding: 0.8rem 1.6rem;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.18);
  color: #ffffff;
}

/* Modal for Insecure Context */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.82);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  padding: 1.5rem;
}

.modal-box {
  background: #151726;
  border: 1px solid rgba(244, 63, 94, 0.4);
  border-radius: 20px;
  max-width: 520px;
  width: 100%;
  padding: 2.25rem 2rem;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.7);
  text-align: left;
}

.modal-header {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  margin-bottom: 1.25rem;
}

.modal-icon {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: rgba(245, 158, 11, 0.15);
  border: 1px solid rgba(245, 158, 11, 0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #f59e0b;
}

.modal-header h3 {
  font-family: 'Outfit', sans-serif;
  font-size: 1.25rem;
  color: #ffffff;
}

.modal-box p {
  font-size: 0.9rem;
  color: var(--text-secondary);
  line-height: 1.6;
  margin-bottom: 1.25rem;
}

.solution-list {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  margin-bottom: 1.75rem;
}

.solution-item {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-subtle);
  border-radius: 12px;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.solution-title {
  font-size: 0.92rem;
  font-weight: 600;
  color: #ffffff;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.solution-desc {
  font-size: 0.82rem;
  color: var(--text-muted);
}

.banner-warning {
  width: 100%;
  max-width: 700px;
  background: rgba(245, 158, 11, 0.1);
  border: 1px solid rgba(245, 158, 11, 0.3);
  border-radius: 14px;
  padding: 0.85rem 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  font-size: 0.88rem;
  color: #fbbf24;
}

.banner-warning a, .banner-warning button {
  background: #f59e0b;
  color: #000;
  border: none;
  font-weight: 600;
  padding: 0.4rem 0.9rem;
  border-radius: 8px;
  cursor: pointer;
  text-decoration: none;
  font-size: 0.82rem;
  white-space: nowrap;
}

/* Toast */
.toast {
  position: fixed;
  bottom: 30px;
  background: rgba(22, 25, 40, 0.95);
  color: #ffffff;
  border: 1px solid var(--border-subtle);
  padding: 0.75rem 1.4rem;
  border-radius: 12px;
  font-size: 0.88rem;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(16px);
  z-index: 1000;
  opacity: 0;
  transform: translateY(16px);
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  pointer-events: none;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

/* Utilities */
.hidden {
  display: none !important;
}

.fade-in {
  animation: fadeIn 0.3s ease forwards;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}
