/**
 * Дополнительные стили для приложения Affecta
 */

/* Общие стили */
body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}


/* Мягкая светлая тема - переопределение белого фона */
:root:not(.dark) {
    --bg-primary: #F8FAFC;
    --bg-secondary: #F1F5F9;
    --bg-card: #FFFFFF;
    --bg-card-hover: #F8FAFC;
}


.bg-white:not(.dark *) {
    background-color: var(--bg-card) !important;
}

/* Стили для textarea, select и input - светлая тема */
textarea,
select,
input[type="text"],
input[type="number"],
input[type="date"],
input[type="email"],
input[type="password"],
input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="submit"]):not([type="button"]) {
    background-color: #FAFBFC !important;
    color: #111827 !important;
    border-color: #D1D5DB !important;
}

textarea::placeholder,
input::placeholder {
    color: #9CA3AF !important;
    opacity: 1 !important;
}

select option {
    background-color: #FAFBFC !important;
    color: #111827 !important;
}

/* Дополнительная специфичность для модальных окон */
#addCustomStateModal input[type="text"],
#addCustomStateModal input[type="number"],
#addMedicationModal input[type="text"],
#addMedicationModal input[type="number"],
#addCustomStateModal select,
#addMedicationModal select {
    background-color: #FAFBFC !important;
    color: #111827 !important;
}

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

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

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

/* Анимированные элементы */
.fade-in {
    animation: fadeIn 0.3s ease-out;
}

.slide-in {
    animation: slideIn 0.3s ease-out;
}

.pulse-animation {
    animation: pulse 2s infinite;
}

/* Кастомные ползунки */
input[type="range"] {
    -webkit-appearance: none;
    appearance: none;
    height: 6px;
    background: #E5E7EB;
    border-radius: 3px;
    outline: none;
    transition: background 0.3s ease;
}

