/* Основные стили и сброс */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    /* Светлая тема */
    --primary-blue: #1a365d;
    --secondary-blue: #2d4a8a;
    --light-blue: #e6f2ff;
    --snow-white: #f8fafc;
    --silver-gray: #e2e8f0;
    --dark-gray: #4a5568;
    --accent-gold: #d4af37;
    --accent-red: #c53030;
    --accent-green: #38a169;
    --shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    --shadow-hover: 0 10px 15px rgba(0, 0, 0, 0.1);
    --border-radius: 8px;
    --transition: all 0.3s ease;
    
    /* Тёмная тема - значения по умолчанию, переопределяются в .dark-theme */
    --bg-color: white;
    --text-color: var(--primary-blue);
    --card-bg: var(--snow-white);
    --border-color: var(--silver-gray);
}

body {
    font-family: 'Open Sans', sans-serif;
    background: linear-gradient(135deg, #f5f7fa 0%, #e4edf5 100%);
    color: var(--primary-blue);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    background-color: var(--bg-color);
    color: var(--text-color);
    transition: var(--transition);
}

/* Тёмная тема - фон всей страницы */
.dark-theme {
    --bg-color: #0f172a;
    --text-color: #e2e8f0;
    --card-bg: #1e293b;
    --border-color: #334155;
    --primary-blue: #cbd5e1;
    --secondary-blue: #60a5fa;
    --light-blue: #1e3a8a;
    --snow-white: #1e293b;
    --silver-gray: #475569;
    --dark-gray: #cbd5e1;
    --accent-gold: #fbbf24;
    --accent-red: #f87171;
    --accent-green: #4ade80;
    --shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
    --shadow-hover: 0 10px 15px rgba(0, 0, 0, 0.4);
}

/* В тёмной теме меняем фон body на тёмный, убирая градиент */
.dark-theme body {
    background: var(--bg-color);
}

/* Шапка и подвал в тёмной теме остаются светлыми (синими) */
.dark-theme .header,
.dark-theme .footer {
    background: linear-gradient(135deg, #1a365d 0%, #2d4a8a 100%) !important;
    color: white !important;
}

.dark-theme .header::before {
    opacity: 0.1;
}

/* Дата в шапке в тёмной теме остаётся светлой */
.dark-theme .date-range {
    color: #cbd5e1 !important;
}

/* Ссылка в подвале в тёмной теме остаётся золотой */
.dark-theme .footer-link {
    color: #d4af37 !important;
}

.dark-theme .footer-link:hover {
    color: white !important;
    border-bottom: 1px dotted #d4af37 !important;
}

.container {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

/* Шапка */
.header {
    background: linear-gradient(135deg, var(--primary-blue) 0%, var(--secondary-blue) 100%);
    color: white;
    padding: 20px 0;
    box-shadow: var(--shadow);
    position: relative;
    overflow: hidden;
}

.header::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" width="100" height="100" viewBox="0 0 100 100"><circle cx="10" cy="10" r="2" fill="white" opacity="0.3"/><circle cx="50" cy="30" r="1.5" fill="white" opacity="0.3"/><circle cx="80" cy="20" r="1" fill="white" opacity="0.3"/><circle cx="30" cy="70" r="1.5" fill="white" opacity="0.3"/><circle cx="70" cy="60" r="2" fill="white" opacity="0.3"/><circle cx="90" cy="80" r="1" fill="white" opacity="0.3"/></svg>');
    opacity: 0.1;
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 20px;
    position: relative;
    z-index: 1;
}

.header-text {
    flex: 1;
    min-width: 300px;
}

.main-title {
    font-family: 'PT Sans', sans-serif;
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 8px;
    line-height: 1.2;
}

.date-range {
    display: block;
    font-size: 1.5rem;
    font-weight: 400;
    margin-top: 5px;
    color: var(--silver-gray);
}

.subtitle {
    font-size: 1.1rem;
    opacity: 0.9;
}

/* Логотип */
.logo-container {
    display: flex;
    justify-content: center;
    align-items: center;
}

.festival-logo {
    max-width: 120px;
    max-height: 120px;
    width: auto;
    height: auto;
    filter: drop-shadow(0 5px 10px rgba(0, 0, 0, 0.2));
    transition: var(--transition);
}

.festival-logo:hover {
    transform: scale(1.05);
    filter: drop-shadow(0 8px 15px rgba(0, 0, 0, 0.3));
}

/* Основной контент */
.main {
    flex: 1;
    padding: 30px 0;
}

.calendar-container {
    background-color: var(--card-bg);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    padding: 25px;
    margin-bottom: 30px;
}

.month-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 25px;
    flex-wrap: wrap;
    gap: 15px;
}

.month-title {
    font-family: 'PT Sans', sans-serif;
    font-size: 1.8rem;
    color: var(--primary-blue);
    font-weight: 700;
}

.current-date-time {
    font-size: 1rem;
    color: var(--dark-gray);
    background: var(--light-blue);
    padding: 8px 15px;
    border-radius: var(--border-radius);
    font-weight: 600;
    text-align: center;
    border: 1px solid var(--border-color);
    min-width: 250px;
}

.calendar-wrapper {
    margin-bottom: 25px;
    position: relative;
}

.weekdays {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 5px;
    margin-bottom: 10px;
}

.weekday {
    text-align: center;
    font-weight: 600;
    color: var(--dark-gray);
    padding: 10px 5px;
    background-color: var(--light-blue);
    border-radius: 4px;
}

.weekday.weekend {
    background-color: rgba(212, 175, 55, 0.2);
}

.calendar {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 8px;
}

.day {
    aspect-ratio: 1;
    background-color: var(--snow-white);
    border: 2px solid var(--border-color);
    border-radius: var(--border-radius);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--transition);
    padding: 5px;
    position: relative;
    overflow: hidden;
}

