/* ===== VARIABLES ===== */
:root {
  /* Цветовая палитра */
  --bg-primary: #0F0F13;
  --bg-secondary: #1A1A23;
  --bg-tertiary: #252532;
  --bg-card: #1E1E2E;
  
  /* Акцентные цвета */
  --accent-primary: #6366F1;
  --accent-secondary: #8B5CF6;
  --accent-success: #10B981;
  --accent-warning: #F59E0B;
  --accent-danger: #EF4444;
  
  /* Текст */
  --text-primary: #F8FAFC;
  --text-secondary: #CBD5E1;
  --text-muted: #94A3B8;
  
  /* Бейджи */
  --owner-bg: linear-gradient(135deg, #DC2626, #B91C1C);
  --admin-bg: linear-gradient(135deg, #F59E0B, #D97706);
  
  /* Остальное */
  --border-radius: 12px;
  --border-radius-sm: 8px;
  --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.3);
  --transition: all 0.2s ease-in-out;
}

/* ===== RESET & BASE STYLES ===== */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  height: 100%;
  font-size: 16px;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.5;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ===== HEADER ===== */
.header {
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--bg-tertiary);
  padding: 1rem;
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(10px);
}

.header-content {
  display: flex;
  justify-content: space-between;
  align-items: center;
  max-width: 1400px;
  margin: 0 auto;
}

.logo {
  font-size: 1.5rem;
  font-weight: 700;
  background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.header-info {
  display: flex;
  gap: 1.5rem;
  font-size: 0.875rem;
  color: var(--text-secondary);
}

#connectionStatus::before {
  content: "●";
  margin-right: 0.5rem;
  color: var(--accent-warning);
}

#connectionStatus.connected::before {
  color: var(--accent-success);
}

/* ===== MAIN CONTENT ===== */
.main {
  flex: 1;
  padding: 2rem;
  max-width: 1400px;
  margin: 0 auto;
  width: 100%;
}

/* ===== ROOM SELECTION ===== */
.room-selection {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 60vh;
}

.room-card {
  background: var(--bg-card);
  padding: 2rem;
  border-radius: var(--border-radius);
  box-shadow: var(--shadow);
  text-align: center;
  max-width: 400px;
  width: 100%;
}

.room-card h2 {
  margin-bottom: 1.5rem;
  color: var(--text-primary);
}

