/* ===== КАСТОМНЫЙ КАЛЕНДАРЬ С БОКОВОЙ ПАНЕЛЬЮ ===== */

/* Основной контейнер календаря */
.custom-calendar {
    position: fixed;
    background: var(--bg-white);
    border-radius: var(--form-dropdown-radius);
    box-shadow: var(--form-dropdown-shadow);
    border: var(--form-dropdown-border);
    z-index: 40;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: 14px;
    line-height: 1.4;
    color: var(--text-color);
    animation: calendarShow 0.2s ease-out;
}

/* Календарь без боковой панели */
.custom-calendar.without-sidebar {
    width: 246px;
    padding: var(--form-dropdown-padding);
}

/* Календарь с боковой панелью */
.custom-calendar.with-sidebar {
    width: 496px; /* 246px (календарь) + 250px (панель) */
    display: flex;
    padding: 0;
}

/* Левая часть - основной календарь */
.calendar-main {
    width: 246px;
    padding: var(--form-dropdown-padding);
    flex-shrink: 0;
}

/* Правая часть - боковая панель */
.calendar-sidebar {
    width: 250px;
    background: var(--bg-light);
    border-left: 1px solid var(--border-color);
    padding: 16px 12px;
    display: flex;
    flex-direction: column;
    gap: 5px;
}

/* Заголовок календаря */
.calendar-header {
    display: flex;
    align-items: center;
    margin-bottom: 16px;
    position: relative;
}

.calendar-title {
    font-weight: 500;
    font-size: 15px;
    color: var(--text-color);
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 4px;
    transition: all 0.2s ease;
    white-space: nowrap; /* Предотвращаем перенос текста */
}

/* Стили для заголовка в зависимости от режима */
.calendar-title .month-name {
    color: var(--text-color); /* Название месяца остается как есть */
}

.calendar-title .year-name {
    color: var(--text-light); /* Только год серым */
}

.calendar-title:hover {
    background: var(--bg-light);
}

.calendar-nav {
    display: flex;
    gap: 8px;
    width: 100%;
    justify-content: space-between;
}

.calendar-nav-btn {
    width: 32px;
    height: 32px;
    border: none;
    background: var(--bg-light);
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 25px;
    color: var(--text-light);
    transition: all 0.2s ease;
    line-height: 1;
    position: relative;
    z-index: 10;
    /* Убираем подсветку при нажатии на мобильных */
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
}

.nav-arrow {
    margin-top: -6px;
    pointer-events: none; /* Предотвращаем перехват кликов стрелкой */
}

.calendar-nav-btn:hover {
    background: var(--bg-light);
    color: var(--text-color);
    transform: scale(1.05);
}

.calendar-nav-btn:active {
    background: var(--bg-light);
    transform: scale(0.95);
}

