/* Календарь мероприятий */
.events-calendar {
    background: var(--bg-card, #fff);
    border: 1px solid var(--border-color, #DDEAF4);
    border-radius: 12px;
    box-shadow: 0 2px 12px rgba(15, 70, 133, 0.06);
    padding: 1.5rem 1.25rem 1.25rem;
    margin: 1.5rem 0 2rem;
}

.ec-header-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    margin-bottom: 0.75rem;
}

.ec-title {
    font-size: 1.35rem;
    font-weight: 700;
    color: var(--text-primary, #003f81);
    letter-spacing: 0.02em;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.ec-title i { color: var(--accent, #FC6F1A); }

.ec-stats {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem 1.25rem;
    font-size: 0.95rem;
    color: var(--text-secondary, #555);
    margin-bottom: 0.75rem;
}

.ec-stats strong {
    color: var(--text-primary, #003f81);
    font-weight: 700;
}

.ec-hint-row {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    gap: 0.75rem 1rem;
    margin-bottom: 1rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border-color, #DDEAF4);
}

.ec-hint-row p {
    margin: 0;
    font-size: 0.9rem;
    color: var(--text-secondary, #555);
    max-width: 42rem;
}

.ec-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem 1.25rem;
    font-size: 0.82rem;
    color: var(--text-secondary, #555);
}

.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-filter {
    margin-bottom: 1rem;
}

.ec-filter label {
    display: inline-flex;
    flex-direction: column;
    gap: 0.25rem;
    font-size: 0.85rem;
    color: var(--text-secondary, #555);
}

.ec-filter select {
    min-width: 200px;
    padding: 0.4rem 0.6rem;
    border: 1px solid var(--border-color, #DDEAF4);
    border-radius: 6px;
    background: var(--bg-card, #fff);
    color: var(--text-primary, #003f81);
}

.ec-toolbar {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1rem;
}

.ec-views {
    display: inline-flex;
    gap: 0.35rem;
}

.ec-views .btn {
    font-size: 0.875rem;
    padding: 0.35rem 0.9rem;
}

.ec-views .btn.active,
.ec-views .btn.active:hover,
.ec-views .btn.btn-outline.active,
.ec-views .btn.btn-outline.active:hover {
    background: var(--bg-header, #0F4685) !important;
    border-color: var(--bg-header, #0F4685) !important;
    color: #fff !important;
}

.ec-nav {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex: 1;
    justify-content: center;
}

.ec-nav-btn {
    border: 1px solid var(--border-color, #DDEAF4);
    background: var(--bg-card, #fff);
    color: var(--text-primary, #003f81);
    border-radius: 999px;
    padding: 0.35rem 0.9rem;
    font-size: 0.875rem;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s;
}

.ec-nav-btn:hover {
    background: var(--bg-muted, #F2F8FD);
}

.ec-jump {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex: 1;
    justify-content: center;
    min-width: 220px;
}

.ec-jump-label {
    font-size: 0.8rem;
    color: var(--text-secondary, #555);
}

.ec-jump select {
    max-width: 140px;
    padding: 0.35rem 0.5rem;
    border: 1px solid var(--border-color, #DDEAF4);
    border-radius: 6px;
    background: var(--bg-card, #fff);
    color: var(--text-primary, #003f81);
}

.ec-period-title {
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--text-primary, #003f81);
    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: var(--bg-muted, #F2F8FD);
    color: var(--text-primary, #003f81);
    font-weight: 600;
    font-size: 0.85rem;
    padding: 0.55rem 0.35rem;
    text-align: center;
    border: 1px solid var(--border-color, #DDEAF4);
}

.ec-grid td {
    vertical-align: top;
    border: 1px solid var(--border-color, #DDEAF4);
    background: var(--bg-card, #fff);
    height: 110px;
    padding: 0.35rem;
    position: relative;
}

.ec-grid td.ec-other { background: var(--bg-muted, #F2F8FD); opacity: 0.85; }

.ec-grid td.ec-today {
    background: #fff7ef;
    box-shadow: inset 0 0 0 2px var(--accent, #FC6F1A);
}

.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: var(--bg-muted, #F2F8FD); }

.ec-day-num {
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text-primary, #003f81);
    margin-bottom: 0.25rem;
    line-height: 1.2;
}

.ec-other .ec-day-num { color: var(--text-secondary, #555); }

.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;
    color: #1a323c;
}

.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;
}

.ec-week-grid .ec-event-text { -webkit-line-clamp: 4; }

.ec-day-view {
    background: var(--bg-card, #fff);
    border: 1px solid var(--border-color, #DDEAF4);
    border-radius: 10px;
    padding: 1rem;
    min-height: 280px;
}

.ec-day-view-header {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary, #003f81);
    margin-bottom: 1rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--border-color, #DDEAF4);
}

.ec-day-view .ec-event {
    font-size: 0.9rem;
    padding: 0.65rem 0.85rem;
    margin-bottom: 0.5rem;
}

.ec-day-view .ec-event-text { -webkit-line-clamp: unset; }

.ec-empty {
    color: var(--text-secondary, #555);
    font-style: italic;
    font-size: 0.9rem;
    padding: 1rem 0;
}

.ec-add-block {
    background: var(--bg-card, #fff);
    border: 1px solid var(--border-color, #DDEAF4);
    border-radius: 12px;
    box-shadow: 0 2px 12px rgba(15, 70, 133, 0.06);
    padding: 1.25rem 1.25rem 1.5rem;
    margin: 0 0 2rem;
}

.ec-add-title {
    margin: 0 0 0.35rem;
    font-size: 1.15rem;
    color: var(--text-primary, #003f81);
    display: flex;
    align-items: center;
    gap: 0.45rem;
}

.ec-add-title i { color: var(--accent, #FC6F1A); }

.ec-add-hint {
    margin: 0 0 1rem;
    font-size: 0.9rem;
    color: var(--text-secondary, #555);
}

.ec-add-form { display: flex; flex-direction: column; gap: 0.85rem; }

.ec-add-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem 1rem;
    align-items: flex-end;
}

.ec-field {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
    min-width: 140px;
    flex: 1 1 140px;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-primary, #003f81);
}

.ec-field-grow { flex: 2 1 220px; }
.ec-field-wide { flex: 3 1 280px; }
.ec-field-submit {
    flex: 0 0 auto;
    min-width: auto;
    justify-content: flex-end;
    display: flex;
    flex-direction: row;
    align-items: flex-end;
    gap: 0.5rem;
}

.ec-add-block-edit {
    outline: 2px solid rgba(15, 70, 133, 0.25);
    outline-offset: 2px;
}

.ec-field input[type="text"],
.ec-field input[type="date"],
.ec-field input[type="file"],
.ec-field select,
.ec-field textarea {
    font-weight: 400;
    padding: 0.45rem 0.6rem;
    border: 1px solid var(--border-color, #DDEAF4);
    border-radius: 6px;
    background: var(--bg-card, #fff);
    color: var(--text-primary, #003f81);
    font-size: 0.95rem;
}

.ec-field-hint {
    font-weight: 400;
    font-size: 0.75rem;
    color: var(--text-secondary, #555);
}

.ec-visibility-fieldset {
    border: 0;
    padding: 0.25rem 0 0;
    margin: 0;
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem 1.25rem;
    align-items: center;
}

.ec-visibility-fieldset legend {
    float: none;
    width: auto;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-primary, #003f81);
    margin-bottom: 0.35rem;
    padding: 0;
}

.ec-radio {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.9rem;
    font-weight: 400;
    color: var(--text-primary, #003f81);
    cursor: pointer;
}

.text-danger { color: #dc3545; }

/* Модалки */
.ec-modal[hidden] { display: none !important; }

.ec-modal {
    position: fixed;
    inset: 0;
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.ec-modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(15, 30, 60, 0.45);
}

.ec-modal-dialog {
    position: relative;
    z-index: 1;
    width: 100%;
    max-width: 640px;
}

.ec-modal-dialog.ec-modal-sm { max-width: 360px; }

.ec-modal-content {
    background: var(--bg-card, #fff);
    border-radius: 12px;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.18);
    overflow: hidden;
}

.ec-modal-header,
.ec-modal-footer {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 1rem 1.1rem;
}

.ec-modal-footer {
    align-items: center;
    flex-wrap: nowrap;
    justify-content: flex-start;
    gap: 0.45rem;
    border-top: 1px solid var(--border-color, #DDEAF4);
}

.ec-modal-footer .btn {
    white-space: nowrap;
    flex: 0 1 auto;
}

@media (max-width: 640px) {
    .ec-modal-footer {
        flex-wrap: wrap;
    }
}

.ec-modal-body { padding: 0 1.1rem 1rem; }

.ec-modal-heading {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.ec-modal-icon {
    font-size: 1.75rem;
    color: var(--accent, #FC6F1A);
}

.ec-modal-title {
    margin: 0;
    font-size: 1.1rem;
    color: var(--text-primary, #003f81);
}

.ec-modal-badge {
    display: inline-block;
    font-size: 0.75rem;
    padding: 0.2rem 0.55rem;
    border-radius: 999px;
    margin-bottom: 0.25rem;
    border-left: 3px solid;
}

.ec-modal-close {
    border: none;
    background: transparent;
    font-size: 1.5rem;
    line-height: 1;
    color: var(--text-secondary, #555);
    cursor: pointer;
    padding: 0 0.25rem;
}

.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 var(--border-color, #DDEAF4);
    background: var(--bg-muted, #F2F8FD);
}

.mb-0 { margin-bottom: 0; }
.mb-2 { margin-bottom: 0.5rem; }
.mt-3 { margin-top: 1rem; }
.text-muted { color: var(--text-secondary, #555); }
.btn-sm { font-size: 0.85rem; padding: 0.35rem 0.75rem; }

@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(--bg-card);
    border-color: var(--border-color);
}

[data-theme="dark"] .ec-grid td.ec-today {
    background: rgba(246, 173, 85, 0.12);
}

[data-theme="dark"] .ec-event {
    color: #1a323c !important;
}

[data-theme="dark"] .ec-modal-content {
    background: var(--bg-card);
    color: var(--text-primary);
}
