/* ============================================================
   SHARED.CSS — единый базовый стиль для всех workspace-страниц
   Подключать первым: <link rel="stylesheet" href="../shared.css">
   ============================================================ */

/* ── Переменные ─────────────────────────────────────────── */
:root {
  /* Основные цвета */
  --primary:        #2563eb;
  --primary-hover:  #1d4ed8;
  --primary-light:  #dbeafe;
  --secondary:      #6b7280;
  --success:        #10b981;
  --success-hover:  #059669;
  --warning:        #f59e0b;
  --error:          #ef4444;
  --info:           #06b6d4;

  /* Серая шкала */
  --gray-50:  #f9fafb;
  --gray-100: #f3f4f6;
  --gray-200: #e5e7eb;
  --gray-300: #d1d5db;
  --gray-400: #9ca3af;
  --gray-500: #6b7280;
  --gray-600: #4b5563;
  --gray-700: #374151;
  --gray-800: #1f2937;
  --gray-900: #111827;

  /* Фоны */
  --bg-page:    #f3f4f6;
  --bg-surface: #ffffff;

  /* Текст */
  --text-primary:   #1f2937;
  --text-secondary: #4b5563;
  --text-muted:     #9ca3af;
  --text-white:     #ffffff;

  /* Тени */
  --shadow-sm: 0 1px 2px rgba(0,0,0,.05);
  --shadow-md: 0 4px 6px rgba(0,0,0,.07), 0 1px 3px rgba(0,0,0,.06);
  --shadow-lg: 0 10px 15px rgba(0,0,0,.1), 0 4px 6px rgba(0,0,0,.05);
  --shadow-xl: 0 20px 40px rgba(0,0,0,.12);

  /* Радиусы */
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-xl: 20px;

  /* Прочее */
  --sidebar-width: 260px;
  --transition:    all 0.2s ease;
  --font:          -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

/* ── Reset ──────────────────────────────────────────────── */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html { scroll-behavior: smooth; }

body {
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  color: var(--text-primary);
  background: var(--bg-page);
  min-height: 100vh;
}

a { text-decoration: none; color: inherit; }

/* ── Скроллбар ──────────────────────────────────────────── */
::-webkit-scrollbar       { width: 4px; height: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--gray-300); border-radius: 2px; }

/* ── Анимации ───────────────────────────────────────────── */
@keyframes spin {
  to { transform: rotate(360deg); }
}
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes slideInRight {
  from { opacity: 0; transform: translateX(40px); }
  to   { opacity: 1; transform: translateX(0); }
}
@keyframes slideUp {
  from { opacity: 0; transform: translateY(20px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes modalIn {
  from { opacity: 0; transform: translate(-50%, -50%) scale(0.93); }
  to   { opacity: 1; transform: translate(-50%, -50%) scale(1); }
}
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: .5; }
}

/* ── Layout ─────────────────────────────────────────────── */
.sidebar {
  position: fixed;
  left: 0;
  top: 0;
  width: var(--sidebar-width);
  height: 100vh;
  background: var(--bg-surface);
  border-right: 1px solid var(--gray-200);
  box-shadow: var(--shadow-sm);
  overflow-y: auto;
  z-index: 100;
  transition: transform 0.3s ease;
}

.main-content {
  margin-left: var(--sidebar-width);
  padding: 24px;
  min-height: 100vh;
}

/* Search-layout pages (Apollo / RocketReach / CoreSignal): the two-panel
   search UI sits flush against the sidebar and fills full height. */
.main-content:has(.search-page-layout) {
  padding: 0;
}

/* ── Nav icon: hide emoji by default, SVGs visible once injected ── */
.nav-item-icon {
  font-size: 0;
  line-height: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 16px;
  height: 16px;
  color: inherit;
}

.nav-item-icon svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  display: block;
}

/* ── Навигация (sidebar nav-item) ───────────────────────── */
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 16px;
  color: var(--gray-500);
  font-size: 13px;
  border-left: 2px solid transparent;
  transition: var(--transition);
  cursor: pointer;
}
.nav-item:hover {
  background: var(--gray-100);
  color: var(--gray-800);
}
.nav-item.active {
  background: var(--primary-light);
  color: var(--primary);
  border-left-color: var(--primary);
  font-weight: 500;
}