.calendar-nav-btn:focus {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

/* Дни недели */
.calendar-weekdays {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 2px;
    margin-bottom: 8px;
}

.weekday {
    text-align: center;
    font-size: 12px;
    font-weight: 500;
    color: var(--primary-color);
    padding: 8px 4px;
}

/* Дни месяца */
.calendar-days {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 2px;
}

.calendar-day {
    width: 28px;
    height: 28px;
    border: none;
    background: transparent;
    border-radius: 4px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    color: var(--primary-color);
    transition: background-color 0.2s ease, border-color 0.2s ease, color 0.2s ease;
    position: relative;
}

.calendar-day:hover:not(.disabled):not(.selected):not(.today) {
    border: 1px solid var(--primary-color);
    border-radius: 4px;
}

.calendar-day.today {
    border: 1px solid var(--primary-color);
    background: rgba(52, 73, 94, 0.1);
    font-weight: 500;
}

.calendar-day.today:hover:not(.disabled):not(.selected) {
    background: rgba(52, 73, 94, 0.2);
    border: 1px solid var(--primary-color);
}

.calendar-day.selected {
    background: var(--primary-color);
    color: var(--bg-white);
    font-weight: 600;
    border: none;
}

.calendar-day.selected:hover {
    background: var(--primary-color);
    border: none;
}

.calendar-day.other-month {
    color: var(--primary-color); /* Тот же цвет, что и у обычных дней */
    cursor: pointer; /* Делаем кликабельными */
}

.calendar-day.disabled {
    color: var(--border-color);
    cursor: not-allowed;
}

.calendar-day.disabled:hover {
    background: transparent;
    border: none;
}

/* Стили для диапазона дат */
.calendar-day.range-single {
    background-color: var(--primary-color);
    color: var(--bg-white);
    border-radius: 4px;
}

.calendar-day.range-start {
    background-color: var(--primary-color);
    color: var(--bg-white);
    border-radius: 50% 0 0 50%;
}

.calendar-day.range-end {
    background-color: var(--primary-color);
    color: var(--bg-white);
    border-radius: 0 50% 50% 0;
}

.calendar-day.range-between {
    background-color: rgba(52, 73, 94, 0.2);
    color: var(--primary-color);
}

.calendar-day.range-start.range-end {
    border-radius: 50%;
}

.calendar-day.range-start:not(.range-end) {
    border-radius: 4px 0 0 4px;
}

.calendar-day.range-end:not(.range-start) {
    border-radius: 0 4px 4px 0;
}

/* Вид месяцев */
.calendar-months {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    padding: 8px 0;
}

.calendar-month {
    padding: 10px 8px;
    border: none;
    background: transparent;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    color: var(--text-color);
    transition: all 0.2s ease;
    text-align: center;
}

.calendar-month:hover {
    background: var(--bg-light);
}

.calendar-month.current {
    background: var(--primary-color);
    color: var(--bg-white);
    font-weight: 600;
}

.calendar-month.selected {
    background: var(--primary-color);
    color: var(--bg-white);
    font-weight: 600;
}

.calendar-month.selected:hover {
    background: var(--primary-dark);
}

/* Вид годов */
.calendar-years {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
    padding: 8px 0;
}

.calendar-year {
    padding: 10px 8px;
    border: none;
    background: transparent;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    color: var(--text-color);
    transition: all 0.2s ease;
    text-align: center;
}

.calendar-year:hover {
    background: var(--bg-light);
}

.calendar-year.current {
    background: var(--primary-color);
    color: var(--bg-white);
    font-weight: 600;
}

.calendar-year.selected {
    background: var(--primary-color);
    color: var(--bg-white);
    font-weight: 600;
}

.calendar-year.selected:hover {
    background: var(--primary-dark);
}

/* Кнопки действий */
.calendar-actions {
    display: flex;
    gap: 8px;
    margin-top: 16px;
    padding-top: 10px;
    border-top: 1px solid var(--border-color);
}

.calendar-btn {
    flex: 1;
    padding: 4px 12px;
    border: 1px solid var(--primary-color);
    background: var(--bg-white);
    border-radius: 4px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 400;
    color: var(--primary-color);
    transition: all 0.2s ease;
}

.calendar-btn:hover {
    background: var(--bg-white);
    border-color: var(--primary-color);
}

.calendar-btn.primary {
    background: var(--primary-color);
    color: var(--bg-white);
    border-color: var(--primary-color);
}

.calendar-btn.primary:hover {
    background: var(--primary-dark);
    border-color: var(--primary-dark);
}

/* Боковая панель */
.sidebar-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-color);
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border-color);
}

.sidebar-link {
    display: block;
    padding: 5px 10px;
    background: transparent;
    border: none;
    text-decoration: none;
    transition: all 0.2s ease;
    font-size: 13px;
    font-weight: 400;
    color: var(--text-color);
    text-align: left;
    line-height: 1.3;
    border-radius: 4px;
    cursor: pointer;
    width: 100%;
}

.sidebar-link:hover {
    background: var(--primary-color);
    color: var(--bg-white);
    text-decoration: none;
}

.sidebar-link.active {
    background: var(--primary-color);
    color: var(--bg-white);
}

