:root {
  --bg-primary: #0a0a0a;
  --bg-secondary: #151515;
  --bg-tertiary: #1e1e1e;
  --accent-primary: #10b981;
  --accent-hover: #34d399;
  --accent-danger: #ef4444;
  --accent-warning: #f59e0b;
  --text-primary: #ffffff;
  --text-secondary: #e5e7eb;
  --text-muted: #9ca3af;
  --border-color: #2d2d2d;
  --border-light: #404040;
  --user-bubble: #065f46;
  --bot-bubble: #262626;
  --code-bg: #1e1e1e;
  --sidebar-width: 280px;
  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.5);
  --transition: all 0.2s ease;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Inter', sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
  height: 100vh;
}

/* Login Page */
.login-container {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  padding: 20px;
  background: linear-gradient(135deg, #0a0a0a 0%, #1a1a2e 100%);
}

.login-box {
  background: var(--bg-secondary);
  border-radius: var(--radius-lg);
  padding: 40px;
  width: 100%;
  max-width: 400px;
  box-shadow: var(--shadow-md);
  border: 1px solid var(--border-color);
  animation: fadeIn 0.5s ease-out;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(-20px); }
  to { opacity: 1; transform: translateY(0); }
}

.login-box h2 {
  margin-bottom: 24px;
  text-align: center;
  font-size: 24px;
  font-weight: 600;
  color: var(--accent-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

.login-box form {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.login-input {
  padding: 14px 16px;
  border-radius: var(--radius-md);
  background: var(--bg-tertiary);
  border: 1px solid var(--border-light);
  color: var(--text-primary);
  font-size: 15px;
  transition: var(--transition);
}

.login-input:focus {
  outline: none;
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 2px rgba(16, 185, 129, 0.1);
}

.login-btn {
  padding: 14px;
  border-radius: var(--radius-md);
  background: var(--accent-primary);
  border: none;
  color: white;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.login-btn:hover {
  background: var(--accent-hover);
  transform: translateY(-1px);
}

.login-btn:active {
  transform: translateY(0);
}

.error-message {
  color: var(--accent-danger);
  text-align: center;
  padding: 12px;
  background: rgba(239, 68, 68, 0.1);
  border-radius: var(--radius-sm);
  margin-top: 10px;
  font-size: 14px;
}

.hint {
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--border-color);
}

/* Lobby Page */
.lobby-container {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

.sidebar {
  width: var(--sidebar-width);
  background: var(--bg-secondary);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  height: 100%;
  min-width: var(--sidebar-width);
}

.sidebar-header {
  padding: 24px 20px 20px;
  border-bottom: 1px solid var(--border-color);
}

.sidebar-header h3 {
  font-size: 20px;
  font-weight: 600;
  color: var(--accent-primary);
  margin: 0;
  display: flex;
  align-items: center;
  gap: 8px;
}

.user-info {
  background: var(--bg-tertiary);
  padding: 16px;
  margin: 20px;
  border-radius: var(--radius-md);
  border-left: 3px solid var(--accent-primary);
}

.user-info h4 {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.user-info p {
  color: var(--text-muted);
  font-size: 13px;
  margin-bottom: 8px;
}

.connection-status {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent-primary);
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

.create-room {
  padding: 0 20px 20px;
  border-bottom: 1px solid var(--border-color);
}

.create-room h4 {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.room-input-group {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
}

.room-input {
  flex: 1;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  background: var(--bg-tertiary);
  border: 1px solid var(--border-light);
  color: var(--text-primary);
  font-size: 14px;
  min-width: 0;
}

.room-input:focus {
  outline: none;
  border-color: var(--accent-primary);
}

.create-btn {
  padding: 12px 20px;
  border-radius: var(--radius-sm);
  background: var(--accent-primary);
  border: none;
  color: white;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
  white-space: nowrap;
  min-width: 80px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.create-btn:hover {
  background: var(--accent-hover);
}

.create-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.rooms-section {
  flex: 1;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.rooms-section h4 {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-secondary);
  padding: 20px 20px 12px;
  margin: 0;
  display: flex;
  align-items: center;
  gap: 8px;
}

.rooms-list {
  flex: 1;
  overflow-y: auto;
  padding: 0 12px 20px;
}

.rooms-list::-webkit-scrollbar {
  width: 4px;
}

.rooms-list::-webkit-scrollbar-track {
  background: transparent;
}

.rooms-list::-webkit-scrollbar-thumb {
  background: var(--border-light);
  border-radius: 2px;
}

.room-item {
  background: var(--bg-tertiary);
  padding: 14px;
  margin-bottom: 8px;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: var(--transition);
  border: 1px solid transparent;
  display: flex;
  justify-content: space-between;
  align-items: center;
  min-width: 0;
}

.room-item:hover {
  background: rgba(255, 255, 255, 0.03);
  border-color: var(--border-light);
}

.room-item.active {
  background: rgba(16, 185, 129, 0.1);
  border-color: var(--accent-primary);
}

.room-info {
  flex: 1;
  min-width: 0;
  overflow: hidden;
}

.room-name {
  font-weight: 500;
  color: var(--text-primary);
  font-size: 14px;
  margin-bottom: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.room-creator {
  font-size: 12px;
  color: var(--text-muted);
}

.room-meta {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
  min-width: 60px;
}

.user-count {
  background: var(--accent-primary);
  color: white;
  padding: 4px 8px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 500;
  min-width: 24px;
  text-align: center;
}

.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-muted);
}

.empty-state i {
  font-size: 48px;
  margin-bottom: 16px;
  opacity: 0.3;
}

.empty-state p {
  margin-bottom: 8px;
  font-size: 15px;
}

.sidebar-footer {
  padding: 20px;
  border-top: 1px solid var(--border-color);
}

.logout-btn {
  width: 100%;
  padding: 12px;
  background: transparent;
  border: 1px solid var(--border-light);
  color: var(--text-secondary);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: var(--transition);
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.logout-btn:hover {
  background: rgba(239, 68, 68, 0.1);
  border-color: var(--accent-danger);
  color: var(--accent-danger);
}

/* Main Content */
.main-content {
  flex: 1;
  padding: 40px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  max-width: 800px;
  margin: 0 auto;
  overflow-y: auto;
}

.main-content h1 {
  font-size: 36px;
  margin-bottom: 20px;
  color: var(--accent-primary);
  font-weight: 700;
}

.main-content p {
  color: var(--text-secondary);
  margin-bottom: 30px;
  line-height: 1.6;
  font-size: 16px;
  max-width: 600px;
}

.features-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 20px;
  width: 100%;
  margin-top: 30px;
}

.feature-card {
  background: var(--bg-tertiary);
  padding: 24px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  transition: var(--transition);
  text-align: left;
}

.feature-card:hover {
  border-color: var(--accent-primary);
  transform: translateY(-4px);
}

.feature-card i {
  font-size: 24px;
  color: var(--accent-primary);
  margin-bottom: 16px;
}

.feature-card h3 {
  color: var(--text-primary);
  margin-bottom: 12px;
  font-size: 17px;
  font-weight: 600;
}

.feature-card p {
  color: var(--text-muted);
  font-size: 14px;
  margin: 0;
}

.instructions {
  background: var(--bg-tertiary);
  padding: 28px;
  border-radius: var(--radius-md);
  margin-top: 40px;
  width: 100%;
  text-align: left;
}

.instructions h3 {
  color: var(--accent-primary);
  margin-bottom: 20px;
  font-size: 18px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.instructions ol {
  color: var(--text-secondary);
  padding-left: 24px;
  line-height: 1.8;
}

.instructions li {
  margin-bottom: 12px;
  font-size: 15px;
}

/* Room Page */
.room-container {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

.participants-panel {
  width: var(--sidebar-width);
  background: var(--bg-secondary);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  height: 100%;
  min-width: var(--sidebar-width);
}

.room-header {
  padding: 24px 20px 20px;
  border-bottom: 1px solid var(--border-color);
}

.room-header h3 {
  font-size: 20px;
  font-weight: 600;
  color: var(--accent-primary);
  margin: 0 0 8px 0;
  display: flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.room-info {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.room-key {
  font-size: 13px;
  color: var(--text-muted);
  background: var(--bg-tertiary);
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  font-family: monospace;
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.room-role {
  font-size: 12px;
  color: var(--accent-primary);
  background: rgba(16, 185, 129, 0.1);
  padding: 4px 8px;
  border-radius: 12px;
  font-weight: 500;
}

.participants-section {
  flex: 1;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.participants-section h4 {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-secondary);
  padding: 20px 20px 12px;
  margin: 0;
  display: flex;
  align-items: center;
  gap: 8px;
}

.participants-count {
  background: var(--accent-primary);
  color: white;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 500;
}

.participants-list {
  flex: 1;
  overflow-y: auto;
  padding: 0 12px 20px;
}

.participants-list::-webkit-scrollbar {
  width: 4px;
}

.participants-list::-webkit-scrollbar-thumb {
  background: var(--border-light);
  border-radius: 2px;
}

.participant-item {
  background: var(--bg-tertiary);
  padding: 14px;
  margin-bottom: 8px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-left: 3px solid transparent;
  transition: var(--transition);
  min-width: 0;
}

.participant-item.creator {
  border-left-color: var(--accent-primary);
}

.participant-item.me {
  background: rgba(16, 185, 129, 0.1);
}

.participant-info {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  min-width: 0;
}

.participant-status {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--accent-primary);
  flex-shrink: 0;
}

.participant-status.muted {
  background: var(--accent-danger);
}

.participant-details {
  flex: 1;
  min-width: 0;
}

.participant-name {
  font-weight: 500;
  color: var(--text-primary);
  font-size: 14px;
  margin-bottom: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.participant-role {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
}

.mute-controls {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}

.mute-btn {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  border: none;
  cursor: pointer;
  font-size: 14px;
  transition: var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--border-light);
  color: var(--text-primary);
}

.mute-btn:hover {
  opacity: 0.8;
}

.mute-btn.mic.active {
  background: var(--accent-warning);
  color: white;
}

.mute-btn.play.active {
  background: var(--accent-danger);
  color: white;
}

.recordings-section {
  border-top: 1px solid var(--border-color);
  padding: 20px;
}

.recordings-section h4 {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.recordings-list {
  max-height: 200px;
  overflow-y: auto;
}

.recordings-list::-webkit-scrollbar {
  width: 4px;
}

.recordings-list::-webkit-scrollbar-thumb {
  background: var(--border-light);
  border-radius: 2px;
}

.recording-item {
  background: var(--bg-tertiary);
  padding: 12px;
  margin-bottom: 8px;
  border-radius: var(--radius-sm);
  display: flex;
  justify-content: space-between;
  align-items: center;
  border: 1px solid transparent;
  transition: var(--transition);
  min-width: 0;
}

.recording-item:hover {
  border-color: var(--border-light);
}

.recording-details {
  flex: 1;
  min-width: 0;
  overflow: hidden;
}

.recording-name {
  font-weight: 500;
  color: var(--text-primary);
  font-size: 13px;
  margin-bottom: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.recording-meta {
  font-size: 11px;
  color: var(--text-muted);
  display: flex;
  gap: 8px;
}

.download-btn {
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  background: var(--accent-primary);
  color: white;
  text-decoration: none;
  font-size: 12px;
  transition: var(--transition);
  border: none;
  cursor: pointer;
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

.download-btn:hover {
  background: var(--accent-hover);
}

/* Chat Area */
.chat-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: var(--bg-primary);
  overflow: hidden;
}

.chat-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border-color);
  background: var(--bg-secondary);
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-shrink: 0;
}

.chat-header h2 {
  font-size: 22px;
  font-weight: 600;
  color: var(--accent-primary);
  margin: 0;
  display: flex;
  align-items: center;
  gap: 10px;
}

.room-controls {
  display: flex;
  gap: 10px;
}

.control-btn {
  padding: 10px 18px;
  border-radius: var(--radius-md);
  border: none;
  cursor: pointer;
  font-weight: 500;
  transition: var(--transition);
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  white-space: nowrap;
}

.control-btn.primary {
  background: var(--accent-primary);
  color: white;
}

.control-btn.primary:hover {
  background: var(--accent-hover);
}

.control-btn.warning {
  background: var(--accent-warning);
  color: white;
}

.control-btn.warning:hover {
  background: #fbbf24;
}

.control-btn.danger {
  background: var(--accent-danger);
  color: white;
}

.control-btn.danger:hover {
  background: #f87171;
}

.control-btn.secondary {
  background: var(--bg-tertiary);
  color: var(--text-primary);
  border: 1px solid var(--border-light);
}

.control-btn.secondary:hover {
  background: var(--border-light);
}

.control-btn.active {
  background: rgba(16, 185, 129, 0.2);
  color: var(--accent-primary);
  border-color: var(--accent-primary);
}

.audio-container {
  flex: 1;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 24px;
  overflow: hidden;
}

.audio-visualizer {
  height: 120px;
  background: var(--bg-tertiary);
  border-radius: var(--radius-md);
  margin-bottom: 20px;
  position: relative;
  overflow: hidden;
  border: 1px solid var(--border-color);
  flex-shrink: 0;
}

.visualizer-bar {
  position: absolute;
  bottom: 0;
  width: 4px;
  background: linear-gradient(to top, var(--accent-primary), #3b82f6);
  border-radius: 2px;
}

.audio-controls {
  display: flex;
  justify-content: center;
  gap: 15px;
  flex-wrap: wrap;
  flex-shrink: 0;
}

.remote-audio-container {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 12px;
  margin-top: 20px;
  overflow-y: auto;
  padding: 10px;
}

.log-panel {
  background: var(--bg-tertiary);
  border-radius: var(--radius-md);
  padding: 20px;
  flex: 1;
  overflow-y: auto;
  font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
  font-size: 13px;
  line-height: 1.5;
  border: 1px solid var(--border-color);
  min-height: 200px;
}

.log-panel::-webkit-scrollbar {
  width: 8px;
}

.log-panel::-webkit-scrollbar-thumb {
  background: var(--border-light);
  border-radius: 4px;
}

.log-entry {
  padding: 8px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  color: var(--text-muted);
  animation: slideIn 0.3s ease-out;
}

@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateX(-10px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

.log-entry.success {
  color: var(--accent-primary);
}

.log-entry.error {
  color: var(--accent-danger);
}

.log-entry.warning {
  color: var(--accent-warning);
}

.log-entry.info {
  color: #3b82f6;
}

/* Typing Animation */
.typing-indicator {
  display: flex;
  gap: 4px;
  padding: 12px 24px;
  background: var(--bot-bubble);
  border-radius: var(--radius-lg);
  width: fit-content;
  border: 1px solid var(--border-light);
  margin-bottom: 8px;
}

.typing-indicator span {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent-primary);
  opacity: 0.4;
  animation: typing 1.4s infinite ease-in-out;
}

.typing-indicator span:nth-child(1) { animation-delay: -0.32s; }
.typing-indicator span:nth-child(2) { animation-delay: -0.16s; }

@keyframes typing {
  0%, 80%, 100% { transform: scale(0.8); opacity: 0.4; }
  40% { transform: scale(1); opacity: 1; }
}

/* Responsive Design */
@media (max-width: 1024px) {
  .room-container,
  .lobby-container {
    flex-direction: column;
  }
  
  .sidebar,
  .participants-panel {
    width: 100%;
    height: auto;
    max-height: 40vh;
    border-right: none;
    border-bottom: 1px solid var(--border-color);
    min-width: unset;
  }
  
  .main-content {
    padding: 20px;
  }
  
  .chat-header {
    padding: 16px 20px;
  }
  
  .room-controls {
    flex-wrap: wrap;
    justify-content: flex-end;
  }
  
  .control-btn {
    padding: 8px 14px;
    font-size: 13px;
  }
}

@media (max-width: 768px) {
  .login-box {
    padding: 30px 20px;
    margin: 20px;
  }
  
  .room-controls {
    flex-direction: column;
    width: 100%;
  }
  
  .control-btn {
    width: 100%;
    justify-content: center;
  }
  
  .room-input-group {
    flex-direction: column;
  }
  
  .features-grid {
    grid-template-columns: 1fr;
  }
  
  .audio-controls {
    flex-direction: column;
    align-items: center;
  }
  
  .audio-visualizer {
    height: 80px;
  }
}

@media (max-width: 480px) {
  .room-header {
    padding: 16px;
  }
  
  .room-header h3 {
    font-size: 18px;
  }
  
  .participants-panel,
  .sidebar {
    max-height: 35vh;
  }
  
  .mute-controls {
    flex-direction: column;
  }
  
  .mute-btn {
    width: 28px;
    height: 28px;
    font-size: 12px;
  }
}

/* Utility Classes */
.hidden {
  display: none !important;
}

.visible {
  display: block !important;
}

.flex-center {
  display: flex;
  align-items: center;
  justify-content: center;
}

.text-truncate {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.spinner {
  animation: spin 1s linear infinite;
}

@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

.tooltip {
  position: relative;
  display: inline-block;
}

.tooltip .tooltip-text {
  visibility: hidden;
  width: 120px;
  background-color: var(--bg-tertiary);
  color: var(--text-primary);
  text-align: center;
  padding: 5px;
  border-radius: var(--radius-sm);
  position: absolute;
  z-index: 1;
  bottom: 125%;
  left: 50%;
  margin-left: -60px;
  opacity: 0;
  transition: opacity 0.3s;
  font-size: 12px;
  border: 1px solid var(--border-light);
}

.tooltip:hover .tooltip-text {
  visibility: visible;
  opacity: 1;
}