/**
 * mod_rdkcal v2 — pełen arkusz stylów
 * @copyright (C) 2026 Urząd Miasta Radomska
 *
 * Paleta wyprowadzona z oficjalnych barw miasta (herb i flaga):
 *   --rdk-blue   → błękit herbowy (nagłówki, header)
 *   --rdk-navy   → granat rycerski (typografia ciemna)
 *   --rdk-red    → czerwień bramy (akcenty, alerty)
 *   --rdk-yellow → żółć flagi (highlight)
 *   --rdk-gold   → złoto logo (loga premium)
 *
 * Wszystkie style scope'owane w .re-wrapper, żeby uniknąć kolizji
 * z innymi stylami szablonu Joomla.
 */

/* === Zmienne CSS i base === */
.re-wrapper {
    --rdk-blue: #0b3d91;
    --rdk-navy: #082a63;
    --rdk-red: #c8102e;
    --rdk-yellow: #f4b400;
    --rdk-gold: #b8860b;
    --rdk-burgundy: #600000;        /* RGBA(96,0,0,1) — tła dat i CTA "Zobacz szczegóły" */
    --rdk-burgundy-dark: #400000;   /* hover state */

    --rdk-bg: #ffffff;
    --rdk-gray-50: #f5f7fb;
    --rdk-gray-100: #eef2f9;
    --rdk-gray-200: #e2e8f0;
    --rdk-gray-300: #cbd5e1;
    --rdk-gray-500: #6c757d;
    --rdk-gray-700: #475569;
    --rdk-gray-900: #212529;

    background: var(--rdk-bg);
    border-radius: 8px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.05);
    padding: 16px;
    position: relative;
    overflow: hidden;
    font-family: inherit;
    color: var(--rdk-gray-900);
    box-sizing: border-box;
}

.re-wrapper *,
.re-wrapper *::before,
.re-wrapper *::after {
    box-sizing: border-box;
}

/* === Header z tytułem i filtrami === */
.re-header {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-bottom: 12px;
    gap: 10px;
    text-align: center;
}

.re-header .re-title {
    color: var(--rdk-navy);
    font-size: 1.05rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.re-mini-filters {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    justify-content: center;
}

.re-btn-filter {
    background: transparent;
    border: 1.5px solid var(--rdk-burgundy);
    color: var(--rdk-burgundy);
    padding: 7px 14px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.82rem;
    font-weight: 600;
    transition: all 0.2s ease;
    font-family: inherit;
    box-shadow: 0 1px 2px rgba(96, 0, 0, 0.06);
}

.re-btn-filter:hover {
    background: rgba(96, 0, 0, 0.08);
    border-color: var(--rdk-burgundy-dark);
    color: var(--rdk-burgundy-dark);
}

.re-btn-filter.active {
    background: var(--rdk-burgundy);
    color: #fff;
    border-color: var(--rdk-burgundy);
    box-shadow: 0 2px 6px rgba(96, 0, 0, 0.25);
}

.re-btn-filter:focus-visible {
    outline: 2px solid var(--rdk-burgundy-dark);
    outline-offset: 2px;
}

/* === Nawigacja miesiącami === */
.re-month-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    background: var(--rdk-gray-50);
    border-radius: 6px;
    padding: 6px 10px;
}

.re-arrow {
    background: transparent;
    border: none;
    font-size: 1.1rem;
    cursor: pointer;
    color: var(--rdk-gray-500);
    padding: 4px 10px;
    border-radius: 4px;
    transition: all 0.2s ease;
}

.re-arrow:hover,
.re-arrow:focus-visible {
    background: var(--rdk-burgundy);
    color: #fff;
    outline: none;
}

.re-current-month-label {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--rdk-navy);
    margin: 0;
    text-transform: capitalize;
}

/* === Pojemnik dynamiczny + loader === */
/* KLUCZOWE: max-height JEST tu, nie tylko na .re-events-list / .re-event-details.
   Bez tego, gdy któryś szablon Joomla ma resety overflow na poziomie zawartości,
   moduł rozciąga się na pełną wysokość treści zamiast scrollować wewnątrz. */
.re-content-area {
    position: relative;
    min-height: 320px;
    max-height: 480px;
    overflow-y: auto;
    overflow-x: hidden;
}

