/* ========== МОДАЛКИ ========== */
.modal {
  display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%;
  background: var(--bg-mask); justify-content: center; align-items: center;
  z-index: 100; -webkit-backdrop-filter: blur(2px); backdrop-filter: blur(40px);
}
.modal.show { display: flex; }

.modal-content {
  background: var(--bg-modal); border: 1px solid var(--border-inverted);
  border-radius: var(--radius-2xl); padding: 24px; width: 440px;
  max-height: 85vh; overflow-y: auto; box-shadow: var(--shadow-lv3);
  animation: modalIn var(--transition-duration-slow) var(--ease-out);
  box-sizing: border-box; outline: none;
}
@keyframes modalIn { from { opacity: 0; transform: translateY(20px) scale(0.96); } to { opacity: 1; transform: translateY(0) scale(1); } }

.modal-wide { width: 820px; max-width: 94vw; }

.modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; }
.modal-header h2 { font-size: 18px; font-weight: 600; line-height: 24px; }

.modal-close {
  background: none; border: none; color: var(--text-tertiary); font-size: 20px;
  cursor: pointer; padding: 6px; border-radius: 50%; width: 32px; height: 32px;
  display: flex; align-items: center; justify-content: center;
  transition: all var(--transition-duration-fast) var(--ease-in-out);
}
.modal-close:hover { background: var(--bg-hover); color: var(--text-primary); }

.modal-content input, .modal-content textarea, .modal-content select {
  width: 100%; background: var(--bg-input); border: 1px solid var(--border-l2);
  color: var(--text-primary); padding: 10px 14px; border-radius: 10px;
  font-size: 14px; margin-bottom: 10px; font-family: var(--font-family);
  outline: none; box-sizing: border-box;
  transition: border-color var(--transition-duration-fast) var(--ease-in-out);
}
.modal-content input:focus, .modal-content textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(0, 113, 227, 0.15); }

.btn-primary, .btn-secondary {
  padding: 10px 20px; border-radius: 10px; font-size: 14px; cursor: pointer;
  border: none; font-weight: 500; transition: all var(--transition-duration) var(--ease-in-out);
  font-family: var(--font-family); display: inline-flex; align-items: center; justify-content: center; box-sizing: border-box;
}
.btn-primary { background: linear-gradient(135deg, #0071e3, #409cff); color: #fff; box-shadow: 0 2px 8px rgba(0, 113, 227, 0.3); }
.btn-primary:hover { box-shadow: 0 8px 24px rgba(0, 113, 227, 0.4); transform: translateY(-1px); }
.btn-primary:active { transform: scale(0.97); }
.btn-secondary { background: var(--bg-input); color: var(--text-primary); border: 1px solid var(--border-l2); }
.btn-secondary:hover { background: var(--bg-hover); }

/* ========== СФЕРЫ В МОДАЛКЕ ========== */
.sfery-modal-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px; max-height: 50vh; overflow-y: auto; padding: 4px; }
.sfery-modal-item { display: flex; align-items: center; gap: 8px; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--border-l2); background: rgba(255, 255, 255, 0.02); cursor: pointer; transition: all var(--transition-duration-fast) var(--ease-in-out); font-size: 13px; font-weight: 500; color: var(--text-primary); }
.sfery-modal-item:hover { border-color: var(--accent); background: rgba(0, 113, 227, 0.08); transform: translateY(-1px); }
.sfery-modal-item .sf-icon { font-size: 20px; flex-shrink: 0; }
.sfery-modal-category { margin-bottom: 16px; }
.sfery-modal-category h4 { font-size: 13px; font-weight: 600; color: var(--accent); margin-bottom: 10px; text-transform: uppercase; letter-spacing: 0.03em; }
.sfery-modal-search { width: 100%; padding: 12px 16px; border-radius: 10px; border: 1px solid var(--border-l2); background: rgba(255, 255, 255, 0.04); color: var(--text-primary); font-size: 14px; font-family: var(--font-family); margin-bottom: 16px; outline: none; box-sizing: border-box; }
.sfery-modal-search::placeholder { color: var(--text-caption); }
.sfery-modal-search:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(0, 113, 227, 0.08); }

/* ========== ПРОФИЛЬ ========== */
.profile-menu-modal { display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: var(--bg-mask); justify-content: center; align-items: center; z-index: 200; -webkit-backdrop-filter: blur(2px); backdrop-filter: blur(40px); }
.profile-menu-modal.show { display: flex; }

