/* Modal CSS */
.ath-booking-modal {
    display: none;
    position: fixed;
    z-index: 99999;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: var(--ath-modal-overlay-bg, rgba(15, 23, 42, 0.7));
    backdrop-filter: blur(5px);
}

.ath-booking-modal-content {
    background-color: var(--ath-modal-bg, var(--ath-card-bg, #ffffff));
    margin: 5vh auto;
    padding: 40px 30px;
    border-radius: var(--ath-modal-border-radius, var(--ath-border-radius-card, 12px));
    width: 90%;
    max-width: var(--ath-modal-container-width, 600px);
    max-height: 90vh;
    overflow-y: auto;
    overflow-x: hidden;
    color: var(--ath-modal-text-color, inherit);
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    position: relative;
    animation: athModalSlide 0.3s ease;
}

.ath-booking-modal-content::-webkit-scrollbar {
    width: 6px;
}
.ath-booking-modal-content::-webkit-scrollbar-track {
    background: transparent;
    border-radius: 10px;
}
.ath-booking-modal-content::-webkit-scrollbar-thumb {
    background: color-mix(in srgb, currentColor 20%, transparent);
    border-radius: 10px;
}

@media (max-width: 768px) {
    .ath-booking-modal-content {
        width: 100%;
        max-width: 100%;
        max-height: 100dvh;
        height: 100dvh;
        margin: 0;
        border-radius: 0;
        padding: 40px 20px 20px;
    }
    
    .ath-booking-title.ath-has-watermark {
        /* Wymuszenie małych liter zamiast twardego tekstu nadpisuje dowolny język translacji (np. reservation) */
        --wm-transform: lowercase !important; 
        --wm-size: 5.2rem !important;
        --wm-bottom: auto !important;
        --wm-top: -5vw !important;
        --wm-right: auto !important;
        --wm-left: -2vw !important;
        --wm-color: rgba(255, 255, 255, 0.08) !important;
        margin: 0px 10px 25px !important;
        padding: 40px 20px 0px !important;
        position: relative !important;
    }
}

@keyframes athModalSlide {
    from { transform: translateY(-30px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

.ath-booking-close {
    position: absolute;
    right: 20px;
    top: 15px;
    color: color-mix(in srgb, currentColor 50%, transparent);
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    line-height: 1;
}

.ath-booking-close:hover {
    color: inherit;
}

.ath-booking-title {
    color: var(--ath-modal-heading-color, var(--ath-heading-color, inherit));
}

.ath-booking-modal-content .ath-form-label {
    color: var(--ath-modal-form-text-color, color-mix(in srgb, currentColor 70%, transparent));
}

/* Usunięto wyciekającą klasę .ath-row, która psuła margin-bottom w globalnym headerze */
.ath-booking-row {
    display: flex;
    gap: 15px;
    margin-bottom: 15px;
}
.ath-booking-col {
    flex: 1;
}

.ath-booking-form label {
    display: block;
    margin-bottom: 5px;
    font-size: 13px;
    font-weight: 600;
    color: var(--ath-modal-form-text-color, color-mix(in srgb, currentColor 70%, transparent));
}

.ath-booking-form input,
.ath-booking-form select,
.ath-booking-form textarea {
    width: 100%;
    padding: 12px 16px;
    border: none;
    background-color: var(--ath-modal-input-bg, color-mix(in srgb, currentColor 5%, transparent));
    color: inherit;
    border-radius: var(--ath-border-radius-input, 8px);
    font-family: inherit;
    font-size: 15px;
    box-shadow: var(--ath-modal-input-shadow, inset 1px 1px 4px 0px rgba(0, 0, 0, 0.4));
    box-sizing: border-box;
}

.ath-booking-form input:focus,
.ath-booking-form select:focus {
    outline: none;
    border-color: var(--ath-primary-color, #2563eb);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--ath-primary-color, #2563eb) 10%, transparent);
}

.ath-booking-form input[type="date"] {
    color-scheme: dark; /* Natively handles picker UI for dark modal */
}

.ath-booking-form input[type="date"]::-webkit-calendar-picker-indicator {
    filter: brightness(0) invert(1);
    opacity: 0.8;
    cursor: pointer;
}
.ath-booking-form input[type="date"]::-webkit-calendar-picker-indicator:hover {
    opacity: 1;
}

.ath-booking-form input.ath-input-error,
.ath-booking-form select.ath-input-error {
    border-color: var(--ath-error-color, #ef4444) !important;
    background-color: color-mix(in srgb, var(--ath-error-color, #ef4444) 10%, transparent) !important;
}

/* Odstępy między polami formularza w modalu */
.ath-booking-form .ath-form-field {
    margin-bottom: 20px;
}
.ath-booking-form .ath-form-field:last-child {
    margin-bottom: 0;
}

/* Switcher typu klienta — naprawa stylów labeli */
.ath-client-type-switcher label {
    display: flex !important;
    align-items: center;
    justify-content: center;
    margin-bottom: 0 !important;
    font-weight: inherit !important;
    color: inherit !important;
    font-size: inherit !important;
    line-height: 1.2;
}

.ath-client-type-switcher .ath-switcher-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
}

/* === ATheme Events Calendar Block === */
.ath-events-calendar-wrapper {
    background: #ffffff;
    border-radius: var(--ath-border-radius-card, 16px);
    box-shadow: 0 4px 20px rgba(0,0,0,0.04);
    padding: 30px;
    margin-bottom: 40px;
    border: 1px solid #f1f5f9;
    width: 100%;
    box-sizing: border-box;
}

.ath-calendar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.ath-cal-month-title {
    margin: 0;
    font-size: 1.5rem;
    font-family: var(--ath-font-heading);
    color: var(--ath-secondary-color, #1e293b);
}

.ath-cal-nav {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    color: var(--ath-secondary-color, #1e293b);
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
}
.ath-cal-nav:hover {
    background: var(--ath-primary-color, #2563eb);
    color: #ffffff;
    border-color: var(--ath-primary-color, #2563eb);
}

.ath-calendar-weekdays {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    text-align: center;
    font-weight: 600;
    color: #64748b;
    margin-bottom: 10px;
}
.ath-events-calendar-wrapper[data-layout="daily"] .ath-calendar-weekdays {
    display: none;
}

.ath-calendar-days-grid {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    grid-auto-rows: minmax(110px, auto);
    gap: 10px;
    transition: opacity 0.3s ease;
}
.ath-events-calendar-wrapper[data-layout="daily"] .ath-calendar-days-grid {
    grid-template-columns: 1fr;
    grid-auto-rows: auto;
}
.ath-events-calendar-wrapper[data-layout="weekly"] .ath-calendar-days-grid {
    grid-auto-rows: minmax(180px, auto);
}

.ath-calendar-days-grid.is-loading {
    opacity: 0.5;
    pointer-events: none;
}

.ath-cal-day {
    position: relative;
    min-width: 0;
    min-height: 120px;
    border-radius: var(--ath-border-radius-input, 8px);
    background: #f8fafc;
    border: 1px solid #f1f5f9;
    padding: 10px;
    display: flex;
    flex-direction: column;
    transition: all 0.3s ease;
}
.ath-cal-day.ath-cal-empty {
    background: transparent;
    border-color: transparent;
}
.ath-cal-day.ath-cal-has-events:not(.ath-cal-past):not(.ath-cal-empty) {
    cursor: pointer;
}
.ath-cal-day.ath-cal-no-events:not(.ath-cal-empty),
.ath-cal-day.ath-cal-past:not(.ath-cal-empty) {
    cursor: not-allowed;
}
.ath-cal-day.ath-cal-has-events:not(.ath-cal-past):not(.ath-cal-empty):hover {
    box-shadow: 0 10px 25px rgba(0,0,0,0.06);
    transform: translateY(-2px);
    background: #ffffff;
    border-color: #e2e8f0;
    z-index: 200; /* Zapewnia renderowanie popupa i kafla nad sąsiadami */
}
.ath-cal-day.ath-cal-past {
    opacity: 0.5;
}
.ath-cal-day.ath-cal-today {
    border-color: var(--ath-primary-color, #2563eb);
    background: rgba(37,99,235,0.03);
}

.ath-cal-date-num {
    font-weight: 700;
    font-size: 1.1rem;
    color: #334155;
    margin-bottom: 10px;
    align-self: flex-end;
}
.ath-cal-today .ath-cal-date-num {
    color: var(--ath-primary-color, #2563eb);
}

.ath-cal-events-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
    flex: 1;
}

.ath-cal-ev-text-item {
    font-size: 11px;
    color: var(--ath-primary-color, #1e3a8a);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: flex;
    gap: 4px;
    align-items: center;
    line-height: 1.3;
    padding: 2px 0;
    pointer-events: none;
}
.ath-cal-ev-text-item strong {
    font-weight: 700;
}
.ath-cal-ev-text-item span {
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.ath-cal-ev-pill {
    font-size: 11px;
    padding: 6px 10px;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    text-align: left;
    line-height: 1.3;
}
.ath-cal-ev-available {
    background: rgba(37,99,235,0.1);
    color: #1e40af;
    border: 1px solid rgba(37,99,235,0.2);
}
.ath-cal-ev-available:hover {
    background: var(--ath-primary-color, #2563eb);
    color: #ffffff;
}

.ath-cal-events-list .ath-cal-ev-pill {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: block;
}
.ath-cal-events-list .ath-cal-ev-time {
    font-weight: normal;
    opacity: 0.8;
}
.ath-cal-ev-more {
    font-size: 0.75rem;
    color: #64748b;
    font-weight: 600;
    text-align: center;
    margin-top: 4px;
}

/* === THE EXPANDABLE POPUP OVERLAY === */
.ath-cal-day-popup {
    position: absolute;
    inset: 0;
    background: rgba(255, 255, 255, 0.98);
    backdrop-filter: blur(8px);
    border: 1px solid rgba(0,0,0,0.08); /* slightly stronger border for the popup */
    border-radius: var(--ath-border-radius-input, 8px);
    padding: 10px;
    display: flex;
    flex-direction: column;
    box-shadow: 0 15px 35px rgba(0,0,0,0.1);
    opacity: 0;
    pointer-events: none;
    z-index: 100;
    transition: all 0.3s cubic-bezier(0.25, 1, 0.5, 1);
    min-width: 100%;
}
.ath-cal-events-list-full {
    display: flex;
    flex-direction: column;
    gap: 6px;
    overflow-y: auto;
    max-height: calc(100% - 30px);
}
.ath-cal-events-list-full::-webkit-scrollbar {
    width: 4px;
}
.ath-cal-events-list-full::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 4px;
}

.ath-cal-day-popup .ath-cal-date-num {
    margin-bottom: 5px;
}

/* Default Popup Expansion: Dynamic Width & Center Out */
/* Działa WYŁĄCZNIE gdy nałożono klasę is-popup-open (po kliknięciu w każdym kalendarzu) */
.ath-cal-day.is-popup-open .ath-cal-day-popup {
    opacity: 1;
    pointer-events: auto;
    top: -20px;
    left: 50%;
    transform: translateX(-50%);
    width: max-content; /* Dostosowanie wielkości do treści wydarzenia! */
    max-width: 320px;
    min-width: calc(100% + 40px);
    bottom: auto;
    min-height: max-content;
    height: auto;
    border-radius: 12px;
}

/* Kolumna od lewej krawędzi (Poniedziałek, Wtorek) */
.ath-cal-day:nth-child(7n+1).is-popup-open .ath-cal-day-popup,
.ath-cal-day:nth-child(7n+2).is-popup-open .ath-cal-day-popup {
    left: -10px;
    transform: none;
}

/* Kolumna od prawej krawędzi (Sobota, Niedziela) */
body .ath-events-calendar-wrapper:not([data-dropdown="true"]) .ath-cal-day:nth-child(7n):hover .ath-cal-day-popup,
body .ath-events-calendar-wrapper:not([data-dropdown="true"]) .ath-cal-day:nth-child(7n+6):hover .ath-cal-day-popup,
.ath-cal-day:nth-child(7n).is-popup-open .ath-cal-day-popup,
.ath-cal-day:nth-child(7n+6).is-popup-open .ath-cal-day-popup {
    left: auto;
    right: -10px;
    transform: none;
}

/* Zabezpieczenie na ostatnich 2 wierszach (Bottom rows) - zapobiega ucinaniu na dole */
body .ath-events-calendar-wrapper:not([data-dropdown="true"]) .ath-cal-day:nth-last-child(-n+14):hover .ath-cal-day-popup,
.ath-cal-day:nth-last-child(-n+14).is-popup-open .ath-cal-day-popup {
    bottom: -15px;
    top: auto;
}

@media (max-width: 768px) {
    .ath-events-calendar-wrapper {
        padding: 20px 15px !important;
    }
    .ath-calendar-weekdays {
        display: none;
    }
    .ath-calendar-days-grid {
        grid-template-columns: 1fr;
    }
    .ath-cal-day.ath-cal-empty {
        display: none;
    }
    .ath-cal-day {
        min-height: auto;
        flex-direction: row;
        align-items: center;
        gap: 15px;
    }
    .ath-cal-date-num {
        align-self: center;
        margin-bottom: 0;
        font-size: 1.3rem;
        min-width: 30px;
    }
}

/* Warianty biletów - obramowanie */
.ath-ticket-row {
    border-bottom: 1px solid var(--ath-border-color, color-mix(in srgb, currentColor 15%, transparent));
    padding-bottom: 12px;
}
.ath-ticket-row:last-child {
    border-bottom: none;
    padding-bottom: 0;
}


.ath-tickets-ui-container, .ath-tickets-total, .ath-booking-modal-content {
    border: none;
    outline: none !important;
}
