.defa-exam-calendar {
    --cal-primary: #16447d;
    --cal-primary-dark: #0f3769;
    --cal-border: #caddea;
    --cal-text: #050505;
    --cal-muted: #a4b0ba;

    width: 100%;
    font-family: "Open Sans", Arial, sans-serif;
    color: var(--cal-text);
}

/* Calendar toolbar */

.defa-calendar-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    margin-bottom: 20px;
}

.defa-calendar-title-nav {
    display: flex;
    align-items: center;
    gap: 14px;
}

.defa-calendar-month {
    margin: 0;
    color: var(--cal-primary);
    font-size: clamp(24px, 3.2vw, 30px);
    line-height: 1;
    font-weight: 800;
}

.defa-calendar-nav {
    width: 46px;
    height: 46px;
    padding: 0;
    border: 1px solid var(--cal-border);
    border-radius: 6px;
    background: #fff;
    color: var(--cal-primary);
    font-size: 30px;
    line-height: 1;
    cursor: pointer;
}

.defa-calendar-nav:hover {
    background: #f3f8fc;
}

/* Exam-center filter */

.defa-calendar-filter-wrap {
    min-width: 260px;
}

.defa-calendar-center-filter,
.defa-calendar-state-filter {
    width: 100%;
    min-height: 46px;
    padding: 9px 36px 9px 14px;
    border: 1px solid var(--cal-border);
    border-radius: 6px;
    background: #fff;
    color: var(--cal-text);
    font: inherit;
}

/* Calendar structure */

.defa-calendar-shell {
    overflow: hidden;
    border: 1px solid var(--cal-border);
    background: #fff;
}

.defa-calendar-weekdays,
.defa-calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
}

/* Weekday header */

.defa-calendar-weekdays {
    background: var(--cal-primary);
}

.defa-calendar-weekdays span {
    padding: 16px 8px;
    border-right: 2px solid #fff;
    color: #fff;
    text-align: center;
    font-size: 20px;
    line-height: 1;
    font-weight: 700;
}

.defa-calendar-weekdays span:last-child {
    border-right: 0;
}

/* Calendar cells */

.defa-calendar-day {
    padding: 10px 9px 8px;
    border-right: 1px solid var(--cal-border);
    border-bottom: 1px solid var(--cal-border);
    background: #fff;
    overflow: hidden;
}

.defa-calendar-day:nth-child(7n) {
    border-right: 0;
}

.defa-calendar-day:nth-last-child(-n + 7) {
    border-bottom: 0;
}

/* Blank cells outside the current month */

.defa-calendar-day.outside-month {
    background: #fff;
}

/* Dates containing exams */

.defa-calendar-day.has-events {
    background: #eaf5ff;
    cursor: pointer;
}

.defa-calendar-day.today {
    box-shadow:
        inset 0 0 0 3px
        rgba(22, 68, 125, 0.25);
}

/* Date number */

.defa-calendar-day-header {
    display: flex;
    align-items: center;
}

.defa-calendar-day-number {
    color: var(--cal-muted);
    font-size: 46px;
    line-height: 0.95;
    font-weight: 700;
}

.defa-calendar-day.has-events
.defa-calendar-day-number {
    color: #000;
    font-weight: 800;
}

.defa-calendar-mobile-month,
.defa-calendar-mobile-day {
    display: none;
}
/* Events inside a date */

.defa-calendar-events {
    display: grid;
    gap: 7px;
    margin-top: 2px;
}

.defa-calendar-center-group {
    min-width: 0;
}

