/* Календарь мероприятий */
.events-calendar {
    background: #fff;
    border-radius: var(--radius-lg);
    box-shadow: var(--card-shadow-lg);
    padding: 1.75rem 1.5rem 1.5rem;
    margin-bottom: 2rem;
}

.ec-title {
    font-size: 1.35rem;
    font-weight: 700;
    color: var(--color-primary);
    letter-spacing: 0.04em;
    margin-bottom: 0.75rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.ec-title i {
    color: var(--color-primary-light);
}

.ec-stats {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem 1.25rem;
    font-size: 0.95rem;
    color: #5a6b5e;
    margin-bottom: 0.75rem;
}

.ec-stats strong {
    color: var(--color-primary);
    font-weight: 700;
}

.ec-hint-row {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    gap: 0.75rem 1rem;
    margin-bottom: 1.25rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid #ebe6dc;
}

.ec-hint-row p {
    margin: 0;
    font-size: 0.9rem;
    color: #6b7c6f;
}

.ec-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem 1.25rem;
    font-size: 0.82rem;
    color: #5a6b5e;
}

.ec-legend-item {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
}

.ec-legend-swatch {
    width: 14px;
    height: 14px;
    border-radius: 3px;
    border-left: 3px solid;
    flex-shrink: 0;
}

.ec-toolbar {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1rem;
}

.ec-views .btn {
    font-size: 0.875rem;
    padding: 0.35rem 1rem;
}

.ec-views .btn.active {
    background: var(--color-primary);
    border-color: var(--color-primary);
    color: #fff;
}

.ec-nav {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex: 1;
    justify-content: center;
}

.ec-nav-btn {
    border: 1px solid #c8cfc9;
    background: #fff;
    color: var(--color-primary);
    border-radius: 999px;
    padding: 0.35rem 0.9rem;
    font-size: 0.875rem;
    transition: background 0.15s, border-color 0.15s;
}

.ec-nav-btn:hover {
    background: #f5f2eb;
    border-color: #a8b5aa;
}

.ec-jump {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex: 1;
    justify-content: center;
    min-width: 220px;
}

.ec-jump select {
    max-width: 140px;
}

.ec-period-title {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--color-primary);
    margin: 0;
    min-width: 140px;
    text-align: center;
}

.ec-grid-wrap {
    overflow-x: auto;
}

.ec-grid {
    width: 100%;
    border-collapse: collapse;
    table-layout: fixed;
    min-width: 640px;
}

.ec-grid th {
    background: #eef1ee;
    color: var(--color-primary);
    font-weight: 600;
    font-size: 0.85rem;
    padding: 0.55rem 0.35rem;
    text-align: center;
    border: 1px solid #dde3dd;
}

.ec-grid td {
    vertical-align: top;
    border: 1px solid #dde3dd;
    background: #fffef9;
    height: 110px;
    padding: 0.35rem;
    position: relative;
}

.ec-grid td.ec-other {
    background: #f7f6f2;
}

.ec-grid td.ec-today {
    background: #fef6e4;
    box-shadow: inset 0 0 0 2px var(--color-accent);
}

.ec-grid td.ec-day-empty,
.ec-week-grid td.ec-day-empty,
.ec-day-view.ec-day-empty {
    cursor: pointer;
}

.ec-grid td.ec-day-empty:hover,
.ec-week-grid td.ec-day-empty:hover {
    background: #faf8f2;
}

.ec-day-num {
    font-size: 0.82rem;
    font-weight: 600;
    color: #4a5a4e;
    margin-bottom: 0.25rem;
    line-height: 1.2;
}

.ec-other .ec-day-num {
    color: #a8b0a9;
}

.ec-visibility-fieldset {
    border: 0;
    padding: 0;
    margin: 0;
}

.ec-visibility-fieldset legend {
    float: none;
    width: auto;
}

.ec-events {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
}

.ec-event {
    display: flex;
    align-items: flex-start;
    gap: 0.25rem;
    width: 100%;
    border: none;
    border-left: 3px solid;
    border-radius: 4px;
    padding: 0.2rem 0.35rem;
    font-size: 0.72rem;
    line-height: 1.25;
    text-align: left;
    cursor: pointer;
    transition: filter 0.15s, transform 0.1s;
    overflow: hidden;
}

.ec-event:hover {
    filter: brightness(0.97);
    transform: translateY(-1px);
}

.ec-event i {
    font-size: 0.65rem;
    margin-top: 0.1rem;
    flex-shrink: 0;
    opacity: 0.85;
}

.ec-event-text {
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    word-break: break-word;
}

/* Неделя */
.ec-week-grid td {
    height: 320px;
}

.ec-week-grid .ec-event {
    font-size: 0.78rem;
    padding: 0.35rem 0.45rem;
    margin-bottom: 0.15rem;
}

.ec-week-grid .ec-event-text {
    -webkit-line-clamp: 4;
}

/* День */
.ec-day-view {
    background: #fffef9;
    border: 1px solid #dde3dd;
    border-radius: var(--radius-md);
    padding: 1rem;
    min-height: 280px;
}

.ec-day-view-header {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--color-primary);
    margin-bottom: 1rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid #ebe6dc;
}

.ec-day-view .ec-event {
    font-size: 0.9rem;
    padding: 0.65rem 0.85rem;
    margin-bottom: 0.5rem;
    width: 100%;
}

