/* ═══════════════════════════════════════════
   UI.CSS — auth, кнопки, формы, звонки, toast, context-menu,
            sticker-panel, drag, эмодзи + медиа-запросы
   ═══════════════════════════════════════════ */

/* ═══ AUTH ═══ */
.auth-wrap {
  position: fixed;
  inset: 0;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  display: flex;
  flex-direction: column;
  padding: 20px;
  background: var(--bg);
  z-index: 1;
}

.auth-card {
  background: var(--sidebar);
  border-radius: 16px;
  padding: 32px;
  width: 100%;
  max-width: 400px;
  box-shadow: 0 20px 60px var(--shadow);
  position: relative;
  margin: auto;
  flex-shrink: 0;
}

.auth-logo {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background: linear-gradient(135deg, #2aabee, #229ed9);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 20px;
}

.auth-title {
  text-align: center;
  font-size: 22px;
  margin-bottom: 8px;
}

.auth-sub {
  text-align: center;
  color: var(--muted);
  margin-bottom: 28px;
  font-size: 14px;
}

.auth-tabs {
  display: flex;
  margin-bottom: 20px;
  background: var(--bg);
  border-radius: 10px;
  padding: 4px;
}

.auth-tab {
  flex: 1;
  padding: 10px;
  text-align: center;
  border-radius: 8px;
  color: var(--muted);
  font-weight: 500;
  cursor: pointer;
  user-select: none;
}

.auth-tab.active {
  background: var(--active);
  color: var(--text);
}

.form-group {
  margin-bottom: 14px;
}

.form-group label {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.form-input {
  width: 100%;
  padding: 12px 14px;
  background: var(--bg);
  border-radius: 10px;
  color: var(--text);
  font-size: 15px;
  border: 1px solid transparent;
  transition: border-color 0.2s;
}

.form-input:focus {
  border-color: var(--accent);
}

.btn-primary {
  width: 100%;
  padding: 14px;
  background: var(--active);
  border-radius: 10px;
  color: var(--text);
  font-weight: 600;
  font-size: 15px;
  margin-top: 8px;
  transition: background 0.2s;
}

.btn-primary:hover {
  opacity: 0.9;
}

.btn-primary:disabled {
  opacity: 0.7;
  cursor: not-allowed;
}

.btn-danger {
  width: 100%;
  padding: 14px;
  background: rgba(231, 76, 60, 0.1);
  color: var(--danger);
  border-radius: 10px;
  font-weight: 600;
  font-size: 15px;
  margin-top: 12px;
  transition: background 0.2s;
}

.btn-danger:hover {
  background: rgba(231, 76, 60, 0.2);
}

.auth-error {
  color: var(--danger);
  font-size: 13px;
  text-align: center;
  margin-top: 12px;
  min-height: 18px;
}

.auth-avatar {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  margin: 0 auto 16px;
  background: #5288c1;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 32px;
  font-weight: 600;
  position: relative;
  overflow: hidden;
  cursor: pointer;
  color: #fff;
}

.auth-avatar img,
.auth-avatar video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.auth-avatar::after {
  content: '📷';
  position: absolute;
  bottom: 0;
  right: 0;
  background: var(--active);
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  border: 2px solid var(--sidebar);
}

/* ═══ TOAST ═══ */
.toast {
  position: fixed;
  bottom: 30px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--sidebar);
  color: var(--text);
  padding: 12px 20px;
  border-radius: 10px;
  font-size: 14px;
  z-index: 200;
  box-shadow: 0 10px 30px var(--shadow);
  border: 1px solid var(--border);
}

/* ═══ PHOTO VIEWER ═══ */
.photo-viewer {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.95);
  z-index: 300;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  cursor: zoom-out;
}

.photo-viewer img,
.photo-viewer video {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  border-radius: 8px;
}

/* ═══ CONTEXT MENU (ПКМ) ═══ */
.context-menu {
  position: fixed;
  background: var(--sidebar);
  border-radius: 12px;
  box-shadow: 0 4px 20px var(--shadow);
  z-index: 150;
  min-width: 200px;
  overflow: hidden;
  border: 1px solid var(--border);
  display: flex;
  flex-direction: column;
}

.context-menu-item {
  padding: 10px 16px;
  font-size: 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  transition: background 0.15s;
}

.context-menu-item:hover {
  background: var(--hover);
}

.context-menu-item.danger {
  color: var(--danger);
}

/* ═══ EMOJI PANEL ═══ */
.emoji-bar-wrapper {
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  padding: 4px 8px;
  display: flex;
  align-items: center;
  gap: 4px;
}

.emoji-quick-list {
  display: flex;
  gap: 4px;
  flex: 1;
  flex-wrap: wrap;
}