input[type="range"]:hover {
    background: #D1D5DB;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    background: #4F46E5;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

input[type="range"]::-webkit-slider-thumb:hover {
    background: #4338CA;
    transform: scale(1.1);
}

input[type="range"]::-moz-range-thumb {
    width: 20px;
    height: 20px;
    background: #4F46E5;
    border-radius: 50%;
    cursor: pointer;
    border: none;
    transition: all 0.3s ease;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

input[type="range"]::-moz-range-thumb:hover {
    background: #4338CA;
    transform: scale(1.1);
}

/* Кастомные чекбоксы */
input[type="checkbox"] {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    border: 2px solid #D1D5DB;
    border-radius: 4px;
    position: relative;
    cursor: pointer;
    transition: all 0.3s ease;
}

input[type="checkbox"]:checked {
    background: #4F46E5;
    border-color: #4F46E5;
}

input[type="checkbox"]:checked::after {
    content: '';
    position: absolute;
    left: 5px;
    top: 2px;
    width: 5px;
    height: 9px;
    border: solid white;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

input[type="checkbox"]:hover {
    border-color: #9CA3AF;
}

/* Кастомные радиокнопки */
input[type="radio"] {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    border: 2px solid #D1D5DB;
    border-radius: 50%;
    position: relative;
    cursor: pointer;
    transition: all 0.3s ease;
}

input[type="radio"]:checked {
    border-color: #4F46E5;
}

input[type="radio"]:checked::after {
    content: '';
    position: absolute;
    left: 3px;
    top: 3px;
    width: 8px;
    height: 8px;
    background: #4F46E5;
    border-radius: 50%;
}

input[type="radio"]:hover {
    border-color: #9CA3AF;
}

/* Стили для модальных окон */
.modal-backdrop {
    backdrop-filter: blur(4px);
    background-color: rgba(0, 0, 0, 0.5);
}

.modal-content {
    max-height: 90vh;
    overflow-y: auto;
}

/* Стили для графиков */
.chart-container {
    position: relative;
    height: 300px;
    margin: 20px 0;
}

/* Стили для таблиц */
.table-hover tbody tr:hover {
    background-color: #F1F5F9;
    transition: background-color 0.2s ease;
}

/* Стили для карточек */
.card-hover {
    transition: all 0.3s ease;
}

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

/* Стили для кнопок */
.btn-primary {
    background: linear-gradient(135deg, #4F46E5 0%, #7C3AED 100%);
    transition: all 0.3s ease;
}

.btn-primary:hover {
    background: linear-gradient(135deg, #4338CA 0%, #6D28D9 100%);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(79, 70, 229, 0.4);
}

/* Стили для навигации */
.nav-link {
    position: relative;
    transition: all 0.3s ease;
}

.nav-link::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 0;
    width: 0;
    height: 2px;
    background: #4F46E5;
    transition: width 0.3s ease;
}

.nav-link:hover::after,
.nav-link.active::after {
    width: 100%;
}

/* Стили для загрузки */
.loading {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid #f3f3f3;
    border-top: 3px solid #4F46E5;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

/* Стили для уведомлений */
.alert {
    animation: slideInRight 0.3s ease-out;
}

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

/* Стили для форм */
.form-group {
    margin-bottom: 1.5rem;
}

.form-label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: #374151;
}

.form-input {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid #D1D5DB;
    border-radius: 0.375rem;
    transition: all 0.3s ease;
}

.form-input:focus {
    outline: none;
    border-color: #4F46E5;
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

.form-input.error {
    border-color: #EF4444;
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.1);
}

/* Стили для статистики */
.stat-card {
    background: linear-gradient(135deg, #FEFEFE 0%, #F8FAFC 100%);
    border: 1px solid #E2E8F0;
    transition: all 0.3s ease;
}

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

/* Стили для мобильных устройств */
@media (max-width: 768px) {
    /* Закрепленный слайдер дат на мобильных */
    .fixed.top-0 {
        border-radius: 0;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    }
    
    .modal-content {
        margin: 1rem;
        max-height: calc(100vh - 2rem);
    }
    
    .chart-container {
        height: 250px;
    }
    
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    /* Мобильная адаптация для кнопок состояний (стиль eMoods - единый блок) */
    .state-btn,
    .binary-btn,
    .custom-binary-btn,
    .custom-cat-btn,
    .day-type-btn {
        min-height: 44px; /* Минимальная высота для удобного нажатия */
        padding: 0.625rem 0.75rem;
        font-size: 0.875rem;
        /* Сохраняем стиль eMoods на мобильных - единый блок */
        background-color: #374151;
        border: none;
        border-right: 1px solid #4B5563;
        border-radius: 0;
        color: #FFFFFF;
        text-transform: uppercase;
    }
    
    [data-state-group] .state-btn:last-child,
    .binary-btn:last-of-type,
    [data-custom-binary] .custom-binary-btn:last-child,
    [data-custom-cat] .custom-cat-btn:last-child {
        border-right: none;
    }
    
    [data-state-group] .state-btn:first-child,
    .binary-btn:first-of-type,
    [data-custom-binary] .custom-binary-btn:first-child,
    [data-custom-cat] .custom-cat-btn:first-child {
        border-top-left-radius: 0.375rem;
        border-bottom-left-radius: 0.375rem;
    }
    
    [data-state-group] .state-btn:last-child,
    .binary-btn:last-of-type,
    [data-custom-binary] .custom-binary-btn:last-child,
    [data-custom-cat] .custom-cat-btn:last-child {
        border-top-right-radius: 0.375rem;
        border-bottom-right-radius: 0.375rem;
    }
    
    .state-btn.active,
    .binary-btn.active,
    .custom-binary-btn.active,
    .custom-cat-btn.active,
    .day-type-btn.active {
        background-color: #7C3AED;
        color: #FFFFFF;
    }
    
    /* Мобильная адаптация для ползунков */
    input[type="range"] {
        height: 8px;
        -webkit-tap-highlight-color: transparent;
    }
    
    input[type="range"]::-webkit-slider-thumb {
        width: 24px;
        height: 24px;
        box-shadow: 0 3px 6px rgba(0, 0, 0, 0.2);
    }
    
    input[type="range"]::-moz-range-thumb {
        width: 24px;
        height: 24px;
        box-shadow: 0 3px 6px rgba(0, 0, 0, 0.2);
    }
    
    /* Улучшенные отступы на мобильных */
    .space-y-6 > * + * {
        margin-top: 1rem;
    }
    
    /* Компактные заголовки */
    h1 {
        font-size: 1.5rem;
        line-height: 1.75rem;
    }
    
    h2 {
        font-size: 1.125rem;
        line-height: 1.5rem;
    }
    
    /* Мобильная адаптация для форм */
    .form-group {
        margin-bottom: 1rem;
    }
    
    /* Мобильная адаптация для модальных окон */
    .modal-content {
        border-radius: 0.5rem;
        padding: 1.25rem;
    }
    
    /* Компактные карточки на мобильных */
    .bg-white.rounded-lg.shadow-sm {
        padding: 1rem;
    }
    
    /* Стили для нижней навигационной панели */
    nav.fixed.bottom-0 {
        -webkit-tap-highlight-color: transparent;
    }
    
    nav.fixed.bottom-0 a {
        -webkit-tap-highlight-color: rgba(99, 102, 241, 0.1);
    }
}

@media (max-width: 640px) {
    .stats-grid {
        grid-template-columns: 1fr;
    }
    
    .chart-container {
        height: 200px;
    }
    
    /* Еще более компактные стили для маленьких экранов */
    h1 {
        font-size: 1.25rem;
    }
    
    .bg-white.rounded-lg.shadow-sm {
        padding: 0.875rem;
    }
}

/* Утилитарные классы */
.text-shadow {
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.backdrop-blur {
    backdrop-filter: blur(8px);
}

.scroll-smooth {
    scroll-behavior: smooth;
}

/* Стили для печати */
@media print {
    .no-print {
        display: none !important;
    }
    
    body {
        background: white !important;
        color: black !important;
    }
    
    .container {
        max-width: none !important;
        width: 100% !important;
    }
}

/* Дополнительные стили для улучшения UX */
.transition-all {
    transition: all 0.3s ease;
}

.focus-ring:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

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

/* Стили для кнопок в стиле eMoods - единый блок с разделителями */
.state-btn,
.binary-btn,
.custom-binary-btn,
.custom-cat-btn,
.day-type-btn {
    background-color: #374151;
    color: #FFFFFF;
    font-weight: 500;
    text-transform: uppercase;
    transition: all 0.2s ease;
    border: none;
    border-right: 1px solid #4B5563;
    border-radius: 0;
    outline: none;
}

/* Убираем рамки у кнопок редактирования и добавления */
#medications-section .flex.gap-2 button,
#medications-section .flex.gap-2 a,
#custom-states-section .flex.gap-2 button,
#custom-states-section .flex.gap-2 a {
    border: none !important;
    outline: none !important;
    box-shadow: none !important;
}

/* Убираем разделитель у последней кнопки в группе */
[data-state-group] .state-btn:last-child,
.binary-btn:last-of-type,
[data-custom-binary] .custom-binary-btn:last-child,
[data-custom-cat] .custom-cat-btn:last-child {
    border-right: none;
}

/* Первая кнопка - скругление слева */
[data-state-group] .state-btn:first-child,
.binary-btn:first-of-type,
[data-custom-binary] .custom-binary-btn:first-child,
[data-custom-cat] .custom-cat-btn:first-child {
    border-top-left-radius: 0.375rem;
    border-bottom-left-radius: 0.375rem;
}

/* Последняя кнопка - скругление справа */
[data-state-group] .state-btn:last-child,
.binary-btn:last-of-type,
[data-custom-binary] .custom-binary-btn:last-child,
[data-custom-cat] .custom-cat-btn:last-child {
    border-top-right-radius: 0.375rem;
    border-bottom-right-radius: 0.375rem;
}

/* Внешние границы для всего блока */
[data-state-group],
[data-custom-cat] {
    border: 1px solid #4B5563;
    border-radius: 0.375rem;
    overflow: hidden;
}

/* Для бинарных кнопок - компактные, не растягиваются */
.binary-btn-group,
[data-custom-binary] {
    border: 1px solid #4B5563;
    border-radius: 0.375rem;
    overflow: hidden;
    display: inline-flex;
    width: auto;
}

/* Бинарные кнопки не должны растягиваться */
.binary-btn-group .binary-btn,
[data-custom-binary] .custom-binary-btn {
    flex: 0 0 auto;
    width: auto;
}

/* Для grid контейнеров */
[data-state-group] {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0;
}

[data-custom-cat] {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0;
}

/* Мобильная адаптация для кастомных категориальных состояний */
@media (max-width: 768px) {
    [data-custom-cat] {
        grid-template-columns: repeat(4, 1fr);
    }
    
    [data-custom-cat] .custom-cat-btn {
        padding: 0.5rem 0.25rem;
        font-size: 0.75rem;
    }
}

@media (max-width: 640px) {
    [data-custom-cat] .custom-cat-btn {
        padding: 0.5rem 0.125rem;
        font-size: 0.7rem;
    }
}

.state-btn:hover,
.binary-btn:hover,
.custom-binary-btn:hover,
.custom-cat-btn:hover,
.day-type-btn:hover {
    background-color: #4B5563;
}

/* Стили для активных состояний кнопок (выбранные) */
.state-btn.active,
.binary-btn.active,
.custom-binary-btn.active,
.custom-cat-btn.active,
.day-type-btn.active {
    background-color: #7C3AED;
    color: #FFFFFF;
    font-weight: 600;
}

/* Убираем скрытые маркеры и иконки из чекбоксов в пользовательских состояниях */
.custom-state-multi-checkbox {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.custom-state-multi-checkbox input[type="checkbox"] {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    border: 2px solid #D1D5DB;
    border-radius: 4px;
    position: relative;
    cursor: pointer;
    transition: all 0.3s ease;
    margin-right: 10px;
    flex-shrink: 0;
}

.custom-state-multi-checkbox input[type="checkbox"]:checked {
    background-color: #6366F1;
    border-color: #6366F1;
}

.custom-state-multi-checkbox input[type="checkbox"]:checked::after {
    display: none;
}

.custom-state-multi-checkbox label {
    display: flex;
    align-items: center;
    cursor: pointer;
    padding: 10px 16px;
    border: 2px solid #E5E7EB;
    border-radius: 6px;
    transition: all 0.2s ease;
    background-color: #FAFBFC;
}

.custom-state-multi-checkbox label:hover {
    background-color: #F1F5F9;
    border-color: #D1D5DB;
}

/* Стили для выбранных чекбоксов в пользовательских состояниях */
.custom-state-multi-checkbox label:has(input[type="checkbox"]:checked) {
    background-color: #EEF2FF;
    border-color: #6366F1;
}

.custom-state-multi-checkbox label:has(input[type="checkbox"]:checked) span {
    color: #4338CA;
    font-weight: 500;
}

/* Альтернативный способ для браузеров без поддержки :has() */
.custom-state-multi-checkbox label.active {
    background-color: #EEF2FF;
    border-color: #6366F1;
}

.custom-state-multi-checkbox label.active span {
    color: #4338CA;
    font-weight: 500;
}

/* Стили для градиентов */
.gradient-primary {
    background: linear-gradient(135deg, #4F46E5 0%, #7C3AED 100%);
}

.gradient-secondary {
    background: linear-gradient(135deg, #10B981 0%, #059669 100%);
}

.gradient-accent {
    background: linear-gradient(135deg, #F59E0B 0%, #D97706 100%);
}

/* ============================================
   СТИЛИ ДЛЯ ТЕМНОЙ ТЕМЫ
   ============================================ */

/* Стили для textarea, select и input - темная тема */
.dark textarea,
.dark select,
.dark input[type="text"],
.dark input[type="number"],
.dark input[type="date"],
.dark input[type="email"],
.dark input[type="password"],
.dark input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="submit"]):not([type="button"]) {
    background-color: #374151 !important;
    color: #F9FAFB !important;
    border-color: #4B5563 !important;
}

.dark textarea::placeholder,
.dark input::placeholder {
    color: #9CA3AF !important;
    opacity: 1 !important;
}

.dark select option {
    background-color: #374151 !important;
    color: #F9FAFB !important;
}

/* Дополнительная специфичность для модальных окон в темной теме */
.dark #addCustomStateModal input[type="text"],
.dark #addCustomStateModal input[type="number"],
.dark #addMedicationModal input[type="text"],
.dark #addMedicationModal input[type="number"],
.dark #addCustomStateModal select,
.dark #addMedicationModal select {
    background-color: #374151 !important;
    color: #F9FAFB !important;
    border-color: #4B5563 !important;
}

/* Кастомные ползунки - темная тема */
.dark input[type="range"] {
    background: #4B5563;
}

.dark input[type="range"]:hover {
    background: #6B7280;
}

.dark input[type="range"]::-webkit-slider-thumb {
    background: #6366F1;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.dark input[type="range"]::-webkit-slider-thumb:hover {
    background: #818CF8;
}

.dark input[type="range"]::-moz-range-thumb {
    background: #6366F1;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.dark input[type="range"]::-moz-range-thumb:hover {
    background: #818CF8;
}

/* Кастомные чекбоксы - темная тема */
.dark input[type="checkbox"] {
    border-color: #6B7280;
    background-color: #374151;
}

.dark input[type="checkbox"]:checked {
    background: #6366F1;
    border-color: #6366F1;
}

.dark input[type="checkbox"]:hover {
    border-color: #9CA3AF;
}

/* Кастомные радиокнопки - темная тема */
.dark input[type="radio"] {
    border-color: #6B7280;
    background-color: #374151;
}

.dark input[type="radio"]:checked {
    border-color: #6366F1;
}

.dark input[type="radio"]:checked::after {
    background: #6366F1;
}

.dark input[type="radio"]:hover {
    border-color: #9CA3AF;
}

/* Стили для модальных окон - темная тема */
.dark .modal-backdrop {
    background-color: rgba(0, 0, 0, 0.75);
}

.dark .modal-content {
    background-color: #374151;
    color: #F9FAFB;
}

/* Стили для таблиц - темная тема */
.dark .table-hover tbody tr:hover {
    background-color: #4B5563;
}

/* Стили для карточек - темная тема */
.dark .card-hover:hover {
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
}

.dark .stat-card {
    background: linear-gradient(135deg, #374151 0%, #1F2937 100%);
    border: 1px solid #4B5563;
}

.dark .stat-card:hover {
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.5);
}

/* Стили для форм - темная тема */
.dark .form-label {
    color: #E5E7EB;
}

.dark .form-input {
    background-color: #374151;
    color: #F9FAFB;
    border-color: #4B5563;
}

.dark .form-input:focus {
    border-color: #6366F1;
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2);
}

.dark .form-input.error {
    border-color: #EF4444;
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.2);
}

/* Стили для кнопок в темной теме (стиль eMoods - единый блок) */
.dark .state-btn,
.dark .binary-btn,
.dark .custom-binary-btn,
.dark .custom-cat-btn,
.dark .day-type-btn {
    background-color: #374151;
    color: #FFFFFF;
    border: none;
    border-right: 1px solid #4B5563;
    border-radius: 0;
}

.dark [data-state-group] .state-btn:last-child,
.dark .binary-btn:last-of-type,
.dark [data-custom-binary] .custom-binary-btn:last-child,
.dark [data-custom-cat] .custom-cat-btn:last-child {
    border-right: none;
}

.dark [data-state-group] .state-btn:first-child,
.dark .binary-btn:first-of-type,
.dark [data-custom-binary] .custom-binary-btn:first-child,
.dark [data-custom-cat] .custom-cat-btn:first-child {
    border-top-left-radius: 0.375rem;
    border-bottom-left-radius: 0.375rem;
}

.dark [data-state-group] .state-btn:last-child,
.dark .binary-btn:last-of-type,
.dark [data-custom-binary] .custom-binary-btn:last-child,
.dark [data-custom-cat] .custom-cat-btn:last-child {
    border-top-right-radius: 0.375rem;
    border-bottom-right-radius: 0.375rem;
}

.dark [data-state-group],
.dark [data-custom-cat] {
    border: 1px solid #4B5563;
    border-radius: 0.375rem;
    overflow: hidden;
}

.dark .binary-btn-group,
.dark [data-custom-binary] {
    display: inline-flex;
    width: auto;
}

.dark .binary-btn-group .binary-btn,
.dark [data-custom-binary] .custom-binary-btn {
    flex: 0 0 auto;
    width: auto;
}

.dark .state-btn:hover,
.dark .binary-btn:hover,
.dark .custom-binary-btn:hover,
.dark .custom-cat-btn:hover,
.dark .day-type-btn:hover {
    background-color: #4B5563;
}

/* Стили для активных состояний кнопок - темная тема (выбранные) */
.dark .state-btn.active,
.dark .binary-btn.active,
.dark .custom-binary-btn.active,
.dark .custom-cat-btn.active,
.dark .day-type-btn.active {
    background-color: #7C3AED;
    color: #FFFFFF;
    font-weight: 600;
}

/* Пользовательские состояния - темная тема */
.dark .custom-state-multi-checkbox input[type="checkbox"] {
    border-color: #6B7280;
    background-color: #374151;
}

.dark .custom-state-multi-checkbox input[type="checkbox"]:checked {
    background-color: #6366F1;
    border-color: #6366F1;
}

.dark .custom-state-multi-checkbox label {
    border-color: #4B5563;
    background-color: #374151;
    color: #E5E7EB;
}

.dark .custom-state-multi-checkbox label:hover {
    background-color: #4B5563;
    border-color: #6B7280;
}

.dark .custom-state-multi-checkbox label:has(input[type="checkbox"]:checked),
.dark .custom-state-multi-checkbox label.active {
    background-color: #4338CA;
    border-color: #6366F1;
}

.dark .custom-state-multi-checkbox label:has(input[type="checkbox"]:checked) span,
.dark .custom-state-multi-checkbox label.active span {
    color: #E0E7FF;
    font-weight: 500;
}

/* Стили для загрузки - темная тема */
.dark .loading {
    border-color: #4B5563;
    border-top-color: #6366F1;
}

/* Плавный переход при переключении темы */
* {
    transition-property: background-color, border-color, color, fill, stroke;
    transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
    transition-duration: 200ms;
}

/* Исключения для элементов, которые не должны анимироваться */
svg,
img,
canvas,
video {
    transition: none;
}

/* Стили для графиков Chart.js - темная тема */
.dark .chart-container {
    color: #E5E7EB;
}

/* Стили для печати - темная тема */
@media print {
    .dark body {
        background: white !important;
        color: black !important;
    }
}

/* ============================================= */
/* ФИНАЛЬНЫЕ КОСТЫЛИ - МАКСИМАЛЬНАЯ СПЕЦИФИЧНОСТЬ */
/* ============================================= */

/* Темная тема - принудительный фон */
html.dark body,
html.dark body.bg-gray-50,
html.dark body.bg-gray-50.dark\:bg-gray-900,
html[class*="dark"] body {
    background-color: #111827 !important;
    background: #111827 !important;
}

/* Светлая тема - принудительный фон */
html:not(.dark) body,
html:not(.dark) body.bg-gray-50 {
    background-color: #F8FAFC !important;
    background: #F8FAFC !important;
}

/* ============================================= */
/* ИСПРАВЛЕННЫЕ СТИЛИ - БАЛАНС МЕЖДУ ТЕМАМИ */
/* ============================================= */

/* ТЕМНАЯ ТЕМА */
html.dark body {
    background-color: #111827 !important;
    background: #111827 !important;
}

/* Принудительно красим фон контейнеров в темный цвет в темной теме,
   если они должны быть темными (bg-white dark:bg-gray-800) */
html.dark .bg-white.dark\:bg-gray-800 {
    background-color: #1f2937 !important; /* gray-800 */
}

/* СВЕТЛАЯ ТЕМА */
/* Возвращаем нормальные цвета для светлой темы */
html:not(.dark) body {
    background-color: #F8FAFC !important;
    background: #F8FAFC !important;
}

html:not(.dark) .bg-white {
    background-color: #ffffff !important;
}

html:not(.dark) .bg-gray-50 {
    background-color: #F9FAFB !important; /* gray-50 */
}

/* Убираем прозрачность main, так как она ломала светлую тему */
/* Фон main будет определяться через tailwind классы или наследоваться от body */