:root {
  --bg-light: #f3f4f6;
  --bg-dark: #1f2937;
  --text-light: #1f2937;
  --text-dark: #f3f4f6;
  --card-bg-light: #ffffff;
  --card-bg-dark: #374151;
  --sidebar-bg-light: #e5e7eb;
  --sidebar-bg-dark: #1f2937;
  --button-bg-light: #3b82f6;
  --button-bg-dark: #60a5fa;
  --button-text-light: #ffffff;
  --button-text-dark: #ffffff;
  --table-header-light: #f9fafb;
  --table-header-dark: #4b5563;
}

body {
  font-family: 'Arial', sans-serif;
  background: linear-gradient(135deg, var(--bg-light), #dbeafe);
  color: var(--text-light);
  transition: background 0.3s ease, color 0.3s ease;
  margin: 0; /* Убираем отступы по умолчанию */
  min-height: 100vh;
}

/* Тёмная тема */
.dark body {
  background: linear-gradient(315deg, rgb(13, 32, 70), rgb(55, 76, 126));
  color: var(--text-dark);
}

/* Убираем конфликтующие стили */
.bg-white {
  background-color: #ffffff;
}

.dark .bg-white {
  background-color: #1f2937; /* gray-800 */
}

/* Боковое меню */
#sidebar {
  position: fixed !important;
  top: 0 !important;
  bottom: 0 !important;
  left: 0 !important;
  width: 16rem !important; /* 256px */
  height: 100vh !important;
  z-index: 1000 !important;
  background-color: var(--sidebar-bg-light);
  box-shadow: 4px 0 15px rgba(0, 0, 0, 0.15);
  transition: transform 0.3s ease-in-out !important;
}

#sidebar .p-4 {
  height: 100% !important;
  display: flex !important;
  flex-direction: column !important;
  padding: 1.5rem !important;
}

#sidebar nav {
  flex: 1 !important;
  display: flex !important;
  flex-direction: column !important;
}

.dark #sidebar {
  background-color: var(--sidebar-bg-dark);
}

/* Вручную компенсируем недостающие классы Tailwind */
.-translate-x-full {
  transform: translateX(-100%) !important;
}

/* Плавный и разумный сдвиг всей страницы на десктопе при открытом меню */
@media (min-width: 769px) {
  body {
    transition: padding-left 0.3s ease-in-out !important;
  }
  .sidebar-open {
    padding-left: 16rem !important;
  }
}

#menu-toggle {
  transition: transform 0.2s;
}

#menu-toggle:hover {
  transform: scale(1.1);
}

/* Базовые стили карточки */
.card {
  padding: 1.5rem;
  background-color: var(--card-bg-light);
  border-radius: 0.5rem;
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
  width: 100%;
  max-width: 400px; /* Компактный размер для форм */
  transition: all 0.3s ease-in-out;
}

.dark .card {
  background-color: var(--card-bg-dark);
}

/* Карточка аналитики */
.card-container .card {
  max-width: none; /* Полная ширина для аналитики */
}

/* Карточка админки */
.admin-card {
  width: 100%;
  max-width: 48rem; /* 768px для таблиц в админке */
  background-color: var(--card-bg-light);
  animation: fadeIn 0.5s ease-in;
}

.dark .admin-card {
  background-color: var(--card-bg-dark);
}

/* Сдвиг при открытой панели больше не нужен, так как сдвигается весь body */

/* Заголовок таблицы */
thead {
  background-color: #e5e7eb; /* bg-gray-200 */
  position: sticky;
  top: 0;
  z-index: 10;
  transition: background-color 0.3s ease;
}

.dark thead {
  background-color: #374151; /* bg-gray-700 */
}

/* Таблицы */
#targets-table {
  width: 100%;
  overflow-x: hidden;
}

#targets-table table {
  width: 100%;
  table-layout: fixed;
}

#targets-table th,
#targets-table td {
  padding: 0.75rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Настраиваем ширину колонок */
#targets-table th:first-child,
#targets-table td:first-child {
  width: 20%;
}

#targets-table th:last-child,
#targets-table td:last-child {
  width: 10%;
}

#targets-table th:nth-child(2),
#targets-table td:nth-child(2),
#targets-table th:nth-child(3),
#targets-table td:nth-child(3),
#targets-table th:nth-child(4),
#targets-table td:nth-child(4) {
  width: 15%;
}

#targets-table th:nth-child(5),
#targets-table td:nth-child(5),
#targets-table th:nth-child(6),
#targets-table td:nth-child(6) {
  width: 12.5%;
}

/* Адаптивность */
@media (max-width: 768px) {
  .card {
    padding: 1rem;
  }

  .sidebar-open .card {
    margin-left: 0; /* Отключаем сдвиг на мобильных */
  }

  #targets-table th:nth-child(5),
  #targets-table td:nth-child(5),
  #targets-table th:nth-child(6),
  #targets-table td:nth-child(6) {
    display: none;
  }
  
  #targets-table th,
  #targets-table td {
    width: 20%;
    font-size: 0.875rem;
    padding: 0.5rem;
  }

  #targets-table th:first-child,
  #targets-table td:first-child {
    width: 30%;
  }

  #targets-table th:last-child,
  #targets-table td:last-child {
    width: 15%;
  }
}

/* Анимация появления */
@keyframes fadeIn {
  from { 
    opacity: 0; 
    transform: translateY(10px); 
  }
  to { 
    opacity: 1; 
    transform: translateY(0); 
  }
}

/* Тёмная тема для текста */
.dark .text-gray-600 {
  color: #d1d5db;
}

.dark .text-gray-800 {
  color: #f3f4f6;
}

