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

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

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

/* НАВИГАЦИЯ */
.navbar-dark {
  background: linear-gradient(135deg, #1e3c72 0%, #2a5298 100%) !important;
}

[data-bs-theme="dark"] .navbar-dark {
  background: linear-gradient(135deg, #0d1b2a 0%, #1b263b 100%) !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;
}

/* ТЕКУЩАЯ ДАТА */
.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 { 
  cursor: pointer; 
  transition: all 0.2s; 
  min-height: 45px;
  border: 1px solid #dee2e6;
}

.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: 170px; 
  right: 15px; 
  max-width: 350px; 
  z-index: 1030;
  box-shadow: 0 4px 20px rgba(0,0,0,0.3);
}

[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.65em;
  font-weight: bold;
  z-index: 10;
}

@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); }
}

/* КАРТОЧКИ */
.card {
  box-shadow: 0 2px 10px rgba(0,0,0,0.1);
  border: 1px solid #e0e0e0;
}

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

/* АДМИН ПАНЕЛЬ */
#adminPanel .card-header {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

[data-bs-theme="dark"] #adminPanel .card-header {
  background: linear-gradient(135deg, #4a5568 0%, #2d3748 100%);
}

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

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

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

.btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}

/* АНИМАЦИИ */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

.card, .alert {
  animation: fadeIn 0.5s ease-out;
}

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

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

.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-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);
}

/* 🎨 АДАПТИВНЫЙ ДИЗАЙН */

/* DESKTOP (>1200px) */
@media (min-width: 1200px) {
  #scheduleTable { font-size: 0.85rem; }
  .top-right-panel { max-width: 350px; }
  #adminPanel { max-height: 400px; overflow-y: auto; }
}

/* TABLET (768-1200px) */
@media (max-width: 1199px) and (min-width: 768px) {
  .table-responsive { 
    --bs-table-padding-x: 0.5rem; 
    font-size: 0.8rem;
  }
  .work-cell { min-width: 75px !important; }
  .top-right-panel { right: 10px; max-width: 280px; }
}

/* MOBILE (<768px) */
@media (max-width: 767px) {
  body { padding-top: 80px; }
  
  /* Главная таблица → карточки */
  #scheduleTable { display: none; }
  #mobileSchedule { display: block; }
  
  /* Кнопки вертикально */
  .admin-buttons { flex-direction: column; gap: 0.5rem; }
  .btn { width: 100%; margin-bottom: 0.5rem; }
  
  /* Панель сегодня → снизу */
  .top-right-panel {
    position: fixed;
    top: auto;
    bottom: 0;
    right: 0;
    left: 0;
    max-width: none;
    border-radius: 15px 15px 0 0;
    margin: 0 10px;
  }
}

/* MOBILE КАРТОЧКИ */
.mobile-day-card {
  background: var(--bs-card-bg);
  border-radius: 15px;
  margin-bottom: 1rem;
  padding: 1rem;
  box-shadow: 0 8px 25px rgba(0,0,0,0.15);
}

[data-bs-theme="dark"] .mobile-day-card {
  background: #1e1e1e;
}

/* СВАЙПЫ */
.swipe-container {
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
}

.swipe-card {
  scroll-snap-align: start;
  flex-shrink: 0;
  min-width: 100%;
}

/* МОБИЛЬНЫЕ СВАЙПЫ */
@media (max-width: 767px) {
  #mobileSchedule {
    animation: slideUp 0.4s ease-out;
  }
  
  /* СВАЙП КОНТЕЙНЕР */
  .swipe-container {
    height: 60vh;
    overflow-x: auto;
    overflow-y: hidden;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
    scroll-behavior: smooth;
    background: linear-gradient(90deg, transparent 0%, rgba(255,255,255,0.1) 50%, transparent 100%);
  }
  
  [data-bs-theme="dark"] .swipe-container {
    background: linear-gradient(90deg, transparent 0%, rgba(0,0,0,0.3) 50%, transparent 100%);
  }
  
  /* КАРТОЧКИ ДНЕЙ */
  .mobile-day-card {
    scroll-snap-align: start;
    flex-shrink: 0;
    width: 100vw;
    height: 60vh;
    padding: 1.5rem;
    margin-right: 20px;
    border-radius: 20px;
    box-shadow: 0 15px 35px rgba(0,0,0,0.2);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255,255,255,0.1);
    overflow-y: auto;
  }
  
  [data-bs-theme="dark"] .mobile-day-card {
    background: linear-gradient(145deg, #1a1a1a, #2d2d2d);
    border-color: rgba(255,255,255,0.1);
  }
  
  /* СОТРУДНИКИ В КАРТОЧКЕ */
  .mobile-employee {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    margin-bottom: 0.75rem;
    border-radius: 15px;
    transition: all 0.3s;
    border: 1px solid rgba(0,0,0,0.1);
  }
  
  .mobile-employee:hover {
    transform: translateX(5px);
    box-shadow: 0 5px 20px rgba(0,0,0,0.15);
  }
  
  /* СТАТУСЫ */
  .mobile-employee.duty-assigned {
    background: linear-gradient(135deg, #d4edda, #c3e6cb);
    border-color: #28a745;
  }
  
  .mobile-employee.free-employee {
    background: linear-gradient(135deg, #fff3cd, #ffeaa7);
    border-color: #f39c12;
    animation: pulse 2s infinite;
  }
  
  .mobile-employee.staff-shortage {
    background: linear-gradient(135deg, #f8d7da, #f5c6cb);
    border-color: #dc3545;
    animation: shake 0.5s infinite;
  }
  
  /* ПРОГРЕСС НАГРУЗКИ */
  .load-progress {
    height: 4px;
    border-radius: 2px;
    margin-top: 0.25rem;
    background: rgba(0,0,0,0.1);
  }
  
  .load-progress-fill {
    height: 100%;
    border-radius: 2px;
    transition: width 0.3s;
  }
  
  /* ИНДИКАТОРЫ */
  .mobile-day-indicator {
    position: absolute;
    top: 10px;
    right: 15px;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #ffc107;
    box-shadow: 0 0 0 2px white;
  }
  
  [data-bs-theme="dark"] .mobile-day-indicator {
    box-shadow: 0 0 0 2px #1a1a1a;
  }
}

/* АНИМАЦИИ */
@keyframes slideUp {
  from { transform: translateY(30px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

@keyframes slideInLeft {
  from { transform: translateX(-100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}
@media (max-width: 767.98px) {
  #todayPanel {
    display: none !important;
  }
}
/* ✅ Фиксированный первый столбец */
.fixed-first-column {
  overflow-x: auto;
}

.fixed-first-column th:first-child,
.fixed-first-column td:first-child {
  position: sticky;
  left: 0;
  background: var(--bs-table-bg) !important;
  z-index: 10;
  border-right: 2px solid var(--bs-border-color);
  min-width: 220px;
  max-width: 220px;
}

.dark-theme .fixed-first-column th:first-child,
.dark-theme .fixed-first-column td:first-child {
  background: var(--bs-table-dark-bg) !important;
}

/* Мобильная таблица работ */
#workScheduleTable.fixed-first-column th:first-child,
#workScheduleTable.fixed-first-column td:first-child {
  min-width: 180px;
  max-width: 180px;
}