/* re-html-container to przezroczysty wrapper - nie tworzy własnych ograniczeń */
.re-html-container {
    width: 100%;
}

/* Listy wydarzeń i szczegóły - bez własnego max-height (jest na rodzicu).
   Padding-right 6px daje miejsce dla scrollbara na kontenerze. */
.re-events-list,
.re-event-details {
    padding-right: 6px;
}

/* Cienki, dyskretny scrollbar w stylu Radomska */
.re-content-area::-webkit-scrollbar {
    width: 6px;
}

.re-content-area::-webkit-scrollbar-track {
    background: var(--rdk-gray-50);
    border-radius: 3px;
}

.re-content-area::-webkit-scrollbar-thumb {
    background: var(--rdk-gray-300);
    border-radius: 3px;
}

.re-content-area::-webkit-scrollbar-thumb:hover {
    background: var(--rdk-burgundy);
}

.re-loader {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    color: var(--rdk-gray-500);
    font-weight: 500;
    font-size: 0.9rem;
    display: none;
}

.re-loader-spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid var(--rdk-gray-200);
    border-top-color: var(--rdk-blue);
    border-radius: 50%;
    animation: re-spin 0.8s linear infinite;
    vertical-align: middle;
    margin-right: 8px;
}

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

.re-fade-in {
    animation: re-fade-in 0.3s ease-out;
}

@keyframes re-fade-in {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

/* === SIATKA KALENDARZA === */
.re-calendar-view {
    position: relative;
}

.re-calendar-weekdays {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 2px;
    margin-bottom: 4px;
}

.re-weekday {
    text-align: center;
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--rdk-gray-500);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 4px 0;
}

.re-calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    grid-auto-rows: minmax(48px, 1fr);
    gap: 2px;
    position: relative;
}

.re-day {
    position: relative;
    background: var(--rdk-bg);
    border: 1px solid var(--rdk-gray-200);
    border-radius: 4px;
    padding: 4px 4px 2px;
    text-align: center;
    cursor: default;
    transition: all 0.15s ease;
    min-height: 48px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
}

.re-day-number {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--rdk-gray-900);
}

.re-day-other-month {
    background: var(--rdk-gray-50);
}

.re-day-other-month .re-day-number {
    color: var(--rdk-gray-300);
}

.re-day-today {
    background: var(--rdk-gray-100);
    border-color: var(--rdk-blue);
}

.re-day-today .re-day-number {
    color: var(--rdk-blue);
    font-weight: 700;
}

.re-day.re-has-events {
    cursor: pointer;
    background: var(--rdk-gray-100);
    border-color: var(--rdk-blue);
}

.re-day.re-has-events:hover,
.re-day.re-has-events:focus-visible {
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(11, 61, 145, 0.18);
    outline: none;
    border-color: var(--rdk-navy);
}

/* Kropki dla pojedynczych eventów */
.re-day-dots {
    display: flex;
    gap: 2px;
    margin-top: auto;
    padding-top: 4px;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
}

.re-dot {
    display: inline-block;
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: var(--rdk-red);
}

.re-dot-more {
    font-size: 0.65rem;
    color: var(--rdk-red);
    font-weight: 600;
    margin-left: 2px;
}

/* === LISTA EVENTÓW (po kliknięciu w dzień / filtr) === */
.re-events-list {
    padding: 4px 0;
}

.re-list-title {
    font-size: 1rem;
    color: var(--rdk-navy);
    margin: 0 0 12px;
    font-weight: 600;
}

.re-no-events {
    text-align: center;
    color: var(--rdk-gray-500);
    padding: 32px 16px;
    font-style: italic;
}

/* === LISTA WYDARZEŃ — pieczęć urzędowa po lewej + treść po prawej === */

.re-event-item {
    display: flex;
    align-items: stretch;
    gap: 12px;
    padding: 10px 0 12px 0;
    margin-bottom: 0;
    background: transparent;
    border: none;
    border-bottom: 1px solid var(--rdk-gray-200);
    transition: background 0.15s ease;
}

.re-event-item:last-child {
    border-bottom: none;
}

.re-event-item:hover {
    background: rgba(96, 0, 0, 0.025);
}

