/**
 * SEC Calendar - Frontend Styles v3.0 (Fixed)
 * 
 * КЛЮЧЕВОЕ ИЗМЕНЕНИЕ: Убраны все !important и дефолтные значения
 * цветов/фонов/отступов, которые блокировали настройки Elementor.
 * Теперь эти стили служат как «ослабленный fallback» —
 * Elementor-настройки (через {{WRAPPER}}) всегда имеют приоритет.
 */

.sec-calendar-wrapper {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    width: 100%;
    box-sizing: border-box;
}

.sec-intro-text {
    margin-bottom: 20px;
    line-height: 1.6;
}

.sec-calendar {
    border: 1px solid #e1e1e1;
    border-radius: 8px 8px 0 0;
    overflow: hidden;
    background: #ffffff;
    width: 100%;
    box-sizing: border-box;
    display: block;
}

/* ─────────── ШАПКА КАЛЕНДАРЯ ─────────── */

.sec-header {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px 24px;
    background: #f9f9f9;
    width: 100%;
    box-sizing: border-box;
    flex-wrap: nowrap;
    gap: 8px;
    position: relative;
}

.sec-month-nav {
    display: flex;
    align-items: center;
    gap: 8px;
}

.sec-prev,
.sec-next {
    background: none;
    border: none;
    font-size: 1.2rem;
    cursor: pointer;
    padding: 8px 12px;
    color: #666666;
    transition: color 0.2s, background 0.2s;
    flex-shrink: 0;
    border-radius: 4px;
}

.sec-prev:hover,
.sec-next:hover {
    color: #0073aa;
    background: #f0f0f0;
}

.sec-month-title-wrapper {
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    padding: 6px 12px;
    border-radius: 6px;
    transition: background 0.2s;
    user-select: none;
    text-decoration: none;
}

.sec-month-title-wrapper:hover {
    background: #f0f0f0;
}

.sec-month-title {
    margin: 0;
    font-size: 1.6rem;
    font-weight: 600;
    /* Убраны !important — теперь Elementor переопределяет цвет/размер */
}

.sec-month-title a {
    color: inherit;
    text-decoration: inherit;
}

.sec-arrow-down {
    display: inline-block;
    width: 0;
    height: 0;
    border-left: 5px solid transparent;
    border-right: 5px solid transparent;
    border-top: 6px solid #666666;
    margin-left: 6px;
    vertical-align: middle;
    transition: transform 0.2s ease;
    flex-shrink: 0;
}

.sec-month-title-wrapper:hover .sec-arrow-down {
    border-top-color: #0073aa;
}

.sec-month-title-wrapper.active .sec-arrow-down {
    transform: rotate(180deg);
}

.sec-today-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: none;
    cursor: pointer;
    transition: background 0.2s;
    margin-left: 8px;
    /* Убраны жёсткие цвета — теперь Elementor задаёт */
}

/* ─────────── МИНИ-КАЛЕНДАРЬ (ВЫБОР МЕСЯЦА) ─────────── */

.sec-month-picker-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 99998;
    background: transparent;
}

.sec-month-picker {
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    background: #ffffff;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    padding: 16px;
    z-index: 99999;
    min-width: 280px;
    max-width: calc(100vw - 40px);
    margin-top: 8px;
}

.sec-month-picker-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
    padding-bottom: 10px;
    border-bottom: 1px solid #eeeeee;
}

.sec-month-picker-year {
    font-size: 1.1rem;
    font-weight: 600;
    color: #333333;
}

.sec-month-picker-prev-year,
.sec-month-picker-next-year {
    background: none;
    border: none;
    font-size: 1rem;
    cursor: pointer;
    padding: 4px 8px;
    color: #666666;
    border-radius: 4px;
    transition: all 0.2s;
}

.sec-month-picker-prev-year:hover,
.sec-month-picker-next-year:hover {
    background: #f0f0f0;
    color: #0073aa;
}

.sec-month-picker-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
}

.sec-month-picker-month {
    padding: 10px 8px;
    text-align: center;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.2s;
    border: 1px solid transparent;
}

/* ─────────── ПОДЛОЖКА СЕТКИ ─────────── */

.sec-grid-wrapper {
    /* Убраны жёсткий background и padding — Elementor задаёт */
    border-radius: 0 0 8px 8px;
    margin-top: -1px;
}

