/* =========================================================
   NEXUSRTC - MODERN DARK MODE STYLING & GLASSMORPHISM
   ========================================================= */

:root {
  --bg-primary: #0a0d14;
  --bg-surface: #111724;
  --bg-card: rgba(23, 31, 49, 0.7);
  --bg-glass: rgba(18, 25, 40, 0.82);
  --border-color: rgba(255, 255, 255, 0.08);
  --border-highlight: rgba(99, 102, 241, 0.3);

  --accent-primary: #6366f1;
  --accent-primary-hover: #4f46e5;
  --accent-secondary: #06b6d4;
  --accent-success: #10b981;
  --accent-danger: #ef4444;
  --accent-warning: #f59e0b;

  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;

  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-full: 9999px;

  --font-sans: 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;

  --shadow-subtle: 0 10px 30px -10px rgba(0, 0, 0, 0.5);
  --shadow-glow-blue: 0 0 35px -5px rgba(99, 102, 241, 0.25);
  --shadow-glow-cyan: 0 0 35px -5px rgba(6, 182, 212, 0.25);
}

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

body {
  font-family: var(--font-sans);
  background-color: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  overflow-x: hidden;
  background-image: 
    radial-gradient(circle at 15% 20%, rgba(99, 102, 241, 0.12) 0%, transparent 40%),
    radial-gradient(circle at 85% 80%, rgba(6, 182, 212, 0.08) 0%, transparent 40%);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
}

/* App Container */
.app-container {
  display: flex;
  flex-direction: column;
  height: 100vh;
  width: 100vw;
  overflow: hidden;
}

/* Header */
.app-header {
  height: 64px;
  padding: 0 2rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border-color);
  background: var(--bg-glass);
  backdrop-filter: blur(16px);
  z-index: 10;
  flex-shrink: 0;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.brand-icon {
  width: 38px;
  height: 38px;
  border-radius: var(--radius-sm);
  background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  box-shadow: var(--shadow-glow-blue);
}

.brand-icon svg {
  width: 20px;
  height: 20px;
}

.brand-text {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.brand-title {
  font-size: 1.25rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  background: linear-gradient(to right, #ffffff, #cbd5e1);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.brand-badge {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  background: rgba(99, 102, 241, 0.15);
  color: #a5b4fc;
  border: 1px solid rgba(99, 102, 241, 0.3);
  padding: 2px 8px;
  border-radius: var(--radius-full);
}

.header-status {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-secondary);
  background: rgba(255, 255, 255, 0.04);
  padding: 6px 14px;
  border-radius: var(--radius-full);
  border: 1px solid var(--border-color);
}

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

.status-dot.online {
  background: var(--accent-success);
  box-shadow: 0 0 10px var(--accent-success);
}

.status-dot.busy {
  background: var(--accent-warning);
  box-shadow: 0 0 10px var(--accent-warning);
}

/* View Screens */
.view-screen {
  display: none;
  flex: 1;
  overflow: hidden;
  position: relative;
}

.view-screen.active {
  display: flex;
  flex-direction: column;
}

/* =========================================================
   LOBBY / HERO SCREEN
   ========================================================= */

#lobby-screen {
  align-items: center;
  justify-content: center;
  padding: 2rem;
  overflow-y: auto;
}

.hero-section {
  max-width: 860px;
  width: 100%;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  animation: fadeIn 0.5s cubic-bezier(0.16, 1, 0.3, 1);
}

.hero-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.85rem;
  font-weight: 600;
  padding: 6px 16px;
  border-radius: var(--radius-full);
  background: rgba(99, 102, 241, 0.12);
  color: #818cf8;
  border: 1px solid rgba(99, 102, 241, 0.25);
  margin-bottom: 1.5rem;
}

.hero-badge svg {
  width: 15px;
  height: 15px;
}

.hero-title {
  font-size: clamp(2rem, 5vw, 3.25rem);
  font-weight: 800;
  line-height: 1.15;
  letter-spacing: -0.03em;
  margin-bottom: 1.25rem;
}

