/* ========== ЛУННЫЙ КАЛЕНДАРЬ ========== */

.lunar-main-block {
    background: var(--card-bg);
    border: 1px solid var(--border);
    margin-bottom: 2rem;
    position: relative;
    overflow: hidden;
    transition: background-color 0.3s ease, border-color 0.3s ease;
}

/* Цветовая полоска типа дня */
.lunar-main-block::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 0.1875rem;
    background: var(--day-type-color, var(--gold));
    transition: background 0.3s ease;
}

/* Хедер с двумя равными блоками */
.lunar-header {
    display: flex;
    gap: 1.5rem;
    padding: 1.5rem;
}

/* Одинаковые блоки */
.lunar-day-info,
.moon-phase {
    flex: 1;
    text-align: center;
    padding: 1.25rem;
    border: 1px solid var(--border);
    background: var(--card-bg);
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 0.5rem;
    align-items: center;
    transition: background-color 0.3s ease, border-color 0.3s ease;
}

.lunar-day-number {
    height: 3.75rem;
    font-size: 3.5rem;
    font-weight: 700;
    color: var(--gold);
    line-height: 1;
    margin: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.3s ease;
}

.lunar-day-number small {
    font-size: 0.9rem;
    font-weight: 400;
    color: var(--secondary);
    transition: color 0.3s ease;
}

.lunar-day-title {
    height: 2.5rem;
    font-size: 1.25rem;
    margin: 0;
    color: var(--text);
    font-weight: 500;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.3s ease;
}

.lunar-day-type {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0 0.75rem;
    border-radius: 1.875rem;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin: 0;
    height: 1.875rem;
    align-self: center;
    transition: background-color 0.3s ease, color 0.3s ease;
}

.moon-phase-icon {
    height: 3.75rem;
    font-size: 3rem;
    margin: 0;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}

.moon-phase-name {
    height: 2.5rem;
    font-size: 1.125rem;
    margin: 0;
    color: var(--text);
    font-weight: 500;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.3s ease;
}

.lunar-date {
    height: 1.875rem;
    font-size: 1rem;
    color: var(--secondary);
    margin: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.3s ease;
}

/* Детали */
.lunar-details {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
    gap: 1rem;
    transition: border-color 0.3s ease;
}

.detail-item {
    text-align: center;
    padding: 0.5rem;
}

.detail-label {
    display: block;
    font-size: 0.8rem;
    color: var(--secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 0.25rem;
    transition: color 0.3s ease;
}

.detail-value {
    display: block;
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--text);
    transition: color 0.3s ease;
}

/* Блок совета */
.advice-block {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--border);
    background: rgba(198, 164, 63, 0.03);
    transition: background-color 0.3s ease, border-color 0.3s ease;
}

.advice-label {
    font-size: 1rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--gold);
    margin-bottom: 0.5rem;
    transition: color 0.3s ease;
}

.advice-text {
    font-size: 1.125rem;
    line-height: 1.5;
    margin: 0;
    color: var(--text);
    transition: color 0.3s ease;
}

.geolocation-text {
    padding: 0.75rem 1.5rem;
    font-size: 1rem;
    color: var(--secondary);
    text-align: center;
    border-top: 1px solid var(--border);
    transition: color 0.3s ease, border-color 0.3s ease;
}

/* ========== КАЛЕНДАРЬ ========== */

.calendar-container {
    margin-top: 2rem;
}

.calendar-header {
    text-align: center;
    margin-bottom: 1rem;
}

.calendar-month {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--gold);
    margin-bottom: 0.75rem;
    cursor: pointer;
    display: inline-block;
    padding: 0 0.5rem;
    border-radius: 0.375rem;
    transition: color 0.3s ease, background-color 0.3s ease, transform 0.2s ease;
}

.calendar-month:hover {
    background: rgba(198, 164, 63, 0.1);
    transform: scale(1.02);
}

.calendar-nav {
    display: flex;
    justify-content: center;
    gap: 0.5rem;
}

.calendar-nav button {
    background: var(--card-bg);
    border: 1px solid var(--border);
    color: var(--text);
    padding: 0.5rem 1rem;
    cursor: pointer;
    font-size: 1rem;
    font-family: inherit;
    transition: background-color 0.3s ease, color 0.3s ease, border-color 0.3s ease;
}

.calendar-nav button:hover {
    border-color: var(--gold);
    color: var(--gold);
}

.calendar-table-wrapper {
    overflow-x: auto;
}

.calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    border: 1px solid var(--border);
    background: var(--card-bg);
    min-width: 37.5rem;
    transition: border-color 0.3s ease, background-color 0.3s ease;
}

