/* ============================================
   MODERN APPLE-STYLE GLASSMORPHISM THEME
   Светлая + Тёмная тема с переключателем
   ============================================ */

/* === CSS ПЕРЕМЕННЫЕ === */
:root {
  /* Светлая тема */
  --bg-primary: #f5f5f7;
  --bg-secondary: rgba(255, 255, 255, 0.72);
  --bg-card: rgba(255, 255, 255, 0.8);
  --bg-navbar: rgba(255, 255, 255, 0.72);
  --bg-modal: rgba(255, 255, 255, 0.95);

  --text-primary: #1d1d1f;
  --text-secondary: #6e6e73;
  --text-muted: #86868b;

  --border-color: rgba(0, 0, 0, 0.1);
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.08);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.12);
  --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.16);

  --accent-primary: #007aff;
  --accent-success: #34c759;
  --accent-warning: #ff9500;
  --accent-danger: #ff3b30;
  --accent-info: #5ac8fa;

  --blur-amount: 20px;
  --radius-sm: 12px;
  --radius-md: 16px;
  --radius-lg: 20px;

  --transition-fast: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-normal: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Тёмная тема */
[data-theme="dark"] {
  --bg-primary: #000000;
  --bg-secondary: rgba(28, 28, 30, 0.72);
  --bg-card: rgba(28, 28, 30, 0.8);
  --bg-navbar: rgba(28, 28, 30, 0.72);
  --bg-modal: rgba(28, 28, 30, 0.95);

  --text-primary: #f5f5f7;
  --text-secondary: #98989d;
  --text-muted: #636366;

  --border-color: rgba(255, 255, 255, 0.15);
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.5);
  --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.6);

  --accent-primary: #0a84ff;
  --accent-success: #30d158;
  --accent-warning: #ff9f0a;
  --accent-danger: #ff453a;
  --accent-info: #64d2ff;
}

/* === БАЗОВЫЕ СТИЛИ === */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'Segoe UI', Roboto,
               'Helvetica Neue', Arial, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  transition: background var(--transition-normal), color var(--transition-normal);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* === НАВБАР (ВСЕГДА ТЕМНО-СЕРЫЙ) === */
.navbar-custom {
  background: #2c3e50 !important; /* Всегда темно-серый */
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
  transition: all var(--transition-normal);
}

.navbar-custom .navbar-brand {
  color: #ffffff !important; /* Белый текст для контраста */
  font-weight: 600;
  font-size: 1.25rem;
  display: flex;
  align-items: center;
  gap: 12px;
  transition: transform var(--transition-fast);
}

.navbar-custom .navbar-brand:hover {
  transform: translateY(-2px);
}

.navbar-custom .navbar-brand img {
  max-height: 36px;
  border-radius: 8px;
  transition: transform var(--transition-fast);
}

.navbar-custom .navbar-brand:hover img {
  transform: scale(1.05);
}

.navbar-custom .nav-link {
  color: rgba(255, 255, 255, 0.8) !important; /* Светло-серый текст */
  font-weight: 500;
  padding: 8px 16px !important;
  margin: 0 4px;
  border-radius: var(--radius-sm);
  transition: all var(--transition-fast);
  position: relative;
}

.navbar-custom .nav-link:hover {
  color: #ffffff !important; /* Белый при наведении */
  background: rgba(255, 255, 255, 0.1);
  transform: translateY(-1px);
}

