/* 📋 ГРАФИК ДЕЖУРСТВ - СТИЛИ + ТЕМНАЯ ТЕМА */

/* ✅ CSS ПЕРЕМЕННЫЕ */
:root {
  --gradient-primary: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  --gradient-primary-dark: linear-gradient(135deg, #1e3c72 0%, #2a5298 100%);
  --gradient-dark: linear-gradient(135deg, #0d1b2a 0%, #1b263b 100%);
  --gradient-dark-nav: linear-gradient(135deg, #4a5568 0%, #2d3748 100%);
  --shadow-light: 0 2px 10px rgba(0,0,0,0.1);
  --shadow-hover: 0 4px 20px rgba(0,0,0,0.2);
  --shadow-panel: 0 4px 20px rgba(0,0,0,0.3);
}

.loading {
  position: relative;
  opacity: 0.7;
}

.loading::after {
  content: '';
  position: absolute;
  top: 50%; left: 50%;
  width: 24px; height: 24px;
  margin: -12px 0 0 -12px;
  border: 2px solid #f3f3f3;
  border-top: 2px solid #667eea;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* БАЗОВЫЕ СТИЛИ */
body { 
  padding-top: 70px; 
  transition: background-color 0.3s ease, color 0.3s ease;
}
tbody {
    transition: padding-top 0.2s ease;
}

.admin-row:hover {
    background-color: #f8f9ff !important;
}

[data-bs-theme="dark"] body {
  background-color: #121212 !important;
  color: #e0e0e0 !important;
}

/* НАВИГАЦИЯ */
.navbar-dark {
  background: var(--gradient-primary-dark) !important;
}

[data-bs-theme="dark"] .navbar-dark {
  background: var(--gradient-dark-nav) !important;
}

/* ОСНОВНЫЕ ТАБЛИЦЫ */
.table {
  --bs-table-bg: #f8f9fa;
  --bs-table-color: #212529;
}

[data-bs-theme="dark"] .table {
  --bs-table-bg: #2d2d2d;
  --bs-table-color: #e0e0e0;
  --bs-table-border-color: #444;
}

.table-light {
  --bs-table-bg: #f8f9fa;
}

[data-bs-theme="dark"] .table-light {
  --bs-table-bg: #3a3a3a;
}

[data-bs-theme="dark"] .table-hover tbody tr:hover {
  --bs-table-accent-bg: #404040 !important;
}

/* ТЕКУЩАЯ ДАТА */
.today-highlight { 
  background-color: #fff3cd !important; 
  border: 2px solid #ffc107 !important; 
  animation: pulse 2s infinite;
}

[data-bs-theme="dark"] .today-highlight { 
  background-color: #ffed4e !important; 
  color: #000 !important;
  border: 2px solid #ffc107 !important; 
}

/* ЯЧЕЙКИ ДЕЖУРСТВ */
.duty-cell {
  transform: translateZ(0); /* Hardware acceleration */
  backface-visibility: hidden;
  contain: layout style;
}

.duty-cell:hover:not(.disabled) { 
  background-color: #e9ecef !important; 
  transform: scale(1.02);
}

[data-bs-theme="dark"] .duty-cell:hover:not(.disabled) { 
  background-color: #404040 !important;
}

.duty-cell.disabled { 
  cursor: not-allowed; 
  color: #aaa; 
  background-color: #f8f9fa !important;
}

[data-bs-theme="dark"] .duty-cell.disabled {
  color: #666;
  background-color: #2a2a2a !important;
}

/* ПАНЕЛЬ СПРАВА */
.top-right-panel { 
  position: fixed; 
  top: 70px; 
  right: 15px; 
  max-width: 300px; 
  z-index: 1030;
  box-shadow: var(--shadow-panel);
  contain: layout style paint;
}

[data-bs-theme="dark"] .top-right-panel {
  background-color: #1e1e1e;
  border: 1px solid #333;
}

/* СТАТУСЫ СОТРУДНИКОВ */
.staff-shortage { 
  background-color: #f8d7da !important; 
  color: #721c24 !important; 
  border: 2px solid #dc3545 !important;
  animation: shake 0.5s infinite;
}

.duty-assigned { 
  background-color: #d4edda !important; 
  color: #155724; 
  border: 2px solid #28a745 !important;
}

.priority-duty { 
  background-color: #cce5ff !important; 
  border: 2px solid #007bff !important;
  box-shadow: 0 0 10px rgba(0,123,255,0.3);
}

.free-employee { 
  background: linear-gradient(135deg, #fff3cd 0%, #ffeaa7 100%) !important; 
  border: 2px solid #f39c12 !important; 
  position: relative;
  animation: pulse 2s infinite;
}

.free-employee::after {
  content: "🆓 свободен";
  position: absolute; top: -8px; right: -8px;
  background: #e67e22; color: white; border-radius: 12px;
  padding: 2px 6px; font-size: 0.7em; font-weight: 600;
  z-index: 10;
}

.glass-card {
  background: rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(20px);
  border: 1px solid rgba(255, 255, 255, 0.2);
  box-shadow: 0 8px 32px rgba(0,0,0,0.1);
}

[data-bs-theme="dark"] .glass-card {
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid rgba(255, 255, 255, 0.1);
}

/* ✅ ОПТИМИЗИРОВАННЫЕ АНИМАЦИИ */
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(243, 156, 18, 0.7); }
  70% { box-shadow: 0 0 0 10px rgba(243, 156, 18, 0); }
  100% { box-shadow: 0 0 0 0 rgba(243, 156, 18, 0); }
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-2px); }
  75% { transform: translateX(2px); }
}

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

/* КАРТОЧКИ */
.card {
  box-shadow: var(--shadow-light);
  border: 1px solid #e0e0e0;
  animation: fadeIn 0.5s ease-out;
}

[data-bs-theme="dark"] .card {
  background-color: #2a2a2a !important;
  border-color: #444;
  color: #e0e0e0;
}

/* АДМИН ПАНЕЛЬ */
#adminPanel .card-header {
  background: var(--gradient-primary);
  color: white;
}

