/* Лунный календарь */

:root {
    /* Масштаб мини-ячейки легенды относительно реального размера ячейки календаря */
    --legend-scale: 0.75; /* 75% по умолчанию (диапазон, который просили: 70–80%) */
}

.ekadashi-page {
    display: flex;
    flex-direction: column;
}

/* Компактная информация о сегодняшнем дне в header - всё в одной строке с заголовком */
.header-left {
    display: flex;
    align-items: center;
}

.header-left h1 {
    display: flex;
    align-items: baseline;
    gap: 12px;
    flex-wrap: wrap;
    font-size: 24px;
    margin: 0;
}

.header-divider {
    color: rgba(52, 152, 219, 0.4);
    font-size: 14px;
    font-weight: 400;
}

.header-date {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary, #2c3e50);
}

.header-info {
    font-size: 14px;
    font-weight: 400;
    color: var(--text-secondary, #5f6b7a);
}

.header-info strong {
    color: var(--accent-color, #3498db);
    font-weight: 700;
}

.header-events {
    display: flex;
    gap: 4px;
    align-items: center;
}

.event-badge-mini {
    background: rgba(52, 152, 219, 0.12);
    color: var(--accent-color, #3498db);
    font-size: 11px;
    font-weight: 600;
    padding: 2px 6px;
    border-radius: 6px;
    border: 1px solid rgba(52, 152, 219, 0.25);
    white-space: nowrap;
}

/* Панель управления городом и настройками календаря */
.calendar-controls {
    background: var(--card-bg, #ffffff);
    border: 1px solid rgba(52, 152, 219, 0.18);
    border-radius: 10px;
    padding: 12px;
    margin-bottom: 16px;
}

.calendar-controls-grid {
    display: grid;
    grid-template-columns: 1.4fr 1fr;
    gap: 12px;
}

.control-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.control-label {
    font-size: 13px;
    font-weight: 700;
    color: var(--text-primary, #2c3e50);
}

.control-row {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.control-select {
    min-width: 220px;
    max-width: 100%;
    padding: 7px 10px;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    background: #ffffff;
    color: #1f2937;
}

.control-btn {
    padding: 7px 12px;
    border: none;
    border-radius: 6px;
    background: var(--accent-color, #3498db);
    color: #ffffff;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
}

.control-btn:hover {
    background: var(--accent-hover, #2980b9);
}

.control-hint {
    font-size: 12px;
    color: var(--text-secondary, #5f6b7a);
}

.toggle-row {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: var(--text-primary, #2c3e50);
}

body.hide-moon-phases .moon-icon {
    display: none;
}

body.hide-ekadashi-highlight .calendar-day.ekadashi-day {
    background: var(--bg-primary, #ffffff);
    border-color: #d1d5db;
    border-width: 1px;
}

body.hide-ekadashi-highlight .ekadashi-marker {
    display: none;
}

/* Навигация по месяцам */
.month-navigation {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 15px;
    margin-bottom: 20px;
    padding: 10px 12px;
    background: var(--card-bg, #ffffff);
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.08);
}

.nav-btn {
    padding: 8px 16px;
    background: var(--accent-color, #3498db);
    color: #ffffff;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    transition: all 0.2s ease;
}

.nav-btn:hover {
    background: var(--accent-hover, #2980b9);
    transform: translateY(-1px);
}

.nav-btn:active {
    transform: translateY(0);
    filter: brightness(0.95);
}

.nav-btn:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.35);
}

.current-period {
    font-size: 16px;
    font-weight: 700;
    color: var(--text-primary, #2c3e50);
    min-width: 120px;
    text-align: center;
    padding: 6px 12px;
    background: rgba(52, 152, 219, 0.08);
    border: 1px solid rgba(52, 152, 219, 0.25);
    border-radius: 18px;
}

/* Сетка календарей */
.calendars-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 15px;
    margin-bottom: 30px;
}

/* Отдельный календарь месяца */
.month-calendar {
    background: var(--card-bg);
    border-radius: 8px;
    padding: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.month-title {
    text-align: center;
    margin-bottom: 10px;
    color: var(--text-primary);
    font-size: 16px;
    font-weight: 600;
}

/* Сетка дней календаря */
.calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 2px;
}

/* Заголовки дней недели */
.day-header {
    text-align: center;
    padding: 4px 2px;
    font-size: 10px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
}

/* Маркеры в правом верхнем углу */
.calendar-day {
    position: relative;
    aspect-ratio: 1;
    border: 1px solid #d1d5db;
    border-radius: 4px;
    padding: 1px;
    cursor: pointer;
    transition: all 0.2s;
    background: var(--bg-primary);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    min-height: 0;
    font-size: 11px;
}

.calendar-day .event-markers {
    position: absolute;
    top: 2px;
    right: 2px;
    display: flex;
    gap: 0;
    flex-direction: row;
    line-height: 1;
    max-width: 95%;
    overflow: hidden;
}

/* Выделение текущего дня */
.calendar-day.today {
    border: 2px solid var(--accent-color, #3498db) !important;
    box-shadow: 0 0 8px rgba(52, 152, 219, 0.5), 0 2px 4px rgba(0, 0, 0, 0.15) !important;
    position: relative;
}

.calendar-day.today::after {
    content: '';
    position: absolute;
    inset: -2px;
    border: 2px solid var(--accent-color, #3498db);
    border-radius: 4px;
    pointer-events: none;
    animation: todayPulse 2s ease-in-out infinite;
}

@keyframes todayPulse {
    0%, 100% { opacity: 0.3; transform: scale(1); }
    50% { opacity: 0.6; transform: scale(1.02); }
}

/* Маркер экадаши */
.ekadashi-marker {
    background: #FF5722;
    color: white;
    font-size: 7px;
    font-weight: bold;
    padding: 1px 3px;
    border-radius: 2px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}

/* Специальные события (новолуние, полнолуние, затмения, равноденствия) */
.special-events {
    font-size: 11px;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
    line-height: 1;
    display: flex;
    gap: 1px;
    align-items: center;
}

/* Иконки затмений - единый символ вместо двух эмодзи */
.eclipse-icon {
    display: inline-block;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    position: relative;
    flex-shrink: 0;
}

.eclipse-icon.solar {
    background: radial-gradient(circle at 40% 40%, #FFD700 0%, #FFA500 60%, #FF8C00 100%);
    box-shadow: 0 0 3px rgba(255, 165, 0, 0.8), inset -3px -3px 4px rgba(0, 0, 0, 0.6);
}

.eclipse-icon.lunar {
    background: radial-gradient(circle at 45% 45%, #f0f0f0 0%, #c0c0c0 70%);
    box-shadow: 0 0 2px rgba(200, 200, 200, 0.9), inset -3px -3px 5px rgba(139, 69, 19, 0.7);
}

.legend-cell .eclipse-icon {
    width: 10px;
    height: 10px;
}

.calendar-day:not(.empty):hover {
    transform: scale(1.05);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    border-color: var(--accent-color);
    z-index: 10;
}

.calendar-day.empty {
    border: none;
    background: transparent;
    cursor: default;
}

/* Номер дня */
.day-number {
    font-size: 15px;
    font-weight: 700;
    color: var(--text-primary, #222);
    line-height: 1.05;
    text-shadow: 0 1px 2px rgba(255,255,255,0.6), 0 1px 1px rgba(0,0,0,0.12);
    position: relative;
    z-index: 2;
}

/* Лунный день */
.lunar-day, .lunar-days {
    font-size: 9px;
    color: #222;
    background: rgba(255,255,255,0.7);
    padding: 1px 4px;
    border-radius: 3px;
    line-height: 1.1;
    margin-top: 2px;
    text-align: center;
    font-weight: 500;
    box-shadow: 0 1px 2px rgba(0,0,0,0.06);
}

.lunar-days b {
    font-weight: 900;
    color: #1976d2;
    text-shadow: 0 1px 2px #fff, 0 1px 2px #1976d2;
}

.legend-symbol b {
    font-weight: 900;
    color: #2196F3;
}

/* Иконка фазы луны */
.moon-icon {
    font-size: 10px;
    line-height: 1;
    margin-top: 0;
}

.moon-icon svg { display: block; }

/* Специальные классы дней */
.calendar-day.ekadashi-day,
.legend-cell.ekadashi-day {
    background: linear-gradient(135deg, #FFE0B2 0%, #FF9800 100%);
    border-color: #E65100;
}
.calendar-day.ekadashi-day { border-width: 2px; }

.calendar-day.new-moon-day,
.legend-cell.new-moon-day {
    background: linear-gradient(135deg, #C5CAE9 0%, #5C6BC0 100%);
    border-color: #283593;
}

.calendar-day.full-moon-day,
.legend-cell.full-moon-day {
    background: linear-gradient(135deg, #FFF9C4 0%, #FFEB3B 100%);
    border-color: #F57F17;
}

.calendar-day.solar-eclipse-day,
.legend-cell.solar-eclipse-day {
    background: linear-gradient(135deg, #FFCCBC 0%, #FF5722 100%);
    border-color: #BF360C;
}
.calendar-day.solar-eclipse-day { border-width: 2px; }

.calendar-day.lunar-eclipse-day,
.legend-cell.lunar-eclipse-day {
    background: linear-gradient(135deg, #F8BBD0 0%, #E91E63 100%);
    border-color: #880E4F;
}
.calendar-day.lunar-eclipse-day { border-width: 2px; }

.calendar-day.equinox-day,
.legend-cell.equinox-day {
    background: linear-gradient(135deg, #B2DFDB 0%, #26A69A 100%);
    border-color: #00695C;
}

.calendar-day.solstice-day,
.legend-cell.solstice-day {
    background: linear-gradient(135deg, #FFE082 0%, #FFB300 100%);
    border-color: #FF8F00;
}

/* Мини-превью ячейки в легенде - общие стили */
.legend-cell {
    /* Размеры - строго одинаковые */
    width: calc(var(--legend-cell-size, 32px) * var(--legend-scale, 0.75));
    height: calc(var(--legend-cell-size, 32px) * var(--legend-scale, 0.75));
    min-width: calc(var(--legend-cell-size, 32px) * var(--legend-scale, 0.75));
    min-height: calc(var(--legend-cell-size, 32px) * var(--legend-scale, 0.75));
    max-width: calc(var(--legend-cell-size, 32px) * var(--legend-scale, 0.75));
    max-height: calc(var(--legend-cell-size, 32px) * var(--legend-scale, 0.75));
    
    /* Box model */
    box-sizing: border-box;
    padding: 0;
    margin: 0;
    
    /* Граница */
    border: 1px solid; /* потоньше рамка в легенде */
    border-radius: 4px;
    
    /* Позиционирование */
    position: relative;
    display: inline-block;
    vertical-align: middle;
    flex-shrink: 0;
    
    /* Визуальные эффекты */
    overflow: hidden;
    box-shadow: 0 1px 2px rgba(0,0,0,0.08);
}

.legend-cell .event-markers {
    position: absolute;
    top: 1px;
    right: 1px;
    display: flex;
    gap: 1px;
    flex-direction: row;
    line-height: 1;
}

.legend-cell .special-events { 
    font-size: 10px;
    line-height: 1;
}

.legend-cell .ekadashi-marker {
    font-size: 10px;
    font-weight: bold;
    padding: 1px 3px;
    line-height: 1;
    box-shadow: none;
}

/* Легенда */
.calendar-legend {
    background: var(--card-bg);
    border-radius: 6px;
    padding: 12px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.calendar-legend h4 {
    margin-top: 0;
    margin-bottom: 10px;
    color: var(--text-primary);
    font-size: 14px;
}

.legend-items {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 8px;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
}

.legend-symbol {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: calc(var(--legend-cell-size, 32px) * var(--legend-scale, 0.75));
    height: calc(var(--legend-cell-size, 32px) * var(--legend-scale, 0.75));
    min-width: calc(var(--legend-cell-size, 32px) * var(--legend-scale, 0.75));
    min-height: calc(var(--legend-cell-size, 32px) * var(--legend-scale, 0.75));
    max-width: calc(var(--legend-cell-size, 32px) * var(--legend-scale, 0.75));
    max-height: calc(var(--legend-cell-size, 32px) * var(--legend-scale, 0.75));
    flex-shrink: 0;
    font-size: 11px;
    text-shadow: 0 1px 2px #fff, 0 1px 2px rgba(0,0,0,0.18);
    line-height: 1;
    display: flex;
    gap: 1px;
    align-items: center;
    background: var(--card-bg, #ffffff);
    box-shadow: 0 1px 2px rgba(0,0,0,0.08);
    box-sizing: border-box;
}

/* Цветовые образцы для легенды */
.legend-swatch {
    width: 14px;
    height: 14px;
    border-radius: 3px;
    border: 1px solid rgba(0,0,0,0.15);
    display: inline-block;
}

.legend-swatch.ekadashi {
    background: linear-gradient(135deg, #FFE0B2 0%, #FF9800 100%);
    border-color: #E65100;
}
.legend-swatch.new-moon {
    background: linear-gradient(135deg, #C5CAE9 0%, #5C6BC0 100%);
    border-color: #283593;
}
.legend-swatch.full-moon {
    background: linear-gradient(135deg, #FFF9C4 0%, #FFEB3B 100%);
    border-color: #F57F17;
}
.legend-swatch.solar-eclipse {
    background: linear-gradient(135deg, #FFCCBC 0%, #FF5722 100%);
    border-color: #BF360C;
}
.legend-swatch.lunar-eclipse {
    background: linear-gradient(135deg, #F8BBD0 0%, #E91E63 100%);
    border-color: #880E4F;
}
.legend-swatch.equinox {
    background: linear-gradient(135deg, #B2DFDB 0%, #26A69A 100%);
    border-color: #00695C;
}
.legend-swatch.solstice {
    background: linear-gradient(135deg, #FFE082 0%, #FFB300 100%);
    border-color: #FF8F00;
}

.ekadashi-symbol {
    background: #FF5722;
    color: white;
    font-size: 12px;
    line-height: 1;
    margin-top: 1px;
    border-radius: 2px;
}

/* Модальное окно с деталями дня */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.45);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 16px;
}
.modal-overlay.visible { display: flex; }
.modal {
    background: var(--card-bg, #fff);
    color: var(--text-primary, #2c3e50);
    width: min(680px, 95%);
    max-height: 90vh;
    border-radius: 10px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}
.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-color, #e5e7eb);
}
.modal-header-content {
    display: flex;
    align-items: center;
    gap: 12px;
}
.modal-title { font-size: 16px; font-weight: 700; }
.modal-date { 
    font-size: 15px; 
    font-weight: 500; 
    color: var(--text-secondary, #5f6b7a); 
}
.modal-close {
    background: transparent; border: none; font-size: 20px; cursor: pointer; color: #666;
}
.modal-body { padding: 14px 16px; overflow: auto; max-height: 70vh; }
.modal-section { margin-bottom: 16px; padding-bottom: 12px; border-bottom: 1px solid rgba(0,0,0,0.05); }
.modal-section:last-child { border-bottom: none; }
.modal-section h5 { margin: 0 0 8px; font-size: 13px; color: var(--text-secondary, #5f6b7a); text-transform: uppercase; letter-spacing: 0.02em; font-weight: 600; }
.modal-kv { display: grid; grid-template-columns: 145px 1fr; gap: 6px 12px; font-size: 14px; }
.modal-kv > div:nth-child(odd) { color: var(--text-secondary, #666); font-weight: 500; }
.modal-kv > div:nth-child(even) { font-weight: 400; }

/* Двухколоночный layout для Солнца и Луны */
.modal-two-columns { 
    display: grid; 
    grid-template-columns: 1fr 1fr; 
    gap: 24px; 
}
.modal-column h5 { margin: 0 0 8px; }

/* На маленьких экранах показываем в одну колонку */
@media (max-width: 600px) {
    .modal-two-columns { 
        grid-template-columns: 1fr; 
        gap: 12px; 
    }
}
.modal-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 6px; }
.modal-list li { padding: 6px 8px; background: rgba(0,0,0,0.035); border: 1px solid rgba(0,0,0,0.08); border-radius: 6px; }

/* Цветовая подсветка событий в модальном окне (соответствует легенде) */
.modal-list li.event-ekadashi {
    background: linear-gradient(135deg, #FFF3E0 0%, #FFB74D 100%);
    border-color: #FF9800;
}
.modal-list li.event-new-moon {
    background: linear-gradient(135deg, #E8EAF6 0%, #9FA8DA 100%);
    border-color: #5C6BC0;
}
.modal-list li.event-full-moon {
    background: linear-gradient(135deg, #FFF9C4 0%, #FFF176 100%);
    border-color: #FBC02D;
}
.modal-list li.event-solar-eclipse {
    background: linear-gradient(135deg, #FFEBEE 0%, #EF5350 100%);
    border-color: #D32F2F;
}
.modal-list li.event-lunar-eclipse {
    background: linear-gradient(135deg, #FCE4EC 0%, #F06292 100%);
    border-color: #C2185B;
}
.modal-list li.event-equinox {
    background: linear-gradient(135deg, #E0F2F1 0%, #80CBC4 100%);
    border-color: #00897B;
}
.modal-list li.event-solstice {
    background: linear-gradient(135deg, #FFF3E0 0%, #FFCC80 100%);
    border-color: #FB8C00;
}

.modal-footer { padding: 12px 16px; border-top: 1px solid var(--border-color, #e5e7eb); display: flex; justify-content: flex-end; gap: 8px; }
.btn { padding: 8px 12px; border-radius: 6px; border: 1px solid transparent; cursor: pointer; font-size: 14px; }
.btn.primary { background: var(--accent-color, #3498db); color: #fff; }
.btn.secondary { background: #f3f4f6; color: #374151; border-color: #e5e7eb; }

/* Крупная дата в модальном окне */
.modal-date {
    font-size: 20px;
    font-weight: 800;
    color: var(--text-primary, #2c3e50);
}

/* Сообщение об ошибке */
.error-message {
    background: #ffebee;
    color: #c62828;
    padding: 20px;
    border-radius: 8px;
    border-left: 4px solid #c62828;
}

.error-message p {
    margin: 0;
}

/* Адаптивность */
@media (max-width: 1024px) {
    .calendars-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .calendar-controls-grid {
        grid-template-columns: 1fr;
    }

    .control-select {
        width: 100%;
        min-width: 0;
    }

    .month-navigation {
        flex-direction: column;
        gap: 10px;
    }
    
    .nav-btn {
        width: 100%;
    }
    
    .calendar-grid {
        gap: 1px;
    }
    
    .calendar-day {
        padding: 1px;
        font-size: 9px;
    }
    
    .day-number {
        font-size: 10px;
    }
    
    .lunar-day {
        font-size: 7px;
    }
    
    .moon-icon {
        font-size: 10px;
    }
    
    .legend-items {
        grid-template-columns: 1fr;
    }
}

@media (min-width: 1400px) {
    .calendars-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

/* Темная тема */
@media (prefers-color-scheme: dark) {
    .calendar-day.ekadashi-day {
        background: linear-gradient(135deg, #4E342E 0%, #5D4037 100%);
        border-color: #FF9800;
    }
    
    .calendar-day.new-moon-day {
        background: linear-gradient(135deg, #1A237E 0%, #283593 100%);
    }
    
    .calendar-day.full-moon-day {
        background: linear-gradient(135deg, #E65100 0%, #EF6C00 100%);
    }
    
    .lunar-day, .lunar-days {
        color: #AAA;
        background: rgba(255, 255, 255, 0.1);
    }
    
    .lunar-days b {
        color: #64B5F6;
    }
}
