/* ============================================
   Components — кнопки, инпуты, аватары, бейджи
   ============================================ */

/* ===== Кнопки ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 20px;
  border: none;
  border-radius: var(--radius-md);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}

.btn-primary {
  background: var(--aion-gradient);
  color: var(--text-on-gradient);
  box-shadow: var(--shadow-glow-strong);
}
.btn-primary:hover {
  background: var(--aion-gradient-hover);
  transform: translateY(-1px);
}
.btn-primary:active { transform: translateY(0); }
.btn-primary:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none;
}

.btn-secondary {
  background: transparent;
  color: var(--text-primary);
  border: 1px solid var(--border-medium);
}
.btn-secondary:hover {
  background: var(--bg-hover);
  border-color: var(--border-strong);
}

.btn-danger {
  background: var(--status-error);
  color: #fff;
}
.btn-danger:hover { background: #ea5b5b; }

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
}
.btn-ghost:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.btn-sm {
  padding: 8px 14px;
  font-size: 13px;
  border-radius: var(--radius-sm);
}

.btn-lg {
  padding: 14px 24px;
  font-size: 15px;
}

.btn-block {
  width: 100%;
  display: flex;
}

/* Иконка-кнопка */
.icon-btn {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-size: 18px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
  flex-shrink: 0;
}
.icon-btn:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}
.icon-btn:active { transform: scale(0.95); }
.icon-btn.active {
  background: var(--bg-active);
  color: var(--text-primary);
}

/* Кнопка отправки */
.send-btn {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--aion-gradient);
  border: none;
  color: var(--text-on-gradient);
  font-size: 18px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
  box-shadow: var(--shadow-glow-strong);
  flex-shrink: 0;
}
.send-btn:hover {
  background: var(--aion-gradient-hover);
  transform: scale(1.05);
}
.send-btn:active { transform: scale(0.95); }

/* ===== Инпуты ===== */
.input {
  width: 100%;
  padding: 12px 14px;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: 14px;
  font-family: var(--font-ui);
  outline: none;
  transition: all 0.15s;
}
.input::placeholder { color: var(--text-muted); }
.input:hover { border-color: var(--border-medium); }
.input:focus {
  border-color: var(--accent-silver);
  box-shadow: var(--shadow-glow);
  background: var(--bg-surface);
}

.input-label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
  margin-top: 12px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

/* Поиск */
.search-input {
  width: 100%;
  padding: 10px 14px 10px 36px;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: 13px;
  outline: none;
  transition: all 0.15s;
  background-image: url("data:image/svg+xml;utf8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='15' height='15' viewBox='0 0 24 24' fill='none' stroke='%238B9BAF' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='11' cy='11' r='8'/%3E%3Cpath d='m21 21-4.35-4.35'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: 12px center;
}
.search-input::placeholder { color: var(--text-muted); }
.search-input:focus {
  border-color: var(--accent-silver);
  box-shadow: var(--shadow-glow);
}

/* Поле ввода сообщения */
.msg-input {
  flex: 1;
  padding: 12px 16px;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  color: var(--text-primary);
  font-size: 14px;
  outline: none;
  transition: all 0.15s;
  min-width: 0;
}
.msg-input::placeholder { color: var(--text-muted); }
.msg-input:focus {
  border-color: var(--accent-silver);
  box-shadow: var(--shadow-glow);
}

/* ===== Аватары ===== */
.avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-size: 17px;
  font-weight: 700;
  color: var(--text-on-gradient);
  background: var(--aion-gradient);
  flex-shrink: 0;
  overflow: hidden;
  position: relative;
}

.avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
}

.avatar-xs { width: 24px; height: 24px; font-size: 10px; }
.avatar-sm { width: 36px; height: 36px; font-size: 14px; }
.avatar-md { width: 44px; height: 44px; font-size: 17px; }
.avatar-lg { width: 64px; height: 64px; font-size: 24px; }
.avatar-xl { width: 96px; height: 96px; font-size: 36px; }

/* Аватар с градиентной обводкой (для активного) */
.avatar-ring {
  padding: 2px;
  background: var(--aion-gradient-ring);
  border-radius: 50%;
  display: inline-flex;
}
.avatar-ring .avatar { border: 2px solid var(--bg-panel); }

/* Статус-точка на аватаре */
.avatar-status {
  position: relative;
}
.avatar-status::after {
  content: '';
  position: absolute;
  bottom: 0;
  right: 0;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--status-offline);
  border: 2px solid var(--bg-panel);
  box-sizing: content-box;
}
.avatar-status.status-online::after { background: var(--status-online); }
.avatar-status.status-away::after { background: var(--status-away); }
.avatar-status.status-error::after { background: var(--status-error); }

/* ===== Бейджи ===== */
.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 6px;
  border-radius: var(--radius-full);
  background: var(--aion-gradient);
  color: var(--text-on-gradient);
  font-size: 10px;
  font-weight: 700;
  line-height: 1;
}