.sec-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 1px;
    background: transparent;
    width: 100%;
    box-sizing: border-box;
    border-radius: 4px;
    overflow: hidden;
}

.sec-grid-mobile {
    display: none;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    background: transparent;
    width: 100%;
    box-sizing: border-box;
}

.sec-weekday {
    text-align: center;
    padding: 10px 0;
    font-weight: 600;
    background: #ffffff;
    font-size: 0.85rem;
    color: #333333;
}

/* ─────────── ЯЧЕЙКИ ДНЕЙ (ПК) ─────────── */

.sec-day {
    background: #ffffff;
    min-height: 150px;
    padding: 10px;
    position: relative;
    font-size: 0.85rem;
    transition: background 0.3s;
    overflow-y: auto;
    overflow-x: hidden;
    box-sizing: border-box;
    cursor: default;
}

.sec-day.empty {
    background: #fafafa;
}

.sec-day.has-events {
    background: #f0f8ff;
}

.sec-day.today {
    background: #e6f7ff;
}

.sec-day:hover {
    background: #f9f9f9;
}

.sec-day.today:hover {
    background: #d6efff;
}

.sec-day-number {
    font-weight: bold;
    margin-bottom: 6px;
    color: #333333;
    min-width: 20px;
    font-size: 0.9rem;
    display: block;
}

/* ─────────── СОБЫТИЯ (ПК) ─────────── */

.sec-event {
    display: block;
    padding: 4px 7px;
    margin-bottom: 4px;
    font-size: 0.82rem;
    cursor: pointer;
    border-radius: 3px;
    background: #e6f7ff;
    color: #0066b3;
    word-wrap: break-word;
    overflow-wrap: break-word;
    white-space: normal;
    max-width: 100%;
    box-sizing: border-box;
    transition: background 0.2s, transform 0.1s;
    line-height: 1.3;
}

.sec-event:hover {
    background: #bae7ff;
    transform: translateY(-1px);
}

.sec-event.sec-event-disabled {
    cursor: default;
    pointer-events: none;
}

.sec-event-more {
    font-size: 0.75rem;
    color: #0073aa;
    cursor: pointer;
    margin-bottom: 3px;
    text-decoration: underline;
}

.sec-event-more:hover {
    color: #005a87;
}

/* ─────────── LOADER ─────────── */

.sec-loader {
    padding: 60px 40px;
    text-align: center;
    background: #ffffff;
    width: 100%;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 20px;
    min-height: 300px;
}

.sec-spinner {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.sec-spinner-dot {
    width: 12px;
    height: 12px;
    background: #0073aa;
    border-radius: 50%;
    animation: sec-spinner-bounce 1.4s ease-in-out infinite both;
}

.sec-spinner-dot:nth-child(1) { animation-delay: -0.32s; }
.sec-spinner-dot:nth-child(2) { animation-delay: -0.24s; }
.sec-spinner-dot:nth-child(3) { animation-delay: -0.16s; }
.sec-spinner-dot:nth-child(4) { animation-delay: -0.08s; }

@keyframes sec-spinner-bounce {
    0%, 80%, 100% { transform: scale(0); opacity: 0.5; }
    40% { transform: scale(1); opacity: 1; }
}

.sec-loader-text {
    color: #666666;
    font-size: 0.95rem;
    font-weight: 500;
}

/* ─────────── МОДАЛЬНОЕ ОКНО ─────────── */

.sec-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.6);
    z-index: 99999;
    padding: 20px;
    box-sizing: border-box;
}

.sec-modal {
    background: #ffffff;
    border-radius: 8px;
    max-width: 500px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    position: relative;
    padding: 25px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    box-sizing: border-box;
}

.sec-modal-close {
    position: absolute;
    top: 15px;
    right: 15px;
    background: none;
    border: none;
    font-size: 28px;
    line-height: 1;
    cursor: pointer;
    color: #666666;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: color 0.2s, background 0.2s;
}

.sec-modal-close:hover {
    color: #ff0000;
    background: #f5f5f5;
}

.sec-modal-title {
    margin: 0 0 10px 0;
    font-size: 1.4rem;
    color: #333333;
    padding-right: 30px;
}

.sec-modal-time {
    color: #666666;
    font-size: 0.9rem;
    margin-bottom: 15px;
}

