/* Веб-сервис аудио/видео звонков. Адаптивная вёрстка. */
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: #1a1d23;
  color: #e4e6eb;
  min-height: 100vh;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}
.hidden { display: none !important; }

/* Вход */
#screen-login {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}
.login-box {
  background: #252830;
  padding: 2rem;
  border-radius: 12px;
  width: 100%;
  max-width: 360px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.3);
}
.login-box h1 { margin: 0 0 1.5rem; font-size: 1.5rem; font-weight: 600; }
.login-box input {
  display: block;
  width: 100%;
  padding: 0.75rem 1rem;
  margin-bottom: 0.75rem;
  border: 1px solid #3d424d;
  border-radius: 8px;
  background: #1a1d23;
  color: #e4e6eb;
  font-size: 16px;
}
.login-box button {
  width: 100%;
  padding: 0.75rem 1rem;
  border: none;
  border-radius: 8px;
  background: #3b82f6;
  color: #fff;
  font-size: 1rem;
  font-weight: 500;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.login-box button:hover { background: #2563eb; }
.login-box .error { color: #f87171; font-size: 0.9rem; margin-top: 0.5rem; }

/* Основная страница */
#screen-main {
  display: flex;
  flex-direction: column;
  height: 100vh;
}
.header {
  padding: 0.75rem 1rem;
  padding-left: max(1rem, env(safe-area-inset-left));
  padding-right: max(1rem, env(safe-area-inset-right));
  background: #252830;
  border-bottom: 1px solid #3d424d;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.header-title { font-weight: 600; font-size: 1.1rem; }
.header-user { flex: 1; color: #9ca3af; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.btn-telegram {
  padding: 0.5rem 0.75rem;
  border: none;
  border-radius: 8px;
  background: #0088cc;
  color: #fff;
  font-size: 0.85rem;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  white-space: nowrap;
}
.btn-telegram:hover { background: #006699; }
.btn-telegram:disabled { opacity: 0.7; cursor: not-allowed; }
.btn-logout {
  padding: 0.5rem 0.75rem;
  border: none;
  border-radius: 8px;
  background: #3d424d;
  color: #e4e6eb;
  font-size: 0.9rem;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.btn-logout:hover { background: #4b5260; }
.main {
  flex: 1;
  overflow-y: auto;
  padding: 1rem;
  padding-left: max(1rem, env(safe-area-inset-left));
  padding-right: max(1rem, env(safe-area-inset-right));
  -webkit-overflow-scrolling: touch;
}
.user-list { list-style: none; margin: 0; padding: 0; }
.user-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 1rem;
  margin-bottom: 0.5rem;
  background: #252830;
  border-radius: 10px;
  border: 1px solid #3d424d;
}
.user-login { font-weight: 500; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.user-actions { display: flex; gap: 0.5rem; flex-shrink: 0; }
.btn-action {
  min-height: 44px;
  padding: 0.5rem 0.75rem;
  border: none;
  border-radius: 8px;
  background: #3b82f6;
  color: #fff;
  font-size: 0.95rem;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.btn-action:hover { background: #2563eb; }
.btn-action[data-action="video"] { background: #059669; }
.btn-action[data-action="video"]:hover { background: #047857; }
.empty-list { color: #9ca3af; text-align: center; padding: 2rem 1rem; }

/* Простой чат */
.chat-block { margin-top: 1.5rem; border-top: 1px solid #3d424d; padding-top: 1rem; }
.chat-title { font-size: 0.95rem; color: #9ca3af; margin: 0 0 0.5rem; }
.chat-messages {
  height: 200px;
  overflow-y: auto;
  background: #1a1d23;
  border: 1px solid #3d424d;
  border-radius: 8px;
  padding: 0.5rem;
  margin-bottom: 0.5rem;
  -webkit-overflow-scrolling: touch;
}
.chat-msg { margin-bottom: 0.5rem; font-size: 0.9rem; word-break: break-word; }
.chat-msg-sender { color: #9ca3af; font-weight: 500; }
.chat-msg-time { color: #6b7280; font-size: 0.75rem; margin-left: 0.25rem; }
.chat-msg-own .chat-msg-body { color: #93c5fd; }
.chat-form { display: flex; gap: 0.5rem; }
.chat-form input { flex: 1; min-width: 0; padding: 0.5rem 0.75rem; border: 1px solid #3d424d; border-radius: 8px; background: #252830; color: #e4e6eb; font-size: 16px; }
.chat-form button { padding: 0.5rem 1rem; border: none; border-radius: 8px; background: #3b82f6; color: #fff; cursor: pointer; flex-shrink: 0; }
.chat-form button:hover { background: #2563eb; }

/* Модальные окна */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 1rem;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}
.modal-content {
  background: #252830;
  border-radius: 12px;
  padding: 1.5rem;
  max-width: 100%;
  max-height: 90vh;
  overflow: auto;
}
.incoming-text { margin: 0 0 1rem; font-weight: 500; }
.incoming-actions { display: flex; gap: 0.5rem; justify-content: center; flex-wrap: wrap; }
.btn { padding: 0.75rem 1.5rem; border: none; border-radius: 8px; font-size: 1rem; cursor: pointer; -webkit-tap-highlight-color: transparent; }
.btn-accept { background: #22c55e; color: #fff; }
.btn-accept:hover { background: #16a34a; }
.btn-reject { background: #6b7280; color: #fff; }
.btn-reject:hover { background: #4b5563; }

/* Экран звонка — на весь экран */
#modal-call.modal { padding: 0; align-items: stretch; }
#modal-call .call-content {
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: none;
  max-height: none;
  height: 100%;
  min-height: 100vh;
  min-height: 100dvh;
  border-radius: 0;
  text-align: center;
}
#modal-call .call-info { margin: 0.5rem 0; font-weight: 500; flex-shrink: 0; }
#modal-call .call-video {
  flex: 1;
  display: flex;
  gap: 0.5rem;
  justify-content: center;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 0.5rem;
  min-height: 0;
}
#modal-call .call-video video {
  flex: 1;
  min-width: 200px;
  min-height: 150px;
  max-width: 100%;
  max-height: 100%;
  background: #1a1d23;
  border-radius: 8px;
  object-fit: cover;
}
#modal-call .call-controls { display: flex; gap: 0.5rem; justify-content: center; flex-wrap: wrap; flex-shrink: 0; padding-bottom: env(safe-area-inset-bottom); }
.call-btn {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  border: none;
  background: #3d424d;
  color: #fff;
  font-size: 1.3rem;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.call-btn:hover { background: #4b5260; }
.call-btn-end { background: #dc2626; }
.call-btn-end:hover { background: #b91c1c; }

@media (max-width: 768px) {
  .user-item { flex-wrap: wrap; }
  .user-actions { width: 100%; justify-content: flex-end; }
  .btn-action { flex: 1; min-width: 0; }
  .modal-content.call-content { border-radius: 0; max-height: none; }
  .call-video video { width: 100%; max-width: 320px; height: 200px; }
  .call-btn { width: 56px; height: 56px; }
}
@media (max-width: 480px) {
  .login-box { padding: 1.5rem; }
  .user-item { flex-direction: column; align-items: stretch; }
  .user-actions { justify-content: stretch; }
  .btn-action { flex: none; }
}
