/**
 * WEC Events Calendar — Google Calendar-style
 * Clean grid, tall cells, events as chips inside each day
 * Mobile-first responsive design
 */

.wec-calendar-wrapper {
    --wec-border: #dadce0;
    --wec-text: #3c4043;
    --wec-muted: #5f6368;
    --wec-primary: #1a73e8;
    --wec-primary-hover: #1765cc;
    --wec-bg-cell: #fff;
    --wec-bg-today: #f8f9fa;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    margin: 0;
    padding: 10px 12px 16px;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    font-size: clamp(13px, 1.5vw, 14px);
    color: var(--wec-text);
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(60, 64, 67, 0.08);
    box-sizing: border-box;
    overflow: hidden;
    position: relative;
    container-type: inline-size;
    container-name: wec-calendar;
}

.wec-calendar-wrapper::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-repeat: no-repeat;
    background-position: center;
    background-size: 40%;
    opacity: 0.06;
    border-radius: 8px;
    pointer-events: none;
    z-index: 0;
}

.wec-calendar-wrapper .wec-header,
.wec-calendar-wrapper .wec-body,
.wec-calendar-wrapper .wec-grid-wrap,
.wec-calendar-wrapper .wec-sidebar,
.wec-calendar-wrapper .wec-loading {
    position: relative;
}

.wec-calendar-wrapper .wec-body,
.wec-calendar-wrapper .wec-grid-wrap {
    z-index: 0;
}

/* Header: Google-style — arrows + title on the left, Today on the right */
.wec-header {
    position: relative;
    z-index: 20;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 12px;
    padding: 0 0 10px 0;
    border-bottom: 1px solid var(--wec-border);
}

.wec-header-nav {
    display: flex;
    flex: 1;
    min-width: 0;
    align-items: center;
    gap: 8px;
}

.wec-prev,
.wec-next {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    padding: 0;
    border: none;
    border-radius: 50%;
    background: transparent;
    color: var(--wec-muted);
    cursor: pointer;
    font-size: 18px;
    line-height: 1;
    transition: background 0.15s, color 0.15s;
}

.wec-prev:hover,
.wec-next:hover {
    background: rgba(60, 64, 67, 0.08);
    color: var(--wec-text);
}

.wec-title-wrap {
    position: relative;
    z-index: 21;
    isolation: isolate;
}

.wec-title {
    margin: 0;
    font-size: 16px;
    font-weight: 400;
    color: var(--wec-text);
    padding: 4px 8px;
    border: none;
    border-radius: 4px;
    background: transparent;
    cursor: pointer;
    font-family: inherit;
    transition: background 0.15s, color 0.15s;
}

.wec-title:hover {
    background: rgba(60, 64, 67, 0.08);
    color: #815374;
}


/* Month/year picker (Google style) — above grid, fully opaque background */
.wec-month-picker {
    position: absolute;
    top: 100%;
    left: 0;
    margin-top: 4px;
    min-width: 200px;
    padding: 12px;
    background: #ffffff !important;
    background-color: #ffffff !important;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(60, 64, 67, 0.15);
    border: 1px solid var(--wec-border);
    z-index: 1000;
    isolation: isolate;
    opacity: 1;
    contain: layout paint;
}

.wec-month-picker[hidden] {
    display: none !important;
}

/* Year row: opaque white background so SUN/MON don't show through */
.wec-picker-year {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
    padding-bottom: 8px;
    padding-top: 2px;
    border-bottom: 1px solid var(--wec-border);
    background: #ffffff !important;
    background-color: #ffffff !important;
}

.wec-picker-year-value {
    font-size: 16px;
    font-weight: 500;
    color: var(--wec-text);
    background: #ffffff !important;
}

.wec-picker-prev-year,
.wec-picker-next-year {
    width: 32px;
    height: 32px;
    padding: 0;
    border: none;
    border-radius: 50%;
    background: transparent;
    color: var(--wec-muted);
    font-size: 18px;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}

.wec-picker-prev-year:hover,
.wec-picker-next-year:hover {
    background: rgba(60, 64, 67, 0.08);
    color: var(--wec-text);
}

.wec-picker-months {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 4px;
    background: #ffffff !important;
}

