/* Modern custom styling for Serverless VideoChat */
@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700&family=Plus+Jakarta+Sans:wght@300;400;500;600;700&display=swap');

:root {
  --bg-primary: #0a0f1d;
  --bg-secondary: #131b2e;
  --glass-bg: rgba(19, 27, 46, 0.65);
  --glass-border: rgba(255, 255, 255, 0.08);
  --glass-highlight: rgba(255, 255, 255, 0.03);
  
  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  
  --accent-primary: #6366f1; /* Indigo */
  --accent-secondary: #a855f7; /* Purple */
  --accent-gradient: linear-gradient(135deg, #6366f1 0%, #a855f7 100%);
  
  --success: #10b981; /* Emerald */
  --danger: #ef4444; /* Rose */
  --warning: #f59e0b; /* Amber */
  --info: #0ea5e9; /* Sky */
  
  --font-heading: 'Outfit', sans-serif;
  --font-body: 'Plus Jakarta Sans', sans-serif;
  
  --shadow-sm: 0 2px 8px -2px rgba(0,0,0,0.5);
  --shadow-md: 0 8px 30px -4px rgba(0,0,0,0.6);
  --shadow-lg: 0 12px 40px -4px rgba(0,0,0,0.8);
  --shadow-glow: 0 0 20px rgba(99, 102, 241, 0.25);
  
  --radius-sm: 8px;
  --radius-md: 16px;
  --radius-lg: 24px;
}

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

body {
  background-color: var(--bg-primary);
  background-image: 
    radial-gradient(at 0% 0%, rgba(99, 102, 241, 0.15) 0px, transparent 50%),
    radial-gradient(at 100% 100%, rgba(168, 85, 247, 0.12) 0px, transparent 50%);
  background-attachment: fixed;
  color: var(--text-primary);
  font-family: var(--font-body);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

/* Header Styles */
header {
  padding: 1.5rem 2rem;
  max-width: 1200px;
  width: 100%;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--glass-border);
}

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

.brand-logo {
  width: 40px;
  height: 40px;
  background: var(--accent-gradient);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-glow);
}

.brand-logo svg {
  width: 22px;
  height: 22px;
  fill: #fff;
}

.brand-name {
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 1.4rem;
  color: var(--text-primary);
  letter-spacing: -0.5px;
  background: var(--accent-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.nav-links {
  display: flex;
  list-style: none;
  gap: 1.5rem;
  align-items: center;
}

.nav-links a {
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 0.95rem;
  font-weight: 500;
  transition: color 0.2s ease, transform 0.2s ease;
}

.nav-links a:hover {
  color: var(--text-primary);
}

/* Main Container Layout */
main {
  flex: 1;
  max-width: 1200px;
  width: 100%;
  margin: 0 auto;
  padding: 2.5rem 1.5rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.status-indicator-bar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  padding: 0.5rem 1rem;
  border-radius: 50px;
  margin-bottom: 2rem;
  font-size: 0.85rem;
  font-weight: 500;
  box-shadow: var(--shadow-sm);
}

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

.status-dot.active {
  background-color: var(--success);
  box-shadow: 0 0 10px var(--success);
  animation: pulse-green 2s infinite;
}

.status-dot.warning {
  background-color: var(--warning);
  box-shadow: 0 0 10px var(--warning);
  animation: pulse-yellow 2s infinite;
}

.status-dot.danger {
  background-color: var(--danger);
  box-shadow: 0 0 10px var(--danger);
  animation: pulse-red 2s infinite;
}

/* Cards & Wizard Panel */
.setup-panel {
  max-width: 600px;
  width: 100%;
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  padding: 2.5rem;
  box-shadow: var(--shadow-lg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  transition: opacity 0.3s ease, transform 0.3s ease;
  position: relative;
}

.setup-panel::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  border-radius: var(--radius-lg);
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.05), rgba(168, 85, 247, 0.05));
  pointer-events: none;
  z-index: -1;
}