/* KARTA DATY po lewej — pieczęć urzędowa z dniem, miesiącem i info o trwaniu */
.re-date-card {
    flex-shrink: 0;
    width: 64px;
    border: 1.5px solid var(--rdk-burgundy);
    border-radius: 6px;
    background: #fff;
    padding: 4px 4px 6px;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    line-height: 1;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(96, 0, 0, 0.08);
    transition: all 0.15s ease;
}

.re-event-item:hover .re-date-card {
    background: var(--rdk-burgundy);
    border-color: var(--rdk-burgundy);
    box-shadow: 0 2px 6px rgba(96, 0, 0, 0.25);
}

.re-event-item:hover .re-date-card-day,
.re-event-item:hover .re-date-card-month,
.re-event-item:hover .re-date-card-duration {
    color: #fff;
}

/* Dzień - duża cyfra burgundy bold */
.re-date-card-day {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--rdk-burgundy);
    line-height: 1.1;
    margin-bottom: 2px;
    transition: color 0.15s ease;
}

/* Miesiąc - 3-literowy skrót, mniejszy, uppercase */
.re-date-card-month {
    font-size: 0.7rem;
    font-weight: 700;
    color: var(--rdk-burgundy);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    transition: color 0.15s ease;
}

/* Trwanie - pod separatorem, drobnym fontem */
.re-date-card-duration {
    margin-top: 4px;
    padding-top: 4px;
    border-top: 1px solid rgba(96, 0, 0, 0.2);
    font-size: 0.65rem;
    font-weight: 600;
    color: var(--rdk-burgundy-dark);
    width: 100%;
    line-height: 1.2;
    transition: color 0.15s ease;
}

.re-event-item:hover .re-date-card-duration {
    border-top-color: rgba(255, 255, 255, 0.3);
}

/* TREŚĆ po prawej — tytuł, opis, link */
.re-event-body {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.re-event-title {
    font-size: 0.95rem;
    color: var(--rdk-burgundy);
    margin: 0 0 4px;
    font-weight: 700;
    line-height: 1.3;
    transition: color 0.15s ease;
}

.re-event-item:hover .re-event-title {
    color: var(--rdk-burgundy-dark);
}

.re-event-intro {
    font-size: 0.82rem;
    color: var(--rdk-gray-700);
    margin: 0 0 6px;
    line-height: 1.45;
}

/* "Zobacz szczegóły" jako lekki link tekstowy */
.re-btn-read {
    display: inline-block;
    background: transparent;
    color: var(--rdk-burgundy);
    border: none;
    padding: 0;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.78rem;
    font-family: inherit;
    text-decoration: none;
    transition: color 0.15s ease;
    align-self: flex-start;
}

.re-btn-read:hover,
.re-btn-read:focus-visible {
    color: var(--rdk-burgundy-dark);
    text-decoration: underline;
    outline: none;
}

/* === SZCZEGÓŁY EVENTU — wariant A2 (lekkie meta z ikonkami SVG) === */

.re-event-details {
    padding: 4px 0;
}

.re-detail-title {
    font-size: 1.35rem;
    color: var(--rdk-burgundy);
    margin: 4px 0 8px;
    font-weight: 700;
    line-height: 1.25;
    padding-bottom: 10px;
    border-bottom: 2px solid rgba(96, 0, 0, 0.15);
}

/* Kontener meta — pionowy stack dwóch linijek z ikonkami */
.re-detail-meta {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 18px;
    margin-top: 12px;
}

/* Pojedyncza linia meta: ikonka + tekst */
.re-detail-meta-line {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.88rem;
    color: var(--rdk-gray-700);
    font-weight: 500;
}

/* Wrapper ikony — ustala kolor i rozmiar SVG */
.re-detail-meta-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    color: var(--rdk-burgundy);
    width: 16px;
    height: 16px;
}

.re-detail-meta-icon svg {
    width: 100%;
    height: 100%;
    display: block;
}

.re-detail-meta-text {
    line-height: 1.3;
}

/* Treść artykułu — bez zmian, zachowujemy lekki styl */
.re-detail-body {
    font-size: 0.92rem;
    line-height: 1.6;
    color: var(--rdk-gray-900);
    margin-bottom: 14px;
}

.re-detail-body p {
    margin: 0 0 12px;
}

.re-detail-body a {
    color: var(--rdk-burgundy);
    text-decoration: underline;
    transition: color 0.15s ease;
}

