/* Bootstrap CSS Variables for Light Theme */
:root {
  --bs-body-bg: #f5f7fa;
  --bs-body-color: #333;
  --bs-border-color: #dee2e6;
  --bs-table-bg: rgba(255, 255, 255, 0.95);
  --bs-table-color: #212529;
  --bs-table-striped-bg: rgba(0, 0, 0, 0.02);
  --bs-table-hover-bg: #f1f3f5;
  --bs-table-border-color: #dee2e6;
  --bs-table-active-bg: rgba(0, 0, 0, 0.05);
  --bs-table-caption-color: #6c757d;
}

/* Bootstrap CSS Variables for Dark Theme */
body.dark-mode {
  --bs-body-bg: #1a1a1a;
  --bs-body-color: #e0e0e0;
  --bs-border-color: rgba(255, 255, 255, 0.1);
  --bs-table-bg: rgba(40, 45, 55, 0.9);
  --bs-table-color: #ffffff;
  --bs-table-striped-bg: rgba(255, 255, 255, 0.03);
  --bs-table-hover-bg: rgba(255, 255, 255, 0.05);
  --bs-table-border-color: rgba(255, 255, 255, 0.1);
  --bs-table-active-bg: rgba(255, 255, 255, 0.1);
  --bs-table-caption-color: #adb5bd;
}

/* Base styles with gradient background */
body, body.dark-mode {
  transition: background-color 0.3s ease, color 0.3s ease;
}