.gradient-text {
  background: linear-gradient(135deg, #60a5fa, #a855f7, #ec4899);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.hero-subtitle {
  font-size: 1.1rem;
  color: var(--text-secondary);
  line-height: 1.6;
  max-width: 640px;
  margin-bottom: 3rem;
}

/* Action Cards */
.action-cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1.5rem;
  width: 100%;
  margin-bottom: 2.5rem;
}

.action-card {
  position: relative;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 2.25rem 2rem;
  text-align: left;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  overflow: hidden;
  backdrop-filter: blur(12px);
  display: flex;
  flex-direction: column;
}

.action-card:hover {
  transform: translateY(-4px);
  border-color: rgba(99, 102, 241, 0.4);
  box-shadow: var(--shadow-glow-blue);
}

.card-icon-wrapper {
  width: 54px;
  height: 54px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 1.5rem;
  color: white;
}

.card-icon-wrapper svg {
  width: 26px;
  height: 26px;
}

.host-gradient {
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  box-shadow: 0 8px 20px -4px rgba(99, 102, 241, 0.4);
}

.join-gradient {
  background: linear-gradient(135deg, #06b6d4, #3b82f6);
  box-shadow: 0 8px 20px -4px rgba(6, 182, 212, 0.4);
}

.action-card h3 {
  font-size: 1.4rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
}

.action-card p {
  color: var(--text-secondary);
  font-size: 0.95rem;
  line-height: 1.5;
  margin-bottom: 1.75rem;
  flex: 1;
}

.action-card .btn {
  width: 100%;
}

/* LAN Info Banner */
.lan-info-banner {
  display: flex;
  align-items: center;
  gap: 1rem;
  background: rgba(30, 41, 59, 0.5);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1rem 1.5rem;
  font-size: 0.9rem;
  color: var(--text-secondary);
  text-align: left;
  max-width: 680px;
}

.lan-info-banner svg {
  width: 28px;
  height: 28px;
  color: var(--accent-secondary);
  flex-shrink: 0;
}

.lan-info-banner code {
  background: rgba(0, 0, 0, 0.4);
  color: #38bdf8;
  padding: 2px 6px;
  border-radius: 4px;
  font-family: var(--font-mono);
  font-size: 0.85rem;
}

/* =========================================================
   BUTTONS & INPUTS
   ========================================================= */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  font-family: var(--font-sans);
  font-size: 0.95rem;
  font-weight: 600;
  padding: 0.8rem 1.5rem;
  border-radius: var(--radius-md);
  border: none;
  cursor: pointer;
  transition: all 0.2s ease;
  text-decoration: none;
}

.btn svg {
  width: 18px;
  height: 18px;
}

.btn-primary {
  background: var(--accent-primary);
  color: white;
}

.btn-primary:hover {
  background: var(--accent-primary-hover);
  box-shadow: 0 4px 15px rgba(99, 102, 241, 0.4);
}

.btn-secondary {
  background: #0284c7;
  color: white;
}

.btn-secondary:hover {
  background: #0369a1;
  box-shadow: 0 4px 15px rgba(2, 132, 199, 0.4);
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border-color);
}

.btn-ghost:hover {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-primary);
}

.btn-icon-small {
  background: rgba(255, 255, 255, 0.1);
  border: none;
  color: white;
  width: 28px;
  height: 28px;
  border-radius: 6px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.btn-icon-small:hover {
  background: rgba(255, 255, 255, 0.2);
}

.btn-icon-small svg {
  width: 14px;
  height: 14px;
}

/* =========================================================
   MODAL WINDOWS
   ========================================================= */

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(5, 8, 15, 0.75);
  backdrop-filter: blur(10px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s ease;
  padding: 1rem;
}

.modal-backdrop.open {
  opacity: 1;
  visibility: visible;
}

.modal-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 2.25rem;
  max-width: 440px;
  width: 100%;
  position: relative;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.7);
  transform: scale(0.95);
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.modal-backdrop.open .modal-card {
  transform: scale(1);
}

.modal-close {
  position: absolute;
  top: 1.25rem;
  right: 1.25rem;
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
  border-radius: 6px;
  transition: color 0.2s;
}

.modal-close:hover {
  color: var(--text-primary);
}