/* Анимации */
@keyframes calendarShow {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

/* Адаптивность */
@media (max-width: 768px) {
    .custom-calendar.with-sidebar {
        width: 100%;
        max-width: 400px;
        flex-direction: column;
    }
    
    .custom-calendar.without-sidebar {
        width: min(310px, calc(100vw - 20px)) !important;
        max-width: 310px !important;
    }
    
    .calendar-main {
        width: 100%;
    }
    
    .calendar-sidebar {
        width: 100%;
        border-left: none;
        border-top: 1px solid var(--border-color);
    }
    
    /* Адаптируем годы для мобильных (3 колонки вместо 4) */
    .custom-calendar.without-sidebar .calendar-years {
        grid-template-columns: repeat(3, 1fr);
    }
}

/* Скрытие календаря */
.custom-calendar.hidden {
    display: none;
}

/* Переключатель в боковой панели */
.sidebar-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: auto;
    padding-top: 16px;
    border-top: 1px solid var(--border-color);
    padding-left: 10px;
    padding-right: 10px;
    width: 100%;
    /* Убираем подсветку при нажатии на мобильных */
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
}

.toggle-label {
    font-size: 13px;
    font-weight: 400;
    color: var(--text-color);
    transition: color 0.2s ease;
    /* Убираем подсветку при нажатии на мобильных */
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
}

.slide-toggle {
    width: 40px;
    height: 15px;
    background: var(--primary-color);
    position: relative;
    border-radius: 50px;
    box-shadow: inset 0px 1px 1px rgba(0,0,0,0.1), 0px 1px 0px rgba(255,255,255,0.2);
    cursor: pointer;
    /* Убираем подсветку при нажатии на мобильных */
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
}

