/* ============================================
   PARALLEL LIFE — STYLES
   CSS-переменные, темы, анимации, компоненты
   ============================================ */

/* --- CSS-переменные по умолчанию (переопределяются из JS) --- */
:root {
  --bg: #0f172a;
  --surface: #1e293b;
  --surface-2: #334155;
  --accent: #38bdf8;
  --accent-hover: #7dd3fc;
  --text: #e2e8f0;
  --text-muted: #94a3b8;
  --danger: #f87171;
  --danger-hover: #fca5a5;
  --success: #4ade80;
  --warning: #fbbf24;
  --border: #475569;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 4px 24px rgba(0,0,0,0.3);
  --transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* --- Админская тема (тёмно-красный акцент) --- */
:root.theme-admin {
  --bg: #1a0a0a;
  --surface: #2d1212;
  --surface-2: #3d1c1c;
  --accent: #ef4444;
  --accent-hover: #f87171;
  --text: #fde2e2;
  --text-muted: #fca5a5;
  --border: #5c2020;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  transition: background var(--transition), color var(--transition);
  line-height: 1.6;
}

/* --- Анимации --- */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20%      { transform: translateX(-6px); }
  40%      { transform: translateX(6px); }
  60%      { transform: translateX(-4px); }
  80%      { transform: translateX(4px); }
}

@keyframes slideDown {
  from { opacity: 0; max-height: 0; }
  to   { opacity: 1; max-height: 500px; }
}

@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50%      { transform: scale(1.05); }
}

.fade-in {
  animation: fadeIn 0.4s ease-out;
}

.shake {
  animation: shake 0.4s ease-out;
}

/* --- Контейнер приложения --- */
#app {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 1rem;
}

/* --- Шапка --- */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: 2rem;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.header__brand {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: -0.02em;
}

.header__user {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 0.9rem;
  color: var(--text-muted);
}

.header__role-badge {
  display: inline-block;
  padding: 0.2rem 0.6rem;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.header__role-badge--admin {
  background: var(--danger);
  color: #fff;
}

.header__role-badge--user {
  background: var(--accent);
  color: var(--bg);
}

.btn-logout {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-muted);
  padding: 0.4rem 0.8rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 0.8rem;
  transition: all var(--transition);
}

.btn-logout:hover {
  border-color: var(--danger);
  color: var(--danger);
}

/* --- Форма входа --- */
.login-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 2rem 1rem;
}

.login-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 2.5rem 2rem;
  width: 100%;
  max-width: 420px;
  box-shadow: var(--shadow);
}

.login-card__title {
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 0.25rem;
  color: var(--accent);
}

.login-card__subtitle {
  font-size: 0.9rem;
  color: var(--text-muted);
  margin-bottom: 2rem;
}

.form-group {
  margin-bottom: 1.25rem;
}

.form-group label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 0.4rem;
  color: var(--text-muted);
}

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 0.7rem 1rem;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--text);
  font-size: 1rem;
  transition: border-color var(--transition), box-shadow var(--transition);
  outline: none;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.15);
}

.form-group input.input-error {
  border-color: var(--danger);
  box-shadow: 0 0 0 3px rgba(248, 113, 113, 0.2);
}

.form-group .error-text {
  font-size: 0.8rem;
  color: var(--danger);
  margin-top: 0.3rem;
  min-height: 1.2rem;
}

.btn-primary {
  width: 100%;
  padding: 0.75rem;
  background: var(--accent);
  color: var(--bg);
  border: none;
  border-radius: var(--radius-sm);
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  transition: all var(--transition);
}

.btn-primary:hover {
  background: var(--accent-hover);
  transform: translateY(-1px);
}

.btn-primary:active {
  transform: translateY(0);
}

/* --- Быстрое переключение --- */
.switch-bar {
  margin-top: 2rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
}