.defa-calendar-center-name {
    color: #000;
    font-size: 14px;
    line-height: 1.05;
    font-weight: 400;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Exam-level labels */

.defa-calendar-levels {
    display: grid;
    grid-template-columns:
        repeat(2, minmax(0, 1fr));
    gap: 4px;
    margin-top: 5px;
}

.defa-calendar-level,
.defa-calendar-level-more {
    min-width: 0;
    padding: 4px 6px;
    border: 0;
    border-radius: 10px;
    color: #fff;
    font: inherit;
    font-size: 13px;
    line-height: 1.15;
    font-weight: 800;
    text-align: center;
    cursor: default;
}


/* Closed labels */

.defa-calendar-level.closed {
    opacity: 0.48;
    filter: grayscale(0.2);
}

/* Exam-level colors */

.level-a1 {
    background: #c550db;
}

.level-a2,
.level-a-mixed {
    background: #ff7900;
}

.level-b1 {
    background: #1575d1;
}

.level-b2 {
    background: #42ae54;
}

.level-c1 {
    background: #7653c7;
}

.level-c2 {
    background: #cf3e6d;
}

.level-other {
    background: #687785;
}

.defa-calendar-level-more {
    background: var(--cal-primary);
}

/* More centers button */

.defa-calendar-more {
    width: 100%;
    padding: 4px 6px;
    border: 0;
    border-radius: 6px;
    background: rgba(22, 68, 125, 0.1);
    color: var(--cal-primary);
    font: inherit;
    font-size: 11px;
    font-weight: 800;
    cursor: default;
}

/* Empty message */

.defa-calendar-empty {
    margin: 16px 0 0;
    padding: 14px;
    border-radius: 8px;
    background: #f7f9fb;
    color: #6b7280;
    text-align: center;
}

/* Popup */

.defa-calendar-modal[hidden] {
    display: none;
}

.defa-calendar-modal {
    position: fixed;
    z-index: 999999;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.defa-calendar-modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(5, 20, 35, 0.58);
}

.defa-calendar-modal-dialog {
    position: relative;
    z-index: 1;
    width: min(100%, 540px);
    max-height: 90vh;
    overflow: auto;
    padding: 0;
    border-radius: 14px;
    background: #fff;
    box-shadow:
        0 20px 60px
        rgba(0, 0, 0, 0.25);
}

/* Popup close button */

.defa-calendar-modal-close {
    position: absolute;
    z-index: 5;
    top: 14px;
    right: 16px;
    width: 34px;
    height: 34px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.16);
    color: #fff;
    font-size: 25px;
    line-height: 32px;
    cursor: pointer;
}

.defa-calendar-modal-close:hover {
    background: rgba(255, 255, 255, 0.26);
}

/* Popup header */

.defa-modal-header {
    padding: 28px 58px 24px 26px;
    background: var(--cal-primary);
    color: #fff;
}

.defa-calendar-modal-content
.defa-modal-header h3 {
    margin: 12px 0 8px;
    color: #fff;
    font-size: 25px;
    line-height: 1.3;
}

.defa-day-modal-header h3 {
    margin-top: 0 !important;
}

.defa-modal-center {
    margin: 0 0 5px;
    color: #fff;
    font-size: 16px;
    font-weight: 700;
}

.defa-modal-date {
    margin: 0;
    color: rgba(255, 255, 255, 0.82);
    font-size: 14px;
}

/* Level-based second-level popup headers */

.defa-event-modal-header.level-a1 {
    background: #c550db;
}

.defa-event-modal-header.level-a2,
.defa-event-modal-header.level-a-mixed {
    background: #ff7900;
}

.defa-event-modal-header.level-b1 {
    background: #1575d1;
}

.defa-event-modal-header.level-b2 {
    background: #42ae54;
}

.defa-event-modal-header.level-c1 {
    background: #7653c7;
}

.defa-event-modal-header.level-c2 {
    background: #cf3e6d;
}

.defa-event-modal-header.level-other {
    background: #687785;
}

/* Booking status */

.defa-modal-status {
    display: inline-block;
    padding: 5px 9px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 700;
}

.defa-modal-header
.defa-modal-status.open {
    background: #dff4df;
    color: #19751f;
}

.defa-modal-header
.defa-modal-status.closed {
    background: #fde3e5;
    color: #ad3037;
}

/* Back button on second-level popup */

.defa-modal-back {
    display: flex;
    align-items: center;
    width: fit-content;
    gap: 7px;
    margin: 0 0 17px;
    padding: 6px 10px;
    border: 1px solid rgba(255, 255, 255, 0.38);
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.13);
    color: #fff;
    font-family: inherit;
    font-size: 13px;
    line-height: 1;
    font-weight: 700;
    cursor: pointer;
    transition:
        background 0.2s ease,
        border-color 0.2s ease,
        transform 0.2s ease;
}

.defa-modal-back:hover {
    border-color: rgba(255, 255, 255, 0.65);
    background: rgba(255, 255, 255, 0.22);
    color: #fff;
    transform: translateX(-2px);
}