.sec-modal-image {
    margin-bottom: 15px;
    border-radius: 6px;
    overflow: hidden;
}

.sec-modal-image img {
    width: 100%;
    height: auto;
    display: block;
}

.sec-modal-desc {
    margin-bottom: 20px;
    line-height: 1.6;
    color: #444444;
}

.sec-modal-desc p { margin: 0 0 10px 0; }
.sec-modal-desc p:last-child { margin-bottom: 0; }

.sec-modal-btn {
    display: inline-block;
    background: #0073aa;
    color: #ffffff;
    padding: 10px 20px;
    border-radius: 4px;
    text-decoration: none;
    font-weight: 500;
    transition: background 0.2s;
}

.sec-modal-btn:hover {
    background: #005a87;
}

/* ─────────── ПОИСК ПО СОБЫТИЯМ ─────────── */

.sec-search-wrapper {
    position: relative;
    margin-bottom: 20px;
    z-index: 100;
    display: inline-block;
    width: auto;
}

.sec-search-input-wrapper {
    position: relative;
    display: inline-flex;
    align-items: center;
}

.sec-search-input {
    width: 200px;
    min-width: 150px;
    max-width: 300px;
    padding: 8px 30px 8px 8px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 14px;
    font-family: inherit;
    transition: all 0.2s ease;
    background: #ffffff;
    box-sizing: border-box;
    line-height: 1.4;
}

.sec-search-input:focus {
    outline: none;
    border-color: #0C6F7A;
    box-shadow: 0 0 0 3px rgba(12, 111, 122, 0.1);
    width: 280px;
}

.sec-search-input::placeholder {
    color: #9ca3af;
}

.sec-search-clear {
    position: absolute;
    right: 6px;
    top: 50%;
    transform: translateY(-50%);
    background: transparent;
    border: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    font-size: 14px;
    color: #9ca3af;
    cursor: pointer;
    padding: 0;
    display: none;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    line-height: 1;
    z-index: 10;
}

.sec-search-clear:hover {
    background: #fee2e2;
    color: #ef4444;
}

.sec-search-clear.visible {
    display: flex;
}

.sec-search-spinner {
    position: absolute;
    right: 28px;
    top: 50%;
    transform: translateY(-50%);
    display: none;
    z-index: 10;
}

.sec-search-spinner.active {
    display: block;
}

.sec-search-spinner-ring {
    width: 14px;
    height: 14px;
    border: 2px solid #e5e7eb;
    border-top-color: #0C6F7A;
    border-radius: 50%;
    animation: sec-search-spin 0.8s linear infinite;
}

@keyframes sec-search-spin {
    to { transform: rotate(360deg); }
}

.sec-search-results {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    min-width: 320px;
    max-width: 400px;
    background: #ffffff;
    border-radius: 10px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15), 0 0 0 1px rgba(0, 0, 0, 0.05);
    max-height: 450px;
    overflow: hidden;
    display: none;
    animation: sec-results-appear 0.2s ease;
    z-index: 1000;
}

.sec-search-results.visible {
    display: block;
}