/* Выпадающий список */
select {
  background-color: #ffffff;
  border: 1px solid #d1d5db;
  color: #374151;
}

.dark select {
  background-color: #4b5563;
  border-color: #6b7280;
  color: #e5e7eb;
}

/* Дополнительные стили для таблиц */
.table-container {
  margin-bottom: 2rem;
  border-radius: 0.5rem;
  overflow: hidden;
}

.table-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
}

.table-title {
  font-size: 1.25rem;
  font-weight: 600;
}

/* Стили для кнопок действий */
.action-button {
  padding: 0.5rem;
  border-radius: 0.25rem;
  transition: all 0.2s;
}

.edit-button {
  color: #3b82f6;
}

.edit-button:hover {
  color: #2563eb;
}

.delete-button {
  color: #ef4444;
}

.delete-button:hover {
  color: #dc2626;
}

/* Стили для статистических показателей */
.stat-value {
  font-size: 1.25rem;
  font-weight: 600;
  color: #3b82f6;
}

.dark .stat-value {
  color: #60a5fa;
}

.stat-label {
  font-size: 0.875rem;
  color: #6b7280;
}

.dark .stat-label {
  color: #9ca3af;
}

/* Тёмная тема для текста */
.dark .text-gray-700 {
  color: #e5e7eb;
}

/* Таблицы в тёмной теме */
.dark table {
  border-color: #4b5563;
  color: var(--text-dark);
}

/* Поля ввода в тёмной теме */
.dark input {
  background-color: #4b5563;
  color: #e5e7eb;
  border-color: #6b7280;
}

.dark input::placeholder {
  color: #9ca3af;
}

.dark button {
  background-color: #3b82f6;
}

.dark button:hover {
  background-color: #2563eb;
}

button:hover {
  transform: scale(1.05);
  transition: transform 0.2s;
}

/* Убираем синее выделение для иконки темы */
.dark #theme-icon {
  filter: brightness(1.2);
  background-color: transparent !important;
  outline: none;
}

/* Увеличиваем иконки на 33.303% (было w-6 h-6 = 24px, станет ~32px) */
#theme-icon {
  width: 32px;
  height: 32px;
  transition: all 0.3s ease;
  filter: none;
  background-color: transparent !important;
  outline: none;
  user-select: none;
}

.nav-sidebar i {
  font-size: 1.5rem;
}

/* Боковая навигация */
.nav-sidebar {
  background-color: #e5e7eb;
  width: 4rem;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding-top: 1rem;
  padding-bottom: 1rem;
  position: fixed;
  height: 100%;
}

.dark .nav-sidebar {
  background-color: #1f2937;
}

.nav-sidebar a {
  margin-bottom: 1rem;
  color: #374151;
  transition: color 0.15s ease-in-out;
}

.dark .nav-sidebar a {
  color: #ffffff;
}

.nav-sidebar a:hover {
  color: #3b82f6;
}

.dark .nav-sidebar a:hover {
  color: #93c5fd;
}

.nav-sidebar a.active {
  color: #3b82f6;
}

.dark .nav-sidebar a.active {
  color: #93c5fd;
}

/* Упрощенная навигация для страниц входа/регистрации */
.login-nav, .register-nav {
  width: 64px;
}

.main-content {
  flex: 1 1 0%;
  margin-left: 4rem;
}

/* Основная структура */
main {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 100vh; /* Полная высота экрана */
  padding: 1rem;
  margin-left: 4rem; /* Учитываем боковую панель */
}

/* Убираем выделение кнопок в админке */
.dark .text-blue-500, .dark .text-red-500 {
  background-color: transparent !important;
  color: #60a5fa !important;
}
.dark .text-blue-500:hover, .dark .text-red-500:hover {
  color: #93c5fd !important;
  text-decoration: underline;
}

/* Кнопка темы */
#theme-toggle {
  background-color: transparent !important;
  border: none;
  padding: 0.5rem;
  border-radius: 0.5rem;
  transition: transform 0.2s ease;
}

#theme-toggle:hover {
  transform: scale(1.1);
}

/* Стили для модальных окон в тёмной теме */
.dark .modal {
  background-color: var(--bg-dark);
  color: var(--text-dark);
}

/* Убираем выделение и копирование для иконок */
.fas, .fa-solid {
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;
  pointer-events: none;
}

/* Разрешаем события для иконок внутри кнопок и ссылок */
button .fas,
a .fas,
button .fa-solid,
a .fa-solid {
  pointer-events: auto;
}

/* Контейнеры и карточки */
.overflow-x-auto {
  background-color: #ffffff;
  transition: background-color 0.3s ease;
  border-radius: 0.5rem;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.dark .overflow-x-auto {
  background-color: #1f2937;
}

/* Контейнер карточки */
.card-container {
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 1rem;
  transition: margin-left 0.3s ease-in-out;
}

/* Сдвиг при открытой панели больше не нужен, так как сдвигается весь body */

@media (max-width: 768px) {
  .card-container {
    padding: 0 0.5rem;
  }
}

/* Позиционирование иконки темы */
.theme-toggle-container {
  position: fixed;
  top: 1rem;
  right: 1rem;
  z-index: 60; /* Выше сайдбара (z-50) */
}

#theme-toggle {
  background-color: transparent !important;
  border: none;
  padding: 0.5rem;
  border-radius: 0.5rem;
  transition: transform 0.2s ease;
}

#theme-toggle:hover {
  transform: scale(1.1);
}

#theme-icon {
  width: 32px;
  height: 32px;
  transition: all 0.3s ease;
  filter: none;
  background-color: transparent !important;
  outline: none;
  user-select: none;
}

.dark #theme-icon {
  filter: brightness(1.2);
} 