.day:hover {
    background-color: var(--light-blue);
    border-color: var(--secondary-blue);
    transform: translateY(-3px);
    box-shadow: var(--shadow-hover);
}

.day.inactive {
    background-color: var(--card-bg);
    color: #94a3b8;
    cursor: default;
}

.day.inactive:hover {
    background-color: var(--card-bg);
    border-color: var(--border-color);
    transform: none;
    box-shadow: none;
}

.day.today {
    border-color: var(--accent-gold);
    background-color: rgba(212, 175, 55, 0.1);
}

.day-number-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.day-number {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 2px;
    line-height: 1;
}

.day-month {
    font-size: 0.8rem;
    color: var(--dark-gray);
    font-weight: 600;
}

.day-events {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 4px;
    width: 100%;
    margin-top: 5px;
}

.event-indicator {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
}

.event-indicator.free {
    background-color: var(--accent-green);
}

.event-indicator.paid {
    background-color: var(--accent-red);
}

/* Разделитель месяцев */
.month-divider {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 20px;
    padding: 10px 0;
    position: relative;
}

.divider-line {
    flex: 1;
    height: 2px;
    background: linear-gradient(90deg, var(--accent-green), var(--accent-red));
    margin: 0 15px;
    position: relative;
}

.divider-line::before {
    content: "🎄";
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    background: var(--card-bg);
    padding: 0 10px;
    font-size: 1.2rem;
}

.divider-label {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--dark-gray);
    background: var(--card-bg);
    padding: 5px 10px;
    border-radius: 20px;
    border: 1px solid var(--border-color);
}

/* Легенда и переключатель темы */
.calendar-legend {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 20px;
    padding-top: 20px;
    border-top: 1px solid var(--border-color);
}

.legend-left {
    display: flex;
    gap: 20px;
    flex-wrap: wrap;
}

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

.legend-color {
    width: 16px;
    height: 16px;
    border-radius: 50%;
}

.legend-color.free {
    background-color: var(--accent-green);
}

.legend-color.paid {
    background-color: var(--accent-red);
}

.legend-marker.today {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    border: 2px solid var(--accent-gold);
    background-color: rgba(212, 175, 55, 0.1);
}

.legend-text {
    font-size: 0.9rem;
    color: var(--dark-gray);
}