/* ── Sidebar structure ───────────────────────────────────── */
.nav-item { position: relative; }
.nav-item.active::before {
  content: "";
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 3px;
  background: var(--primary);
  border-radius: 0 2px 2px 0;
}
.nav-item-text {
  font-size: 13px;
  font-weight: 500;
}

.sidebar-header {
  padding: 20px 16px;
  border-bottom: 1px solid var(--gray-100);
}
.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
}
.sidebar-nav { padding: 12px 0; }
.nav-section { margin-bottom: 20px; }
.nav-section-title {
  padding: 8px 16px 6px;
  font-size: 11px;
  text-transform: uppercase;
  color: var(--text-muted);
  font-weight: 500;
  letter-spacing: 0.5px;
}

/* ── Sidebar toggle button ───────────────────────────────── */
.sidebar-toggle {
  position: fixed;
  top: 20px;
  left: calc(var(--sidebar-width) + 16px);
  background: var(--bg-surface);
  border-radius: var(--radius-sm);
  width: 32px;
  height: 32px;
  border: 1px solid var(--gray-200);
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  z-index: 101;
  display: flex;
  justify-content: center;
  align-items: center;
  font-size: 14px;
  transition: var(--transition);
  color: var(--gray-500);
}
.sidebar-toggle:hover {
  background: var(--gray-50);
  border-color: var(--gray-300);
  color: var(--gray-700);
}

/* ── Collapsed state ─────────────────────────────────────── */
.sidebar.collapsed {
  transform: translateX(calc(-1 * var(--sidebar-width)));
}
.sidebar.collapsed + .sidebar-toggle { left: 20px; }
.sidebar.collapsed ~ .main-content { margin-left: 0; }

/* ── Responsive sidebar ──────────────────────────────────── */
@media (max-width: 768px) {
  .sidebar {
    transform: translateX(calc(-1 * var(--sidebar-width)));
  }
  .sidebar.show { transform: translateX(0); }
  .sidebar-toggle { left: 20px; top: 16px; }
  .main-content { margin-left: 0 !important; padding-top: 60px; }
}
@media (max-width: 480px) {
  .main-content { padding: 12px; padding-top: 56px; }
  .sidebar-logo { font-size: 14px; }
  .nav-item-text { font-size: 12px; }
}

/* ── Кнопки ─────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 18px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  border: none;
  transition: var(--transition);
  white-space: nowrap;
}
.btn:disabled {
  opacity: .5;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--primary);
  color: var(--text-white);
  box-shadow: 0 2px 4px rgba(37,99,235,.25);
}
.btn-primary:hover:not(:disabled) {
  background: var(--primary-hover);
  box-shadow: 0 4px 8px rgba(37,99,235,.35);
  transform: translateY(-1px);
}

.btn-secondary {
  background: var(--bg-surface);
  color: var(--gray-600);
  border: 1.5px solid var(--gray-200);
}
.btn-secondary:hover:not(:disabled) {
  background: var(--gray-50);
  border-color: var(--gray-300);
  color: var(--gray-800);
}

.btn-success {
  background: var(--success);
  color: var(--text-white);
}
.btn-success:hover:not(:disabled) {
  background: var(--success-hover);
  transform: translateY(-1px);
}

.btn-danger {
  background: var(--error);
  color: var(--text-white);
}
.btn-danger:hover:not(:disabled) {
  background: #dc2626;
  transform: translateY(-1px);
}

.btn-sm { padding: 6px 12px; font-size: 12px; }
.btn-lg { padding: 12px 24px; font-size: 15px; }

/* ── Инпуты ─────────────────────────────────────────────── */
.form-input,
.form-select,
.form-textarea {
  width: 100%;
  padding: 10px 14px;
  border: 1.5px solid var(--gray-200);
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-family: var(--font);
  color: var(--text-primary);
  background: var(--bg-surface);
  transition: var(--transition);
  outline: none;
}
.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37,99,235,.1);
}
.form-input:disabled,
.form-select:disabled,
.form-textarea:disabled {
  background: var(--gray-100);
  color: var(--gray-400);
  cursor: not-allowed;
}
.form-label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 6px;
}
.form-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