.navbar-custom .nav-link.active {
  color: #ffffff !important; /* Белый для активной ссылки */
  background: rgba(255, 255, 255, 0.15);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

/* === ПЕРЕКЛЮЧАТЕЛЬ ТЕМЫ === */
.theme-toggle {
  position: relative;
  width: 50px;
  height: 26px;
  background: rgba(255, 255, 255, 0.2); /* Полупрозрачный для навбара */
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 13px;
  cursor: pointer;
  transition: all var(--transition-normal);
  overflow: hidden;
  backdrop-filter: blur(10px);
}

.theme-toggle:hover {
  transform: scale(1.05);
}

.theme-toggle-slider {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 20px;
  height: 20px;
  background: var(--accent-primary);
  border-radius: 50%;
  transition: transform var(--transition-normal);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

[data-theme="dark"] .theme-toggle-slider {
  transform: translateX(24px);
}

/* === ПЕРЕКЛЮЧАТЕЛЬ ЯЗЫКА === */
.lang-switcher {
  display: flex;
  gap: 4px;
  background: rgba(255, 255, 255, 0.1);
  padding: 4px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  backdrop-filter: blur(10px);
}

.lang-btn {
  padding: 4px 10px;
  border: none;
  background: transparent;
  color: rgba(255, 255, 255, 0.7);
  border-radius: 6px;
  cursor: pointer;
  font-weight: 600;
  font-size: 0.75rem;
  transition: all 0.2s ease;
  text-transform: uppercase;
}

.lang-btn:hover {
  background: rgba(255, 255, 255, 0.15);
  color: rgba(255, 255, 255, 0.9);
}

.lang-btn.active {
  background: rgba(255, 255, 255, 0.25);
  color: #ffffff;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

/* === КОНТЕЙНЕР === */
.container {
  margin-top: 32px;
  margin-bottom: 32px;
}

/* === КАРТОЧКИ (GLASSMORPHISM) === */
.card {
  background: var(--bg-card) !important;
  backdrop-filter: blur(var(--blur-amount)) saturate(180%);
  -webkit-backdrop-filter: blur(var(--blur-amount)) saturate(180%);
  border: 1px solid var(--border-color) !important;
  border-radius: var(--radius-md) !important;
  box-shadow: var(--shadow-md) !important;
  transition: all var(--transition-normal);
  overflow: hidden;
}

.card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg) !important;
}

.card-header {
  background: var(--bg-card) !important;
  border-bottom: 1px solid var(--border-color) !important;
  color: var(--text-primary) !important;
  font-weight: 600;
  font-size: 1.1rem;
  padding: 20px 24px;
  border-radius: var(--radius-md) var(--radius-md) 0 0 !important;
}

.card-body {
  padding: 24px;
}

/* === ТАБЛИЦЫ === */
.table {
  color: var(--text-primary);
  border-color: var(--border-color) !important;
}

.table thead th {
  background: var(--bg-secondary) !important;
  color: var(--text-primary) !important;
  font-weight: 600;
  font-size: 0.875rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-color: var(--border-color) !important;
  padding: 16px 12px;
  backdrop-filter: blur(10px);
}

.table tbody tr {
  transition: all var(--transition-fast);
  border-color: var(--border-color) !important;
}

.table tbody tr:hover {
  background: rgba(128, 128, 128, 0.05) !important;
  transform: scale(1.005);
}

.table tbody td {
  padding: 14px 12px;
  vertical-align: middle;
  border-color: var(--border-color) !important;
  color: var(--text-secondary);
}

.table-striped tbody tr:nth-of-type(odd) {
  background: rgba(128, 128, 128, 0.02);
}

/* Закреплённые строки */
.table tbody tr[style*="background-color: #e6f0ff"] {
  background: rgba(0, 122, 255, 0.08) !important;
  border-left: 3px solid var(--accent-primary);
}

[data-theme="dark"] .table tbody tr[style*="background-color: #e6f0ff"] {
  background: rgba(10, 132, 255, 0.15) !important;
}

/* === КНОПКИ === */
.btn {
  font-weight: 500;
  border-radius: var(--radius-sm);
  padding: 10px 20px;
  border: none;
  transition: all var(--transition-fast);
  backdrop-filter: blur(10px);
  font-size: 0.875rem;
  letter-spacing: 0.2px;
}

.btn:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.btn:active {
  transform: translateY(0);
}

.btn-primary {
  background: var(--accent-primary) !important;
  color: white !important;
  border: none !important;
}

.btn-primary:hover {
  background: color-mix(in srgb, var(--accent-primary) 90%, black) !important;
  box-shadow: 0 4px 12px rgba(0, 122, 255, 0.3);
}

.btn-success {
  background: var(--accent-success) !important;
  color: white !important;
}

.btn-success:hover {
  background: color-mix(in srgb, var(--accent-success) 90%, black) !important;
  box-shadow: 0 4px 12px rgba(52, 199, 89, 0.3);
}

.btn-danger {
  background: var(--accent-danger) !important;
  color: white !important;
}

.btn-danger:hover {
  background: color-mix(in srgb, var(--accent-danger) 90%, black) !important;
  box-shadow: 0 4px 12px rgba(255, 59, 48, 0.3);
}

.btn-warning {
  background: var(--accent-warning) !important;
  color: white !important;
}

.btn-warning:hover {
  background: color-mix(in srgb, var(--accent-warning) 90%, black) !important;
  box-shadow: 0 4px 12px rgba(255, 149, 0, 0.3);
}

.btn-info {
  background: var(--accent-info) !important;
  color: white !important;
}

.btn-info:hover {
  background: color-mix(in srgb, var(--accent-info) 90%, black) !important;
  box-shadow: 0 4px 12px rgba(90, 200, 250, 0.3);
}

.btn-secondary {
  background: var(--bg-secondary) !important;
  color: var(--text-primary) !important;
  border: 1px solid var(--border-color) !important;
}

.btn-outline-primary,
.btn-outline-secondary,
.btn-outline-info,
.btn-outline-success,
.btn-outline-warning,
.btn-outline-danger {
  background: transparent !important;
  border: 1.5px solid currentColor !important;
  backdrop-filter: blur(10px);
}

.btn-outline-primary {
  color: var(--accent-primary) !important;
}

.btn-outline-primary:hover {
  background: rgba(0, 122, 255, 0.1) !important;
  color: var(--accent-primary) !important;
}

.btn-sm {
  padding: 6px 12px;
  font-size: 0.8rem;
  border-radius: 8px;
}

.btn-lg {
  padding: 14px 28px;
  font-size: 1rem;
  border-radius: 14px;
}

/* === БЕЙДЖИ === */
.badge {
  font-weight: 600;
  padding: 8px 14px;
  border-radius: 8px;
  font-size: 0.875rem;
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.badge.bg-success {
  background: rgba(52, 199, 89, 0.2) !important;
  color: var(--accent-success) !important;
  border-color: var(--accent-success);
}

.badge.bg-danger {
  background: rgba(255, 59, 48, 0.2) !important;
  color: var(--accent-danger) !important;
  border-color: var(--accent-danger);
}

.badge.bg-primary {
  background: rgba(0, 122, 255, 0.2) !important;
  color: var(--accent-primary) !important;
  border-color: var(--accent-primary);
}

.badge.bg-secondary {
  background: rgba(128, 128, 128, 0.2) !important;
  color: var(--text-secondary) !important;
  border-color: var(--border-color);
}

/* === ФОРМЫ === */
.form-control,
.form-select {
  background: var(--bg-card) !important;
  border: 1px solid var(--border-color) !important;
  color: var(--text-primary) !important;
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  transition: all var(--transition-fast);
  backdrop-filter: blur(10px);
}

.form-control:focus,
.form-select:focus {
  background: var(--bg-card) !important;
  border-color: var(--accent-primary) !important;
  box-shadow: 0 0 0 3px rgba(0, 122, 255, 0.1) !important;
  transform: translateY(-1px);
}

.form-label {
  color: var(--text-primary);
  font-weight: 500;
  margin-bottom: 8px;
  font-size: 0.875rem;
}

/* === МОДАЛЬНЫЕ ОКНА === */
.modal-content {
  background: var(--bg-modal) !important;
  backdrop-filter: blur(var(--blur-amount)) saturate(180%);
  -webkit-backdrop-filter: blur(var(--blur-amount)) saturate(180%);
  border: 1px solid var(--border-color) !important;
  border-radius: var(--radius-lg) !important;
  box-shadow: var(--shadow-lg) !important;
  color: var(--text-primary);
}

.modal-header {
  border-bottom: 1px solid var(--border-color) !important;
  padding: 24px;
}

.modal-title {
  color: var(--text-primary);
  font-weight: 600;
}

.modal-body {
  padding: 24px;
  color: var(--text-secondary);
}

.modal-footer {
  border-top: 1px solid var(--border-color) !important;
  padding: 20px 24px;
}

.modal-backdrop {
  backdrop-filter: blur(5px);
}

/* === АЛЕРТЫ === */
.alert {
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  backdrop-filter: blur(10px);
  padding: 16px 20px;
}

.alert-info {
  background: rgba(90, 200, 250, 0.15) !important;
  color: var(--text-primary) !important;
  border-color: var(--accent-info);
}

.alert-warning {
  background: rgba(255, 149, 0, 0.15) !important;
  color: var(--text-primary) !important;
  border-color: var(--accent-warning);
}

.alert-danger {
  background: rgba(255, 59, 48, 0.15) !important;
  color: var(--text-primary) !important;
  border-color: var(--accent-danger);
}

.alert-success {
  background: rgba(52, 199, 89, 0.15) !important;
  color: var(--text-primary) !important;
  border-color: var(--accent-success);
}

/* === ЗАМЕТКИ === */
.notes-cell {
  background: rgba(255, 248, 220, 0.3) !important;
  border: 1px solid var(--border-color) !important;
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  transition: all var(--transition-fast);
  backdrop-filter: blur(5px);
}

[data-theme="dark"] .notes-cell {
  background: rgba(255, 248, 220, 0.08) !important;
}

.notes-cell:focus {
  background: rgba(255, 248, 220, 0.5) !important;
  border-color: var(--accent-primary) !important;
  box-shadow: 0 0 0 3px rgba(0, 122, 255, 0.1);
}

.emoji-btn {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  backdrop-filter: blur(10px);
  transition: all var(--transition-fast);
}

.emoji-btn:hover {
  transform: scale(1.1);
  box-shadow: var(--shadow-sm);
}

.emoji-picker {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-lg);
  backdrop-filter: blur(var(--blur-amount));
}

/* === ВКЛАДКИ === */
.nav-tabs {
  border-bottom: 1px solid var(--border-color);
}

.nav-tabs .nav-link {
  color: var(--text-secondary);
  border: none;
  border-bottom: 2px solid transparent;
  transition: all var(--transition-fast);
  font-weight: 500;
}

.nav-tabs .nav-link:hover {
  color: var(--text-primary);
  border-bottom-color: var(--border-color);
}

.nav-tabs .nav-link.active {
  color: var(--accent-primary) !important;
  background: transparent !important;
  border-bottom-color: var(--accent-primary) !important;
}

/* === ХЛЕБНЫЕ КРОШКИ === */
.breadcrumb {
  background: var(--bg-card);
  backdrop-filter: blur(10px);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
}

.breadcrumb-item {
  color: var(--text-secondary);
}

.breadcrumb-item.active {
  color: var(--text-primary);
  font-weight: 500;
}

.breadcrumb-item a {
  color: var(--accent-primary);
  text-decoration: none;
  transition: all var(--transition-fast);
}

.breadcrumb-item a:hover {
  color: color-mix(in srgb, var(--accent-primary) 80%, black);
  text-decoration: underline;
}

/* === СПИННЕРЫ === */
.spinner-border {
  border-color: var(--accent-primary);
  border-right-color: transparent;
}

/* === SCROLLBAR === */
::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

::-webkit-scrollbar-track {
  background: var(--bg-primary);
}

::-webkit-scrollbar-thumb {
  background: var(--text-muted);
  border-radius: 5px;
  transition: all var(--transition-fast);
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-secondary);
}