.emoji-btn {
  font-size: 20px;
  padding: 4px;
  border-radius: 8px;
  cursor: pointer;
  transition: transform 0.1s, background 0.1s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.emoji-btn:hover {
  transform: scale(1.2);
  background: var(--hover);
}

.emoji-expand-btn {
  color: var(--muted);
  padding: 4px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
}

.emoji-expand-btn:hover {
  background: var(--hover);
  color: var(--text);
}

.emoji-full-panel {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 4px;
  padding: 8px;
  max-height: 200px;
  overflow-y: auto;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}

.emoji-full-panel .emoji-btn {
  font-size: 22px;
  padding: 4px;
}

/* ═══ STICKER PANEL ═══ */
.sticker-panel {
  position: absolute;
  bottom: 78px;
  right: 20px;
  background: var(--sidebar);
  border-radius: 12px;
  padding: 12px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  width: 340px;
  max-width: calc(100% - 40px);
  max-height: 300px;
  overflow-y: auto;
  box-shadow: 0 10px 30px var(--shadow);
  z-index: 50;
  border: 1px solid var(--border);
  justify-content: flex-start;
}

.sticker-item {
  width: 60px;
  height: 60px;
  object-fit: contain;
  cursor: pointer;
  transition: transform 0.1s;
}

.sticker-item:hover {
  transform: scale(1.1);
}

/* ═══ BLOCKED BANNER ═══ */
.blocked-banner {
  padding: 16px;
  background: var(--sidebar);
  text-align: center;
  color: var(--muted);
  font-size: 14px;
  border-top: 1px solid var(--border);
}

.btn-unblock {
  background: var(--danger);
  color: #fff;
  padding: 10px 20px;
  border-radius: 10px;
  font-weight: 600;
  margin-top: 8px;
}

/* ═══ ЗВОНКИ ═══ */
.call-modal {
  position: fixed;
  inset: 0;
  background: #0e1621;
  z-index: 500;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.call-avatar {
  width: 140px;
  height: 140px;
  border-radius: 50%;
  background: #5288c1;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 56px;
  font-weight: 600;
  color: #fff;
  margin-bottom: 20px;
  overflow: hidden;
}

.call-avatar img,
.call-avatar video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.call-name {
  font-size: 24px;
  font-weight: 600;
  margin-bottom: 8px;
  text-align: center;
  color: #fff;
}

.call-status {
  font-size: 16px;
  color: var(--muted);
  margin-bottom: 60px;
  text-align: center;
}

.call-actions {
  display: flex;
  gap: 30px;
  justify-content: center;
  align-items: flex-start;
  margin-bottom: 20px;
  z-index: 10;
}

.call-btn-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  background: transparent;
  border: none;
  color: #fff;
}

.call-btn-wrap .icon-circle {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.1);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  transition: background 0.2s;
}

.call-btn-wrap:hover .icon-circle {
  background: rgba(255, 255, 255, 0.2);
}

.call-btn-wrap .icon-circle.danger {
  background: #e74c3c;
}

.call-btn-wrap .icon-circle.danger:hover {
  background: #c0392b;
}

.call-btn-wrap .icon-circle.success {
  background: #4dcd5e;
}

.call-btn-wrap .icon-circle.success:hover {
  background: #45b755;
}

.call-btn-wrap .label {
  font-size: 13px;
  color: #fff;
}

.call-btn-wrap .badge {
  position: absolute;
  top: -2px;
  right: -2px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #202b36;
  border: 2px solid #0e1621;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
}

/* ═══ DRAG-N-DROP ═══ */
.drag-ghost {
  position: fixed;
  pointer-events: none;
  z-index: 9999;
  background: var(--out);
  color: var(--text);
  padding: 8px 12px;
  border-radius: 12px;
  max-width: 280px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
  font-size: 13px;
  line-height: 1.4;
  transform: translate(-50%, -50%);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  border: 1px solid var(--accent);
}

/* ═══ STICKER CREATOR ═══ */
#sticker-preview-container {
  width: 300px;
  height: 300px;
  overflow: hidden;
  position: relative;
  background: rgba(0, 0, 0, 0.2);
  border-radius: 10px;
  cursor: grab;
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
}

#sticker-preview-container:active {
  cursor: grabbing;
}

#sticker-preview-img {
  position: absolute;
  transform-origin: center;
  user-select: none;
  pointer-events: none;
  max-width: none;
  top: 50%;
  left: 50%;
}

/* ═══ MIC VOLUME BAR ═══ */
.mic-volume-bar {
  width: 100%;
  height: 6px;
  background: var(--bg);
  border-radius: 3px;
  margin-top: 10px;
  overflow: hidden;
  border: 1px solid var(--border);
}

.mic-volume-fill {
  height: 100%;
  background: var(--online);
  width: 0%;
  transition: width 0.05s;
}

/* ═══ VIDEO TRIMMER (старые ID — оставлено для совместимости) ═══ */
#avatar-trimmer-video {
  width: 100%;
  max-height: 300px;
  border-radius: 8px;
  background: #000;
}

#avatar-trimmer-range {
  width: 100%;
  margin-top: 12px;
  cursor: pointer;
}

/* ═══ МЕДИА-ЗАПРОСЫ ═══ */
@media (max-width: 768px) {
  .sidebar {
    width: 100%;
    position: absolute;
    inset: 0;
    z-index: 10;
  }
  .sidebar.hidden {
    display: none;
  }
  .chat-area {
    position: absolute;
    inset: 0;
    z-index: 20;
    display: none;
  }
  .chat-area.mobile-open {
    display: flex;
  }
  .resizer {
    display: none;
  }
  .select-checkbox {
    left: 10px;
    z-index: 10;
  }
  .message-wrap.in {
    padding-left: 30px;
  }
  .sticker-panel {
    right: 10px;
    width: calc(100% - 20px);
    max-width: 340px;
  }
  .call-actions {
    gap: 15px;
  }
  .call-btn-wrap .icon-circle {
    width: 56px;
    height: 56px;
  }
}