.input-group {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.input-group input {
  padding: 0.75rem;
  border: 1px solid var(--bg-tertiary);
  border-radius: var(--border-radius-sm);
  background: var(--bg-secondary);
  color: var(--text-primary);
  font-size: 1rem;
}

.input-group input:focus {
  outline: none;
  border-color: var(--accent-primary);
}

.button-group {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.btn {
  padding: 0.75rem 1.5rem;
  border: none;
  border-radius: var(--border-radius-sm);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
}

.btn.primary {
  background: var(--accent-primary);
  color: white;
}

.btn.primary:hover {
  background: var(--accent-secondary);
  transform: translateY(-2px);
}

.btn.secondary {
  background: var(--bg-tertiary);
  color: var(--text-primary);
}

.btn.secondary:hover {
  background: var(--bg-secondary);
}

/* ===== CALL INTERFACE ===== */
.call-interface {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  height: calc(100vh - 120px);
}

.call-layout {
  display: flex;
  gap: 1.5rem;
  flex: 1;
  min-height: 0;
}

.video-section {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  min-width: 0;
}

.sidebar {
  width: 350px;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  flex-shrink: 0;
}

/* ===== АДМИН ПАНЕЛЬ ===== */
.admin-panel {
  background: var(--bg-card);
  border: 2px solid var(--accent-warning);
  border-radius: var(--border-radius);
  padding: 1rem;
  margin-bottom: 1rem;
}

.admin-panel h3 {
  color: var(--accent-warning);
  margin-bottom: 0.5rem;
  font-size: 1.1rem;
}

.admin-controls {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.admin-btn {
  background: var(--accent-warning);
  color: white;
  border: none;
  padding: 0.5rem 1rem;
  border-radius: var(--border-radius-sm);
  cursor: pointer;
  font-size: 0.9rem;
  transition: var(--transition);
}

.admin-btn:hover {
  background: #E69C0D;
  transform: translateY(-2px);
}

/* ===== VIDEO CONTAINER ===== */
.video-container {
  flex: 1;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 1rem;
  align-content: start;
  overflow-y: auto;
}

.local-video-wrapper {
  position: relative;
  background: var(--bg-card);
  border-radius: var(--border-radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  aspect-ratio: 16/9;
}

.local-video-wrapper video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: var(--bg-tertiary);
}

.video-label {
  position: absolute;
  bottom: 0.5rem;
  left: 0.5rem;
  background: rgba(0, 0, 0, 0.7);
  padding: 0.25rem 0.75rem;
  border-radius: var(--border-radius-sm);
  font-size: 0.875rem;
  backdrop-filter: blur(10px);
}

.remote-video {
  position: relative;
  background: var(--bg-card);
  border-radius: var(--border-radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  aspect-ratio: 16/9;
}

.remote-video video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: var(--bg-tertiary);
}

/* ===== CONTROL PANEL ===== */
.control-panel {
  display: flex;
  justify-content: center;
  gap: 0.75rem;
  padding: 1rem;
  background: var(--bg-secondary);
  border-radius: var(--border-radius);
  flex-wrap: wrap;
}

.control-btn {
  padding: 0.75rem;
  border: none;
  border-radius: var(--border-radius-sm);
  background: var(--bg-tertiary);
  color: var(--text-primary);
  font-size: 1.25rem;
  cursor: pointer;
  transition: var(--transition);
  min-width: 3rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

.control-btn:hover {
  background: var(--bg-card);
  transform: translateY(-2px);
}

.control-btn.active {
  background: var(--accent-primary);
}

.control-btn.danger {
  background: var(--accent-danger);
}

.control-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

/* ===== USER LIST ===== */
.user-list {
  background: var(--bg-card);
  border-radius: var(--border-radius);
  padding: 1rem;
  height: fit-content;
}

.user-list h3 {
  margin-bottom: 1rem;
  font-size: 1rem;
  color: var(--text-secondary);
}

.user-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem;
  background: var(--bg-secondary);
  border-radius: var(--border-radius-sm);
  margin-bottom: 0.5rem;
}

.user-avatar {
  width: 2rem;
  height: 2rem;
  border-radius: 50%;
  background: var(--accent-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.875rem;
  font-weight: 600;
}

.user-info {
  flex: 1;
}

.user-name {
  font-weight: 600;
  margin-bottom: 0.25rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

/* ===== БЕЙДЖИ ===== */
.user-badge {
  display: inline-block;
  padding: 0.25rem 0.5rem;
  border-radius: 12px;
  font-size: 0.75rem;
  font-weight: 600;
}

.user-badge.owner {
  background: var(--owner-bg);
  color: white;
  font-weight: 900;
  border: 2px solid #FECACA;
  text-shadow: 0 1px 2px rgba(0,0,0,0.3);
  box-shadow: 0 2px 8px rgba(220, 38, 38, 0.4);
}

.user-badge.admin {
  background: var(--admin-bg);
  color: white;
  font-weight: 600;
  border: 1px solid #FDE68A;
}

/* ===== USER ACTIONS ===== */
.user-actions {
  display: flex;
  gap: 0.25rem;
}

.user-action-btn {
  background: var(--bg-tertiary);
  border: none;
  border-radius: 4px;
  padding: 0.25rem;
  cursor: pointer;
  font-size: 0.8rem;
  transition: var(--transition);
}

.user-action-btn:hover {
  background: var(--accent-primary);
}

/* ===== CHAT ===== */
.chat-container {
  background: var(--bg-card);
  border-radius: var(--border-radius);
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 300px;
}

.chat-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem;
  border-bottom: 1px solid var(--bg-tertiary);
}

.chat-header h3 {
  color: var(--text-secondary);
  font-size: 1rem;
}

.chat-toggle {
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 1.2rem;
}

.chat-messages {
  flex: 1;
  padding: 1rem;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  max-height: 300px;
}

.chat-welcome {
  text-align: center;
  color: var(--text-muted);
  font-size: 0.875rem;
  padding: 1rem;
}

.chat-message {
  padding: 0.75rem;
  border-radius: var(--border-radius-sm);
  max-width: 80%;
  word-wrap: break-word;
}

.own-message {
  background: var(--accent-primary);
  color: white;
  align-self: flex-end;
}

.other-message {
  background: var(--bg-secondary);
  color: var(--text-primary);
  align-self: flex-start;
}

.message-sender {
  font-size: 0.75rem;
  font-weight: 600;
  margin-bottom: 0.25rem;
  opacity: 0.8;
}

.message-text {
  font-size: 0.875rem;
}

.message-time {
  font-size: 0.7rem;
  opacity: 0.6;
  margin-top: 0.25rem;
  text-align: right;
}

.chat-input-container {
  display: flex;
  padding: 1rem;
  border-top: 1px solid var(--bg-tertiary);
  gap: 0.5rem;
}

#chatInput {
  flex: 1;
  padding: 0.75rem;
  border: 1px solid var(--bg-tertiary);
  border-radius: var(--border-radius-sm);
  background: var(--bg-secondary);
  color: var(--text-primary);
  font-size: 0.875rem;
}

#chatInput:focus {
  outline: none;
  border-color: var(--accent-primary);
}

#sendMessageBtn {
  padding: 0.75rem 1rem;
  background: var(--accent-primary);
  color: white;
  border: none;
  border-radius: var(--border-radius-sm);
  cursor: pointer;
  transition: var(--transition);
}

#sendMessageBtn:hover {
  background: var(--accent-secondary);
}