/* === АНИМАЦИИ === */
@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ОТКЛЮЧЕНО: вызывало проблемы с видимостью таблицы */
/* .card {
  animation: fadeIn 0.4s ease-out;
} */

/* ФИКС: Убедимся что все элементы видны */
.card,
.card-body {
  opacity: 1 !important;
  visibility: visible !important;
}

table,
.table {
  opacity: 1 !important;
  visibility: visible !important;
  display: table !important;
}

table thead {
  display: table-header-group !important;
}

table tbody {
  display: table-row-group !important;
}

tr {
  display: table-row !important;
}

td, th {
  display: table-cell !important;
}

/* === RESPONSIVE === */
@media (max-width: 768px) {
  .navbar-custom .nav-link {
    padding: 12px 16px !important;
  }

  .card-body {
    padding: 16px;
  }

  .container {
    margin-top: 20px;
  }

  .btn {
    font-size: 0.8rem;
  }
}

/* === ДОПОЛНИТЕЛЬНЫЕ УТИЛИТЫ === */
.text-primary {
  color: var(--text-primary) !important;
}

.text-secondary {
  color: var(--text-secondary) !important;
}

.text-muted {
  color: var(--text-muted) !important;
}

.bg-primary-custom {
  background: var(--bg-primary) !important;
}