.defa-modal-back:focus-visible {
    outline: 2px solid #fff;
    outline-offset: 2px;
}

.defa-modal-back-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 17px;
    line-height: 1;
}

/* Popup body */

.defa-modal-body {
    padding: 24px 26px;
    background: #fff;
}

.defa-modal-details {
    display: grid;
    gap: 0;
    border: 1px solid #e2e8ee;
    border-radius: 9px;
    overflow: hidden;
}

.defa-modal-detail-row {
    display: grid;
    grid-template-columns: 140px minmax(0, 1fr);
    gap: 18px;
    padding: 13px 15px;
    border-bottom: 1px solid #e2e8ee;
}

.defa-modal-detail-row:last-child {
    border-bottom: 0;
}

.defa-modal-detail-label {
    color: #6b7280;
    font-size: 13px;
    font-weight: 700;
}

.defa-modal-detail-value {
    color: #111827;
    font-size: 14px;
    font-weight: 700;
}

.defa-modal-address {
    padding: 14px 15px;
    border-top: 1px solid #e2e8ee;
    background: #f7f9fb;
    color: #6b7280;
    font-size: 13px;
    line-height: 1.6;
}

/* Popup footer */

.defa-modal-footer {
    padding: 0 26px 26px;
    background: #fff;
}

/* Book Now CTA */

.defa-modal-book-button {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 36px;
    padding: 11px 15px;
    border-radius: 7px;
    background: var(--cal-primary);
    color: #fff !important;
    font-size: 15px;
    font-weight: 800;
    text-decoration: none !important;
    transition:
        transform 0.2s ease,
        background 0.2s ease;
}

.defa-modal-book-button:hover {
    background: var(--cal-primary-dark);
    color: #fff !important;
    transform: translateY(-1px);
}

/* Date overview popup */

.defa-day-modal-groups {
    display: grid;
    gap: 20px;
}

.defa-day-modal-group h4 {
    margin: 0 0 8px;
    color: var(--cal-primary);
    font-size: 16px;
}

.defa-day-modal-list {
    display: grid;
    border: 1px solid #dfe4ea;
    border-radius: 8px;
    overflow: hidden;
}

.defa-day-modal-event {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 11px 12px;
    border: 0;
    border-bottom: 1px solid #dfe4ea;
    background: #fff;
    text-align: left;
    font: inherit;
    cursor: default;
}

.defa-day-modal-event:last-child {
    border-bottom: 0;
}


.defa-day-event-main {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
}

.defa-day-event-title {
    overflow: hidden;
    text-overflow: ellipsis;
}

.defa-day-event-copy {
    display: grid;
    gap: 2px;
    min-width: 0;
}

.defa-day-event-module {
    color: #6b7280;
    font-size: 12px;
    line-height: 1.35;
    font-weight: 700;
}

.defa-modal-level {
    flex: 0 0 auto;
    min-width: 40px;
    padding: 3px 7px;
    border-radius: 999px;
    color: #fff;
    font-size: 11px;
    text-align: center;
}

.defa-day-modal-event small {
    flex: 0 0 auto;
    padding: 3px 8px;
    border-radius: 999px;
    font-weight: 700;
}

.defa-day-modal-event small.open {
    color: #19751f;
    background: #dcf5d9;
}

.defa-day-modal-event small.closed {
    color: #ad3037;
    background: #fde3e5;
}

body.defa-calendar-modal-open {
    overflow: hidden;
}

/* Plugin dependency notice */

.defa-calendar-notice {
    padding: 14px;
    border-left: 4px solid #dba617;
    background: #fff8df;
}

/* Tablet */

@media (max-width: 980px) {

    .defa-calendar-day {
        padding: 8px 6px;
    }

    .defa-calendar-day-number {
        font-size: 38px;
    }

    .defa-calendar-center-name {
        font-size: 13px;
    }

    .defa-calendar-level {
        font-size: 11px;
    }

    .defa-calendar-weekdays span {
        font-size: 16px;
    }
}

/* Mobile */