.modal-header {
  margin-bottom: 1.75rem;
}

.modal-icon {
  width: 46px;
  height: 46px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  margin-bottom: 1rem;
}

.modal-header h2 {
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
}

.modal-header p {
  color: var(--text-secondary);
  font-size: 0.9rem;
  line-height: 1.5;
}

.form-group {
  margin-bottom: 1.5rem;
  text-align: left;
}

.form-group label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 0.5rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.form-group input {
  width: 100%;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 0.85rem 1rem;
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 1rem;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.form-group input:focus {
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2);
}

/* PIN Displays */
.pin-preview-box {
  background: rgba(0, 0, 0, 0.3);
  border: 1px dashed rgba(99, 102, 241, 0.3);
  border-radius: var(--radius-md);
  padding: 1.25rem;
  text-align: center;
  margin-bottom: 1.75rem;
}

.pin-preview-label {
  display: block;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #a5b4fc;
  margin-bottom: 0.5rem;
}

.generated-pin-display {
  font-family: var(--font-mono);
  font-size: 2.25rem;
  font-weight: 700;
  letter-spacing: 0.3em;
  color: #38bdf8;
  text-shadow: 0 0 20px rgba(56, 189, 248, 0.4);
}

.pin-hint {
  display: block;
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 0.5rem;
}

.pin-input-field {
  font-family: var(--font-mono) !important;
  font-size: 1.5rem !important;
  letter-spacing: 0.25em;
  text-align: center;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
}

/* =========================================================
   CALL ROOM SCREEN
   ========================================================= */

#call-screen {
  position: relative;
  background: #07090e;
  height: calc(100vh - 64px);
  display: none;
}

#call-screen.active {
  display: flex;
  flex-direction: column;
}

/* Call Top Bar */
.call-top-bar {
  position: absolute;
  top: 1rem;
  left: 1rem;
  right: 1rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  z-index: 20;
  pointer-events: none;
}

.call-top-bar > * {
  pointer-events: auto;
}

.call-pin-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  background: var(--bg-glass);
  backdrop-filter: blur(16px);
  border: 1px solid var(--border-color);
  padding: 8px 16px;
  border-radius: var(--radius-full);
  box-shadow: var(--shadow-subtle);
}

.pin-label {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-muted);
  letter-spacing: 0.05em;
}

.pin-digits {
  font-family: var(--font-mono);
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: 0.15em;
  color: #38bdf8;
}

.call-status-indicator {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--bg-glass);
  backdrop-filter: blur(16px);
  border: 1px solid var(--border-color);
  padding: 8px 18px;
  border-radius: var(--radius-full);
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-secondary);
}

.pulsing-indicator {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent-warning);
  animation: pulse 1.5s infinite;
}

.call-status-indicator.connected .pulsing-indicator {
  background: var(--accent-success);
  animation: none;
  box-shadow: 0 0 10px var(--accent-success);
}

.call-security-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  background: rgba(16, 185, 129, 0.12);
  color: #34d399;
  border: 1px solid rgba(16, 185, 129, 0.25);
  padding: 6px 14px;
  border-radius: var(--radius-full);
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.call-security-badge svg {
  width: 14px;
  height: 14px;
}

/* Video Stage */
.video-stage {
  flex: 1;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  padding: 5rem 1rem 5.5rem 1rem;
  height: 100%;
  width: 100%;
  position: relative;
  transition: all 0.3s ease;
}

/* Picture-in-Picture layout mode */
.video-stage.layout-pip {
  grid-template-columns: 1fr;
}

.video-stage.layout-pip #local-tile {
  position: absolute;
  bottom: 6rem;
  right: 1.5rem;
  width: 280px;
  height: 180px;
  z-index: 15;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.8);
  border: 2px solid rgba(255, 255, 255, 0.2);
}

/* Video Tiles */
.video-tile {
  position: relative;
  background: #10141f;
  border-radius: var(--radius-lg);
  overflow: hidden;
  border: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-subtle);
  transition: all 0.3s ease;
}

.video-tile video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: #000;
}

/* Mirror local camera */
#local-video {
  transform: scaleX(-1);
}