.badge-sm { min-width: 16px; height: 16px; font-size: 9px; padding: 0 5px; }
.badge-muted {
  background: var(--bg-hover);
  color: var(--text-secondary);
}

/* ===== Чипы (фильтры) ===== */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 6px 14px;
  border-radius: var(--radius-full);
  background: var(--bg-hover);
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 600;
  border: none;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s;
}
.chip:hover {
  background: var(--bg-active);
  color: var(--text-primary);
}
.chip.active {
  background: var(--aion-gradient);
  color: var(--text-on-gradient);
  box-shadow: var(--shadow-glow-strong);
}

/* ===== Переключатель (toggle) ===== */
.switch {
  display: inline-flex;
  align-items: center;
  width: 40px;
  height: 22px;
  border-radius: var(--radius-full);
  background: var(--text-muted);
  cursor: pointer;
  position: relative;
  transition: background 0.15s;
  flex-shrink: 0;
  border: none;
  padding: 0;
}
.switch::after {
  content: '';
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #fff;
  position: absolute;
  left: 3px;
  transition: transform 0.2s;
}
.switch.on {
  background: var(--aion-gradient);
}
.switch.on::after {
  transform: translateX(18px);
}

/* ===== Табы ===== */
.tabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--border-line);
  margin-bottom: 16px;
}
.tab {
  padding: 10px 16px;
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: all 0.15s;
}
.tab:hover { color: var(--text-primary); }
.tab.active {
  color: var(--text-primary);
  border-bottom-color: transparent;
  background-image: var(--aion-gradient);
  background-size: 100% 2px;
  background-position: bottom;
  background-repeat: no-repeat;
}

/* ===== Чекбокс ===== */
.checkbox {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text-secondary);
  cursor: pointer;
  user-select: none;
}
.checkbox input {
  width: 16px;
  height: 16px;
  accent-color: var(--accent-solid);
  cursor: pointer;
}

/* ===== Пустое состояние ===== */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 20px;
  text-align: center;
  color: var(--text-secondary);
  height: 100%;
}
.empty-state-icon {
  font-size: 48px;
  opacity: 0.5;
  margin-bottom: 12px;
}
.empty-state-text {
  font-size: 14px;
  max-width: 280px;
}

/* ===== Ошибка ===== */
.error {
  color: var(--status-error);
  font-size: 12px;
  margin-top: 8px;
  min-height: 18px;
}

/* ===== Модальные окна ===== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: var(--bg-overlay);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(4px);
  animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.modal-window {
  background: var(--bg-panel);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  width: 480px;
  max-width: calc(100vw - 32px);
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: modalIn 0.2s ease;
}

@keyframes modalIn {
  from { transform: scale(0.96); opacity: 0; }
  to   { transform: scale(1);    opacity: 1; }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px;
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 700;
  border-bottom: 1px solid var(--border-line);
  flex-shrink: 0;
}

.modal-body {
  padding: 20px 24px;
  overflow-y: auto;
  flex: 1;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 16px 24px;
  border-top: 1px solid var(--border-line);
  flex-shrink: 0;
}

/* ===== Аватар-превью для модалок ===== */
.avatar-upload {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  margin-bottom: 20px;
  cursor: pointer;
}
.avatar-upload-preview {
  width: 88px;
  height: 88px;
  border-radius: 50%;
  background: var(--bg-surface);
  border: 2px dashed var(--border-medium);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 32px;
  color: var(--text-muted);
  background-size: cover;
  background-position: center;
  transition: all 0.15s;
}
.avatar-upload:hover .avatar-upload-preview {
  border-color: var(--accent-solid);
  background-color: var(--bg-hover);
}
.avatar-upload-hint {
  font-size: 12px;
  color: var(--text-muted);
}

/* ===== Утилиты ===== */
.divider {
  height: 1px;
  background: var(--border-line);
  margin: 12px 0;
}

/* ============================================
   SVG-иконки
   ============================================ */

.icon {
  width: 20px;
  height: 20px;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  fill: none;
  flex-shrink: 0;
  display: inline-block;
  vertical-align: middle;
}

.icon-sm { width: 16px; height: 16px; }
.icon-lg { width: 24px; height: 24px; }

/* Обновляем icon-btn — эмодзи были font-size, теперь SVG */
.icon-btn {
  font-size: 0;   /* убираем влияние на размер */
}

/* Кнопка с текстом и иконкой */
.btn .icon {
  width: 16px;
  height: 16px;
}

/* Файловая иконка внутри .file-icon */
.file-icon {
  color: var(--accent-silver);
}
.file-icon .icon {
  width: 20px;
  height: 20px;
}

/* Медиа-плейсхолдер */
.media-item .icon {
  width: 22px;
  height: 22px;
  color: var(--text-muted);
}

/* В контекстном меню */
.context-item .icon {
  color: currentColor;
  opacity: 0.8;
}