@media (max-width: 680px) {

    /* Calendar toolbar */

    .defa-calendar-toolbar {
        display: flex;
        flex-direction: column;
        align-items: stretch;
        gap: 14px;
    }

    .defa-calendar-title-nav {
        display: flex;
        align-items: center;
        justify-content: space-between;
    }
	
	.defa-calendar-shell {
  overflow: hidden;
  border: none;
  background: #fff;
}

    .defa-calendar-month {
        flex: 1;
        margin: 0;
        text-align: center;
        font-size: 29px;
    }

    .defa-calendar-nav {
        flex: 0 0 42px;
        width: 42px;
        height: 42px;
    }

    .defa-calendar-filter-wrap {
        width: 100%;
        min-width: 0;
    }

    /*
     * Hide the desktop weekday heading.
     */
    .defa-calendar-weekdays {
        display: none !important;
    }

    /*
     * Mobile calendar:
     * two exam-date cards per row.
     */
    .defa-calendar-grid {
        display: grid !important;
        grid-template-columns:
            repeat(2, minmax(0, 1fr)) !important;
        gap: 10px;
    }

    /*
     * Hide dates without exams.
     */
    .defa-calendar-day {
        display: none !important;
        width: 100%;
        min-width: 0;
        min-height: 0;
        margin: 0;
        padding: 0 !important;
        border: 0 !important;
        background: transparent;
        overflow: visible;
    }

    .defa-calendar-day.outside-month {
        display: none !important;
    }

    /*
     * Each exam date becomes one card.
     *
     * Row 1: Date
     * Row 2: Exam center and levels
     */
    .defa-calendar-day.has-events {
        display: grid !important;
        grid-template-columns: 1fr !important;
        grid-template-rows: auto 1fr !important;
        align-items: stretch;
        width: 100%;
        min-width: 0;
        margin: 0;
        padding: 0 !important;
        border: 1px solid
            var(--cal-border) !important;
        border-radius: 10px;
        background: #fff;
        box-shadow: none;
        overflow: hidden;
        cursor: pointer;
    }

    /*
     * Remove the desktop today border
     * from the complete mobile card.
     */
    .defa-calendar-day.today {
        box-shadow: none;
    }

    /*
     * Row 1:
     * Month, date and weekday.
     */
    .defa-calendar-day.has-events
    .defa-calendar-day-header {
        grid-column: 1;
        grid-row: 1;
        display: flex !important;
        flex-direction: row;
        align-items: center;
        justify-content: center;
        flex-wrap: wrap;
        column-gap: 6px;
        row-gap: 3px;
        width: 100%;
        min-width: 0;
        min-height: 70px;
        margin: 0;
        padding: 12px 8px;
        background: var(--cal-primary);
        color: #fff;
        text-align: center;
    }

    /*
     * Month is shown only on mobile.
     */
    .defa-calendar-day.has-events
    .defa-calendar-mobile-month {
        display: inline-block !important;
        margin: 0;
        color: rgba(255, 255, 255, 0.9);
        font-size: 13px;
        line-height: 1;
        font-weight: 800;
        letter-spacing: 0.7px;
        text-transform: uppercase;
    }

    .defa-calendar-day.has-events
    .defa-calendar-day-number {
        display: inline-block;
        margin: 0;
        color: #fff !important;
        font-size: 28px;
        line-height: 1;
        font-weight: 800;
    }

    /*
     * Weekday uses the second line
     * inside the date row.
     */
    .defa-calendar-day.has-events
    .defa-calendar-mobile-day {
        display: block !important;
        margin: 0;
        color: rgba(255, 255, 255, 0.82);
        font-size: 11px;
        line-height: 1;
        font-weight: 400;
        letter-spacing: 0.5px;
        text-transform: uppercase;
    }

    /*
     * Today indicator on the date row.
     */
    .defa-calendar-day.today.has-events
    .defa-calendar-day-header {
        box-shadow:
            inset 0 0 0 3px
            rgba(255, 255, 255, 0.4);
    }

    /*
     * Row 2:
     * Center and exam-level pills.
     */
    .defa-calendar-day.has-events
    .defa-calendar-events {
        grid-column: 1;
        grid-row: 2;
        display: flex !important;
        flex-direction: column;
        justify-content: flex-start;
        align-content: initial;
        gap: 10px;
        min-width: 0;
        margin: 0 !important;
        padding: 12px 10px !important;
        background: #eaf5ff;
    }

    .defa-calendar-center-group {
        width: 100%;
        min-width: 0;
        margin: 0;
    }

    .defa-calendar-center-name {
        display: block;
        width: 100%;
        margin: 0 0 8px;
        color: #000;
        font-size: 13px;
        line-height: 1.3;
        font-weight: 700;
        white-space: normal;
        overflow: visible;
        text-overflow: initial;
        text-align: center;
    }

    /*
     * Level pills.
     */
    .defa-calendar-levels {
        display: flex !important;
        flex-wrap: wrap;
        align-items: center;
        justify-content: center;
        grid-template-columns: none;
        gap: 5px;
        width: 100%;
        margin: 0;
    }

    .defa-calendar-level,
    .defa-calendar-level-more {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        flex: 0 0 auto;
        width: auto;
        min-width: 38px;
        min-height: 26px;
        margin: 0;
        padding: 5px 8px;
        border-radius: 999px;
        font-size: 11px;
        line-height: 1;
    }

    .defa-calendar-more {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        align-self: center;
        width: auto;
        margin: 0;
        padding: 5px 8px;
        border-radius: 999px;
        font-size: 10px;
        line-height: 1;
    }

    /* Popup responsive styles */

    .defa-calendar-modal {
        align-items: flex-end;
        padding: 10px;
    }

    .defa-calendar-modal-dialog {
        width: 100%;
        max-height: 92vh;
        padding: 0;
        border-radius: 14px;
    }

    .defa-modal-header {
        padding: 24px 50px 20px 18px;
    }

    .defa-modal-body {
        padding: 18px;
    }

    .defa-modal-footer {
        padding: 0 18px 18px;
    }

    .defa-modal-detail-row {
        grid-template-columns: 1fr;
        gap: 4px;
    }

    .defa-calendar-modal-content
    .defa-modal-header h3 {
        font-size: 21px;
    }

    .defa-modal-back {
        margin-bottom: 15px;
    }

    .defa-day-modal-event {
        align-items: flex-start;
    }

    .defa-day-event-main {
        align-items: flex-start;
    }
}