.re-detail-body a:hover {
    color: var(--rdk-burgundy-dark);
}

.re-detail-body img {
    max-width: 100%;
    height: auto;
    border-radius: 4px;
    margin: 8px 0;
}

.re-link-full-article {
    display: inline-block;
    color: var(--rdk-blue);
    text-decoration: none;
    font-weight: 600;
    font-size: 0.9rem;
    transition: color 0.15s ease;
}

.re-link-full-article:hover {
    color: var(--rdk-red);
}

/* === STOPKA === */
.re-footer {
    margin-top: 14px;
    border-top: 1px solid var(--rdk-gray-200);
    padding-top: 10px;
    display: flex;
    justify-content: flex-end;          /* domyślnie tylko link "Wszystkie wydarzenia" po prawej */
    align-items: center;
    gap: 8px;
    min-height: 32px;
}

.re-footer.re-show-back {
    justify-content: space-between;     /* w trybie list/szczegółów: Wróć (lewa) + Wszystkie (prawa) */
}

/* Przycisk "Wróć do kalendarza" — domyślnie ukryty, JS pokazuje przez klasę re-show-back */
.re-btn-back-footer {
    display: none;
    background: var(--rdk-gray-100);
    color: var(--rdk-navy);
    border: 1px solid var(--rdk-gray-200);
    padding: 6px 12px;
    border-radius: 4px;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.85rem;
    font-family: inherit;
    transition: all 0.15s ease;
}

.re-footer.re-show-back .re-btn-back-footer {
    display: inline-flex;
    align-items: center;
}

.re-btn-back-footer:hover,
.re-btn-back-footer:focus-visible {
    background: var(--rdk-burgundy);
    color: #fff;
    border-color: var(--rdk-burgundy);
    outline: none;
}

.re-link-all {
    color: var(--rdk-burgundy);
    text-decoration: none;
    font-weight: 600;
    font-size: 0.9rem;
    transition: color 0.15s ease;
}

.re-link-all:hover,
.re-link-all:focus-visible {
    color: var(--rdk-burgundy-dark);
    text-decoration: underline;
    outline: none;
}

/* === Komunikaty błędów === */
.re-error {
    background: #fef2f2;
    border-left: 4px solid var(--rdk-red);
    padding: 10px 14px;
    border-radius: 0 4px 4px 0;
    color: #7f1d1d;
    font-size: 0.88rem;
    line-height: 1.4;
}

.re-error code {
    background: #fff;
    padding: 1px 5px;
    border-radius: 3px;
    font-family: ui-monospace, "SF Mono", Menlo, monospace;
    font-size: 0.85em;
}

/* === TRYB KOMPAKTOWY (wybierany przez parametr modułu) === */
.re-mode-compact .re-month-controls {
    display: none;
}

.re-mode-compact .re-calendar-grid {
    grid-auto-rows: minmax(36px, auto);
}

.re-mode-compact .re-day {
    min-height: 36px;
    padding: 2px;
}

.re-mode-compact .re-day-number {
    font-size: 0.78rem;
}

/* === RESPONSYWNOŚĆ === */
@media (max-width: 480px) {
    .re-wrapper {
        padding: 12px;
    }

    .re-header {
        margin-bottom: 8px;
    }

    .re-header .re-title {
        font-size: 0.95rem;
    }

    .re-btn-filter {
        padding: 4px 8px;
        font-size: 0.78rem;
    }

    .re-calendar-grid {
        grid-auto-rows: minmax(40px, 1fr);
    }

    .re-day {
        min-height: 40px;
        padding: 2px;
    }

    .re-day-number {
        font-size: 0.78rem;
    }

    .re-event-item {
        padding: 10px 0;
    }

    .re-detail-title {
        font-size: 1.05rem;
    }
}

/* === Override gdy moduł jest osadzony w wąskim slocie slidera (~280-320px) === */
.re-wrapper[data-display-mode="full"] {
    container-type: inline-size;
}

@container (max-width: 340px) {
    .re-day-number {
        font-size: 0.72rem;
    }

    .re-weekday {
        font-size: 0.65rem;
    }

    .re-date-card {
        width: 56px;
    }

    .re-date-card-day {
        font-size: 1.3rem;
    }
}