/* ===== FOOTER ===== */
.footer {
  background: var(--bg-secondary);
  border-top: 1px solid var(--bg-tertiary);
  padding: 1rem;
  margin-top: auto;
}

.footer-content {
  display: flex;
  justify-content: space-between;
  align-items: center;
  max-width: 1400px;
  margin: 0 auto;
  color: var(--text-muted);
  font-size: 0.875rem;
}

/* ===== MODALS ===== */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  backdrop-filter: blur(5px);
}

.modal-content {
  background: var(--bg-card);
  padding: 2rem;
  border-radius: var(--border-radius);
  max-width: 400px;
  width: 90%;
  max-height: 90vh;
  overflow-y: auto;
}

.modal h2 {
  margin-bottom: 1.5rem;
  color: var(--text-primary);
}

.setting-group {
  margin-bottom: 1rem;
}

.setting-group label {
  display: block;
  margin-bottom: 0.5rem;
  color: var(--text-secondary);
}

.setting-group select {
  width: 100%;
  padding: 0.75rem;
  border-radius: var(--border-radius-sm);
  border: 1px solid var(--bg-tertiary);
  background: var(--bg-secondary);
  color: var(--text-primary);
}

.modal-close {
  width: 100%;
  padding: 0.75rem;
  background: var(--accent-primary);
  color: white;
  border: none;
  border-radius: var(--border-radius-sm);
  cursor: pointer;
  transition: var(--transition);
  margin-top: 1rem;
}

.modal-close:hover {
  background: var(--accent-secondary);
}

/* ===== UTILITY CLASSES ===== */
.hidden {
  display: none !important;
}

/* ===== MEDIA QUERIES ===== */
@media (max-width: 1024px) {
  .call-layout {
    flex-direction: column;
  }
  
  .sidebar {
    width: 100%;
    order: -1;
  }
  
  .video-container {
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  }
}

@media (max-width: 768px) {
  .main {
    padding: 1rem;
  }
  
  .call-interface {
    height: calc(100vh - 100px);
  }
  
  .video-container {
    grid-template-columns: 1fr;
  }
  
  .control-panel {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    border-radius: 0;
    margin-top: 0;
    padding: 0.75rem;
    z-index: 90;
  }
  
  .header-content {
    flex-direction: column;
    gap: 0.5rem;
    text-align: center;
  }
  
  .admin-controls {
    flex-direction: column;
  }
  
  .admin-btn {
    width: 100%;
  }
}

/* Анимации */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

.video-container > * {
  animation: fadeIn 0.3s ease-out;
}

.chat-message {
  animation: fadeIn 0.2s ease-out;
}