.ec-day-view .ec-event-text {
    -webkit-line-clamp: unset;
}

.ec-empty {
    color: #8a968c;
    font-style: italic;
    font-size: 0.9rem;
    padding: 1rem 0;
}

.ec-add-block {
    background: #fff;
    border-radius: var(--radius-md);
    box-shadow: var(--card-shadow);
    padding: 1.25rem;
    margin-top: 1.5rem;
}

.ec-add-block .form-label {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--color-primary);
    margin-bottom: 0.25rem;
}

.ec-add-block .form-text {
    font-size: 0.75rem;
}

.ec-modal-icon {
    font-size: 2rem;
    color: var(--color-accent);
}

.ec-modal-title-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.ec-event-status-icon {
    flex-shrink: 0;
    font-size: 1rem;
    line-height: 1;
}

.ec-event-status-icon.ec-event-status-icon--visible,
#eventModal .ec-event-status-icon.ec-event-status-icon--visible {
    display: inline-block !important;
    font-size: 1.25rem;
    vertical-align: middle;
}

.ec-event-status-icon[hidden] {
    display: none !important;
}

.ec-event .ec-event-status-icon {
    margin-left: auto;
    align-self: center;
    font-size: 0.8rem;
}

.ec-status-completed {
    color: #198754;
}

.ec-status-rescheduled {
    color: #d97706;
}

.ec-status-excluded {
    color: #dc3545;
}

.ec-status-admin-btns {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.ec-status-btn.active {
    background: var(--color-primary);
    border-color: var(--color-primary);
    color: #fff;
}

.ec-status-btn.active .bi {
    color: inherit;
}

.ec-recurrence-block {
    padding-top: 0.25rem;
}

#eventModalDeleteWrap .dropdown-menu {
    min-width: 14rem;
}

.ec-modal-images {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.ec-modal-images img {
    width: 140px;
    height: 100px;
    object-fit: cover;
    border-radius: 10px;
    border: 1px solid #e4ded0;
    background: #fff;
}

@media (max-width: 768px) {
    .ec-toolbar {
        flex-direction: column;
        align-items: stretch;
    }

    .ec-nav {
        order: -1;
    }

    .ec-views {
        justify-content: center;
    }

    .ec-jump {
        justify-content: flex-start;
        min-width: unset;
        width: 100%;
    }

    .ec-jump select {
        max-width: unset;
        flex: 1;
    }

    .ec-grid td {
        height: 90px;
    }

    .ec-event {
        font-size: 0.65rem;
    }
}

[data-theme="dark"] .events-calendar {
    background: var(--color-surface);
    color: var(--color-text);
}

[data-theme="dark"] .ec-title,
[data-theme="dark"] .ec-title i,
[data-theme="dark"] .ec-period-title,
[data-theme="dark"] .ec-grid th,
[data-theme="dark"] .ec-nav-btn {
    color: var(--color-primary-light);
}

[data-theme="dark"] .ec-stats,
[data-theme="dark"] .ec-hint-row p,
[data-theme="dark"] .ec-legend,
[data-theme="dark"] .ec-empty {
    color: var(--color-text-muted);
}

[data-theme="dark"] .ec-stats strong {
    color: var(--color-text);
}

[data-theme="dark"] .ec-hint-row {
    border-color: var(--color-border);
}

[data-theme="dark"] .ec-grid th {
    background: var(--color-bg-subtle);
    border-color: var(--color-border);
}

[data-theme="dark"] .ec-grid td {
    background: var(--color-surface);
    border-color: var(--color-border);
}

[data-theme="dark"] .ec-other .ec-grid td,
[data-theme="dark"] .ec-other .ec-day-num {
    background: var(--color-bg-subtle);
    color: var(--color-text-muted);
}

[data-theme="dark"] .ec-day-num {
    color: var(--color-text);
}

[data-theme="dark"] .ec-nav-btn,
[data-theme="dark"] .ec-add-block {
    background: var(--color-bg-subtle);
    border-color: var(--color-border);
    color: var(--color-text);
}

[data-theme="dark"] .ec-views .btn {
    color: var(--color-text);
    border-color: var(--color-border);
}

[data-theme="dark"] .ec-views .btn.active {
    background: var(--color-primary);
    border-color: var(--color-primary);
    color: #fff;
}

[data-theme="dark"] .ec-event {
    color: #1a323c !important;
}

[data-theme="dark"] .ec-event i:not(.ec-event-status-icon) {
    color: #1a323c !important;
}

[data-theme="dark"] .ec-event .ec-event-text {
    color: #1a323c !important;
}

[data-theme="dark"] .ec-day-view {
    background: var(--color-surface);
    border-color: var(--color-border);
}

[data-theme="dark"] .ec-day-view-header {
    color: var(--color-primary-light);
    border-color: var(--color-border);
}

[data-theme="dark"] .ec-grid td.ec-today {
    background: var(--color-bg-muted);
    box-shadow: inset 0 0 0 2px var(--color-accent);
}

[data-theme="dark"] .ec-grid td.ec-day-empty:hover,
[data-theme="dark"] .ec-week-grid td.ec-day-empty:hover {
    background: var(--color-bg-subtle);
}

[data-theme="dark"] #eventModalCategory {
    color: #1a323c !important;
}

[data-theme="dark"] .ec-modal-images img {
    border-color: var(--color-border);
    background: var(--color-bg-subtle);
}