.switch-bar__title {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.switch-bar__list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.switch-btn {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.9rem;
  background: var(--bg);
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  cursor: pointer;
  font-size: 0.85rem;
  transition: all var(--transition);
}

.switch-btn:hover {
  border-color: var(--accent);
  background: var(--surface);
}

.switch-btn__avatar {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  flex-shrink: 0;
}

/* --- Основной контент (User) --- */
.main-content {
  padding-bottom: 3rem;
}

.tabs {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 2rem;
  border-bottom: 2px solid var(--border);
  padding-bottom: 0;
}

.tab-btn {
  padding: 0.6rem 1.2rem;
  background: transparent;
  border: none;
  border-bottom: 3px solid transparent;
  color: var(--text-muted);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
  margin-bottom: -2px;
}

.tab-btn:hover {
  color: var(--text);
}

.tab-btn.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

/* --- Виджеты --- */
.widgets-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1.25rem;
}

.widget {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: var(--shadow);
  transition: transform var(--transition), box-shadow var(--transition);
  border: 1px solid var(--border);
}

.widget:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 32px rgba(0,0,0,0.4);
}

.widget__header {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-bottom: 1rem;
}

.widget__icon {
  font-size: 1.4rem;
}

.widget__title {
  font-size: 1rem;
  font-weight: 700;
}

.widget__content {
  font-size: 0.9rem;
  color: var(--text-muted);
}

.widget__content input,
.widget__content textarea {
  width: 100%;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--text);
  font-size: 0.9rem;
  margin-bottom: 0.5rem;
  outline: none;
  transition: border-color var(--transition);
}

.widget__content input:focus,
.widget__content textarea:focus {
  border-color: var(--accent);
}

.widget__content textarea {
  resize: vertical;
  min-height: 60px;
  font-family: inherit;
}

/* --- Таймер --- */
.timer-display {
  font-size: 2.5rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--accent);
  text-align: center;
  margin: 0.5rem 0;
  letter-spacing: 0.05em;
}

.timer-buttons {
  display: flex;
  gap: 0.5rem;
  justify-content: center;
}

.timer-buttons button {
  padding: 0.4rem 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--text);
  cursor: pointer;
  font-size: 0.85rem;
  transition: all var(--transition);
}

.timer-buttons button:hover {
  border-color: var(--accent);
  color: var(--accent);
}

/* --- Todo --- */
.todo-list {
  list-style: none;
}

.todo-item {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.9rem;
}

.todo-item:last-child {
  border-bottom: none;
}

.todo-item input[type="checkbox"] {
  accent-color: var(--accent);
  width: 18px;
  height: 18px;
  cursor: pointer;
}

.todo-item.done span {
  text-decoration: line-through;
  color: var(--text-muted);
}

.todo-add {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.75rem;
}

.todo-add input {
  flex: 1;
}

.todo-add button {
  padding: 0.4rem 0.8rem;
  background: var(--accent);
  color: var(--bg);
  border: none;
  border-radius: var(--radius-sm);
  font-weight: 700;
  cursor: pointer;
  font-size: 0.85rem;
  transition: background var(--transition);
}

.todo-add button:hover {
  background: var(--accent-hover);
}

/* --- Заметки --- */
.notes-area {
  width: 100%;
  min-height: 120px;
  resize: vertical;
}

/* --- Погода --- */
.weather-big {
  text-align: center;
  padding: 1rem 0;
}

.weather-temp {
  font-size: 3rem;
  font-weight: 700;
  color: var(--accent);
}

.weather-desc {
  font-size: 0.95rem;
  margin-top: 0.25rem;
}

/* --- Страница "О себе" --- */
.profile-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 2rem;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  max-width: 600px;
}

.profile-card__avatar {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  margin-bottom: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  font-weight: 700;
  color: var(--bg);
}

.profile-card__name {
  font-size: 1.3rem;
  font-weight: 700;
  margin-bottom: 0.25rem;
}

.profile-card__role {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 1rem;
}

.profile-form {
  margin-top: 1.5rem;
}

.profile-form .form-group {
  margin-bottom: 1rem;
}