.wec-picker-month {
    padding: 8px 10px;
    border: none;
    border-radius: 4px;
    background: transparent;
    color: var(--wec-text);
    font-size: 13px;
    font-family: inherit;
    cursor: pointer;
    text-align: center;
    transition: background 0.15s, color 0.15s;
}

.wec-picker-month:hover {
    background: rgba(26, 115, 232, 0.08);
    color: var(--wec-primary);
}

.wec-picker-month--current {
    background: rgba(26, 115, 232, 0.12);
    color: var(--wec-primary);
    font-weight: 500;
}

.wec-picker-month--disabled {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
}

.wec-picker-month--disabled:hover {
    background: transparent;
    color: var(--wec-text);
}

.wec-header-right {
    display: flex;
    align-items: center;
    gap: 8px;
}

.wec-view-toggle {
    display: flex;
    align-items: center;
    border: 1px solid var(--wec-border);
    border-radius: 3px;
    background: #fff;
    overflow: hidden;
}

.wec-view-btn {
    padding: 4px 10px;
    border: none;
    background: transparent;
    color: var(--wec-muted);
    font-size: 12px;
    font-weight: 500;
    font-family: inherit;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
    white-space: nowrap;
    position: relative;
}

.wec-view-btn:hover {
    /* Inactive hover state */
    background: #F3EEF2;
    color: #000;
}

.wec-view-btn--active {
    /* Active state */
    background: #815374;
    color: #fff;
}

.wec-view-btn--active:hover {
    /* Active hover state disabled: keep same as active */
    background: #815374;
    color: #fff;
    cursor: default;
}

.wec-view-btn:not(:last-child) {
    border-right: 1px solid var(--wec-border);
}

.wec-today {
    padding: 6px;
    border: none;
    border-radius: 4px;
    background: transparent;
    color: var(--wec-text);
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
    font-family: inherit;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.wec-today svg {
    width: 20px;
    height: 20px;
    display: block;
}

.wec-today:hover {
    background: rgba(60, 64, 67, 0.08);
    color: #815374;
}

.wec-export {
    padding: 6px;
    border: none;
    border-radius: 4px;
    background: transparent;
    color: var(--wec-text);
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
    font-family: inherit;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.wec-export:hover {
    background: rgba(60, 64, 67, 0.08);
    color: #815374;
}

.wec-export svg {
    width: 20px;
    height: 20px;
    display: block;
}

.wec-export-menu {
    position: absolute;
    z-index: 10003;
    background: #fff;
    border: none;
    border-radius: 5px;
    width: 160px;
    min-height: 188px;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    padding: 20px;
    gap: 20px;
    box-sizing: border-box;
    box-shadow: 0 4px 16px rgba(60, 64, 67, 0.16);
    animation: wec-menuFadeIn 0.15s ease-out;
}

@keyframes wec-menuFadeIn {
    from { opacity: 0; transform: translateY(-4px); }
    to { opacity: 1; transform: translateY(0); }
}

.wec-export-option {
    display: block;
    width: 100%;
    padding: 6px 10px;
    border: none;
    border-radius: 0;
    background: transparent;
    color: var(--wec-text);
    font-size: 14px;
    line-height: 1.3;
    text-align: left;
    cursor: pointer;
    transition: background 0.15s;
    font-family: inherit;
}

.wec-export-option:hover {
    background: #F3EEF2;
    color: #815374;
}

.wec-export-option:active {
    background: #F3EEF2;
    color: #815374;
    box-shadow: inset 4px 0 0 #875074;
}

.wec-export-option:focus-visible {
    outline: none;
    background: #F3EEF2;
    box-shadow: inset 4px 0 0 #875074;
}

/* Filters: inside right sidebar, at top */
.wec-sidebar-filters {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 0;
    background: #FFF8F3;
    padding: 12px;
}

.wec-filter-search-wrap,
.wec-filter-location-wrap,
.wec-filter-type-wrap,
.wec-filter-featured-wrap {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.wec-filter-featured-toggle {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    width: fit-content;
    padding: 0;
    border: none;
    background: transparent;
    cursor: pointer;
    font-size: 13px;
    color: var(--wec-text);
    user-select: none;
}

.wec-filter-featured-toggle-track {
    position: relative;
    width: 38px;
    height: 22px;
    border-radius: 999px;
    background: #c9ced6;
    transition: background-color 0.2s ease;
}

.wec-filter-featured-toggle-thumb {
    position: absolute;
    top: 2px;
    left: 2px;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.25);
    transition: transform 0.2s ease;
}

.wec-filter-featured-toggle.is-on .wec-filter-featured-toggle-track {
    background: #875074;
}

.wec-filter-featured-toggle.is-on .wec-filter-featured-toggle-thumb {
    transform: translateX(16px);
}

.wec-filter-featured-toggle-text {
    font-weight: 500;
    color: var(--wec-text);
}

.wec-filter-featured-toggle:focus-visible {
    outline: 2px solid rgba(135, 80, 116, 0.35);
    outline-offset: 2px;
    border-radius: 6px;
}

.wec-filter-featured-toggle:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

.wec-filter-label {
    font-size: 12px;
    font-weight: 500;
    color: var(--wec-muted);
}

.wec-filter-search {
    width: 100%;
    max-width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--wec-border);
    border-radius: 4px;
    font-size: 14px;
    font-family: inherit;
    color: var(--wec-text);
    background: #fff;
    box-sizing: border-box;
    transition: border-color 0.15s, box-shadow 0.15s;
}

.wec-filter-search:focus {
    outline: none;
    border-color: var(--wec-primary);
    box-shadow: 0 0 0 2px rgba(26, 115, 232, 0.15);
}

.wec-filter-search::placeholder {
    color: var(--wec-muted);
}

.wec-filter-location,
.wec-filter-type {
    width: 100%;
    max-width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--wec-border);
    border-radius: 4px;
    font-size: 14px;
    font-family: inherit;
    color: var(--wec-text);
    background: #fff;
    cursor: pointer;
    box-sizing: border-box;
    transition: border-color 0.15s;
}

