:root {
  color-scheme: light;
  font-size: 16px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #f5f5f5;
  color: #222;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

main {
  width: min(100%, 32rem);
  padding: 2rem;
}

section {
  background: #fff;
  padding: 2rem;
  border-radius: 0.5rem;
  box-shadow: 0 0.5rem 1.5rem rgba(0, 0, 0, 0.08);
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

h1,
h2,
p {
  margin: 0;
  text-align: center;
}

form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

label {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  font-weight: 600;
}

input,
button,
select {
  padding: 0.75rem 1rem;
  border-radius: 0.5rem;
  border: 1px solid rgba(0, 0, 0, 0.1);
  font-size: 1rem;
  min-height: 44px;
}

button,
select,
input[type="submit"] {
  cursor: pointer;
}

button.primary {
  background: #0078d7;
  border: none;
  color: #fff;
  font-weight: 600;
  transition: background 0.2s ease;
}

button.primary:disabled {
  background: rgba(0, 120, 215, 0.5);
  cursor: not-allowed;
}

button.secondary {
  background: transparent;
  border: 1px solid #0078d7;
  color: #0078d7;
  font-weight: 600;
}

button.full-width {
  width: 100%;
}

.user-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.user-card {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: #f0f6ff;
  border-radius: 0.5rem;
  padding: 0.75rem 1rem;
}

@media (min-width: 48rem) {
  body {
    align-items: stretch;
  }

  main {
    padding: 3rem;
  }
}

body.state-call {
  background: #000;
  align-items: stretch;
}

body.state-call main {
  width: 100%;
  max-width: none;
  padding: 0;
  height: 100vh;
  display: flex;
}

body.state-call section[data-screen='call'] {
  position: relative;
  flex: 1 1 auto;
  background: #000;
  color: #fff;
  border-radius: 0;
  box-shadow: none;
  min-height: 100vh;
  padding: 0;
  display: flex;
  flex-direction: column;
}

body.state-call .call-stage {
  position: relative;
  flex: 1 1 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  background: #000;
}

body.state-call #remote-video {
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #000;
}

body.state-call #local-video-container {
  position: absolute;
  top: 1.5rem;
  right: 1.5rem;
  width: 25vw;
  max-width: 16rem;
  min-width: 6rem;
  aspect-ratio: 4 / 3;
  border-radius: 0.75rem;
  box-shadow: 0 0.75rem 2rem rgba(0, 0, 0, 0.4);
  background: #000;
  border: 1px solid rgba(255, 255, 255, 0.2);
  z-index: 2;
  cursor: pointer;
  user-select: none;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

body.state-call #local-video {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
  transition: opacity 0.3s;
}

body.state-call #local-video[hidden] {
  display: none;
}

body.state-call #camera-off-message {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  color: #fff;
  font-size: 0.875rem;
  text-align: center;
  pointer-events: none;
  z-index: 3;
}

body.state-call #no-media {
  position: absolute;
  bottom: calc(1.5rem + 4.5rem);
  left: 50%;
  transform: translateX(-50%);
  padding: 0.75rem 1.5rem;
  background: rgba(0, 0, 0, 0.65);
  color: #fff;
  border-radius: 999px;
  font-weight: 600;
  text-align: center;
  z-index: 2;
}

body.state-call .call-controls {
  position: absolute;
  bottom: 1.5rem;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 0.75rem;
  justify-content: center;
  width: calc(100% - 3rem);
  max-width: 32rem;
  z-index: 3;
}

body.state-call .call-controls button.secondary,
body.state-call .call-controls select.secondary {
  flex: 1;
  background: rgba(0, 0, 0, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.6);
  color: #fff;
  backdrop-filter: blur(6px);
}

body.state-call .call-controls select.secondary {
  cursor: pointer;
}

body.state-call .call-controls select.secondary option {
  background: #222;
  color: #fff;
}

button.danger {
  background: #d13438 !important;
  border: 1px solid #d13438 !important;
  color: #fff !important;
}

button.danger:hover {
  background: #b02a2e !important;
  border: 1px solid #b02a2e !important;
}

body.state-call .call-controls button.danger {
  flex: 1;
  background: rgba(209, 52, 56, 0.8) !important;
  border: 1px solid rgba(209, 52, 56, 0.9) !important;
  backdrop-filter: blur(6px);
  color: #fff !important;
}

body.state-call .call-controls button.danger:hover {
  background: rgba(176, 42, 46, 0.9) !important;
}

/* Rooms list styles */
.rooms-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  max-height: 400px;
  overflow-y: auto;
  padding: 1.5rem 0;
}

.room-card {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: #f8f9fa;
  border: 1px solid #e0e0e0;
  border-radius: 0.5rem;
  padding: 1rem;
  cursor: pointer;
  transition: all 0.2s;
}

.room-card:hover {
  background: #e3f2fd;
  border-color: #0078d7;
  transform: translateY(-2px);
  box-shadow: 0 2px 8px rgba(0, 120, 215, 0.1);
}

.room-info {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.room-name {
  font-weight: 600;
  font-size: 1.1rem;
  color: #222;
}

.room-users {
  font-size: 0.9rem;
  color: #666;
}

.room-arrow {
  color: #0078d7;
  font-size: 1.5rem;
}

.rooms-list:empty::before {
  content: "Нет активных комнат. Создайте новую!";
  display: block;
  text-align: center;
  padding: 2rem;
  color: #999;
}