.wizard-tabs {
  display: flex;
  background: rgba(0, 0, 0, 0.2);
  border-radius: 50px;
  padding: 0.25rem;
  margin-bottom: 2rem;
  border: 1px solid var(--glass-border);
}

.tab-btn {
  flex: 1;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-family: var(--font-heading);
  font-weight: 600;
  font-size: 1rem;
  padding: 0.75rem;
  border-radius: 50px;
  cursor: pointer;
  transition: all 0.25s ease;
}

.tab-btn.active {
  background: var(--accent-gradient);
  color: #fff;
  box-shadow: var(--shadow-sm);
}

/* Wizard Content Screens */
.screen {
  display: none;
  animation: fadeIn 0.4s ease-out;
}

.screen.active {
  display: block;
}

.screen-title {
  font-family: var(--font-heading);
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
}

.screen-desc {
  color: var(--text-secondary);
  font-size: 0.95rem;
  margin-bottom: 1.5rem;
}

/* Form inputs & controls */
.form-group {
  margin-bottom: 1.5rem;
}

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

.textarea-container {
  position: relative;
}

textarea.key-input {
  width: 100%;
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  padding: 1rem;
  font-family: monospace;
  font-size: 0.85rem;
  resize: none;
  line-height: 1.4;
  outline: none;
  transition: border-color 0.25s, box-shadow 0.25s;
  user-select: text;
  -webkit-user-select: text;
}

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

.action-row {
  display: flex;
  gap: 1rem;
  margin-top: 1.5rem;
}

/* Loading indicators */
.loading-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 2rem 0;
  gap: 1rem;
}

.spinner {
  width: 40px;
  height: 40px;
  border: 4px solid var(--glass-border);
  border-top: 4px solid var(--accent-primary);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

.progress-track {
  width: 100%;
  height: 6px;
  background: var(--glass-border);
  border-radius: 5px;
  overflow: hidden;
  margin-top: 0.5rem;
}

.progress-bar {
  height: 100%;
  background: var(--accent-gradient);
  width: 0%;
  transition: width 0.3s ease;
  animation: loading-pulse 1.5s infinite;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.75rem 1.5rem;
  border-radius: 50px;
  font-family: var(--font-heading);
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  border: none;
  text-decoration: none;
}

.btn-primary {
  background: var(--accent-gradient);
  color: #fff;
  box-shadow: var(--shadow-sm);
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-glow);
  opacity: 0.95;
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-primary);
  border: 1px solid var(--glass-border);
}

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

.btn-success {
  background: var(--success);
  color: #fff;
}

.btn-success:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 15px rgba(16, 185, 129, 0.4);
}

.btn-danger {
  background: var(--danger);
  color: #fff;
}

.btn-danger:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 15px rgba(239, 68, 68, 0.4);
}

.btn-icon {
  width: 44px;
  height: 44px;
  padding: 0;
  border-radius: 50%;
}

.btn:active {
  transform: translateY(0);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none !important;
  box-shadow: none !important;
}

/* Video Grid layout */
.video-interface {
  display: none;
  flex-direction: column;
  width: 100%;
  max-width: 960px;
  gap: 1.5rem;
  animation: fadeIn 0.5s ease-out;
}

.video-interface.active {
  display: flex;
}

.video-wrapper {
  position: relative;
  width: 100%;
  aspect-ratio: 16/9;
  background: #000;
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--glass-border);
}

.remote-video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: radial-gradient(circle, var(--bg-secondary) 0%, var(--bg-primary) 100%);
}

.local-video-card {
  position: absolute;
  bottom: 1.5rem;
  right: 1.5rem;
  width: 25%;
  aspect-ratio: 16/9;
  border-radius: var(--radius-md);
  overflow: hidden;
  box-shadow: var(--shadow-md);
  border: 2px solid var(--glass-border);
  z-index: 10;
  transition: all 0.3s ease;
}

.local-video-card:hover {
  border-color: var(--accent-primary);
  transform: scale(1.02);
}