.wec-filter-location:focus,
.wec-filter-type:focus {
    outline: none;
    border-color: var(--wec-primary);
}

/* Separator between filters and event list in sidebar */
.wec-sidebar-separator {
    height: 0;
    border: none;
    border-top: 1px solid var(--wec-border);
    margin: 16px 0;
}

/* Body: grid + right sidebar */
.wec-body {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0;
    min-height: 320px;
    min-width: 0;
}

/* Layout sin panel lateral (show_panel="false") */
.wec-calendar-wrapper[data-show-panel="false"] .wec-body {
    grid-template-columns: 1fr !important;
}

/* Collapsed panel: strip with button to reopen */
.wec-calendar-wrapper.wec-sidebar-collapsed .wec-body {
    grid-template-columns: 1fr 48px;
}

.wec-grid-wrap {
    padding: 0 12px 0 0;
    background: transparent;
    min-width: 0;
    overflow-x: auto;
}

/* Weekdays — one row, columns can shrink */
.wec-weekdays {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    border: 1px solid var(--wec-border);
    margin-bottom: 0;
    background: #FFF8F3;
    padding: 16px 0;
}

.wec-wday {
    text-align: center;
    font-size: 13px;
    font-weight: 500;
    color: var(--wec-muted);
    padding: 6px 2px;
}

.wec-wday-long {
    display: none;
}

.wec-wday-short {
    display: inline;
    text-transform: uppercase;
    letter-spacing: 0.02em;
    font-size: 10px;
}

/* Day grid: cells that adapt to width */
.wec-days {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    grid-auto-rows: minmax(60px, 1fr);
    border: 1px solid var(--wec-border);
    border-top: none;
    min-width: min(100%, 320px);
}

/* Year view: grid of 12 months */
.wec-days--year-view {
    grid-template-columns: 1fr;
    grid-auto-rows: auto;
    border: none;
}