[data-bs-theme="dark"] #adminPanel .card-header {
  background: var(--gradient-dark);
}

/* МОДАЛЬНЫЕ ОКНА */
.modal-content {
  border-radius: 12px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.3);
  animation: fadeIn 0.3s ease-out;
}

[data-bs-theme="dark"] .modal-content {
  background-color: #2d2d2d !important;
  color: #e0e0e0 !important;
}

/* КНОПКИ */
.btn {
  border-radius: 8px;
  font-weight: 500;
  transition: all 0.2s ease;
}

.btn:not(:disabled):not(.disabled):hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-hover);
}

/* РЕСПОНСИВ */
@media (max-width: 768px) {
  .top-right-panel {
    right: 5px;
    max-width: 280px;
    font-size: 0.9em;
  }
  
  .work-cell, .duty-cell {
    min-width: 70px;
  }
}

@media (max-width: 576px) {
  .duty-cell { 
    min-height: 40px; 
    font-size: 0.85em; 
  }
  
  .top-right-panel { 
    position: static !important; 
    max-width: 100%; 
    margin: 10px 0;
    box-shadow: var(--shadow-light);
  }
  
  body { padding-top: 60px; }
}

/* ТЕМНАЯ ТЕМА - ГЛОБАЛЬНАЯ */
.dark-theme {
  --bs-body-bg: #121212;
  --bs-body-color: #e0e0e0;
  color: #cdcdcd;
}