/* v1.5.2: Day popup module + booking action */
.defa-day-event-main {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
}

.defa-day-event-module {
    display: inline-block;
    color: #4b5563;
    font-size: 13px;
    line-height: 1.35;
    font-weight: 700;
    white-space: nowrap;
}

.defa-day-book-button {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 34px;
    padding: 7px 12px;
    border-radius: 7px;
    background: var(--cal-primary);
    color: #fff !important;
    text-decoration: none !important;
    font-size: 12px;
    font-weight: 800;
    transition:
        transform 0.2s ease,
        background 0.2s ease;
}

.defa-day-book-button:hover,
.defa-day-book-button:focus {
    background: var(--cal-primary-dark);
    color: #fff !important;
    text-decoration: none !important;
    transform: translateY(-1px);
}

.defa-day-booking-closed {
    flex: 0 0 auto;
    font-size: 12px;
    font-weight: 700;
}

@media (max-width: 575.98px) {
    .defa-day-modal-event {
        align-items: center;
    }

    .defa-day-event-module {
        white-space: normal;
    }
}


/* v1.5.4: Available slots beside exam center in date popup */
.defa-day-modal-group > h4 {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    flex-wrap: wrap;
}

.defa-day-center-name {
    min-width: 0;
}

.defa-day-center-slots {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    padding: 4px 8px;
    border-radius: 999px;
    background: #eef5ff;
    color: var(--cal-primary);
    font-size: 12px;
    line-height: 1.2;
    font-weight: 800;
    white-space: nowrap;
}

@media (max-width: 575.98px) {
    .defa-day-modal-group > h4 {
        align-items: flex-start;
    }

    .defa-day-center-slots {
        white-space: normal;
    }
}


/* v1.6.4 location labels */
.defa-modal-center-location,
.defa-day-center-location {
    display: block;
    font-size: 0.88em;
    font-weight: 500;
    opacity: 0.9;
    margin-top: 2px;
}


/* v1.6.5: popup availability and header visibility fixes */
.defa-day-modal-header .defa-modal-date {
    color: #fff;
}

.defa-day-center-slots.defa-no-slots {
    background: #f7eded;
    color: #9b3434;
}
