/* =============================================
   TIMPRO — Main CSS
   Светлая и тёмная тема с CSS переменными
   ============================================= */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

/* --- Светлая тема (по умолчанию) --- */
:root {
  --bg-primary:    #f8fafc;
  --bg-secondary:  #ffffff;
  --bg-card:       #ffffff;
  --bg-tertiary:   #f1f5f9;
  --bg-hover:      #e8edf5;
  --bg-active:     #e0e7ff;

  --text-primary:  #0f172a;
  --text-secondary:#475569;
  --text-muted:    #94a3b8;
  --text-inverse:  #ffffff;

  --accent:        #2e7dff;
  --accent-hover:  #1e63e0;
  --accent-light:  #e6f0ff;
  --accent-2:      #b83ce6;

  --success:       #22c55e;
  --warning:       #f59e0b;
  --danger:        #ef4444;
  --info:          #3b82f6;

  --border:        #e2e8f0;
  --border-focus:  #2e7dff;
  --shadow-sm:     0 1px 3px rgba(0,0,0,0.08);
  --shadow-md:     0 4px 16px rgba(0,0,0,0.10);
  --shadow-lg:     0 8px 32px rgba(0,0,0,0.12);

  --sidebar-width: 260px;
  --topbar-height: 56px;
  --radius-sm:     8px;
  --radius-md:     12px;
  --radius-lg:     16px;
  --radius-xl:     24px;

  --transition:    all 0.2s ease;
}

/* --- Тёмная тема (глубокий сине-графитовый, чёткие границы, читаемый текст) --- */
[data-theme="dark"] {
  --bg-primary:    #0b1120;   /* фон страницы — самый тёмный */
  --bg-secondary:  #161e2e;   /* карточки/панели */
  --bg-card:       #18212f;   /* приподнятые карточки/списки */
  --bg-tertiary:   #1f2a3c;   /* поля ввода, чипы, дорожки */
  --bg-hover:      #26324a;
  --bg-active:     #2e3e5c;

  --text-primary:  #e7edf5;   /* мягкий белый, не режет глаз */
  --text-secondary:#a4b1c4;
  --text-muted:    #748499;   /* заметно светлее прежнего — подписи читаются */
  --text-inverse:  #0b1120;

  --accent:        #4d9cff;
  --accent-hover:  #6aa9ff;
  --accent-light:  #19293f;   /* подсветка активного на тёмном */
  --accent-2:      #c56bf0;

  --success:       #34d399;
  --warning:       #fbbf24;
  --danger:        #f87171;
  --info:          #60a5fa;

  --border:        #2b3850;   /* видимые границы между поверхностями */
  --border-focus:  #4d9cff;
  --shadow-sm:     0 1px 3px rgba(0,0,0,0.4);
  --shadow-md:     0 6px 20px rgba(0,0,0,0.5);
  --shadow-lg:     0 12px 40px rgba(0,0,0,0.6);
}

