/* Reset and base styles */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --primary-color: #4f46e5;
  --primary-hover: #4338ca;
  --danger-color: #ef4444;
  --danger-hover: #dc2626;
  --success-color: #22c55e;
  --bg-dark: #0f0f0f;
  --bg-card: #1a1a1a;
  --bg-lighter: #2a2a2a;
  --text-primary: #ffffff;
  --text-secondary: #a0a0a0;
  --border-color: #333;
  --face-box-color: #22c55e;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
  background-color: var(--bg-dark);
  color: var(--text-primary);
  min-height: 100vh;
}

.container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 20px;
  min-height: 100vh;
}

/* Landing Page */
.landing {
  display: flex;
  align-items: center;
  justify-content: center;
}

.hero {
  text-align: center;
  max-width: 600px;
}

.hero h1 {
  font-size: 3rem;
  font-weight: 700;
  margin-bottom: 10px;
  background: linear-gradient(135deg, var(--primary-color), #818cf8);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.subtitle {
  font-size: 1.2rem;
  color: var(--text-secondary);
  margin-bottom: 40px;
}

.actions {
  background: var(--bg-card);
  padding: 30px;
  border-radius: 16px;
  border: 1px solid var(--border-color);
}

.btn {
  display: inline-block;
  padding: 14px 32px;
  font-size: 1rem;
  font-weight: 600;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  text-decoration: none;
  transition: all 0.2s ease;
}

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

.btn-primary:hover {
  background: var(--primary-hover);
  transform: translateY(-2px);
}

.btn-secondary {
  background: var(--bg-lighter);
  color: white;
}

.btn-secondary:hover {
  background: #3a3a3a;
}

.divider {
  display: flex;
  align-items: center;
  margin: 20px 0;
  color: var(--text-secondary);
}

.divider::before,
.divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border-color);
}

.divider span {
  padding: 0 15px;
}

.join-form {
  display: flex;
  gap: 10px;
}

.join-form input {
  flex: 1;
  padding: 14px 16px;
  font-size: 1rem;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  background: var(--bg-dark);
  color: var(--text-primary);
  outline: none;
  transition: border-color 0.2s;
}

.join-form input:focus {
  border-color: var(--primary-color);
}

.features {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
  margin-top: 40px;
}

.feature {
  padding: 20px;
  background: var(--bg-card);
  border-radius: 12px;
  border: 1px solid var(--border-color);
}

.feature-icon {
  font-size: 2rem;
  margin-bottom: 10px;
}

.feature h3 {
  font-size: 1rem;
  margin-bottom: 5px;
}

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

/* Room Page */
.room {
  display: flex;
  flex-direction: column;
  height: 100vh;
  padding: 15px;
}

.room-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 0;
  margin-bottom: 15px;
  border-bottom: 1px solid var(--border-color);
}

.room-info h1 {
  font-size: 1.2rem;
  font-weight: 600;
}

.room-id-container {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.room-id-container code {
  background: var(--bg-lighter);
  padding: 4px 8px;
  border-radius: 4px;
  font-family: monospace;
}

.btn-icon {
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
  transition: all 0.2s;
}

.btn-icon:hover {
  background: var(--bg-lighter);
  color: var(--text-primary);
}

.participants-count {
  font-size: 0.9rem;
  color: var(--text-secondary);
}

/* Video Grid */
.video-grid {
  flex: 1;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
  gap: 15px;
  overflow: auto;
}

.video-container {
  position: relative;
  background: var(--bg-card);
  border-radius: 12px;
  overflow: hidden;
  aspect-ratio: 16/9;
  border: 2px solid var(--border-color);
}

.video-container.local {
  border-color: var(--primary-color);
}

.video-container video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.face-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.video-label {
  position: absolute;
  bottom: 10px;
  left: 10px;
  background: rgba(0, 0, 0, 0.7);
  padding: 5px 12px;
  border-radius: 6px;
  font-size: 0.85rem;
}

.face-detection-status {
  position: absolute;
  top: 10px;
  right: 10px;
  background: rgba(0, 0, 0, 0.7);
  padding: 5px 10px;
  border-radius: 6px;
  font-size: 0.75rem;
  display: none;
}

.face-detection-status.active {
  display: block;
  background: rgba(34, 197, 94, 0.3);
  border: 1px solid var(--success-color);
}

/* Controls */
.controls {
  display: flex;
  justify-content: center;
  gap: 15px;
  padding: 20px;
  margin-top: 15px;
  background: var(--bg-card);
  border-radius: 12px;
}

.control-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 56px;
  height: 56px;
  border: none;
  border-radius: 50%;
  background: var(--bg-lighter);
  color: var(--text-primary);
  cursor: pointer;
  transition: all 0.2s;
}

.control-btn:hover {
  background: #3a3a3a;
  transform: scale(1.05);
}

.control-btn.active {
  background: var(--primary-color);
}

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

.control-btn.danger:hover {
  background: var(--danger-hover);
}

.control-btn:not(.active) .icon-on {
  display: none;
}

.control-btn:not(.active) .icon-off {
  display: block;
}

.control-btn.active .icon-on {
  display: block;
}

.control-btn.active .icon-off {
  display: none;
}

.hidden {
  display: none !important;
}

.btn-label {
  display: none;
}

#toggle-face-detection {
  width: auto;
  padding: 0 20px;
  border-radius: 28px;
}

#toggle-face-detection .btn-label {
  display: inline;
}

/* Loading Overlay */
.overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.9);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.overlay.hidden {
  display: none;
}

.loading-content {
  text-align: center;
}

.spinner {
  width: 50px;
  height: 50px;
  border: 4px solid var(--bg-lighter);
  border-top-color: var(--primary-color);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin: 0 auto 20px;
}

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

#loading-message {
  color: var(--text-secondary);
  font-size: 1rem;
}

/* Responsive */
@media (max-width: 768px) {
  .hero h1 {
    font-size: 2rem;
  }

  .features {
    grid-template-columns: 1fr;
  }

  .join-form {
    flex-direction: column;
  }

  .video-grid {
    grid-template-columns: 1fr;
  }

  .controls {
    gap: 10px;
    padding: 15px;
  }

  .control-btn {
    width: 48px;
    height: 48px;
  }

  #toggle-face-detection {
    padding: 0 15px;
  }
}

/* Face detection box styling */
.face-box {
  position: absolute;
  border: 3px solid var(--face-box-color);
  border-radius: 8px;
  pointer-events: none;
  box-shadow: 0 0 10px rgba(34, 197, 94, 0.5);
}

/* Toast notifications */
.toast {
  position: fixed;
  bottom: 100px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg-card);
  color: var(--text-primary);
  padding: 12px 24px;
  border-radius: 8px;
  border: 1px solid var(--border-color);
  z-index: 1001;
  animation: slideUp 0.3s ease;
}

@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateX(-50%) translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
  }
}