.dark-theme .table { --bs-table-bg: #1e1e1e; }
.dark-theme .card-footer { background-color: #252525 !important; }

.dark-theme .form-control,
.dark-theme .form-select,
.dark-theme .form-check-input:checked {
  background-color: #404040;
  border-color: #555;
  color: #e0e0e0;
}
.dark-theme .form-text {  color: #cdcdcd;}

.dark-theme .form-control:focus,
.dark-theme .form-select:focus {
  background-color: #4a4a4a;
  border-color: #667eea;
  box-shadow: 0 0 0 0.2rem rgba(102, 126, 234, 0.25);
}
.dark-theme .card-footer{
  background-color: #121212 !important;  
}
.dark-theme .duty-assigned {
  background-color: #032403 !important;
}
/* УВЕДОМЛЕНИЯ */
.notification {
  position: fixed; top: 20px; right: 20px; 
  padding: 15px 20px; border-radius: 8px; 
  color: white; font-weight: 500; z-index: 10000;
  box-shadow: var(--shadow-panel);
  animation: slideIn 0.3s ease-out;
  max-width: 350px;
}

.notification.success { background: #10b981; }
.notification.error { background: #ef4444; }
.notification.info { background: #3b82f6; }

@keyframes slideIn {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* ДАШБОРД (готов к активации) */
.dashboard { 
  background: var(--gradient-primary); 
  border-radius: 15px; 
  color: white;
  padding: 20px;
}

.kpi-card { 
  border-radius: 10px; 
  text-align: center; 
  transition: transform 0.2s ease;
  cursor: default;
}

.kpi-card:hover { transform: translateY(-2px); }
.tiny { font-size: 0.75em; opacity: 0.9; }

/* ✅ МОБИЛЬНЫЙ СВАЙПЕР — КРИТИЧНО! */
#mobileDaysSwipe {
  display: grid;
  grid-auto-columns: 95vw;
  grid-auto-flow: column;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
}

#mobileDaysSwipe::-webkit-scrollbar {
  display: none; /* Chrome/Safari */
}

.mobile-day-card {
  flex: 0 0 95vw !important;  /* ← КЛЮЧЕВОЙ ФИКС */
  scroll-snap-align: start !important;
  min-height: 450px;
  border-radius: 16px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.2);
}

@media (max-width: 576px) {
  .mobile-day-card { flex: 0 0 98vw !important; }
}

.virtual-table {
  contain: strict;
  will-change: transform;
}


.sync-badge {
    animation: pulse 2s infinite;
    box-shadow: 0 0 10px rgba(0,0,0,0.3);
}

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

/* Loading спиннер */
.loading-spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid #f3f3f3;
    border-top: 2px solid #3498db;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.skeleton-block {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: loading 1.5s infinite;
    border-radius: 4px;
    height: 40px;
}

@keyframes loading {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

.duty-cell {
    vertical-align: middle !important;
    line-height: 1.2;
    min-height: 60px;
}

.duty-cell small {
    display: block;
    font-size: 0.65em;
    margin-top: -2px;
}

.fixed-first-column .table {
  position: relative;
  overflow-x: auto; /* Горизонтальный скролл для длинных таблиц */
}

.fixed-first-column thead th:first-child,
.fixed-first-column tbody td:first-child {
  position: sticky;
  left: 0;
  z-index: 10;
  background-color: #fff; /* Наследует цвет темы */
  border-right: 2px solid #dee2e6; /* Граница для разделения */
  min-width: 200px; /* Фиксированная ширина столбца имён */
  max-width: 250px;
}

.fixed-first-column thead th:first-child {
  z-index: 11; /* Выше для заголовка */
  background-color: #f8f9fa !important; /* Фон для светлой темы */
}

@media (prefers-color-scheme: dark) {
  .fixed-first-column thead th:first-child {
    background-color: #343a40 !important; /* Тёмная тема */
  }
  /* 1. Ячейки редактирования */
.admin-editable {
  cursor: pointer;
  border: 2px solid #0d6efd !important;
}
.non-editable {
  cursor: default;
}

/* 2. Sticky первый столбец (из прошлого ответа) */
.fixed-first-column .table {
  position: relative;
  overflow-x: auto;
}
.fixed-first-column thead th:first-child,
.fixed-first-column tbody td:first-child {
  position: sticky;
  left:  0;
  z-index: 10;
  background-color: inherit;
  border-right: 2px solid #dee2e6;
  min-width: 200px;
  max-width: 250px;
}

/* 3. Состояния ячеек */
.free-employee { background-color: #e8f5e8; }
.duty-assigned { background-color: #fff3cd; }
.disabled { background-color: #f8f9fa; opacity: 0.6; }
.today-highlight { box-shadow: inset 0 0 0 2px #0d6efd; }

/* 4. Мобильные карточки */
.mobile-day-card { 
  width: 85vw; 
  min-height: 400px; 
  scroll-snap-align: center;
}
.mobile-employee {
  transition: transform 0.2s ease;
}
.mobile-employee:hover {
  transform: translateY(-2px);
}

/* 5. Анимации */
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.notification {
  animation: fadeIn 0.3s ease-out;
}