.bg-secondary-custom {
  background: var(--bg-secondary) !important;
}

.border-custom {
  border-color: var(--border-color) !important;
}

/* === LIST GROUP === */
.list-group-item {
  background: var(--bg-card) !important;
  border: 1px solid var(--border-color) !important;
  color: var(--text-primary);
  transition: all var(--transition-fast);
  backdrop-filter: blur(10px);
}

.list-group-item:hover {
  background: rgba(128, 128, 128, 0.05) !important;
  transform: translateX(4px);
}

.list-group-item a {
  color: var(--accent-primary);
  text-decoration: none;
  transition: color var(--transition-fast);
}

.list-group-item a:hover {
  color: color-mix(in srgb, var(--accent-primary) 80%, black);
}

/* === CHECKBOX & SWITCH === */
.form-check-input {
  background-color: var(--bg-card);
  border-color: var(--border-color);
  transition: all var(--transition-fast);
}

.form-check-input:checked {
  background-color: var(--accent-primary);
  border-color: var(--accent-primary);
}

.form-check-input:focus {
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 3px rgba(0, 122, 255, 0.15);
}

/* === DROPDOWN === */
.dropdown-menu {
  background: var(--bg-modal) !important;
  backdrop-filter: blur(var(--blur-amount)) saturate(180%);
  border: 1px solid var(--border-color) !important;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  padding: 8px;
}

.dropdown-item {
  color: var(--text-primary);
  border-radius: 8px;
  padding: 10px 16px;
  transition: all var(--transition-fast);
}

.dropdown-item:hover {
  background: rgba(128, 128, 128, 0.1) !important;
  color: var(--text-primary);
}

/* === УЛУЧШЕННАЯ АНИМАЦИЯ ПОЯВЛЕНИЯ === */
.modal.fade .modal-dialog {
  transition: transform 0.3s ease-out, opacity 0.3s ease-out;
}

.modal.show .modal-dialog {
  transform: scale(1) translateY(0);
}