/* Переключатель темы */
.theme-toggle-container {
    display: flex;
    align-items: center;
    gap: 10px;
}

.theme-label {
    font-size: 0.9rem;
    color: var(--dark-gray);
    font-weight: 500;
}

.theme-switch {
    position: relative;
    display: inline-block;
    width: 60px;
    height: 30px;
}

.theme-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.theme-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: var(--silver-gray);
    transition: var(--transition);
    border-radius: 34px;
}

.theme-slider:before {
    position: absolute;
    content: "";
    height: 22px;
    width: 22px;
    left: 4px;
    bottom: 4px;
    background-color: white;
    transition: var(--transition);
    border-radius: 50%;
}

input:checked + .theme-slider {
    background-color: var(--secondary-blue);
}

input:checked + .theme-slider:before {
    transform: translateX(30px);
}

/* Модальное окно */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.7);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    padding: 20px;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.modal {
    background-color: var(--card-bg);
    border-radius: var(--border-radius);
    width: 100%;
    max-width: 800px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.2);
    animation: slideUp 0.3s ease;
}

@keyframes slideUp {
    from { transform: translateY(30px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

.modal-close {
    position: absolute;
    top: 15px;
    right: 15px;
    background: none;
    border: none;
    font-size: 1.5rem;
    color: var(--dark-gray);
    cursor: pointer;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: var(--transition);
    z-index: 10;
}

.modal-close:hover {
    background-color: var(--silver-gray);
    color: var(--primary-blue);
}

.modal-header {
    padding: 25px 25px 15px;
    border-bottom: 1px solid var(--border-color);
    position: relative;
}

.modal-title {
    font-family: 'PT Sans', sans-serif;
    font-size: 1.6rem;
    color: var(--primary-blue);
    margin-bottom: 8px;
}

.modal-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 15px;
    margin-top: 10px;
}

.events-count {
    font-size: 1rem;
    color: var(--dark-gray);
    font-weight: 600;
}

.modal-filters {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
}

.filter-btn {
    padding: 6px 12px;
    background-color: var(--light-blue);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    color: var(--dark-gray);
    font-size: 0.9rem;
    cursor: pointer;
    transition: var(--transition);
}

.filter-btn:hover {
    background-color: var(--silver-gray);
}

.filter-btn.active {
    background-color: var(--secondary-blue);
    color: white;
    border-color: var(--secondary-blue);
}

.category-filter {
    padding: 6px 12px;
    border: 1px solid var(--border-color);
    border-radius: 20px;
    background-color: var(--card-bg);
    color: var(--dark-gray);
    font-size: 0.9rem;
    cursor: pointer;
    transition: var(--transition);
}

.category-filter:hover {
    border-color: var(--secondary-blue);
}

.modal-content {
    padding: 20px 25px;
    overflow-y: auto;
    flex: 1;
}

.event-card {
    background-color: var(--snow-white);
    border-radius: var(--border-radius);
    padding: 20px;
    margin-bottom: 15px;
    border-left: 4px solid var(--secondary-blue);
    transition: var(--transition);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.event-card:hover {
    transform: translateX(5px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

.event-card.paid {
    border-left-color: var(--accent-red);
}

.event-card.free {
    border-left-color: var(--accent-green);
}

.event-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    flex-wrap: wrap;
    margin-bottom: 10px;
    gap: 10px;
}

.event-title {
    font-family: 'PT Sans', sans-serif;
    font-size: 1.3rem;
    color: var(--primary-blue);
    font-weight: 700;
    flex: 1;
    min-width: 250px;
}

.event-time {
    background-color: var(--secondary-blue);
    color: white;
    padding: 5px 12px;
    border-radius: 20px;
    font-weight: 600;
    font-size: 0.9rem;
    white-space: nowrap;
}

.event-details {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    margin-bottom: 15px;
}

.event-detail {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 0.9rem;
    color: var(--dark-gray);
}

.event-detail i {
    color: var(--secondary-blue);
}

.event-place {
    font-weight: 600;
    color: var(--primary-blue);
    margin-bottom: 10px;
}

.event-description {
    line-height: 1.5;
    margin-bottom: 15px;
    color: var(--dark-gray);
}

.event-note {
    background-color: rgba(212, 175, 55, 0.1);
    padding: 10px 15px;
    border-radius: 6px;
    border-left: 3px solid var(--accent-gold);
    font-size: 0.95rem;
    color: var(--dark-gray);
}

.no-events {
    text-align: center;
    padding: 40px 20px;
    color: var(--dark-gray);
    font-size: 1.1rem;
}

.no-events i {
    font-size: 3rem;
    margin-bottom: 15px;
    color: var(--silver-gray);
}

/* Подвал */
.footer {
    background-color: var(--primary-blue);
    color: white;
    padding: 25px 0;
    text-align: center;
    margin-top: auto;
}

.footer-text {
    font-size: 0.95rem;
    line-height: 1.5;
    opacity: 0.9;
    max-width: 100%;
    margin: 0 auto;
    padding: 0 10px;
}

.footer-link {
    color: var(--accent-gold);
    text-decoration: none;
    font-weight: 600;
    transition: var(--transition);
    border-bottom: 1px dotted transparent;
    display: inline-block;
}

.footer-link:hover {
    color: white;
    border-bottom: 1px dotted var(--accent-gold);
}

/* Адаптивность */
@media (max-width: 768px) {
    .header-content {
        flex-direction: column;
        text-align: center;
    }
    
    .main-title {
        font-size: 1.7rem;
    }
    
    .date-range {
        font-size: 1.3rem;
    }
    
    .festival-logo {
        max-width: 90px;
        max-height: 90px;
    }
    
    .month-header {
        flex-direction: column;
        align-items: center;
        text-align: center;
        gap: 10px;
    }
    
    .month-title {
        font-size: 1.5rem;
        order: 1;
    }
    
    .month-title:last-child {
        order: 3;
    }
    
    .current-date-time {
        order: 2;
        min-width: 100%;
        font-size: 0.9rem;
        padding: 6px 10px;
    }
    
    .weekday, .day {
        font-size: 0.9rem;
    }
    
    .day-number {
        font-size: 1.3rem;
    }
    
    .day-month {
        font-size: 0.7rem;
    }
    
    .month-divider {
        flex-direction: column;
        gap: 10px;
    }
    
    .divider-line {
        width: 100%;
        margin: 10px 0;
    }
    
    .calendar-legend {
        flex-direction: column;
        gap: 15px;
        align-items: flex-start;
    }
    
    .theme-toggle-container {
        align-self: stretch;
        justify-content: space-between;
    }
    
    .modal {
        max-height: 85vh;
    }
    
    .modal-title {
        font-size: 1.4rem;
    }
    
    .modal-controls {
        flex-direction: column;
        align-items: stretch;
    }
    
    .modal-filters {
        justify-content: center;
    }
    
    .event-title {
        font-size: 1.2rem;
        min-width: 100%;
    }
    
    .event-header {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .event-time {
        align-self: flex-start;
    }
    
    .footer-text {
        font-size: 0.85rem;
        line-height: 1.4;
    }
}

@media (max-width: 576px) {
    .calendar {
        gap: 4px;
    }
    
    .weekday, .day {
        padding: 5px 2px;
        font-size: 0.8rem;
    }
    
    .day-number {
        font-size: 1.1rem;
    }
    
    .day-month {
        font-size: 0.6rem;
    }
    
    .event-indicator {
        width: 6px;
        height: 6px;
    }
    
    .legend-left {
        flex-direction: column;
        gap: 10px;
    }
    
    .theme-toggle-container {
        flex-direction: column;
        gap: 5px;
        align-items: center;
    }
    
    .modal-header, .modal-content {
        padding: 15px;
    }
    
    .modal-filters {
        flex-direction: column;
        align-items: stretch;
    }
    
    .filter-btn, .category-filter {
        width: 100%;
        text-align: center;
    }
    
    .event-card {
        padding: 15px;
    }
    
    .footer-text {
        font-size: 0.8rem;
        padding: 0 5px;
    }
    
    .festival-logo {
        max-width: 70px;
        max-height: 70px;
    }
}