.local-video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform: scaleX(-1); /* Mirror view for local camera */
  background: #111;
}

/* Floating control bar */
.control-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  padding: 0.75rem 2rem;
  border-radius: 50px;
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  width: max-content;
  margin: 0 auto;
  box-shadow: var(--shadow-lg);
}

.control-btn {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--glass-border);
  width: 48px;
  height: 48px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
}

.control-btn svg {
  width: 20px;
  height: 20px;
  fill: var(--text-primary);
}

.control-btn:hover {
  background: rgba(255, 255, 255, 0.15);
  transform: scale(1.08);
}

.control-btn.active {
  background: var(--accent-gradient);
  border-color: transparent;
}

.control-btn.muted {
  background: rgba(239, 68, 68, 0.2);
  border-color: rgba(239, 68, 68, 0.4);
}

.control-btn.muted svg {
  fill: var(--danger);
}

.control-btn-danger {
  background: var(--danger);
  border-color: transparent;
}

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

/* Toast Notifications */
.toast-msg {
  position: fixed;
  bottom: 2rem;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  padding: 0.75rem 1.5rem;
  border-radius: 50px;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  opacity: 0;
  transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275), opacity 0.3s ease;
  z-index: 9999;
}

.toast-msg.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

.toast-msg svg {
  fill: var(--success);
  width: 18px;
  height: 18px;
}

/* Footer styling */
footer {
  padding: 2rem;
  text-align: center;
  border-top: 1px solid var(--glass-border);
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-top: auto;
}

footer a {
  color: var(--text-secondary);
  text-decoration: none;
  transition: color 0.2s;
}

footer a:hover {
  color: var(--text-primary);
}

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

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

@keyframes pulse-green {
  0% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.4); }
  70% { box-shadow: 0 0 0 10px rgba(16, 185, 129, 0); }
  100% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

@keyframes pulse-yellow {
  0% { box-shadow: 0 0 0 0 rgba(245, 158, 11, 0.4); }
  70% { box-shadow: 0 0 0 10px rgba(245, 158, 11, 0); }
  100% { box-shadow: 0 0 0 0 rgba(245, 158, 11, 0); }
}

@keyframes pulse-red {
  0% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.4); }
  70% { box-shadow: 0 0 0 10px rgba(239, 68, 68, 0); }
  100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0); }
}

@keyframes loading-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.6; }
}

/* Connection Pending Overlay styling */
.connection-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(10, 15, 29, 0.96); /* Replaced blurred background with high-opacity dark color to bypass iOS Safari backdrop input focus bugs */
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  z-index: 1000; /* Fixed position and higher z-index to break free of .video-wrapper overflow constraints */
  padding: 1.5rem;
  transition: opacity 0.3s ease;
}

.overlay-card {
  margin: auto;
  max-width: 500px;
  width: 100%;
  background: var(--bg-secondary);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  padding: 2rem;
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  animation: scaleUp 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes scaleUp {
  from { transform: scale(0.9); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

/* Responsive queries */
@media (max-width: 768px) {
  main {
    padding: 1.5rem 1rem;
  }
  
  .setup-panel {
    padding: 1.5rem;
  }
  
  .local-video-card {
    width: 35%;
    bottom: 1rem;
    right: 1rem;
  }
  
  .action-row {
    flex-direction: column;
  }
  
  header {
    padding: 1rem;
    flex-direction: column;
    gap: 1rem;
  }

  .connection-overlay {
    padding: 0.75rem;
  }

  .overlay-card {
    padding: 1.25rem;
    gap: 1rem;
    margin: 1rem auto;
    border-radius: var(--radius-md);
  }

  textarea.key-input {
    font-size: 16px; /* Forcing min 16px computed font size on mobile to block iOS Safari auto-zooming and keyboard shift bugs */
    padding: 0.75rem;
  }

  .screen-title {
    font-size: 1.25rem;
  }

  .screen-desc {
    font-size: 0.85rem;
    margin-bottom: 1rem;
  }
}