.wec-year-view {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.wec-year-month {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.wec-year-month-title {
    font-size: 16px;
    font-weight: 500;
    color: var(--wec-text);
    padding: 8px 0 4px;
    border-bottom: 1px solid var(--wec-border);
}

.wec-year-month-days {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    grid-auto-rows: minmax(50px, 1fr);
    border: 1px solid var(--wec-border);
}

.wec-year-month-days .wec-day {
    min-height: 50px;
}

.wec-year-month-days .wec-day--empty {
    min-height: 50px;
}

.wec-year-month-days .wec-day-num {
    font-size: 10px;
    top: 2px;
    right: 4px;
}

.wec-year-month-days .wec-day-events {
    padding: 14px 2px 2px 4px;
}

.wec-year-month-days .wec-event-chip {
    font-size: 8px;
    padding: 1px 3px;
    line-height: 1.2;
}

.wec-year-month-days .wec-day-more {
    font-size: 8px;
}

.wec-day {
    min-height: 60px;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    border-right: 1px solid var(--wec-border);
    border-bottom: 1px solid var(--wec-border);
    cursor: pointer;
    position: relative;
    background: var(--wec-bg-cell);
    transition: background 0.15s;
}

.wec-day:nth-child(7n) {
    border-right: none;
}

.wec-day:hover {
    background: #f8f9fa;
}

.wec-day--empty {
    cursor: default;
    background: #f8f9fa;
    min-height: 60px;
}

.wec-day--empty:hover {
    background: #f8f9fa;
}

.wec-day--today {
    background: var(--wec-bg-today);
}

.wec-day--today:hover {
    background: #f1f3f4;
}

.wec-day--selected {
    background: #F3F3F3;
}

.wec-day--selected:hover {
    background: #F3F3F3;
}

/* Day number — top-right corner like Google */
.wec-day-num {
    position: absolute;
    top: 4px;
    right: 4px;
    font-size: 10px;
    font-weight: 400;
    color: var(--wec-muted);
    line-height: 1;
}

.wec-day--today .wec-day-num {
    color: var(--wec-primary);
    font-weight: 500;
}

.wec-day--selected .wec-day-num {
    color: var(--wec-primary);
}

/* Event area within cell */
.wec-day-events {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 18px 4px 4px 6px;
    overflow: hidden;
    align-items: stretch;
}

/* Event chip — horizontal colored bar, Google-style */
.wec-event-chip {
    display: flex;
    align-items: center;
    gap: 4px;
    width: 100%;
    text-align: left;
    padding: 3px 6px;
    border: none;
    border-radius: 3px;
    background: var(--chip-color, #e8eaed);
    color: #3c4043;
    font-size: 10px;
    font-weight: 400;
    line-height: 1.35;
    cursor: pointer;
    overflow: hidden;
    word-wrap: break-word;
    transition: opacity 0.15s, filter 0.15s, box-shadow 0.15s;
}

.wec-event-chip:hover {
    opacity: 0.9;
    filter: brightness(0.95);
}

.wec-event-chip--featured {
    box-shadow: 0 0 0 2px currentColor inset;
    font-weight: 500;
}

.wec-featured-badge {
    flex-shrink: 0;
    font-size: 12px;
    color: #f4c430;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

/* "+N more" */
.wec-day-more {
    font-size: 11px;
    color: var(--wec-primary);
    cursor: pointer;
    padding: 2px 0;
    font-weight: 500;
}

.wec-day-more:hover {
    text-decoration: underline;
}

/* Right sidebar: retractable button + filters and list */
.wec-sidebar {
    display: flex;
    flex-direction: column;
    padding: 0;
    margin-left: 0;
    margin-top: 12px;
    border-left: none;
    border-top: 1px solid var(--wec-border);
    background: transparent;
    min-height: 0;
}

.wec-sidebar-toggle {
    flex-shrink: 0;
    width: 100%;
    min-width: 0;
    height: 36px;
    padding: 0;
    border: none;
    border-right: none;
    border-bottom: 1px solid var(--wec-border);
    background: #f8f9fa;
    color: var(--wec-muted);
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s, color 0.15s;
}

.wec-sidebar-toggle:hover {
    background: #e8eaed;
    color: var(--wec-primary);
}

.wec-sidebar-toggle-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.wec-sidebar-toggle-icon img {
    display: block;
    width: 20px;
    height: 20px;
}

.wec-sidebar-toggle-icon svg {
    display: block;
    width: 20px;
    height: 20px;
}

.wec-sidebar-inner {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    padding: 0 0 16px 16px;
    overflow: hidden;
}

.wec-sidebar-collapsed .wec-sidebar .wec-sidebar-inner {
    display: none !important;
}

.wec-sidebar-collapsed .wec-sidebar .wec-sidebar-toggle {
    width: 100%;
    min-width: 0;
    height: 36px;
    border-left: none;
    border-bottom: 1px solid var(--wec-border);
}

.wec-sidebar-title {
    flex-shrink: 0;
    margin: 0;
}

.wec-sidebar-events-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    flex-shrink: 0;
    margin-bottom: 4px;
}

.wec-sidebar-events-header .wec-sidebar-title {
    margin: 0;
    min-width: 0;
    flex: 1;
}

.wec-sidebar-add-event {
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 6px;
    border-radius: 4px;
    border: none;
    background: transparent;
    color: var(--wec-text);
    font-family: inherit;
    text-decoration: none;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}

.wec-sidebar-add-event:hover {
    background: rgba(60, 64, 67, 0.08);
    color: var(--wec-primary);
}

.wec-sidebar-add-event svg {
    width: 20px;
    height: 20px;
    display: block;
}

.wec-events-list {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
}

/* ========== Mobile-first: Tablet and up (481px+) ========== */
@media (min-width: 481px) {
    .wec-calendar-wrapper {
        padding: 12px 16px 20px;
        margin: 0;
    }

    .wec-header {
        margin-bottom: 12px;
        flex-wrap: nowrap;
        gap: 8px;
    }

    .wec-header-nav {
        flex: 0 1 auto;
    }

    .wec-title {
        font-size: 18px;
    }

    .wec-prev,
    .wec-next {
        width: 32px;
        height: 32px;
        font-size: 18px;
    }

    .wec-header-right {
        flex-wrap: nowrap;
    }

    .wec-view-btn {
        padding: 4px 10px;
        font-size: 12px;
    }

    .wec-today {
        padding: 6px;
    }
    
    .wec-today svg {
        width: 20px;
        height: 20px;
    }

    .wec-export {
        width: auto;
        padding: 6px 12px;
        font-size: 13px;
    }

    .wec-wday {
        padding: 6px 2px;
    }

    .wec-days {
        grid-auto-rows: minmax(70px, 1fr);
    }

    .wec-day {
        min-height: 70px;
    }

    .wec-day--empty {
        min-height: 70px;
    }

    .wec-day-num {
        font-size: 11px;
        top: 4px;
        right: 4px;
    }

    .wec-day-events {
        padding: 20px 4px 4px 6px;
    }

    .wec-event-chip {
        font-size: 11px;
        padding: 4px 6px;
    }

    .wec-sidebar-inner {
        padding: 12px 0 12px 12px;
    }

    .wec-filter-search,
    .wec-filter-location,
    .wec-filter-type {
        font-size: 13px;
        padding: 6px 10px;
    }

    .wec-event-item {
        padding: 8px 10px;
        font-size: 13px;
    }

    .wec-month-picker {
        min-width: 240px;
    }
}

    .wec-sidebar-title {
        margin: 0 0 12px 0;
        font-size: 14px;
        font-weight: 500;
        color: var(--wec-text);
    }

    .wec-sidebar-events-header {
        margin-bottom: 12px;
    }

    .wec-sidebar-events-header .wec-sidebar-title {
        margin: 0;
    }

.wec-events-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.wec-no-events {
    margin: 0;
    font-size: 13px;
    color: var(--wec-muted);
}

/* Sidebar items — Google-style list */
.wec-event-item {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    width: 100%;
    text-align: left;
    padding: 6px 8px;
    border: none;
    border-left: 3px solid var(--chip-color, var(--wec-primary));
    border-radius: 0 4px 4px 0;
    background: #f8f9fa;
    cursor: pointer;
    font-size: 12px;
    color: var(--wec-text);
    transition: background 0.15s;
}

.wec-event-item:hover {
    background: #e8eaed;
}

.wec-event-item--featured {
    border-left-color: #d4af37;
    background: #fef9e7;
}

.wec-event-item--featured:hover {
    background: #fef3c7;
}

.wec-event-item strong {
    display: block;
    margin-bottom: 2px;
    font-weight: 500;
    flex: 1;
}

.wec-event-time {
    display: block;
    font-size: 12px;
    color: var(--wec-muted);
}

.wec-featured-badge-item {
    display: inline-block;
    margin-left: 6px;
    color: #d4af37;
    font-size: 14px;
    font-weight: bold;
    text-shadow: 0 1px 2px rgba(212, 175, 55, 0.2);
    white-space: nowrap;
    flex-shrink: 0;
}

/* Loading */
.wec-loading {
    padding: 8px 0;
    font-size: 13px;
    color: var(--wec-muted);
}

.wec-loading:not(:empty)::after {
    content: '';
    display: inline-block;
    width: 18px;
    height: 18px;
    border: 2px solid #e8eaed;
    border-top-color: var(--wec-primary);
    border-radius: 50%;
    animation: wec-spin 0.8s linear infinite;
    margin-left: 8px;
    vertical-align: middle;
}

.wec-redirect-overlay {
    position: absolute;
    inset: 0;
    z-index: 9000;
    background: rgba(255, 255, 255, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
}

.wec-redirect-overlay[hidden] {
    display: none !important;
}

.wec-redirect-dialog {
    background: #fff;
    border-radius: 8px;
    padding: 16px 20px;
    box-shadow: 0 4px 16px rgba(60, 64, 67, 0.2);
    display: flex;
    align-items: center;
    gap: 12px;
}

.wec-redirect-spinner {
    width: 22px;
    height: 22px;
    border: 2px solid #e8eaed;
    border-top-color: var(--wec-primary);
    border-radius: 50%;
    animation: wec-spin 0.8s linear infinite;
}

.wec-redirect-text {
    margin: 0;
    font-size: 14px;
    color: var(--wec-text);
}

@keyframes wec-spin {
    to { transform: rotate(360deg); }
}

/* Modal */
.wec-modal {
    position: fixed;
    inset: 0;
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    box-sizing: border-box;
    overflow-y: auto;
}

.wec-modal[hidden] {
    display: none !important;
}

.wec-modal-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
}

.wec-modal-content {
    position: relative;
    background: #fff;
    border-radius: 8px;
    max-width: 480px;
    width: 100%;
    max-height: calc(100vh - 32px);
    overflow: hidden;
    box-shadow: 0 8px 32px rgba(60, 64, 67, 0.2);
    animation: wec-modalFadeIn 0.2s ease-out;
    z-index: 10001;
    display: flex;
    flex-direction: column;
}

@keyframes wec-modalFadeIn {
    from { opacity: 0; transform: scale(0.98); }
    to { opacity: 1; transform: scale(1); }
}

.wec-modal-close {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 32px;
    height: 32px;
    padding: 0;
    border: none;
    border-radius: 50%;
    background: transparent;
    font-size: 22px;
    line-height: 1;
    color: var(--wec-muted);
    cursor: pointer;
    z-index: 1;
    transition: background 0.15s, color 0.15s;
}

.wec-modal-close:hover {
    background: #f1f3f4;
    color: var(--wec-text);
}

.wec-modal-body {
    padding: 20px 24px;
    overflow-y: auto;
    flex: 1;
    min-height: 0;
}

.wec-modal-image {
    width: 100%;
    height: 200px;
    margin-bottom: 16px;
    border-radius: 8px;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f8f9fa;
}

.wec-modal-image img {
    width: 100%;
    height: 100%;
    display: block;
    object-fit: contain;
}

.wec-modal-info h3 {
    margin: 0 0 8px 0;
    font-size: 20px;
    font-weight: 400;
    color: var(--wec-text);
    line-height: 1.4;
}

.wec-modal-location,
.wec-modal-desc {
    margin: 0 0 8px 0;
    font-size: 14px;
    line-height: 1.5;
    color: var(--wec-muted);
}

.wec-modal-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--wec-border);
    flex-shrink: 0;
    background: #fff;
    border-radius: 0 0 8px 8px;
    text-align: center;
}

.wec-modal-link {
    display: block !important;
    width: 100%;
    padding: 10px 24px;
    background: #1a73e8 !important;
    color: #fff !important;
    text-decoration: none;
    border-radius: 4px;
    font-size: 14px;
    font-weight: 500;
    transition: background 0.15s;
    min-height: 44px;
    line-height: 1.4;
    box-sizing: border-box;
    text-align: center;
}

.wec-modal-link:hover {
    background: #1765cc !important;
    color: #fff !important;
}

/* ========== Tooltip ========== */
.wec-event-tooltip {
    position: fixed;
    z-index: 10002;
    max-width: 320px;
    min-width: 240px;
    pointer-events: auto;
    animation: wec-tooltipFadeIn 0.15s ease-out;
}

@keyframes wec-tooltipFadeIn {
    from { opacity: 0; transform: translateY(-4px); }
    to { opacity: 1; transform: translateY(0); }
}

.wec-tooltip-content {
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 4px 16px rgba(60, 64, 67, 0.2), 0 0 0 1px rgba(0, 0, 0, 0.05);
    overflow: visible;
    display: flex;
    flex-direction: column;
    min-height: auto;
}

.wec-tooltip-image {
    width: 100%;
    height: 120px;
    padding-top: 8px;
    box-sizing: border-box;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f8f9fa;
}

.wec-tooltip-image img {
    width: 100%;
    height: 100%;
    display: block;
    object-fit: contain;
}

.wec-tooltip-info {
    padding: 12px 16px;
    flex: 1;
    overflow: hidden;
}

.wec-tooltip-info h3 {
    margin: 0 0 6px 0;
    font-size: 16px;
    font-weight: 500;
    color: var(--wec-text);
    line-height: 1.4;
}

.wec-tooltip-location,
.wec-tooltip-desc {
    margin: 0 0 6px 0;
    font-size: 13px;
    line-height: 1.4;
    color: var(--wec-muted);
}

.wec-tooltip-desc {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
}

.wec-tooltip-footer {
    padding: 12px 16px;
    border-top: 1px solid var(--wec-border);
    flex-shrink: 0;
    display: block;
    background: #fff;
    border-radius: 0 0 8px 8px;
}

.wec-tooltip-arrow {
    position: absolute;
    width: 0;
    height: 0;
}

.wec-tooltip-arrow--top {
    top: -8px;
    left: 50%;
    transform: translateX(-50%);
    border-left: 8px solid transparent;
    border-right: 8px solid transparent;
    border-bottom: 8px solid #fff;
    filter: drop-shadow(0 -2px 4px rgba(0, 0, 0, 0.1));
}

.wec-tooltip-arrow--bottom {
    bottom: -8px;
    left: 50%;
    transform: translateX(-50%);
    border-left: 8px solid transparent;
    border-right: 8px solid transparent;
    border-top: 8px solid #fff;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.1));
}

.wec-tooltip-arrow--left {
    left: -8px;
    top: 50%;
    transform: translateY(-50%);
    border-top: 8px solid transparent;
    border-bottom: 8px solid transparent;
    border-right: 8px solid #fff;
    filter: drop-shadow(-2px 0 4px rgba(0, 0, 0, 0.1));
}

.wec-tooltip-arrow--right {
    right: -8px;
    top: 50%;
    transform: translateY(-50%);
    border-top: 8px solid transparent;
    border-bottom: 8px solid transparent;
    border-left: 8px solid #fff;
    filter: drop-shadow(2px 0 4px rgba(0, 0, 0, 0.1));
}

/* ========== Mobile-first: Desktop (769px+) ========== */
@media (min-width: 769px) {
    .wec-calendar-wrapper {
        padding: clamp(12px, 2.5vw, 24px);
        margin: 0;
    }

    .wec-header {
        margin-bottom: 16px;
        padding-bottom: 12px;
        flex-wrap: nowrap;
    }

    .wec-header-nav {
        flex: 0 1 auto;
    }

    .wec-title {
        font-size: 22px;
    }

    .wec-prev,
    .wec-next {
        width: 36px;
        height: 36px;
        font-size: 20px;
    }

    .wec-header-right {
        flex-wrap: nowrap;
    }

    .wec-view-toggle {
        border-radius: 6px;
    }

    .wec-view-btn {
        padding: 6px 14px;
        font-size: 13px;
    }

    .wec-year-month-title {
        font-size: 18px;
    }

    .wec-year-month-days {
        grid-auto-rows: minmax(60px, 1fr);
    }

    .wec-year-month-days .wec-day {
        min-height: 60px;
    }

    .wec-year-month-days .wec-day--empty {
        min-height: 60px;
    }

    .wec-today {
        padding: 8px;
    }
    
    .wec-today svg {
        width: 22px;
        height: 22px;
    }

    .wec-export {
        width: auto;
        padding: 8px 16px;
        font-size: 14px;
    }

    .wec-wday-long {
        display: inline;
    }

    .wec-wday-short {
        display: none;
    }

    .wec-wday {
        padding: 8px 4px;
    }

    .wec-days {
        grid-auto-rows: minmax(80px, 1fr);
    }

    .wec-day {
        min-height: 80px;
    }

    .wec-day--empty {
        min-height: 80px;
    }

    .wec-day-num {
        font-size: 12px;
        top: 6px;
        right: 8px;
    }

    .wec-day-events {
        padding: 28px 6px 6px 8px;
    }

    .wec-event-chip {
        font-size: 11px;
        padding: 2px 6px;
    }

    .wec-grid-wrap {
        padding: 0 16px 0 0;
    }

    .wec-body {
        grid-template-columns: 1fr minmax(0, 280px);
    }

    .wec-sidebar {
        margin-left: 0;
        margin-top: 0;
        border-left: 1px solid var(--wec-border);
        border-top: none;
        flex-direction: row;
    }

    .wec-sidebar-toggle {
        width: 32px;
        min-width: 32px;
        height: 100%;
        border-right: 1px solid var(--wec-border);
        border-bottom: none;
        align-items: flex-start;
        justify-content: center;
        padding-top: 8px;
    }

    .wec-sidebar-inner {
        padding: 16px 0 16px 16px;
    }

    .wec-filter-search,
    .wec-filter-location,
    .wec-filter-type {
        padding: 8px 12px;
        font-size: 14px;
    }

    .wec-event-item {
        padding: 8px 10px;
        font-size: 13px;
    }

    .wec-calendar-wrapper.wec-sidebar-collapsed .wec-body {
        grid-template-columns: 1fr 48px;
    }

    .wec-sidebar-collapsed .wec-sidebar .wec-sidebar-toggle {
        width: 48px;
        min-width: 48px;
        height: 100%;
        border-right: none;
        border-left: 1px solid var(--wec-border);
        border-bottom: none;
        align-items: flex-start;
        justify-content: center;
        padding-top: 8px;
    }
}

/* ========== Container queries: narrow container (calendar in single column) ========== */
@container wec-calendar (max-width: 900px) {
    .wec-body {
        display: flex;
        flex-direction: column-reverse;
    }

    /* Calendar grid and search sidebar share the same width when stacked */
    .wec-grid-wrap {
        padding: 0;
    }

    .wec-sidebar {
        margin-left: 0;
        border-left: none;
        border-top: 1px solid var(--wec-border);
        margin-top: 12px;
        padding-top: 0;
        flex-direction: column;
    }

    .wec-sidebar-toggle {
        width: 100%;
        min-width: 0;
        height: 36px;
        border-right: none;
        border-bottom: 1px solid var(--wec-border);
    }

    .wec-sidebar-inner {
        padding: 12px 0 12px 0;
    }

    .wec-calendar-wrapper.wec-sidebar-collapsed .wec-body {
        grid-template-columns: 1fr;
    }

    .wec-sidebar-collapsed .wec-sidebar .wec-sidebar-toggle {
        width: 100%;
        min-width: 0;
        height: 36px;
        border-left: none;
    }
}

@container wec-calendar (max-width: 500px) {
    .wec-wday-long {
        display: none;
    }

    .wec-wday-short {
        display: inline;
        text-transform: uppercase;
        letter-spacing: 0.02em;
        font-size: 10px;
    }

    .wec-days {
        grid-auto-rows: minmax(60px, 1fr);
    }

    .wec-day {
        min-height: 60px;
    }

    .wec-day--empty {
        min-height: 60px;
    }

    .wec-event-chip {
        font-size: 9px;
    }
}