.calendar-weekday {
    text-align: center;
    padding: 0.75rem 0.25rem;
    font-weight: 600;
    font-size: 0.75rem;
    color: var(--gold);
    background: rgba(198, 164, 63, 0.05);
    border-bottom: 1px solid var(--border);
    transition: color 0.3s ease, background-color 0.3s ease, border-color 0.3s ease;
}

.calendar-cell {
    padding: 0.5rem;
    border-right: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
    cursor: pointer;
    background: var(--card-bg);
    min-height: 4.375rem;
    position: relative;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    border-left: 0.1875rem solid transparent;
    transition: background-color 0.3s ease, border-color 0.3s ease;
}

.calendar-cell.today {
    background: rgba(198, 164, 63, 0.08);
}

.calendar-cell.selected {
    background: rgba(198, 164, 63, 0.15);
    border-left-width: 0.1875rem;
}

.calendar-cell:hover:not(.empty) {
    background: rgba(198, 164, 63, 0.08);
    transform: translateY(-0.0625rem);
}

.calendar-cell.empty {
    background: transparent;
    cursor: default;
    border-left-color: transparent !important;
}

.calendar-day {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--text);
    line-height: 1.2;
    text-align: right;
    transition: color 0.3s ease;
}

.calendar-lunar {
    font-size: 1rem;
    color: var(--gold);
    text-align: left;
    align-self: flex-end;
    font-weight: 500;
    transition: color 0.3s ease;
}

.calendar-content {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    width: 100%;
    min-height: 100%;
}

/* Индикатор загрузки */
.loading-indicator {
    text-align: center;
    padding: 3rem;
    color: var(--secondary);
}

.loading-spinner {
    display: inline-block;
    width: 2.5rem;
    height: 2.5rem;
    border: 0.125rem solid var(--border);
    border-top-color: var(--gold);
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* ========== ПОПАП ВЫБОРА МЕСЯЦА И ГОДА ========== */

.month-year-popup {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.6);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    transition: background-color 0.3s ease;
}

.popup-content {
    background: #1a1a2e;
    padding: 1.5rem;
    min-width: 20rem;
    max-width: 25rem;
    box-shadow: 0 0.5rem 2rem rgba(0, 0, 0, 0.4);
    border: 1px solid rgba(198, 164, 63, 0.3);
    transition: background-color 0.3s ease, border-color 0.3s ease;
}

.popup-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.25rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid rgba(198, 164, 63, 0.3);
    transition: border-color 0.3s ease;
}

.popup-header h3 {
    margin: 0;
    font-size: 1.125rem;
    color: #e5e5e5;
    font-weight: 500;
    transition: color 0.3s ease;
}

.popup-close {
    background: none;
    border: none;
    font-size: 1.75rem;
    cursor: pointer;
    color: #888;
    padding: 0;
    width: 2rem;
    height: 2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.3s ease;
}

.popup-close:hover {
    color: #c6a43f;
}

.year-selector {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    padding: 0.75rem;
}

.year-selector button {
    background: none;
    border: none;
    width: 2.25rem;
    height: 2.25rem;
    cursor: pointer;
    font-size: 1.125rem;
    color: #888;
    transition: color 0.3s ease;
}

.year-selector button:hover {
    color: #c6a43f;
}

.popup-year {
    font-size: 1.25rem;
    font-weight: 600;
    color: #c6a43f;
    transition: color 0.3s ease;
}

.months-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.75rem;
    margin-bottom: 1.5rem;
}

.month-btn {
    padding: 0.75rem 0.5rem;
    background: none;
    border: none;
    cursor: pointer;
    text-align: center;
    font-size: 0.875rem;
    color: #e5e5e5;
    transition: color 0.3s ease;
}

.month-btn:hover {
    color: #c6a43f;
}

.month-btn.selected {
    color: #c6a43f;
    font-weight: 600;
}

.popup-footer {
    display: flex;
    justify-content: space-between;
    gap: 0.75rem;
    padding-top: 0.75rem;
    border-top: 1px solid rgba(198, 164, 63, 0.3);
    transition: border-color 0.3s ease;
}

.popup-today,
.popup-confirm {
    flex: 1;
    padding: 0.625rem;
    border: none;
    cursor: pointer;
    font-size: 0.875rem;
    background: none;
    color: #888;
    transition: color 0.3s ease;
}

.popup-today:hover,
.popup-confirm:hover {
    color: #c6a43f;
}

.popup-confirm {
    color: #c6a43f;
}

/* ========== АДАПТАЦИЯ ========== */