.video-placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: #0f1422;
  color: var(--text-muted);
  text-align: center;
  padding: 2rem;
  z-index: 2;
}

.avatar-pulse {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background: rgba(99, 102, 241, 0.15);
  color: #818cf8;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 1.25rem;
  animation: pulseGlow 2s infinite;
}

.avatar-pulse svg {
  width: 36px;
  height: 36px;
}

.placeholder-text {
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 0.5rem;
}

.placeholder-subtext {
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.video-overlay-info {
  position: absolute;
  bottom: 1rem;
  left: 1rem;
  right: 1rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  pointer-events: none;
  z-index: 5;
}

.user-badge {
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(8px);
  padding: 6px 14px;
  border-radius: var(--radius-full);
  font-size: 0.85rem;
  font-weight: 600;
  color: white;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.you-indicator {
  background: rgba(99, 102, 241, 0.3);
  color: #a5b4fc;
  font-size: 0.7rem;
  font-weight: 800;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  letter-spacing: 0.05em;
  border: 1px solid rgba(99, 102, 241, 0.4);
}

/* In-Call Controls Bar */
.call-controls-bar {
  position: absolute;
  bottom: 1.25rem;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 0.75rem;
  background: var(--bg-glass);
  backdrop-filter: blur(20px);
  border: 1px solid var(--border-color);
  padding: 0.6rem 1.25rem;
  border-radius: var(--radius-full);
  box-shadow: 0 15px 35px -5px rgba(0, 0, 0, 0.6);
  z-index: 25;
}

.control-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  width: 56px;
  height: 56px;
  border-radius: var(--radius-full);
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: var(--text-primary);
  cursor: pointer;
  transition: all 0.2s ease;
}

.control-btn svg {
  width: 20px;
  height: 20px;
}

.control-btn .btn-label {
  font-size: 0.65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--text-secondary);
}

.control-btn:hover {
  background: rgba(255, 255, 255, 0.15);
  transform: translateY(-2px);
}

.control-btn.active-off {
  background: rgba(239, 68, 68, 0.2);
  border-color: rgba(239, 68, 68, 0.4);
  color: var(--accent-danger);
}

.control-btn.active-off .btn-label {
  color: var(--accent-danger);
}

.control-btn.hangup-btn {
  background: var(--accent-danger);
  border-color: var(--accent-danger);
  color: white;
  width: 64px;
}

.control-btn.hangup-btn:hover {
  background: #dc2626;
  box-shadow: 0 0 20px rgba(239, 68, 68, 0.5);
}

/* =========================================================
   TOAST NOTIFICATIONS
   ========================================================= */

.toast-container {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  z-index: 200;
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 0.85rem 1.25rem;
  color: var(--text-primary);
  font-size: 0.9rem;
  box-shadow: var(--shadow-subtle);
  animation: slideInRight 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  pointer-events: auto;
}

.toast.toast-success {
  border-color: rgba(16, 185, 129, 0.4);
}

.toast.toast-error {
  border-color: rgba(239, 68, 68, 0.4);
}

.toast.toast-info {
  border-color: rgba(6, 182, 212, 0.4);
}

/* =========================================================
   ANIMATIONS & RESPONSIVE
   ========================================================= */

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

@keyframes pulseGlow {
  0%, 100% { box-shadow: 0 0 0 0 rgba(99, 102, 241, 0.4); }
  50% { box-shadow: 0 0 0 16px rgba(99, 102, 241, 0); }
}

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

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

@media (max-width: 768px) {
  .app-header {
    padding: 0 1rem;
  }
  .brand-badge {
    display: none;
  }
  .video-stage {
    grid-template-columns: 1fr;
    grid-template-rows: 1fr 1fr;
    padding: 4.5rem 0.5rem 5.5rem 0.5rem;
  }
  .action-cards-grid {
    grid-template-columns: 1fr;
  }
  .call-top-bar {
    top: 0.5rem;
    left: 0.5rem;
    right: 0.5rem;
  }
  .call-security-badge {
    display: none;
  }
  .control-btn {
    width: 48px;
    height: 48px;
  }
  .control-btn.hangup-btn {
    width: 56px;
  }
}