@keyframes sec-results-appear {
    from {
        opacity: 0;
        transform: translateY(-6px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.sec-search-results-header {
    padding: 10px 14px;
    background: #f9fafb;
    border-bottom: 1px solid #e5e7eb;
    font-size: 0.8rem;
    color: #6b7280;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.sec-search-results-count {
    font-weight: 500;
    color: #374151;
}

.sec-search-toggle-past {
    background: none;
    border: none;
    color: #0C6F7A;
    cursor: pointer;
    font-size: 0.8rem;
    text-decoration: underline;
    padding: 0;
}

.sec-search-toggle-past:hover {
    color: #095963;
}

.sec-search-results-list {
    list-style: none;
    margin: 0;
    padding: 0;
    max-height: 380px;
    overflow-y: auto;
    overscroll-behavior: contain;
}

.sec-search-results-list::-webkit-scrollbar {
    width: 5px;
}

.sec-search-results-list::-webkit-scrollbar-track {
    background: #f3f4f6;
}

.sec-search-results-list::-webkit-scrollbar-thumb {
    background: #d1d5db;
    border-radius: 3px;
}

.sec-search-results-list::-webkit-scrollbar-thumb:hover {
    background: #9ca3af;
}

.sec-search-result-item {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 12px 14px;
    border-bottom: 1px solid #f3f4f6;
    cursor: pointer;
    transition: all 0.15s ease;
}

.sec-search-result-item:last-child {
    border-bottom: none;
}

.sec-search-result-item:hover,
.sec-search-result-item.active {
    background: #f0fdfa;
}

.sec-search-result-item.active {
    box-shadow: inset 3px 0 0 #0C6F7A;
}

.sec-search-result-image {
    width: 48px;
    height: 48px;
    border-radius: 6px;
    overflow: hidden;
    flex-shrink: 0;
    background: linear-gradient(135deg, #f3f4f6 0%, #e5e7eb 100%);
    display: flex;
    align-items: center;
    justify-content: center;
}

.sec-search-result-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.sec-search-result-image.empty {
    font-size: 1.3rem;
    color: #9ca3af;
}

.sec-search-result-content {
    flex: 1;
    min-width: 0;
}

.sec-search-result-title {
    font-weight: 600;
    font-size: 0.9rem;
    color: #111827;
    margin-bottom: 3px;
    line-height: 1.3;
}

.sec-search-result-title mark,
.sec-search-result-excerpt mark {
    background: linear-gradient(120deg, #fef08a 0%, #fde047 100%);
    color: inherit;
    padding: 1px 2px;
    border-radius: 2px;
}

.sec-search-result-meta {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
    margin-bottom: 4px;
}

.sec-search-result-date {
    font-size: 0.8rem;
    color: #6b7280;
    display: flex;
    align-items: center;
    gap: 3px;
}

.sec-search-result-date.past {
    color: #9ca3af;
}

.sec-search-result-time {
    font-size: 0.8rem;
    color: #6b7280;
    padding-left: 6px;
    border-left: 1px solid #e5e7eb;
}

.sec-search-result-category {
    font-size: 0.7rem;
    padding: 2px 6px;
    background: #f0fdfa;
    color: #0C6F7A;
    border-radius: 999px;
    font-weight: 500;
}

.sec-search-result-excerpt {
    font-size: 0.8rem;
    color: #6b7280;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.sec-search-past-badge {
    font-size: 0.65rem;
    padding: 1px 5px;
    background: #f3f4f6;
    color: #9ca3af;
    border-radius: 3px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.sec-search-no-results {
    padding: 30px 16px;
    text-align: center;
}

.sec-search-no-results-icon {
    font-size: 2.5rem;
    margin-bottom: 10px;
    opacity: 0.5;
}

.sec-search-no-results-text {
    color: #6b7280;
    font-size: 0.9rem;
}

.sec-search-min-chars {
    padding: 16px;
    text-align: center;
    color: #9ca3af;
    font-size: 0.85rem;
}

.sec-search-error {
    padding: 16px;
    text-align: center;
    color: #ef4444;
    font-size: 0.85rem;
}

.sec-search-history {
    padding: 6px 0;
}

.sec-search-history-title {
    padding: 6px 14px;
    font-size: 0.7rem;
    color: #9ca3af;
    text-transform: uppercase;
    letter-spacing: 0.4px;
}

.sec-search-history-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    cursor: pointer;
    transition: background 0.15s;
}

.sec-search-history-item:hover {
    background: #f3f4f6;
}

.sec-search-history-icon {
    color: #9ca3af;
    font-size: 0.85rem;
}

.sec-search-history-text {
    flex: 1;
    font-size: 0.85rem;
    color: #374151;
}

.sec-search-history-remove {
    background: none;
    border: none;
    color: #9ca3af;
    cursor: pointer;
    padding: 3px;
    border-radius: 3px;
    opacity: 0;
    transition: all 0.15s;
}

.sec-search-history-item:hover .sec-search-history-remove {
    opacity: 1;
}

.sec-search-history-remove:hover {
    background: #fee2e2;
    color: #ef4444;
}

/* ─────────── ПОДСВЕТКА ДНЯ ПРИ ПЕРЕХОДЕ ИЗ ПОИСКА ─────────── */

.sec-day.highlighted-from-search {
    animation: sec-highlight-pulse 2s ease;
}

@keyframes sec-highlight-pulse {
    0%, 100% {
        box-shadow: inset 0 0 0 0 transparent;
    }
    50% {
        box-shadow: inset 0 0 0 3px rgba(12, 111, 122, 0.4);
    }
}

/* ═══════════════════════════════════════════════════════════════
   МОБИЛЬНАЯ ВЕРСИЯ
   ═══════════════════════════════════════════════════════════════ */

.sec-day-number-mobile {
    font-size: 1.5rem;
    font-weight: 700;
}

.sec-event-mobile {
    display: block;
    padding: 10px 12px;
    margin-bottom: 8px;
    border-radius: 6px;
    font-size: 0.95rem;
    cursor: pointer;
    transition: background 0.2s, transform 0.1s;
}

.sec-event-mobile:hover {
    transform: translateX(4px);
}

.sec-event-mobile:last-child {
    margin-bottom: 0;
}

.sec-event-mobile.sec-event-mobile-disabled {
    cursor: default;
    pointer-events: none;
}

@media (max-width: 768px) {
    .sec-header {
        flex-wrap: wrap;
        padding: 15px;
        gap: 10px;
    }

    .sec-month-nav {
        width: 100%;
        justify-content: center;
    }

    .sec-today-btn {
        margin-top: 10px;
        margin-left: 0;
    }

    .sec-month-title {
        font-size: 1.3rem;
    }

    .sec-grid {
        display: none;
    }

    .sec-grid-mobile {
        display: grid;
    }

    .sec-day-mobile {
        background: #ffffff;
        border-radius: 8px;
        padding: 15px;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
        min-height: 120px;
    }

    .sec-day-mobile.empty {
        display: none;
    }

    .sec-day-mobile.today {
        background: #e6f7ff;
    }

    .sec-day-mobile.has-events {
        background: #f0f8ff;
    }

    .sec-day-header-mobile {
        display: flex;
        align-items: center;
        gap: 10px;
        margin-bottom: 10px;
        padding-bottom: 10px;
        border-bottom: 1px solid #eeeeee;
    }

    .sec-modal {
        margin: 10px;
        padding: 20px;
    }

    .sec-modal-title {
        font-size: 1.2rem;
    }

    .sec-month-picker {
        left: 50%;
        right: auto;
        transform: translateX(-50%);
        width: calc(100% - 20px);
        max-width: 320px;
    }

    /* Мобильный поиск — на всю ширину */
    .sec-search-wrapper {
        display: block;
        width: 100%;
    }

    .sec-search-input-wrapper {
        display: flex;
        width: 100%;
    }

    .sec-search-input {
        width: 100%;
        max-width: none;
        padding: 12px 35px 12px 10px;
        font-size: 16px;
        border-radius: 8px;
    }

    .sec-search-input:focus {
        width: 100%;
    }

    .sec-search-clear {
        right: 10px;
        width: 22px;
        height: 22px;
    }

    .sec-search-results {
        position: fixed;
        top: auto;
        bottom: 0;
        left: 0;
        right: 0;
        min-width: 100%;
        max-width: 100%;
        max-height: 70vh;
        border-radius: 16px 16px 0 0;
        animation: sec-results-slide-up 0.3s ease;
    }

    @keyframes sec-results-slide-up {
        from { transform: translateY(100%); }
        to { transform: translateY(0); }
    }

    .sec-search-results-header {
        padding: 14px;
        position: relative;
    }

    .sec-search-results-header::before {
        content: "";
        position: absolute;
        top: 6px;
        left: 50%;
        transform: translateX(-50%);
        width: 36px;
        height: 4px;
        background: #d1d5db;
        border-radius: 2px;
    }

    .sec-search-results-list {
        max-height: calc(70vh - 55px);
    }

    .sec-search-result-item {
        padding: 10px 14px;
    }

    .sec-search-result-image {
        width: 42px;
        height: 42px;
    }
}

@media (hover: none) and (pointer: coarse) {
    .sec-event.sec-event-disabled,
    .sec-event-mobile.sec-event-mobile-disabled {
        -webkit-tap-highlight-color: transparent;
    }
    
    .sec-search-history-remove {
        opacity: 1;
    }
}

@media (max-width: 480px) {
    .sec-header {
        padding: 12px;
    }

    .sec-month-title {
        font-size: 1.1rem;
    }

    .sec-prev,
    .sec-next {
        padding: 6px 10px;
        font-size: 1rem;
    }

    .sec-day-mobile {
        padding: 12px;
        min-height: 100px;
    }

    .sec-event-mobile {
        padding: 8px 10px;
        font-size: 0.9rem;
    }
}