.profile-menu-content {
  background: var(--bg-modal); border: 0.5px solid var(--border-l2);
  border-radius: var(--radius-xl); padding: 6px; width: 280px;
  box-shadow: 0 8px 40px rgba(0,0,0,0.4), 0 0 0 0.5px rgba(255,255,255,0.05);
  animation: modalIn 0.2s cubic-bezier(0.22, 0.61, 0.36, 1);
  backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
}

.profile-menu-item-new {
  display: flex; align-items: center; gap: 12px; padding: 12px 14px;
  border-radius: 12px; cursor: pointer; border: none; background: none;
  width: 100%; text-align: left; font-size: 14px; font-weight: 500;
  font-family: var(--font-family); color: var(--text-primary); transition: all 0.15s ease;
}
.profile-menu-item-new:hover { background: var(--bg-hover); }
.profile-menu-item-new.danger { color: var(--red); }
.profile-menu-item-new.danger:hover { background: rgba(255, 59, 48, 0.08); }

/* ========== ЯЗЫК ========== */
.lang-modal { display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: var(--bg-mask); justify-content: center; align-items: center; z-index: 200; -webkit-backdrop-filter: blur(2px); backdrop-filter: blur(40px); }
.lang-modal.show { display: flex; }
.lang-modal-content { background: var(--bg-modal); border: 1px solid var(--border-inverted); border-radius: var(--radius-2xl); padding: 28px; width: 420px; max-height: 70vh; overflow-y: auto; box-shadow: var(--shadow-lv3); animation: modalIn var(--transition-duration-slow) var(--ease-out); box-sizing: border-box; }
.lang-modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; }
.lang-modal-header h3 { font-size: 18px; font-weight: 600; color: var(--text-primary); }
.lang-modal-close { background: none; border: none; font-size: 22px; cursor: pointer; color: var(--text-tertiary); padding: 4px 8px; border-radius: 50%; transition: all var(--transition-duration-fast) var(--ease-in-out); }
.lang-modal-close:hover { color: var(--text-primary); background: var(--bg-hover); }
.lang-list { display: flex; flex-direction: column; gap: 4px; }
.lang-option { display: flex; align-items: center; gap: 14px; padding: 14px 16px; border-radius: var(--radius-md); cursor: pointer; border: none; background: none; width: 100%; text-align: left; font-size: 15px; font-family: var(--font-family); color: var(--text-primary); transition: all var(--transition-duration-fast) var(--ease-in-out); }
.lang-option:hover { background: rgba(0, 113, 227, 0.08); }
.lang-option.active { background: rgba(0, 113, 227, 0.12); font-weight: 600; }
.lang-flag { font-size: 24px; flex-shrink: 0; width: 32px; text-align: center; }
.lang-name { flex: 1; }
.lang-check { color: var(--accent); font-weight: 700; font-size: 18px; }

