/* VideoChat — vanilla CSS (Tailwind dizayniga mos) */
:root {
  --primary-500: #0ea5e9;
  --primary-600: #0284c7;
  --dark-800: #1e293b;
  --dark-900: #0f172a;
  --dark-950: #020617;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body,
#app {
  height: 100%;
  margin: 0;
}

body {
  font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  background: var(--dark-950);
  color: #fff;
}

.hidden {
  display: none !important;
}

/* Spinner */
.spinner {
  display: inline-block;
  width: 2rem;
  height: 2rem;
  border: 2px solid var(--primary-500);
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  flex-shrink: 0;
}

.spinner--lg {
  width: 3rem;
  height: 3rem;
}

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

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes slideIn {
  from {
    transform: translateX(100%);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

.animate-fade-in {
  animation: fadeIn 0.2s ease-out;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: 0.75rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s;
  font-size: 1rem;
  padding: 0 1.25rem;
  height: 2.75rem;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

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

.btn--primary:hover:not(:disabled) {
  background: var(--primary-600);
}

.btn--secondary {
  background: var(--dark-800);
  color: #fff;
}

.btn--secondary:hover:not(:disabled) {
  background: rgba(30, 41, 59, 0.8);
}

/* Register */
.page-register {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  background: linear-gradient(to bottom right, var(--dark-950), var(--dark-900), rgba(14, 165, 233, 0.08));
}

.card-register {
  width: 100%;
  max-width: 28rem;
  padding: 2rem;
  border-radius: 1rem;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(15, 23, 42, 0.8);
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(8px);
}

.card-register__title {
  margin: 0 0 0.5rem;
  text-align: center;
  font-size: 1.5rem;
  font-weight: 700;
}

.card-register__subtitle {
  margin: 0 0 2rem;
  text-align: center;
  font-size: 0.875rem;
  color: rgba(255, 255, 255, 0.7);
}

.alert {
  margin-bottom: 1rem;
  padding: 0.5rem 0.75rem;
  border-radius: 0.5rem;
  text-align: center;
  font-size: 0.875rem;
}

.alert--error {
  background: rgba(239, 68, 68, 0.2);
  color: #fca5a5;
}

.btn-google {
  display: flex;
  width: 100%;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  padding: 0.875rem 1rem;
  border-radius: 0.75rem;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s;
}

.btn-google:hover {
  background: rgba(255, 255, 255, 0.15);
}

.btn-google__icon {
  width: 1.5rem;
  height: 1.5rem;
}

/* Center pages */
.page-center {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  padding: 1rem;
  background: var(--dark-950);
}

.text-error {
  color: #f87171;
}

.text-muted {
  color: rgba(255, 255, 255, 0.8);
}

/* Chat layout */
.chat-page {
  position: fixed;
  inset: 0;
  height: 100vh;
  max-height: 100vh;
  width: 100%;
  overflow: hidden;
  background: var(--dark-950);
  display: flex;
  align-items: center;
  justify-content: center;
}

@supports (height: 100dvh) {
  .chat-page {
    height: 100dvh;
    max-height: 100dvh;
  }
}

/* Mobil: to‘liq ekran. Katta ekran: telefon (9:16) ramka */
.chat-stage {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--dark-900);
}

@media (min-width: 768px) {
  .chat-page {
    background:
      radial-gradient(ellipse at center, rgba(14, 165, 233, 0.08), transparent 60%),
      var(--dark-950);
  }

  .chat-stage {
    /* Telefon portret: 9:16, balandlik ekranga sig‘adi */
    height: min(100dvh, 100vh);
    width: min(100vw, calc(min(100dvh, 100vh) * 9 / 16));
    max-width: 430px;
    max-height: 100dvh;
    border-radius: 1.25rem;
    border: 1px solid rgba(255, 255, 255, 0.12);
    box-shadow:
      0 0 0 1px rgba(0, 0, 0, 0.4),
      0 25px 50px -12px rgba(0, 0, 0, 0.65);
  }
}

.chat-peer {
  position: absolute;
  inset: 0;
  overflow: hidden;
  background: var(--dark-900);
}

.chat-pip {
  position: absolute;
  right: 0.75rem;
  bottom: 5rem;
  z-index: 12;
  width: 22vw;
  max-width: 7.5rem;
  min-width: 5.5rem;
  aspect-ratio: 9 / 16;
  overflow: hidden;
  border-radius: 0.75rem;
  background: var(--dark-900);
  border: 2px solid rgba(255, 255, 255, 0.2);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
}

@media (min-width: 768px) {
  .chat-pip {
    right: 0.85rem;
    bottom: 5rem;
    width: 5.5rem;
    max-width: 5.5rem;
    min-width: 5rem;
    border-radius: 0.85rem;
  }
}

.local-status {
  position: absolute;
  inset: 0;
  z-index: 4;
  pointer-events: none;
}

.local-status .overlay {
  pointer-events: auto;
  padding: 0.35rem;
  gap: 0.35rem;
}

.local-status .overlay p {
  font-size: 0.65rem;
  text-align: center;
  line-height: 1.2;
}

.local-status .overlay .spinner {
  width: 1.25rem;
  height: 1.25rem;
}

.local-status .overlay .btn {
  height: 1.75rem;
  padding: 0 0.5rem;
  font-size: 0.7rem;
  border-radius: 0.5rem;
}

.local-status .overlay button {
  pointer-events: auto;
}

.local-video-wrap {
  position: absolute;
  inset: 0;
  z-index: 1;
}

.chat-pip .video-player {
  border-radius: 0;
}

.chat-pip .video-player__label {
  font-size: 0.7rem;
  padding: 0.15rem 0.4rem;
  bottom: 0.35rem;
  left: 0.35rem;
}

.overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.5rem;
  background: rgba(30, 41, 59, 0.5);
  border-radius: inherit;
  z-index: 5;
}

.overlay--stack {
  gap: 0.5rem;
}

.overlay--error {
  background: rgba(239, 68, 68, 0.2);
  color: #fca5a5;
  font-size: 0.75rem;
  text-align: center;
}

.overlay p {
  margin: 0;
  font-size: 0.75rem;
  color: rgba(255, 255, 255, 0.8);
}

@media (min-width: 768px) {
  .overlay p {
    font-size: 0.875rem;
  }
}

.peer-video-wrap {
  position: absolute;
  inset: 0;
  touch-action: pan-y;
  user-select: none;
  animation: slideIn 0.3s ease-out;
}

/* Video player */
.video-player {
  overflow: hidden;
  border-radius: 1rem;
  background: var(--dark-900);
}

.video-player--fill {
  position: absolute;
  inset: 0;
}

.video-player__inner {
  position: relative;
  width: 100%;
  height: 100%;
}

.video-player video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.video-player__video--mirror {
  transform: scaleX(-1);
}

.video-player__loader {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--dark-900);
}