/* Принудительно задать начальное состояние для темной темы */
body.dark-mode {
  background: linear-gradient(135deg, #1e293b 0%, #334155 50%, #475569 100%) !important;
}

/* Для светлой темы */
body:not(.dark-mode) {
  background: linear-gradient(135deg, #e0f2fe 0%, #f3e8ff 50%, #fce7f3 100%) !important;
}

body {
	font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
	background-color: #f5f7fa;
	background: linear-gradient(135deg, #e0f2fe 0%, #f3e8ff 50%, #fce7f3 100%);
	color: #333;
	line-height: 1.6;
	min-height: 100vh;
	position: relative;
	overflow-x: hidden;
}

/* Animated background elements */
.animated-bg-element {
	position: absolute;
	border-radius: 50%;
	filter: blur(60px);
	opacity: 0.2;
	z-index: -1;
}

.bg-element-1 {
	top: 5%;
	left: 5%;
	width: 20rem;
	height: 20rem;
	background: linear-gradient(45deg, #3b82f6, #8b5cf6);
	animation: float1 8s ease-in-out infinite;
}

.bg-element-2 {
	top: 15%;
	right: 10%;
	width: 18rem;
	height: 18rem;
	background: linear-gradient(45deg, #8b5cf6, #ec4899);
	animation: float2 10s ease-in-out infinite 2s;
}

.bg-element-3 {
	bottom: 20%;
	left: 25%;
	width: 22rem;
	height: 22rem;
	background: linear-gradient(45deg, #ec4899, #f43f5e);
	animation: float3 9s ease-in-out infinite 4s;
}

.bg-element-4 {
	bottom: 15%;
	right: 30%;
	width: 16rem;
	height: 16rem;
	background: linear-gradient(45deg, #6366f1, #3b82f6);
	animation: float4 11s ease-in-out infinite 1s;
}

@keyframes float1 {
	0%, 100% { transform: translate(0, 0) scale(1); }
	33% { transform: translate(100px, -50px) scale(1.2); }
	66% { transform: translate(0, -40px) scale(1); }
}

@keyframes float2 {
	0%, 100% { transform: translate(0, 0) scale(1); }
	33% { transform: translate(-80px, 60px) scale(1.3); }
	66% { transform: translate(0, 40px) scale(1); }
}

@keyframes float3 {
	0%, 100% { transform: translate(0, 0) scale(1); }
	33% { transform: translate(120px, -40px) scale(1.1); }
	66% { transform: translate(0, -20px) scale(1); }
}

@keyframes float4 {
	0%, 100% { transform: translate(0, 0) scale(1); }
	33% { transform: translate(-100px, 80px) scale(1.25); }
	66% { transform: translate(0, 60px) scale(1); }
}

/* Dark mode */
body.dark-mode {
	background-color: #1a1a1a;
	color: #e0e0e0;
	background: linear-gradient(135deg, #1e293b 0%, #334155 50%, #475569 100%);
}

body.dark-mode .animated-bg-element {
	opacity: 0.1;
}

/* Modal theme variables for consistent high-contrast UI */
:root {
  --modal-bg: rgba(255,255,255,1);
  --modal-text: #0f1724;
  --modal-label: #374151;
  --modal-input-bg: #ffffff;
  --modal-border: #e5e7eb;
  --modal-backdrop: rgba(0,0,0,0.12); /* slightly stronger backdrop for light theme */
}

body.dark-mode {
  --modal-bg: #121826; /* slightly lighter modal background for better contrast */
  --modal-text: #e6eef8;
  --modal-label: #cbd5e1;
  --modal-input-bg: #171a28; /* slightly lighter input bg */
  --modal-border: rgba(255,255,255,0.08); /* slightly stronger border */
  --modal-backdrop: rgba(0,0,0,0.6); /* much stronger dark backdrop for readability */
}

body.dark-mode .bg-element-1 { background: linear-gradient(45deg, #1d4ed8, #7e22ce); }
body.dark-mode .bg-element-2 { background: linear-gradient(45deg, #7e22ce, #be123c); }
body.dark-mode .bg-element-3 { background: linear-gradient(45deg, #be123c, #dc2626); }
body.dark-mode .bg-element-4 { background: linear-gradient(45deg, #4f46e5, #1d4ed8); }

/* Container */
.container {
	max-width: 1200px;
	margin: 0 auto;
	padding: 20px;
	position: relative;
	z-index: 10;
}

/* Header переработанный */
header {
  position: relative;
  z-index: 1500;
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.3);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
  padding: 0.75rem 0;
  margin: 10px 20px;
  border-radius: 16px;
  min-height: 70px;
  display: flex;
  align-items: center;
}

body.dark-mode header {
  background: rgba(30, 41, 59, 0.9);
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
}

/* Контейнер header */
header .container-fluid {
  width: 100%;
  padding: 0 20px;
}

/* Flex структура header */
.navbar-content {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
}

/* Левая часть - логотип */
.header-left {
  flex: 0 0 auto;
  padding-left: 10px;
}

.navbar-brand {
  font-weight: bold;
  font-size: 1.5rem;
  color: #333 !important;
  text-decoration: none;
  white-space: nowrap;
}

body.dark-mode .navbar-brand {
  color: #ffffff !important;
}

/* Центральная часть с кнопками */
.header-center {
  flex: 1 1 auto;
  display: flex;
  justify-content: center;
  padding: 0 20px;
}

.nav-buttons {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: center;
  max-width: 1000px;
}

/* Стили для всех кнопок навигации */
.nav-btn {
  padding: 8px 16px;
  border-radius: 10px;
  font-weight: 500;
  font-size: 0.9rem;
  transition: all 0.3s ease;
  cursor: pointer;
  white-space: nowrap;
  text-decoration: none;
  text-align: center;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;

  /* Светлая тема по умолчанию */
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.25), rgba(255, 255, 255, 0.15));
  color: #333;
  border: 1px solid rgba(255, 255, 255, 0.4);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

/* Темная тема для кнопок */
body.dark-mode .nav-btn {
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.1), rgba(255, 255, 255, 0.05));
  color: #ffffff;
  border: 1px solid rgba(255, 255, 255, 0.15);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

/* Ховер эффект для кнопок */
.nav-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
}

body.dark-mode .nav-btn:hover {
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.15), rgba(255, 255, 255, 0.08));
}

/* Активная кнопка */
.nav-btn.active {
  background: linear-gradient(135deg, #667eea, #7c5cff);
  color: white;
  border-color: #667eea;
}

body.dark-mode .nav-btn.active {
  background: linear-gradient(135deg, #4f46e5, #7c3aed);
  border-color: #4f46e5;
}

/* Правая часть с кнопками */
.header-right {
  flex: 0 0 auto;
  display: flex;
  gap: 10px;
  padding-right: 10px;
  align-items: center;
}

/* Информация о пользователе в header */
.user-info {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  margin-right: 10px;
  font-size: 0.9rem;
}

.user-department {
  font-weight: 600;
  color: #333;
  margin-bottom: 2px;
}

.user-fullname {
  color: #666;
  font-size: 0.85rem;
}

body.dark-mode .user-department {
  color: #ffffff;
}

body.dark-mode .user-fullname {
  color: #e0e0e0;
}

/* Специальные стили для кнопок в правой части */
.logout-btn, .theme-btn {
  width: 40px;
  height: 40px;
  padding: 0;
  border-radius: 50%;
  font-size: 1.2rem;
}

/* Мобильное меню */
.mobile-menu {
  display: none;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid rgba(0, 0, 0, 0.1);
}

body.dark-mode .mobile-menu {
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.mobile-menu .nav-buttons {
  flex-direction: column;
  width: 100%;
}

.mobile-menu .nav-btn {
  width: 100%;
  margin-bottom: 5px;
  justify-content: flex-start;
}

/* Адаптивность */
@media (max-width: 1200px) {
  .nav-buttons {
    gap: 6px;
  }

  .nav-btn {
    padding: 6px 12px;
    font-size: 0.85rem;
  }
}

@media (max-width: 992px) {
  .header-center {
    display: none;
  }

  .mobile-menu {
    display: block;
  }

  .navbar-content {
    flex-wrap: wrap;
  }
}

@media (max-width: 576px) {
  header {
    margin: 10px;
    padding: 0.5rem 0;
  }

  .header-left, .header-right {
    padding: 0 5px;
  }

  .navbar-brand {
    font-size: 1.2rem;
  }
}

/* Убираем старую кнопку темы */
.theme-toggle {
  display: none;
}

/* Стили для новой кнопки темы в header */
.theme-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    cursor: pointer;
    transition: all 0.3s ease;
    border: 1px solid rgba(255, 255, 255, 0.3);
    background: rgba(255, 255, 255, 0.25);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

body.dark-mode .theme-btn {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.15);
    color: #ffffff;
}

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

body.dark-mode .theme-btn:hover {
    background: rgba(255, 255, 255, 0.15);
}

.dropdown-menu {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.18);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
    border-radius: 12px;
    padding: 0.5rem 0;
}

body.dark-mode .dropdown-menu {
    background: rgba(60, 70, 90, 0.95); /* Lighter dark background */
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

.dropdown-item {
    color: #333;
    transition: all 0.2s ease;
    padding: 0.5rem 1rem;
    border-radius: 6px;
    margin: 0 0.25rem;
}

body.dark-mode .dropdown-item {
    color: #ffffff; /* White text */
}

.dropdown-item:hover {
    background: rgba(255, 255, 255, 0.2);
    backdrop-filter: blur(4px);
}

body.dark-mode .dropdown-item:hover {
    background: rgba(255, 255, 255, 0.15); /* Lighter hover */
}

/* Card styles */
.task-card {
    background: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(10px);
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    border-left: 4px solid #667eea;
    border: 1px solid rgba(255, 255, 255, 0.3);
}

body.dark-mode .task-card {
    background: rgba(60, 70, 90, 0.7); /* Much lighter dark background */
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: #ffffff; /* White text */
}

.task-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(0,0,0,0.15);
}

.task-card.completed {
    border-left-color: #28a745;
}

.task-card.in-progress {
    border-left-color: #ffc107;
}

.task-card.pending {
    border-left-color: #6c757d;
}

.card-title {
    font-size: 1.25rem;
    margin-bottom: 10px;
    color: #333;
}

body.dark-mode .card-title {
    color: #ffffff; /* White text */
}

.card-text {
    color: #666;
    margin-bottom: 15px;
}

body.dark-mode .card-text {
    color: #e0e0e0; /* Lighter gray text */
}

.status-badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.875rem;
    font-weight: 500;
}

.status-pending {
    background-color: #e9ecef;
    color: #6c757d;
}

.status-in-progress {
    background-color: #fff3cd;
    color: #856404;
}

.status-completed {
    background-color: #d4edda;
    color: #155724;
}

/* Form styles */
.form-group {
    margin-bottom: 1rem;
}

.btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #7c5cff 100%);
    border: none;
    color: #fff;
    padding: 0.65rem 1rem;
    border-radius: 12px;
    box-shadow: 0 8px 30px rgba(99,102,241,0.18);
    transition: transform 0.12s ease, box-shadow 0.12s ease;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 40px rgba(99,102,241,0.22);
}

.btn-success {
    background-color: #28a745;
    border-color: #28a745;
    backdrop-filter: blur(10px);
    background: rgba(40, 167, 69, 0.9);
}

.btn-danger {
    background-color: #dc3545;
    border-color: #dc3545;
    backdrop-filter: blur(10px);
    background: rgba(220, 53, 69, 0.9);
}

body.dark-mode .btn-primary {
    background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%);
    box-shadow: 0 8px 30px rgba(79,70,229,0.18);
}

body.dark-mode .btn-success {
    background: rgba(21, 128, 61, 0.9);
    border-color: #16a34a;
}

body.dark-mode .btn-danger {
    background: rgba(185, 28, 28, 0.9);
    border-color: #dc2626;
}

/* Admin panel */
.admin-panel {
    background: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(10px);
    border-radius: 8px;
    padding: 20px;
    margin-top: 20px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    border: 1px solid rgba(255, 255, 255, 0.3);
}

body.dark-mode .admin-panel {
    background: rgba(60, 70, 90, 0.7); /* Lighter dark background */
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: #ffffff; /* White text */
}

/* Comments section */
.comments-section {
    margin-top: 30px;
    padding-top: 20px;
    border-top: 1px solid rgba(0,0,0,0.1);
}

body.dark-mode .comments-section {
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.comment {
    background: rgba(248, 249, 250, 0.8);
    backdrop-filter: blur(10px);
    padding: 15px;
    border-radius: 8px;
    margin-bottom: 15px;
    border-left: 3px solid #667eea;
    border: 1px solid rgba(255, 255, 255, 0.3);
}

body.dark-mode .comment {
    background: rgba(60, 70, 90, 0.7); /* Lighter dark background */
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: #ffffff; /* White text */
}

.comment-author {
    font-weight: bold;
    color: #333;
}

body.dark-mode .comment-author {
    color: #ffffff; /* White text */
}

.comment-date {
    font-size: 0.875rem;
    color: #666;
    margin-bottom: 10px;
}

body.dark-mode .comment-date {
    color: #e0e0e0; /* Lighter gray text */
}

/* Attachments */
.attachments {
    margin-top: 20px;
}

.attachment-item {
    display: flex;
    align-items: center;
    padding: 10px;
    background: rgba(248, 249, 250, 0.8);
    backdrop-filter: blur(10px);
    border-radius: 6px;
    margin-bottom: 10px;
    border: 1px solid rgba(255, 255, 255, 0.3);
}

body.dark-mode .attachment-item {
    background: rgba(60, 70, 90, 0.7); /* Lighter dark background */
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: #ffffff; /* White text */
}

.attachment-icon {
    margin-right: 10px;
    font-size: 1.2rem;
}

.attachment-name {
    flex-grow: 1;
}

/* Responsive design */
@media (max-width: 768px) {
    .container {
        padding: 10px;
    }
    
    .task-card {
        padding: 15px;
    }
    
    .card-title {
        font-size: 1.1rem;
    }
}

/* Animation for dock effect */
.dock-container {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 10px;
    z-index: 1000;
}

.dock-item {
    width: 50px;
    height: 50px;
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(10px);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(0,0,0,0.2);
    border: 1px solid rgba(255, 255, 255, 0.3);
}

body.dark-mode .dock-item {
    background: rgba(60, 70, 90, 0.9); /* Lighter dark background */
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: #ffffff; /* White text */
}

.dock-item:hover {
    transform: scale(1.2) translateY(-10px);
    box-shadow: 0 8px 25px rgba(0,0,0,0.3);
}

.dock-item.active {
    background: #667eea;
    color: white;
}

body.dark-mode .dock-item.active {
    background: #4f46e5;
}

/* Flash messages */
.alert {
    border-radius: 8px;
    margin-bottom: 20px;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.3);
}

body.dark-mode .alert {
    background: rgba(60, 70, 90, 0.7); /* Lighter dark background */
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: #ffffff; /* White text */
}

/* Theme toggle button */
.theme-toggle {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 3005; /* above header (1500) and FAB (2010) */
    pointer-events: auto; /* ensure it receives clicks when overlapping other elements */
    width: 3rem;
    height: 3rem;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.3);
    box-shadow: 0 4px 15px rgba(0,0,0,0.2);
    background: rgba(255, 255, 255, 0.25);
}

/* Floating action button for primary actions */
.fab {
    position: fixed;
    right: 24px;
    bottom: 24px;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: linear-gradient(135deg,#ff7ab6 0%,#7c5cff 100%);
    color: white;
    font-size: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 16px 40px rgba(124,92,255,0.28);
    border: none;
    z-index: 2010;
    cursor: pointer;
}
.fab:hover { transform: translateY(-3px); }

/* Close icon custom style */
.btn-close-custom, .sidebar-close {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: rgba(255,255,255,0.12);
    color: #fff;
    border: 1px solid rgba(255,255,255,0.08);
    box-shadow: 0 6px 18px rgba(0,0,0,0.12);
    cursor: pointer;
    transition: transform 0.12s ease, background 0.12s ease;
}
.btn-close-custom:hover, .sidebar-close:hover { transform: translateY(-2px); background: rgba(255,255,255,0.18); }
.btn-close-custom svg { width: 16px; height: 16px; }

body.dark-mode .btn-close-custom, body.dark-mode .sidebar-close { background: rgba(255,255,255,0.06); border: 1px solid rgba(255,255,255,0.08); }

/* Ensure default bootstrap close doesn't get lost */
.btn-close { outline: none; }

body.dark-mode .theme-toggle {
    background: rgba(60, 70, 90, 0.25); /* Lighter dark background */
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: #ffffff; /* White text */
}

body:not(.dark-mode) .theme-toggle {
    color: #fbbf24;
}

.theme-toggle:hover {
    transform: scale(1.1);
    background: rgba(255, 255, 255, 0.35);
}

body.dark-mode .theme-toggle:hover {
    background: rgba(60, 70, 90, 0.35); /* Lighter dark background */
}

/* Table styles - Light Theme - Explicitly override Bootstrap dark theme */
body:not(.dark-mode) .container .table,
body:not(.dark-mode) .table {
    background: rgba(255, 255, 255, 0.95) !important;
    backdrop-filter: blur(10px) !important;
    border-radius: 8px !important;
    overflow: hidden !important;
    border: 1px solid rgba(0, 0, 0, 0.1) !important;
    color: #333 !important;
}

body.dark-mode .container .table,
body.dark-mode .table {
    background: rgba(40, 45, 55, 0.9) !important; /* More opaque dark background for better readability */
    border: 1px solid rgba(255, 255, 255, 0.15) !important;
    color: #ffffff !important; /* White text */
}

body:not(.dark-mode) .container .table th,
body:not(.dark-mode) .table th {
    background: #f8f9fa !important;
    color: #212529 !important;
    font-weight: 600 !important;
    border-bottom: 1px solid #dee2e6 !important;
}

body.dark-mode .container .table th,
body.dark-mode .table th {
    background: rgba(255, 255, 255, 0.1) !important;
    color: #ffffff !important; /* White text */
    font-weight: 600 !important;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1) !important;
}

body:not(.dark-mode) .container .table td,
body:not(.dark-mode) .table td {
    color: #212529 !important;
    border-bottom: 1px solid #dee2e6 !important;
}

body.dark-mode .container .table td,
body.dark-mode .table td {
    color: #e0e0e0 !important; /* Light gray text for better contrast */
    border-bottom: 1px solid rgba(255, 255, 255, 0.1) !important;
}

body:not(.dark-mode) .container .table tr:hover,
body:not(.dark-mode) .table tr:hover {
    background: #f1f3f5 !important;
}

body.dark-mode .container .table tr:hover,
body.dark-mode .table tr:hover {
    background: rgba(255, 255, 255, 0.05) !important;
}

/* Table header styling for better visibility */
body:not(.dark-mode) .container .table thead,
body:not(.dark-mode) .table thead {
    background: #f8f9fa !important;
}

body.dark-mode .container .table thead,
body.dark-mode .table thead {
    background: rgba(255, 255, 255, 0.05) !important;
}

/* Additional table elements for complete theme separation */
body:not(.dark-mode) .container .table-striped tbody tr:nth-of-type(odd),
body:not(.dark-mode) .table-striped tbody tr:nth-of-type(odd) {
    background-color: rgba(0, 0, 0, 0.02) !important;
}

body.dark-mode .container .table-striped tbody tr:nth-of-type(odd),
body.dark-mode .table-striped tbody tr:nth-of-type(odd) {
    background-color: rgba(255, 255, 255, 0.03) !important;
}

body:not(.dark-mode) .container .table-striped tbody tr:nth-of-type(even),
body:not(.dark-mode) .table-striped tbody tr:nth-of-type(even) {
    background-color: rgba(0, 0, 0, 0.01) !important;
}

body.dark-mode .container .table-striped tbody tr:nth-of-type(even),
body.dark-mode .table-striped tbody tr:nth-of-type(even) {
    background-color: rgba(255, 255, 255, 0.02) !important;
}

/* Table borders and cells */
body:not(.dark-mode) .container .table td,
body:not(.dark-mode) .container .table th,
body:not(.dark-mode) .table td,
body:not(.dark-mode) .table th {
    border-color: #dee2e6 !important;
}

body.dark-mode .container .table td,
body.dark-mode .container .table th,
body.dark-mode .table td,
body.dark-mode .table th {
    border-color: rgba(255, 255, 255, 0.1) !important;
}

/* Table hover effects */
body:not(.dark-mode) .container .table-hover tbody tr:hover,
body:not(.dark-mode) .table-hover tbody tr:hover {
    background-color: #f1f3f5 !important;
}

body.dark-mode .container .table-hover tbody tr:hover,
body.dark-mode .table-hover tbody tr:hover {
    background-color: rgba(255, 255, 255, 0.05) !important;
}

/* Table active row */
body:not(.dark-mode) .container .table-active,
body:not(.dark-mode) .table-active {
    background-color: rgba(0, 0, 0, 0.05) !important;
}

body.dark-mode .container .table-active,
body.dark-mode .table-active {
    background-color: rgba(255, 255, 255, 0.1) !important;
}

/* Table caption */
body:not(.dark-mode) .container .table caption,
body:not(.dark-mode) .table caption {
    color: #6c757d !important;
}

body.dark-mode .container .table caption,
body.dark-mode .table caption {
    color: #adb5bd !important;
}

/* Form controls */
.form-control {
    background: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.3);
}

body.dark-mode .form-control {
    background: rgba(60, 70, 90, 0.7); /* Lighter dark background */
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: #ffffff; /* White text */
}

/* Card header */
.card {
    background: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 12px;
}

body.dark-mode .card {
    background: rgba(60, 70, 90, 0.7); /* Lighter dark background */
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: #ffffff; /* White text */
}

/* Action card styles for logistic dashboard */
.action-card {
    height: 250px;
    cursor: pointer;
    transition: transform 0.2s;
    border: 2px solid var(--border-color);
}

.action-card:hover {
    transform: translateY(-5px);
    border-color: var(--primary-color);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

.action-icon {
    font-size: 48px;
    margin-bottom: 20px;
}

/* Стили для темной темы */
body.dark-mode .action-card {
    background-color: var(--card-bg-dark);
    border-color: var(--border-color-dark);
}

body.dark-mode .action-card:hover {
    border-color: var(--primary-color);
}

.card-header {
    background: rgba(0, 0, 0, 0.03);
    border-bottom: 1px solid rgba(0, 0, 0, 0.1);
}

body.dark-mode .card-header {
    background: rgba(255, 255, 255, 0.1);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

/* Navbar toggler */
.navbar-toggler {
    border: 1px solid rgba(255, 255, 255, 0.3);
    background: rgba(255, 255, 255, 0.25);
}

body.dark-mode .navbar-toggler {
    background: rgba(60, 70, 90, 0.25); /* Lighter dark background */
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.navbar-toggler-icon {
    background-image: url("image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 30 30'%3e%3cpath stroke='rgba%280, 0, 0, 0.55%29' stroke-linecap='round' stroke-miterlimit='10' stroke-width='2' d='M4 7h22M4 15h22M4 23h22'/%3e%3c/svg%3e");
}

body.dark-mode .navbar-toggler-icon {
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 30 30'%3e%3cpath stroke='rgba%28255, 255, 255, 0.55%29' stroke-linecap='round' stroke-miterlimit='10' stroke-width='2' d='M4 7h22M4 15h22M4 23h22'/%3e%3c/svg%3e");
}

/* Updated navbar links styling */
.navbar-nav .nav-item {
    margin: 0 0.25rem;
}

.navbar-nav .nav-item .nav-link {
    padding: 0.5rem 1rem;
    border-radius: 8px;
    transition: all 0.3s ease;
}

.navbar-nav .nav-item .nav-link:hover {
    background: rgba(255, 255, 255, 0.2);
    backdrop-filter: blur(4px);
    color: #1f2937 !important;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
}

body.dark-mode .navbar-nav .nav-item .nav-link:hover {
    background: rgba(255, 255, 255, 0.15); /* Lighter hover */
    color: #ffffff !important; /* White text */
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

/* User info in navbar */
.navbar-text {
    color: #333;
    font-weight: 500;
}

body.dark-mode .navbar-text {
    color: #ffffff; /* White text */
}

/* Search input */
#searchTasks {
    background: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.3);
}

body.dark-mode #searchTasks {
    background: rgba(60, 70, 90, 0.7); /* Lighter dark background */
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: #ffffff; /* White text */
}

/* Card header */
.modal-content {
    background: var(--modal-bg) !important;
    color: var(--modal-text) !important;
    border-radius: 12px;
    border: 1px solid var(--modal-border) !important;
    box-shadow: 0 20px 60px rgba(2,6,23,0.35) !important;
}

/* Ensure Bootstrap modal and its backdrop sit above our overlay elements */
.modal-backdrop {
    background-color: var(--modal-backdrop) !important;
    z-index: 2000 !important;
    pointer-events: none !important; /* do not intercept clicks; we handle outside clicks in JS */
}
.modal {
    z-index: 2001 !important;
}

/* Modal header/body specific color tweaks for readability */
/* Make the modal title use the main modal text color for max contrast */
.modal .modal-header .modal-title {
    color: var(--modal-text) !important;
    font-weight: 700 !important;
}

/* Ensure body text inside modals uses the high-contrast modal text color */
.modal .modal-body,
.modal .modal-body p,
.modal .modal-body .form-text {
    color: var(--modal-text) !important;
}

/* Labels remain slightly muted but readable */
.modal .modal-body .form-label,
.modal .modal-body label {
    color: var(--modal-label) !important;
}

.modal .form-control {
    background: var(--modal-input-bg) !important;
    color: var(--modal-text) !important;
    border: 1px solid var(--modal-border) !important;
}

/* Stronger placeholder contrast and make explicit for both themes */
.modal .form-control::placeholder { color: rgba(0,0,0,0.5) !important; }
body.dark-mode .modal .form-control::placeholder { color: rgba(255,255,255,0.65) !important; }

/* Make modal footer buttons stand out on darker modal backgrounds */
.modal-footer .btn {
    min-width: 96px;
}

/* Right side panel (item details) */
.sidepanel {
    position: fixed;
    right: -420px;
    top: 90px; /* Отступ от верха с учетом header */
    width: 400px;
    height: calc(100vh - 100px); /* Высота минус header */
    background: linear-gradient(135deg, #ffffff, #f8fafc);
    color: #222;
    transition: right 0.35s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    z-index: 1490; /* Ниже header (1500) но выше контента */
    overflow-y: auto;
    box-shadow: -5px 0 25px rgba(0,0,0,0.12);
    border-radius: 16px 0 0 16px;
    padding-top: 20px; /* Add padding to move content down by ~2cm */
    padding-left: 20px; /* Add left padding to increase text indent */
    padding-right: 20px; /* Add right padding for consistency */
}

.sidepanel.active {
  right: 20px;
}

body.dark-mode .sidepanel {
    background: linear-gradient(135deg, #1f2937, #111827);
    color: #e6eef8;
}

.sidepanel .comment { background: rgba(255,255,255,0.9); padding: 10px; border-radius: 8px; margin-bottom: 8px; }
body.dark-mode .sidepanel .comment { background: rgba(255,255,255,0.05); }

/* Bootstrap modal/backdrop - consolidated and forced-on-top values */
.modal-backdrop {
    background-color: var(--modal-backdrop) !important;
    z-index: 10000 !important; /* ensure backdrop is above app header/overlays */
    pointer-events: auto !important; /* allow backdrop to intercept clicks for proper modal behavior */
    opacity: 1 !important;
}

/* Fix modal positioning */
.modal-backdrop {
    z-index: 1040 !important;
}

.modal {
    z-index: 1050 !important;
}

/* Дополнительные стили для модальных окон - ОПУСТИТЬ НИЖЕ HEADER */
.modal-dialog {
    margin-top: 100px !important; /* Добавляем отступ сверху */
    transition: margin-top 0.3s ease;
}

/* На мобильных устройствах уменьшаем отступ */
@media (max-width: 768px) {
    .modal-dialog {
        margin-top: 80px !important;
    }
}

/* Для очень маленьких экранов */
@media (max-height: 600px) {
    .modal-dialog {
        margin-top: 60px !important;
    }
}

/* Убедимся, что модальное окно не выходит за пределы экрана */
.modal-content {
    max-height: calc(100vh - 120px) !important;
    overflow-y: auto;
}

/* Для модального окна отправки (bulkSendModal) можно добавить дополнительные стили */
#bulkSendModal .modal-dialog {
    margin-top: 110px !important; /* Чуть больше отступ для окна отправки */
}

/* Убрать конфликтующие стили для backdrop если есть */
.modal-backdrop {
    z-index: 1040 !important;
}

.modal {
    z-index: 1050 !important;
}

/* Ensure modal is responsive */
@media (max-width: 576px) {
    .modal-dialog {
        margin: 0.5rem !important;
    }
}

/* Ensure form controls are visible in modal */
.modal-body .form-control {
    background: var(--modal-input-bg) !important;
    color: var(--modal-text) !important;
    border: 1px solid var(--modal-border) !important;
}

body.dark-mode .modal-body .form-control {
    background: rgba(30, 41, 59, 0.8) !important;
}

/* Стили для фото в боковой панели */
.photo-thumbnail {
    max-width: 200px;
    max-height: 200px;
    object-fit: cover;
    border-radius: 8px;
    border: 2px solid #dee2e6;
    transition: transform 0.3s;
}

.photo-thumbnail:hover {
    transform: scale(1.05);
}

.photo-thumbnail-container {
    position: relative;
    display: inline-block;
    margin-bottom: 10px;
}

.photo-thumbnail-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.3s;
    border-radius: 6px;
    cursor: pointer;
}

.photo-thumbnail-container:hover .photo-thumbnail-overlay {
    opacity: 1;
}

.photo-thumbnail-overlay span {
    font-size: 24px;
    color: white;
    background: rgba(0, 0, 0, 0.7);
    padding: 8px;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Убедимся, что бэкдропы не блокируют когда модальное окно скрыто */
.modal-backdrop:not(.show) {
    opacity: 0 !important;
    pointer-events: none !important;
    display: none !important;
}

/* Удаляем лишние бэкдропы */
body > .modal-backdrop ~ .modal-backdrop {
    display: none !important;
    opacity: 0 !important;
}

/* Гарантируем, что только активные модальные окна имеют бэкдроп */
.modal:not(.show) ~ .modal-backdrop {
    display: none !important;
}

/* Исправляем pointer-events для модальных окон */
.modal.show {
    pointer-events: auto !important;
}

.modal-backdrop.show {
    pointer-events: auto !important;
}

/* Улучшаем закрытие sidepanel */
.sidepanel:not(.active) {
    pointer-events: none !important;
}

/* Убираем возможные остаточные стили блокировки */
body.modal-open {
    overflow: auto !important;
    padding-right: 0 !important;
}

/* Адаптивность для таблицы */
@media (max-width: 1200px) {
    .table td:nth-child(4),
    .table th:nth-child(4),
    .table td:nth-child(5),
    .table th:nth-child(5) {
        max-width: 150px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }
}

@media (max-width: 992px) {
    .table {
        display: block;
        overflow-x: auto;
    }
}