/* ========== TOAST, TOOLTIP, БАННЕРЫ ========== */
.toast { position: fixed; top: 40px; left: 50%; transform: translateX(-50%); background: var(--bg-layer-3); color: #fff; padding: 12px 18px; border-radius: var(--radius-md); font-size: 14px; font-weight: 500; line-height: 22px; z-index: 999; opacity: 0; transition: all var(--transition-duration-slow) var(--ease-in-out); pointer-events: none; border: 1px solid var(--border-inverted); box-shadow: 0 0 4px 2px rgba(0, 0, 0, 0.04), 0 4px 16px 0 rgba(0, 0, 0, 0.1); }
.tooltip { display: none; position: fixed; background: #3a3a3c; color: #f5f5f7; padding: 6px 12px; border-radius: 10px; font-size: 13px; font-weight: 500; line-height: 1.5; z-index: 200; pointer-events: none; white-space: nowrap; box-shadow: 0 6px 16px rgba(0, 0, 0, 0.3); border: 1px solid var(--border-inverted); font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; }
.tooltip.show { display: block; }
.offline-banner { display: none; position: fixed; top: 0; left: 0; right: 0; background: var(--red); color: #fff; text-align: center; padding: 8px; z-index: 300; font-size: 13px; font-weight: 500; }
.offline-banner.show { display: block; }
.update-banner { position: fixed; bottom: 20px; left: 20px; right: 20px; background: var(--bg-modal); border: 0.5px solid var(--accent); border-radius: var(--radius-lg); padding: 12px 20px; display: none; justify-content: space-between; align-items: center; z-index: 1000; box-shadow: 0 8px 30px rgba(0, 0, 0, 0.3); font-size: 14px; gap: 12px; flex-wrap: wrap; -webkit-backdrop-filter: blur(20px); backdrop-filter: blur(40px); }
.update-banner.show { display: flex; }
.update-banner button { background: var(--accent); color: #fff; border: none; padding: 8px 20px; border-radius: 30px; cursor: pointer; font-weight: 600; font-size: 13px; transition: all var(--transition-duration-fast) var(--ease-in-out); white-space: nowrap; font-family: var(--font-family); }
.update-banner button:hover { background: var(--accent-hover); transform: scale(1.02); }
.cookie-banner { position: fixed; bottom: 20px; left: 20px; right: 20px; background: var(--bg-modal); border: 1px solid var(--border-l1); border-radius: var(--radius-lg); padding: 16px 20px; z-index: 1000; display: none; justify-content: space-between; align-items: center; gap: 12px; box-shadow: 0 8px 30px rgba(0, 0, 0, 0.3); font-size: 14px; flex-wrap: wrap; }
.cookie-banner.show { display: flex; }
.cookie-banner a { color: var(--accent); text-decoration: underline; }
.cookie-banner .btn-primary { white-space: nowrap; }

/* ========== МОДАЛКА ДЕЙСТВИЙ ЧАТА ========== */
.chat-action-modal {
  display: none;
  position: fixed;
  z-index: 300;
  background: var(--bg-modal);
  border: 0.5px solid var(--border-l2);
  border-radius: var(--radius-lg);
  padding: 6px;
  min-width: 180px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.4);
  animation: modalIn 0.15s ease;
}
.chat-action-modal.show { display: block; }

.chat-action-item {
  display: flex; align-items: center; gap: 10px;
  width: 100%; padding: 10px 14px;
  border: none; background: none;
  color: var(--text-primary); font-size: 13px; font-weight: 500;
  font-family: var(--font-family); cursor: pointer;
  border-radius: var(--radius-sm); transition: all 0.15s ease; text-align: left;
}
.chat-action-item:hover { background: var(--bg-hover); }
.chat-action-item.danger { color: var(--red); }
.chat-action-item.danger:hover { background: rgba(255, 59, 48, 0.08); }
.chat-action-item i, .chat-action-item [data-lucide] { flex-shrink: 0; }

/* ========== МОДАЛКИ ПЕРЕИМЕНОВАНИЯ И УДАЛЕНИЯ ========== */
.admin-confirm-overlay {
  position: fixed; top: 0; left: 0; width: 100%; height: 100%;
  background: rgba(0, 0, 0, 0.5); display: flex; align-items: center; justify-content: center;
  z-index: 300; backdrop-filter: blur(2px);
}
.admin-confirm-dialog {
  background: var(--bg-modal); border: 0.5px solid var(--border-l2);
  border-radius: var(--radius-xl); padding: 24px; width: 360px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.4); animation: modalIn 0.2s ease;
}
.admin-confirm-title { font-size: 16px; font-weight: 600; color: var(--text-primary); margin-bottom: 8px; }
.admin-confirm-text { font-size: 14px; color: var(--text-secondary); margin-bottom: 20px; }
.admin-confirm-actions { display: flex; gap: 8px; justify-content: flex-end; }

.admin-btn {
  padding: 10px 20px; border-radius: 10px; font-size: 14px; font-weight: 500;
  cursor: pointer; border: none; font-family: var(--font-family); transition: all 0.2s ease;
  background: var(--bg-input); color: var(--text-primary); border: 0.5px solid var(--border-l2);
}
.admin-btn:hover { background: var(--bg-hover); }
.admin-btn.primary { background: var(--accent); color: #fff; border: none; }
.admin-btn.primary:hover { filter: brightness(1.1); }
.admin-btn.danger { background: var(--red); color: #fff; border: none; }
.admin-btn.danger:hover { filter: brightness(1.1); }

.modal-input {
  width: 100%; background: var(--bg-input); border: 1px solid var(--border-l2);
  color: var(--text-primary); padding: 10px 14px; border-radius: 10px;
  font-size: 14px; font-family: var(--font-family); outline: none;
  margin-bottom: 16px; box-sizing: border-box;
}
.modal-input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(0,113,227,0.1); }

.model-modal-content { max-width: 360px; padding: 24px; }
.model-option.active { border-color: var(--accent) !important; background: rgba(0,113,227,0.06) !important; }
.model-option.active .model-check { display: flex !important; }