/* ── Карточки ───────────────────────────────────────────── */
.card {
  background: var(--bg-surface);
  border-radius: var(--radius-lg);
  border: 1px solid var(--gray-200);
  box-shadow: var(--shadow-sm);
  padding: 24px;
}
.card-header {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--gray-200);
}

/* ── Таблицы ────────────────────────────────────────────── */
.table-wrapper {
  width: 100%;
  overflow-x: auto;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
}
table {
  width: 100%;
  border-collapse: collapse;
  background: var(--bg-surface);
  font-size: 13px;
}
thead th {
  background: var(--gray-50);
  padding: 10px 12px;
  text-align: left;
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--text-secondary);
  border-bottom: 2px solid var(--gray-200);
  position: sticky;
  top: 0;
  z-index: 10;
}
tbody td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--gray-100);
  color: var(--text-primary);
  vertical-align: top;
}
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--gray-50); }
.table-empty td {
  text-align: center;
  color: var(--text-muted);
  padding: 40px;
  font-style: italic;
}

/* ── Модалки / диалоги ──────────────────────────────────── */
dialog, .modal {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: var(--bg-surface);
  border: none;
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-xl);
  padding: 28px;
  width: 90%;
  max-width: 520px;
  max-height: 88vh;
  overflow-y: auto;
  z-index: 1000;
  animation: modalIn 0.25s ease-out;
}
dialog[open] { display: block; }
dialog::backdrop, .modal-backdrop {
  background: rgba(0,0,0,.55);
  backdrop-filter: blur(4px);
}
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 999;
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}
.modal-title {
  font-size: 18px;
  font-weight: 600;
  color: var(--text-primary);
}
.modal-close {
  background: none;
  border: none;
  font-size: 20px;
  cursor: pointer;
  color: var(--gray-400);
  line-height: 1;
  transition: var(--transition);
}
.modal-close:hover { color: var(--gray-700); }
.modal-footer {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 24px;
  padding-top: 16px;
  border-top: 1px solid var(--gray-200);
}

/* ── Нотификации ────────────────────────────────────────── */
.notification {
  position: fixed;
  top: 16px;
  right: 16px;
  padding: 12px 18px;
  border-radius: var(--radius-md);
  color: var(--text-white);
  font-size: 14px;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  max-width: 340px;
  z-index: 9999;
  animation: slideInRight 0.3s ease-out;
}
.notification.success { background: var(--success); }
.notification.error   { background: var(--error); }
.notification.warning { background: var(--warning); color: var(--gray-900); }
.notification.info    { background: var(--info); }

/* ── Бейджи ─────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
}
.badge-success { background: #d1fae5; color: #065f46; }
.badge-error   { background: #fee2e2; color: #991b1b; }
.badge-warning { background: #fef3c7; color: #92400e; }
.badge-info    { background: #e0f2fe; color: #075985; }
.badge-gray    { background: var(--gray-100); color: var(--gray-600); }

/* ── Спиннер / загрузка ─────────────────────────────────── */
.spinner {
  width: 18px;
  height: 18px;
  border: 2px solid var(--gray-200);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  display: inline-block;
  flex-shrink: 0;
}
.spinner-white {
  border-color: rgba(255,255,255,.3);
  border-top-color: white;
}

.loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(255,255,255,.7);
  backdrop-filter: blur(3px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  z-index: 9998;
}
.loading-overlay.active { display: flex; }
.loading-overlay:not(.active) { display: none; }
.loading-text {
  font-size: 15px;
  font-weight: 500;
  color: var(--text-secondary);
  animation: pulse 1.5s ease-in-out infinite;
}

/* ── Утилиты ─────────────────────────────────────────────── */
.flex   { display: flex; }
.flex-col { display: flex; flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2  { gap: 8px; }
.gap-3  { gap: 12px; }
.gap-4  { gap: 16px; }
.mt-2   { margin-top: 8px; }
.mt-4   { margin-top: 16px; }
.mb-4   { margin-bottom: 16px; }
.w-full { width: 100%; }
.text-sm   { font-size: 12px; }
.text-muted { color: var(--text-muted); }
.font-semibold { font-weight: 600; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