/* Аккуратные точечные правки тёмной темы (где раньше «проваливалось») */
[data-theme="dark"] ::-webkit-scrollbar-thumb { background: #2b3850; }
[data-theme="dark"] ::-webkit-scrollbar-thumb:hover { background: #3b4a66; }
[data-theme="dark"] .input:focus { box-shadow: 0 0 0 3px rgba(77,156,255,0.18); }
[data-theme="dark"] img.msgr-logo { filter: none; }

/* --- Сброс и база --- */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

html { font-size: 14px; scroll-behavior: smooth; }

body {
  /* Системный шрифт Apple (San Francisco) — нативный, удобный и читабельный */
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display",
    "Helvetica Neue", "Segoe UI", Roboto, Arial, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  transition: background 0.3s ease, color 0.3s ease;
  min-height: 100vh;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  letter-spacing: -0.01em;
}

a { text-decoration: none; color: inherit; }
img { max-width: 100%; }
button { cursor: pointer; font-family: inherit; border: none; background: none; }
input, textarea, select { font-family: inherit; outline: none; }
ul, ol { list-style: none; }

/* --- Скроллбар --- */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 99px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* --- Утилиты --- */
.flex { display: flex; }
.flex-col { display: flex; flex-direction: column; }
.items-center { align-items: center; }
.justify-center { justify-content: center; }
.justify-between { justify-content: space-between; }
.gap-1 { gap: 4px; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.gap-4 { gap: 16px; }
.w-full { width: 100%; }
.h-full { height: 100%; }
.hidden { display: none !important; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* --- Кнопки --- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 20px;
  border-radius: var(--radius-md);
  font-size: 14px;
  font-weight: 500;
  transition: var(--transition);
  cursor: pointer;
  white-space: nowrap;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
}
.btn-primary:hover { background: var(--accent-hover); transform: translateY(-1px); box-shadow: var(--shadow-md); }

.btn-secondary {
  background: var(--bg-tertiary);
  color: var(--text-primary);
  border: 1px solid var(--border);
}
.btn-secondary:hover { background: var(--bg-hover); }

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
}
.btn-ghost:hover { background: var(--bg-hover); color: var(--text-primary); }

.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { opacity: 0.9; }

.btn-sm { padding: 6px 14px; font-size: 13px; }
.btn-lg { padding: 14px 28px; font-size: 15px; }
.btn-icon { padding: 8px; border-radius: var(--radius-sm); }

/* --- Инпуты --- */
.input {
  width: 100%;
  padding: 10px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg-secondary);
  color: var(--text-primary);
  font-size: 14px;
  transition: var(--transition);
}
.input:focus { border-color: var(--border-focus); box-shadow: 0 0 0 3px rgba(46,125,255,0.12); }
.input::placeholder { color: var(--text-muted); }

/* --- Карточки --- */
.card {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow-sm);
}

/* --- Бейджи --- */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 99px;
  font-size: 11px;
  font-weight: 600;
}
.badge-accent  { background: var(--accent-light); color: var(--accent); }
.badge-success { background: #dcfce7; color: #16a34a; }
.badge-warning { background: #fef3c7; color: #d97706; }
.badge-danger  { background: #fee2e2; color: #dc2626; }

[data-theme="dark"] .badge-success { background: #14532d44; color: #4ade80; }
[data-theme="dark"] .badge-warning { background: #78350f44; color: #fbbf24; }
[data-theme="dark"] .badge-danger  { background: #7f1d1d44; color: #f87171; }

/* --- Переключатель темы --- */
.theme-toggle {
  width: 40px;
  height: 22px;
  background: var(--border);
  border-radius: 99px;
  position: relative;
  cursor: pointer;
  transition: var(--transition);
  flex-shrink: 0;
}
.theme-toggle.active { background: var(--accent); }
.theme-toggle::after {
  content: '';
  position: absolute;
  width: 16px;
  height: 16px;
  background: white;
  border-radius: 50%;
  top: 3px;
  left: 3px;
  transition: var(--transition);
  box-shadow: var(--shadow-sm);
}
.theme-toggle.active::after { left: 21px; }

/* --- Аватар --- */
.avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--accent-light);
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 600;
  flex-shrink: 0;
  overflow: hidden;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar-sm { width: 28px; height: 28px; font-size: 11px; }
.avatar-lg { width: 48px; height: 48px; font-size: 16px; }

/* --- Разделитель --- */
.divider {
  height: 1px;
  background: var(--border);
  width: 100%;
  margin: 12px 0;
}

/* --- Toast уведомления --- */
#toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.toast {
  padding: 12px 18px;
  border-radius: var(--radius-md);
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
  font-size: 13px;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 260px;
  animation: toastIn 0.3s ease;
}
.toast.success { border-left: 3px solid var(--success); }
.toast.error   { border-left: 3px solid var(--danger); }
.toast.info    { border-left: 3px solid var(--info); }

@keyframes toastIn {
  from { opacity: 0; transform: translateX(20px); }
  to   { opacity: 1; transform: translateX(0); }
}

/* --- Адаптив --- */
@media (max-width: 768px) {
  :root { --sidebar-width: 0px; }
  .hide-mobile { display: none !important; }
}
@media (min-width: 769px) {
  .hide-desktop { display: none !important; }
}