/* Планшеты (481px - 768px) */
@media (min-width: 30.0625rem) and (max-width: 48rem) {
    .lunar-header {
        flex-direction: column;
        gap: 1rem;
        padding: 1rem;
    }

    .lunar-day-info,
    .moon-phase {
        padding: 1rem;
    }

    .lunar-day-number,
    .moon-phase-icon {
        height: 3.125rem;
        font-size: 2rem;
    }

    .lunar-day-title,
    .moon-phase-name {
        height: 2.1875rem;
        font-size: 1rem;
    }

    .lunar-day-type,
    .lunar-date {
        height: 1.75rem;
        font-size: 0.75rem;
        padding: 0.2rem 0.6rem;
    }

    .lunar-details {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.75rem;
        padding: 0.875rem 1rem;
    }

    .detail-label {
        font-size: 0.7rem;
    }

    .detail-value {
        font-size: 0.9rem;
    }

    .advice-block {
        padding: 1rem 1.25rem;
    }

    .advice-label {
        font-size: 0.8rem;
    }

    .advice-text {
        font-size: 0.9rem;
    }

    .calendar-table-wrapper {
        overflow-x: auto;
    }

    .calendar-grid {
        min-width: 37.5rem;
    }

    .calendar-cell {
        min-height: 3.75rem;
        padding: 0.5rem;
    }

    .calendar-day {
        font-size: 1rem;
    }

    .calendar-lunar {
        font-size: 0.75rem;
    }

    .calendar-weekday {
        font-size: 0.75rem;
        padding: 0.5rem 0.2rem;
    }
}

/* Мобильные (до 480px) */
@media (max-width: 30rem) {
    .lunar-header {
        flex-direction: column;
        gap: 0.75rem;
        padding: 0.75rem;
    }

    .lunar-day-info,
    .moon-phase {
        padding: 0.75rem;
    }

    .lunar-day-number,
    .moon-phase-icon {
        height: 2.8125rem;
        font-size: 1.75rem;
    }

    .lunar-day-title,
    .moon-phase-name {
        height: 2rem;
        font-size: 1.125rem;
    }

    .lunar-day-type,
    .lunar-date {
        height: 1.75rem;
        font-size: 0.8rem;
        padding: 0.2rem 0.6rem;
    }

    .lunar-details {
        grid-template-columns: 1fr;
        gap: 0.5rem;
        padding: 0.75rem;
    }

    .detail-item {
        display: flex;
        justify-content: space-between;
        align-items: center;
        text-align: left;
        padding: 0.25rem 0;
    }

    .detail-label {
        margin-bottom: 0;
        flex: 1;
        font-size: 0.75rem;
    }

    .detail-value {
        font-size: 0.9rem;
    }

    .advice-block {
        padding: 0.75rem;
    }

    .advice-label {
        font-size: 0.8rem;
    }

    .advice-text {
        font-size: 0.9rem;
    }

    .geolocation-text {
        padding: 0.5rem 0.75rem;
        font-size: 0.75rem;
    }

    .calendar-table-wrapper {
        overflow-x: auto;
        margin: 0 -0.75rem;
        padding: 0 0.75rem;
    }

    .calendar-grid {
        min-width: 23.75rem;
    }

    .calendar-cell {
        min-height: 3.4375rem;
        padding: 0.4rem;
    }

    .calendar-day {
        font-size: 0.9rem;
    }

    .calendar-lunar {
        font-size: 0.7rem;
    }

    .calendar-weekday {
        font-size: 0.7rem;
        padding: 0.5rem 0.2rem;
    }

    .calendar-month {
        font-size: 1rem;
    }

    .calendar-nav button {
        padding: 0.375rem 0.75rem;
        font-size: 0.8rem;
    }

    .popup-content {
        margin: 1.25rem;
        padding: 1.25rem;
        min-width: auto;
    }

    .months-grid {
        gap: 0.625rem;
    }

    .month-btn {
        padding: 0.625rem 0.375rem;
        font-size: 0.8125rem;
    }

    .year-selector button {
        width: 2rem;
        height: 2rem;
    }
}

/* ========== СВЕТЛАЯ ТЕМА ========== */

:root.light-mode .calendar-cell.today {
    background: rgba(184, 155, 94, 0.08);
}

:root.light-mode .calendar-cell.selected {
    background: rgba(184, 155, 94, 0.12);
}

:root.light-mode .advice-block {
    background: rgba(184, 155, 94, 0.03);
}

:root.light-mode .lunar-day-info,
:root.light-mode .moon-phase {
    background: var(--card-bg);
}

:root.light-mode .popup-content {
    background: var(--bg);
}

:root.light-mode .popup-header h3 {
    color: var(--text);
}

:root.light-mode .month-btn {
    color: var(--text);
}