/* --- История --- */
.history-list {
  list-style: none;
  max-width: 600px;
}

.history-item {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.9rem;
}

.history-item:last-child {
  border-bottom: none;
}

.history-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  margin-top: 0.4rem;
  flex-shrink: 0;
}

.history-detail {
  color: var(--text);
}

.history-time {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 0.15rem;
}

/* --- Заглушка пустого состояния --- */
.empty-state {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--text-muted);
}

.empty-state__icon {
  font-size: 3rem;
  margin-bottom: 1rem;
}

.empty-state__text {
  font-size: 1rem;
}

/* --- Админ-панель --- */
.admin-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1rem;
  margin-bottom: 2rem;
}

.stat-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 1.25rem;
  text-align: center;
  border: 1px solid var(--border);
}

.stat-card__value {
  font-size: 2rem;
  font-weight: 700;
  color: var(--accent);
}

.stat-card__label {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 0.25rem;
}

/* --- Таблица пользователей --- */
.users-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border);
}

.users-table th {
  text-align: left;
  padding: 0.85rem 1rem;
  background: var(--surface-2);
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  white-space: nowrap;
}

.users-table td {
  padding: 0.75rem 1rem;
  border-top: 1px solid var(--border);
  font-size: 0.9rem;
  vertical-align: middle;
}

.users-table tr:hover td {
  background: rgba(255,255,255,0.02);
}

.status-badge {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  border-radius: 12px;
  font-size: 0.75rem;
  font-weight: 600;
}

.status-badge--active {
  background: rgba(74, 222, 128, 0.15);
  color: var(--success);
}

.status-badge--blocked {
  background: rgba(248, 113, 113, 0.15);
  color: var(--danger);
}

.status-badge--admin {
  background: rgba(251, 191, 36, 0.15);
  color: var(--warning);
}

.admin-actions {
  display: flex;
  gap: 0.35rem;
  flex-wrap: wrap;
}

.btn-sm {
  padding: 0.3rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: transparent;
  color: var(--text-muted);
  font-size: 0.75rem;
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
}

.btn-sm:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.btn-sm--danger:hover {
  border-color: var(--danger);
  color: var(--danger);
}

.btn-sm--warning:hover {
  border-color: var(--warning);
  color: var(--warning);
}

/* --- Модальное окно (история в админке) --- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 1rem;
}

.modal {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 2rem;
  max-width: 600px;
  width: 100%;
  max-height: 80vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0,0,0,0.5);
  border: 1px solid var(--border);
}

.modal__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
}

.modal__title {
  font-size: 1.1rem;
  font-weight: 700;
}

.modal__close {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 1.5rem;
  cursor: pointer;
  padding: 0.25rem;
  line-height: 1;
  transition: color var(--transition);
}

.modal__close:hover {
  color: var(--danger);
}

/* --- Адаптив --- */
@media (max-width: 700px) {
  .header {
    flex-direction: column;
    align-items: flex-start;
  }

  .users-table {
    font-size: 0.8rem;
  }

  .users-table th,
  .users-table td {
    padding: 0.6rem 0.5rem;
  }

  .widgets-grid {
    grid-template-columns: 1fr;
  }

  .timer-display {
    font-size: 2rem;
  }
}

/* --- Адаптив таблицы для скролла --- */
.table-wrapper {
  overflow-x: auto;
  border-radius: var(--radius);
  margin-bottom: 2rem;
}

/* --- Уведомление-тост --- */
.toast {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  padding: 0.75rem 1.25rem;
  background: var(--surface-2);
  color: var(--text);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  box-shadow: 0 8px 32px rgba(0,0,0,0.4);
  font-size: 0.9rem;
  z-index: 2000;
  animation: fadeIn 0.3s ease-out;
}

.toast--success { border-left: 4px solid var(--success); }
.toast--danger  { border-left: 4px solid var(--danger); }
.toast--info    { border-left: 4px solid var(--accent); }