.slide-toggle label {
    display: block;
    width: 15px;
    height: 10.5px;
    cursor: pointer;
    position: absolute;
    top: 2px;
    left: 22px;
    z-index: 1;
    background: linear-gradient(to bottom, #fcfff4 0%, #dfe5d7 40%, #b3bead 100%);
    border-radius: 50px;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0px 2px 5px 0px rgba(0,0,0,0.3);
    /* Убираем подсветку при нажатии на мобильных */
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
}

.slide-toggle input[type=checkbox] {
    visibility: hidden;
}

.slide-toggle input[type=checkbox]:checked + label {
    left: 2px;
    box-shadow: 0px 3px 8px 0px rgba(0,0,0,0.4);
}

/* ===== АДАПТИВНОСТЬ ДЛЯ МОБИЛЬНЫХ УСТРОЙСТВ ===== */

/* ===== ТЕМНАЯ ТЕМА ДЛЯ КАЛЕНДАРЯ ===== */
html[data-theme="dark"] .custom-calendar {
    background: #2a2a2a;
    border-color: rgba(255, 255, 255, 0.1);
    color: #e0e0e0;
}

html[data-theme="dark"] .calendar-sidebar {
    background: #2a2a2a;
    border-left-color: rgba(255, 255, 255, 0.1);
}

html[data-theme="dark"] .calendar-title {
    color: #e0e0e0;
}

html[data-theme="dark"] .calendar-title:hover {
    background: rgba(255, 255, 255, 0.1);
}

html[data-theme="dark"] .calendar-nav-btn {
    background: rgba(255, 255, 255, 0.1);
    color: #e0e0e0;
}

html[data-theme="dark"] .calendar-nav-btn:hover {
    background: rgba(255, 255, 255, 0.15);
    color: #e0e0e0;
}

html[data-theme="dark"] .calendar-nav-btn:active {
    background: rgba(255, 255, 255, 0.2);
}

html[data-theme="dark"] .calendar-nav-btn:focus {
    outline-color: var(--primary-color);
}

html[data-theme="dark"] .weekday {
    color: #e0e0e0;
}

html[data-theme="dark"] .calendar-day {
    color: #e0e0e0;
}

html[data-theme="dark"] .calendar-day:hover:not(.today):not(.disabled):not(.selected) {
    background: rgba(255, 255, 255, 0.1);
}

html[data-theme="dark"] .calendar-day.today {
    border-color: var(--primary-color);
    background: rgba(255, 255, 255, 0.1);
}

html[data-theme="dark"] .calendar-day.today:hover:not(.disabled):not(.selected) {
    background: rgba(255, 255, 255, 0.15);
    border-color: var(--primary-color);
}

html[data-theme="dark"] .calendar-day.selected {
    background: var(--primary-color);
    color: #ffffff;
}

html[data-theme="dark"] .calendar-day.other-month {
    color: #b0b0b0;
}

html[data-theme="dark"] .calendar-day.disabled {
    color: #666666;
}

html[data-theme="dark"] .calendar-day.range-single {
    background-color: var(--primary-color);
    color: #ffffff;
}

html[data-theme="dark"] .calendar-day.range-start {
    background-color: var(--primary-color);
    color: #ffffff;
}

html[data-theme="dark"] .calendar-day.range-end {
    background-color: var(--primary-color);
    color: #ffffff;
}

html[data-theme="dark"] .calendar-day.range-between {
    background-color: rgba(255, 255, 255, 0.1);
    color: var(--primary-color);
}

html[data-theme="dark"] .calendar-month {
    color: #e0e0e0;
}

html[data-theme="dark"] .calendar-month:hover {
    background: rgba(255, 255, 255, 0.1);
}

html[data-theme="dark"] .calendar-month.current {
    background: var(--primary-color);
    color: #ffffff;
}

html[data-theme="dark"] .calendar-month.selected {
    background: var(--primary-color);
    color: #ffffff;
}

html[data-theme="dark"] .calendar-month.selected:hover {
    background: var(--primary-color);
    opacity: 0.9;
}

html[data-theme="dark"] .calendar-year {
    color: #e0e0e0;
}

html[data-theme="dark"] .calendar-year:hover {
    background: rgba(255, 255, 255, 0.1);
}

html[data-theme="dark"] .calendar-year.current {
    background: var(--primary-color);
    color: #ffffff;
}

html[data-theme="dark"] .calendar-year.selected {
    background: var(--primary-color);
    color: #ffffff;
}

html[data-theme="dark"] .calendar-year.selected:hover {
    background: var(--primary-color);
    opacity: 0.9;
}

html[data-theme="dark"] .calendar-actions {
    border-top-color: rgba(255, 255, 255, 0.1);
}

html[data-theme="dark"] .calendar-btn {
    border-color: var(--primary-color) !important;
    background: transparent !important;
    color: var(--primary-color) !important;
}

html[data-theme="dark"] .calendar-btn:hover {
    background: var(--primary-color) !important;
    color: #ffffff !important;
    border-color: var(--primary-color) !important;
}

html[data-theme="dark"] .calendar-btn.primary {
    background: var(--primary-color) !important;
    color: #ffffff !important;
    border-color: var(--primary-color) !important;
}

html[data-theme="dark"] .calendar-btn.primary:hover {
    background: var(--primary-color) !important;
    opacity: 0.9;
    border-color: var(--primary-color) !important;
}

html[data-theme="dark"] .sidebar-title {
    color: #e0e0e0;
    border-bottom-color: rgba(255, 255, 255, 0.1);
}

html[data-theme="dark"] .sidebar-link {
    color: #e0e0e0;
}

html[data-theme="dark"] .sidebar-link:hover {
    background: var(--primary-color);
    color: #ffffff;
}

html[data-theme="dark"] .sidebar-link.active {
    background: var(--primary-color);
    color: #ffffff;
}

html[data-theme="dark"] .sidebar-toggle {
    border-top-color: rgba(255, 255, 255, 0.1);
}

html[data-theme="dark"] .toggle-label {
    color: #e0e0e0;
}

html[data-theme="dark"] .slide-toggle {
    background: var(--primary-color);
}