.video-player__label {
  position: absolute;
  bottom: 0.5rem;
  left: 0.5rem;
  padding: 0.25rem 0.5rem;
  border-radius: 0.5rem;
  background: rgba(0, 0, 0, 0.6);
  font-size: 0.875rem;
  color: #fff;
  z-index: 2;
}

/* Menu */
.chat-menu {
  position: absolute;
  top: 0.75rem;
  right: 0.75rem;
  z-index: 20;
}

.chat-menu__trigger {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.375rem 0.75rem;
  border: none;
  border-radius: 0.5rem;
  background: rgba(0, 0, 0, 0.5);
  color: rgba(255, 255, 255, 0.9);
  cursor: pointer;
  backdrop-filter: blur(4px);
}

.chat-menu__trigger:hover {
  background: rgba(0, 0, 0, 0.7);
}

.chat-menu__name {
  font-size: 0.875rem;
  font-weight: 500;
}

.chat-menu__icon {
  width: 1rem;
  height: 1rem;
  color: rgba(255, 255, 255, 0.7);
}

.chat-menu__dropdown {
  position: absolute;
  right: 0;
  top: 100%;
  margin-top: 0.25rem;
  min-width: 11.25rem;
  padding: 0.25rem 0;
  border-radius: 0.75rem;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: var(--dark-800);
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.4);
  z-index: 100;
}

.chat-menu__item {
  display: flex;
  width: 100%;
  padding: 0.625rem 1rem;
  border: none;
  background: none;
  color: rgba(255, 255, 255, 0.9);
  font-size: 0.875rem;
  text-align: left;
  cursor: pointer;
}

.chat-menu__item:hover {
  background: rgba(255, 255, 255, 0.1);
}

.chat-menu__item--danger {
  color: #fca5a5;
}

/* Controls — pastki markazda, PiP ustida emas */
.chat-controls {
  position: absolute;
  bottom: 1rem;
  left: 0;
  right: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  z-index: 15;
}

.ctrl-btn {
  width: 2.75rem;
  height: 2.75rem;
  border: none;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.6);
  font-size: 1.25rem;
  cursor: pointer;
  transition: background 0.15s, opacity 0.15s;
}

.ctrl-btn:hover:not(:disabled) {
  background: rgba(0, 0, 0, 0.8);
}

.ctrl-btn--off {
  opacity: 0.7;
}

.ctrl-btn--next {
  background: var(--primary-500);
}

.ctrl-btn--next:hover:not(:disabled) {
  background: var(--primary-600);
}

.ctrl-btn--next:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* Language selection */
.page-language {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  background: linear-gradient(to bottom right, var(--dark-950), var(--dark-900), rgba(14, 165, 233, 0.08));
}

.card-language {
  width: 100%;
  max-width: 28rem;
  padding: 1.75rem;
  border-radius: 1rem;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(15, 23, 42, 0.9);
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
}

.card-language__title {
  margin: 0 0 0.5rem;
  text-align: center;
  font-size: 1.35rem;
  font-weight: 700;
}

.card-language__subtitle {
  margin: 0 0 1.25rem;
  text-align: center;
  font-size: 0.875rem;
  color: rgba(255, 255, 255, 0.7);
  line-height: 1.4;
}

.lang-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
}

.lang-btn {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 0.85rem;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 0.75rem;
  background: rgba(255, 255, 255, 0.06);
  color: #fff;
  cursor: pointer;
  text-align: left;
  transition: background 0.15s, border-color 0.15s;
}

.lang-btn:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(14, 165, 233, 0.5);
}

.lang-btn--active {
  border-color: var(--primary-500);
  background: rgba(14, 165, 233, 0.2);
}

.lang-btn:disabled {
  opacity: 0.6;
  cursor: wait;
}

.lang-btn__flag {
  font-size: 1.25rem;
  line-height: 1;
}

.lang-btn__label {
  font-size: 0.9rem;
  font-weight: 500;
}

.lang-error {
  margin: 0.75rem 0 0;
  text-align: center;
  font-size: 0.875rem;
  color: #fca5a5;
}

.lang-cancel {
  width: 100%;
  margin-top: 1rem;
}

.lang-settings-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(2, 6, 23, 0.85);
  backdrop-filter: blur(4px);
  overflow: auto;
}
