/* calendar.less */
// Calendar colour variables defined.
$calendarEventCategoryColor: #e0cbe0 !default; // Pale purple.
$calendarEventCourseColor: #ffd3bd !default; // Pale red.
$calendarEventGlobalColor: #d6f8cd !default; // Pale green.
$calendarEventGroupColor: #fee7ae !default; // Pale yellow.
$calendarEventUserColor: #dce7ec !default; // Pale blue.
$calendarEventOtherColor: #ced4da !default; // Pale gray.
// Border colours for the event colour indicators.
$calendarEventCategoryBorderColor: #9e619f !default; // Purple.
$calendarEventCourseBorderColor: #d34600 !default; // Red-orange.
$calendarEventGlobalBorderColor: #2b8713 !default; // Green.
$calendarEventGroupBorderColor: #9a6e02 !default; // Dark orange.
$calendarEventUserBorderColor: #4e7c91 !default; // Blue.
$calendarEventOtherBorderColor: #687889 !default; // Gray.
// Border for the event colour indicators.
$calendarEventCategoryBorder: 2px solid $calendarEventCategoryBorderColor !default; // Purple.
$calendarEventCourseBorder: 2px solid $calendarEventCourseBorderColor !default; // Red-orange.
$calendarEventGlobalBorder: 2px solid $calendarEventGlobalBorderColor !default; // Green.
$calendarEventGroupBorder: 2px solid $calendarEventGroupBorderColor !default; // Dark orange.
$calendarEventUserBorder: 2px solid $calendarEventUserBorderColor !default; // Blue.
$calendarEventOtherBorder: 2px solid $calendarEventOtherBorderColor !default; // Gray.
// This will be the colour of mini-calendar links, hide/show filter icons, edit/delete icon buttons.
$calendarEventColor: #0d5ca1 !default;
$calendarCurrentDateColor: $white;
$calendarCurrentDateBackground: $primary;
// Calendar event background colours defined.
.calendar_event_category {
    background-color: $calendarEventCategoryColor;

    .commands a {
        color: $calendarEventColor;
    }
}

.calendar_event_course {
    background-color: $calendarEventCourseColor;

    .commands a {
        color: $calendarEventColor;
    }
}

.calendar_event_site {
    background-color: $calendarEventGlobalColor;

    .commands a {
        color: $calendarEventColor;
    }
}

.calendar_event_group {
    background-color: $calendarEventGroupColor;

    .commands a {
        color: $calendarEventColor;
    }
}

.calendar_event_user {
    background-color: $calendarEventUserColor;

    .commands a {
        color: $calendarEventColor;
    }
}

.calendar_event_other {
    background-color: $calendarEventOtherColor;

    .commands a {
        color: $calendarEventColor;
    }
}

@mixin footer-links {
    span.footer-link:after {
        content: "\2022";
        color: $primary;
    }
    span.footer-link:last-child:after {
        content: none;
    }
}

// Calendar restyling.
.calendartable {
    width: 100%;
    table-layout: fixed;

    th,
    td {
        width: 14%;
        vertical-align: top;
        text-align: center;
        border: 0;
    }
}

.calendar-controls {
    .previous,
    .next,
    .current {
        display: block;
        float: left;
        width: 12%;
    }

    .previous {
        text-align: left;
        border: 1px solid transparent;
        width: 25%;
    }

    .current {
        text-align: center;
        width: 50%;
    }

    .next {
        text-align: right;
        border: 1px solid transparent;
        width: 25%;
    }

    .drop-target {
        box-sizing: border-box;
        border: 1px dashed $primary;
    }
}

.filters {
    table {
        border-collapse: separate;
        border-spacing: 2px;
        width: 100%;
    }
}

#region-main {
    .maincalendar {
        .calendarwrapper {
            td {
                & > div {
                    height: 11.5em;
                    overflow: hidden;
                }
            }
        }
    }
}

.maincalendar {
    vertical-align: top;
    padding: 0;

    .bottom {
        text-align: left;
        width: 98%;
        margin: 10px auto;
        @include footer-links;
    }

    .heightcontainer {
        height: 100%;
        position: relative;
    }

    .calendarmonth {
        width: 98%;
        margin: 10px auto;

        ul {
            margin: 0;
            padding: 0;

            li[data-event-folded="true"] {
                display: none;
            }

            li {
                list-style-type: none;
                line-height: 1.2em;

                > a {
                    @include text-truncate;
                    max-width: 100%;
                    display: inline-block;

                    &:hover {
                        text-decoration: $link-decoration;

                        .eventname {
                            text-decoration: $link-hover-decoration;
                        }
                    }
                }

                a[data-action="view-day-link"] {
                    @include text-truncate;
                }

                .icon {
                    margin-left: 0.25em;
                    margin-right: 0.25em;
                    vertical-align: initial;
                }

                .calendar-circle {
                    width: 12px;
                    height: 12px;
                    border-radius: 6px;
                    vertical-align: middle;
                    display: inline-block;

                    &.calendar_event_category {
                        background-color: $calendarEventCategoryColor;
                        border: $calendarEventCategoryBorder;
                    }

                    &.calendar_event_course {
                        background-color: $calendarEventCourseColor;
                        border: $calendarEventCourseBorder;
                    }

                    &.calendar_event_site {
                        background-color: $calendarEventGlobalColor;
                        border: $calendarEventGlobalBorder;
                    }

                    &.calendar_event_group {
                        background-color: $calendarEventGroupColor;
                        border: $calendarEventGroupBorder;
                    }

                    &.calendar_event_user {
                        background-color: $calendarEventUserColor;
                        border: $calendarEventUserBorder;
                    }

                    &.calendar_event_other {
                        background-color: $calendarEventOtherColor;
                        border: $calendarEventOtherBorder;
                    }
                }
            }
        }

        th {
            text-align: left;
            padding-left: 16px;
        }

        td {
            a.day:focus {
                display: inline-block;
                border-radius: 50%;
                box-shadow: $input-btn-focus-box-shadow;
            }

            .day-number-circle {
                display: inline-block;
                line-height: 0;
                width: 30px;
                height: 30px;

                .day-number {
                    display: inline-block;
                    padding: 50% 4px;
                    width: 100%;
                    text-align: center;
                }
            }

            &.today {
                .day-number-circle {
                    border-radius: 50%;
                    color: $calendarCurrentDateColor;
                    background-color: $calendarCurrentDateBackground;
                }
            }
        }

        td.day {
            &:hover {
                transform: scale(1.25);
                background-color: rgba(darken($primary, 20%), .2);
                box-shadow: 0 8px 20px rgba(darken($primary, 20%), .15);
                z-index: 2;
                position: relative
            }

            [data-region="day-content"] ul {
                transition: all 0.3s ease-in-out;

                li {
                    transition: all 0.3s ease;
                    opacity: .7;
                    padding: 2px 4px
                }
            }

            &:hover [data-region="event-item"] {
                .calendar-circle::before {
                    margin-bottom: 4px;
                    font-size: 1rem;
                    opacity: .9
                }

                .eventname {
                    font-weight: 600;
                    margin-top: 4px
                }

                &::after {
                    content: "🕒 10:00 AM";
                    font-size: .7rem;
                    color: #666;
                    margin-top: 2px;
                    opacity: .8
                }
            }

            [data-region="day-content"] ul li {
                transition: all 0.3s ease;
                opacity: .7;
                padding: 2px 4px;
                transform: translateY(0)
            }

            &:hover [data-region="day-content"] {
                ul {
                    display: block;
                    margin-top: 10px;
                    transform: scale(1);
                    opacity: 1;
                    transition: all 0.3s ease-in-out;

                    li {
                        background: #f3f3f3;
                        border-left: 4px solid $primary;
                        padding: 8px 12px;
                        border-radius: 6px;
                        margin-bottom: 6px;
                        opacity: 1;
                        display: flex;
                        flex-direction: column;
                        align-items: flex-start;
                        font-size: .85rem;
                        color: #222;
                        box-shadow: 0 2px 4px rgba(0, 0, 0, .04);
                        border-left: 4px solid $primary;
                        animation: fadeSlideIn 0.4s ease forwards;

                        &:nth-child(1) {
                            animation-delay: 0.05s
                        }

                        &:nth-child(2) {
                            animation-delay: 0.15s
                        }

                        &:nth-child(3) {
                            animation-delay: 0.25s
                        }

                        &:nth-child(4) {
                            animation-delay: 0.35s
                        }

                        &:nth-child(5) {
                            animation-delay: 0.45s
                        }
                    }
                }
            }

            &:hover [data-region="event-item"]::after {
                content: "🕒 10:00 AM";
                font-size: .7rem;
                color: #666;
                margin-top: 2px;
                opacity: .7
            }

            &:hover::after {
                content: "+ Add Event";
                position: absolute;
                bottom: 8px;
                right: 10px;
                font-size: .75rem;
                font-weight: 600;
                color: $primary;
                background: #e6f0ff;
                border-radius: 6px;
                padding: 4px 8px;
                box-shadow: 0 2px 5px rgba(0, 0, 0, .05);
                cursor: pointer;
                transition: background 0.2s ease;
                margin-bottom: -30px;

                &:hover {
                    background: #d0e8ff
                }
            }

            > div {
                height: auto !important;
                min-height: 60px
            }
        }

        td.day,
        td.dayblank {
            height: auto !important;
            vertical-align: top;
            overflow: visible;
            position: relative;
            transition: all 0.3s ease-in-out;
            transform-origin: center;
        }

        .clickable:hover {
            background-color: $calendar-month-clickable-bg;
        }

        @media screen and (max-width: 768px) {
            border-spacing: 6px;
            padding: 12px
        }
        // sunday
        td:nth-child(1) {
            color: #fff;
            background: #b7b5b5;
        }

        tr td:nth-child(1):hover {
            color: #fff;
            background: #979595;
            position: relative;
            z-index: 1
        }

        // saturday
        td:nth-child(7) {
            color: #fff;
            background: #2b2b2b26;
        }

        tr td:nth-child(7):hover {
            color: #fff;
            background: #979595;
            position: relative;
            z-index: 1
        }

        @keyframes fadeSlideIn {
            from {
                opacity: 0;
                transform: translateY(8px)
            }
            to {
                opacity: 1;
                transform: translateY(0)
            }
        }
    }

    .controls {
        width: 98%;
        margin: 10px auto;
    }

    .calendar_event_category,
    .calendar_event_course,
    .calendar_event_site,
    .calendar_event_group,
    .calendar_event_user {
        a:has(> .icon) {
            &:hover {
                color: darken($calendarEventColor, 15%);
                text-decoration: $link-decoration;
            }
        }
    }

    .calendar_event_category {
        border-color: $calendarEventCategoryColor;
    }

    .calendar_event_course {
        border-color: $calendarEventCourseColor;
    }

    .calendar_event_site {
        border-color: $calendarEventGlobalColor;
    }

    .calendar_event_group {
        border-color: $calendarEventGroupColor;
    }

    .calendar_event_user {
        border-color: $calendarEventUserColor;
    }

    .calendar_event_other {
        border-color: $calendarEventOtherColor;
    }

    .calendartable {
        td,
        li {
            padding: 4px;
        }

        li {
            text-align: left;
        }
    }

    .header {
        overflow: hidden;

        .buttons {
            float: right;
        }
    }

    .event {
        .card-header img {
            vertical-align: baseline;
        }

        .location {
            word-break: break-all;
            overflow-wrap: break-word;
        }
    }

    table#subscription_details_table {
        td {
            vertical-align: middle;

            > .btn-group button {
                padding-left: 0;
            }
        }
    }
}

// Calendar export.
#page-calendar-export {
    .indent {
        padding-left: 20px;
    }
}

// Block minicalendar.
.block {
    .bottom {
        width: 98%;
        margin: 10px auto;
        @include footer-links;
    }

    .minicalendar {
        max-width: 280px;
        margin: 0 auto;
        width: 100%;

        th,
        td {
            padding: 2px;
            font-size: 0.8em;
            text-align: center;
        }

        td {
            &.weekend {
                color: $text-muted;
            }

            a {
                width: 100%;
                height: 100%;
                display: block;
                color: $calendarEventColor;
            }

            &.duration_global {
                border-top: 1px solid $calendarEventGlobalColor;
                border-bottom: 1px solid $calendarEventGlobalColor;

                &.duration_finish {
                    background-color: $calendarEventGlobalColor;
                }
            }

            &.duration_category {
                border-top: 1px solid $calendarEventCategoryColor;
                border-bottom: 1px solid $calendarEventCategoryColor;

                &.duration_finish {
                    background-color: $calendarEventCategoryColor;
                }
            }

            &.duration_course {
                border-top: 1px solid $calendarEventCourseColor;
                border-bottom: 1px solid $calendarEventCourseColor;

                &.duration_finish {
                    background-color: $calendarEventCourseColor;
                }
            }

            &.duration_group {
                border-top: 1px solid $calendarEventGroupColor;
                border-bottom: 1px solid $calendarEventGroupColor;

                &.duration_finish {
                    background-color: $calendarEventGroupColor;
                }
            }

            &.duration_user {
                border-top: 1px solid $calendarEventUserColor;
                border-bottom: 1px solid $calendarEventUserColor;

                &.duration_finish {
                    background-color: $calendarEventUserColor;
                }
            }

            &.duration_other {
                border-top: 1px solid $calendarEventOtherColor;
                border-bottom: 1px solid $calendarEventOtherColor;

                &.duration_finish {
                    background-color: $calendarEventOtherColor;
                }
            }
        }

        caption {
            font-size: inherit;
            font-weight: inherit;
            line-height: inherit;
            text-align: center;
        }
    }

    .calendar_filters {
        ul {
            list-style: none;
            margin: 0;
            padding: 0;
        }

        li {
            margin-bottom: 0.2em;

            span {
                &.calendar_event_category {
                    i {
                        color: $calendarEventColor;
                    }
                }

                &.calendar_event_course {
                    i {
                        color: $calendarEventColor;
                    }
                }

                &.calendar_event_site {
                    i {
                        color: $calendarEventColor;
                    }
                }

                &.calendar_event_group {
                    i {
                        color: $calendarEventColor;
                    }
                }

                &.calendar_event_user {
                    i {
                        color: $calendarEventColor;
                    }
                }

                &.calendar_event_other {
                    i {
                        color: $calendarEventColor;
                    }
                }

                img {
                    padding: 0 0.2em;
                    margin: 0;
                }
            }

            .icon {
                vertical-align: initial;
                margin: 0 0.1rem 0 0.4rem;
            }

            > a {
                &:hover {
                    text-decoration: $link-decoration;

                    .eventname {
                        text-decoration: $link-hover-decoration;
                    }
                }
            }
        }
    }

    .content {
        h3 {
            &.eventskey {
                margin-top: 0.5em;
            }
        }
    }
}

// Side block in Course view page is different with other side blocks.
// We should hide the navigation text and re-arrange the Calendar links.
.path-course-view {
    .block {
        &.block_calendar_month {
            .maincalendar {
                div.header {
                    visibility: hidden;
                    height: 0;
                }

                .calendarwrapper {
                    .arrow_text {
                        @include visually-hidden;
                    }
                }
            }

            .footer {
                .bottom {
                    .footer-link {
                        display: block;
                    }

                    .footer-link:after {
                        content: none;
                    }
                }
            }
        }
    }
}

/* Display month name above the calendar */
table.calendartable caption {
    caption-side: top;
}

@mixin day-number-has-event {
    .day-number {
        display: inline-block;
        position: relative;

        &:before {
            content: '.';
            display: inline-block;
            position: absolute;
            bottom: 0.4em;
            left: 0;
            text-align: center;
            width: 100%;
            font-size: 3em;
            color: inherit;
        }
    }
}

@media (min-width: 768px) {
    #page-calender-view {
        .container-fluid {
            min-width: 1024px;
        }
    }
}

@media (min-width: 768px) {
    [data-blockregion]:not([data-blockregion="content"]) {
        .block {
            &.block_calendar_month {
                .maincalendar {
                    div.header {
                        visibility: hidden;
                        height: 0;
                    }

                    .calendarwrapper {
                        .current {
                            width: 40%;
                            font-size: inherit;
                            line-height: inherit;
                        }

                        .previous,
                        .next {
                            width: 30%;

                            .arrow_text {
                                display: none;
                            }
                        }
                    }

                    .calendartable {
                        &.calendarmonth {
                            th,
                            td {
                                border: none;
                                text-align: center !important; // stylelint-disable-line declaration-no-important
                                padding: 0;
                            }

                            td {
                                height: auto;
                                font-size: 0.8em;

                                &.hasevent {
                                    [data-region="day-content"] {
                                        display: none;
                                    }

                                    @include day-number-has-event;
                                }

                                &:after {
                                    content: "";
                                    display: block;
                                    margin-top: calc(100% - 26px);
                                }

                                &.clickable:hover {
                                    background-color: inherit;
                                }

                                &.clickable:not(.today):hover {
                                    .day-number-circle {
                                        border-radius: 50%;
                                        background-color: $calendar-month-clickable-bg;
                                    }
                                }
                            }
                        }
                    }
                }

                .bottom {
                    // This adds a border on the top side of the footer container.
                    // So we won't have to add a <hr> element in the footer_options template.
                    border-top: $border-width solid $card-border-color;
                    padding-top: map-get($spacers, 2);
                }
            }
        }
    }
}

@media (max-width: 768px) {
    .maincalendar {
        .calendartable {
            &.calendarmonth {
                th,
                td {
                    border: none;
                    text-align: center !important; // stylelint-disable-line declaration-no-important
                    padding: 0;
                }

                td {
                    height: auto;
                    font-size: inherit;
                    padding: 0;

                    &.hasevent {
                        [data-region="day-content"] {
                            display: none;
                        }

                        @include day-number-has-event;
                    }

                    &:after {
                        content: "";
                        display: block;
                        margin-top: calc(100% - 26px);
                    }

                    & > div {
                        height: auto !important; // stylelint-disable-line declaration-no-important
                    }
                }
            }
        }
    }
}

.calendarwrapper {
    position: relative;
}

.day-popover-content {
    &:empty + .day-popover-alternate {
        display: block;
    }
}

.location-content {
    overflow-wrap: break-word;
}

.description-content {
    overflow-wrap: break-word;

    > p {
        margin: 0;
    }
}

.cal_courses_flt {
    color: $gray-600;
    max-width: 75%;
}

#calendarviewdropdown,
.cal_courses_flt,
button[data-action="new-event-button"] {
    font-size: .9rem;
    font-weight: 500;
    border-radius: 8px;
    border: none;
    padding: 18px 28px;
    margin-right: 10px;
    background: #00c896;
    color: #fff;
    box-shadow: 0 2px 6px rgba(0, 0, 0, .1)
}

button[data-action="new-event-button"] {
    background: #ff7b54
}

button[data-action="new-event-button"]:hover,
#calendarviewdropdown:hover,
.cal_courses_flt:hover {
    opacity: .9
}

[data-region="day-content"] ul {
    list-style: none;
    padding: 0;
    margin-top: 8px
}

[data-region="event-item"] a {
    display: flex;
    align-items: center;
    padding: 6px 10px;
    margin-bottom: 4px;
    border-radius: 8px;
    text-decoration: none;
    font-size: .8rem;
    font-weight: 500;
    color: #333;
    transition: background 0.2s ease;
    animation: fadeIn 0.6s ease;
    gap: 6px;
    @media screen and (max-width: 768px) {
        font-size: .75rem
    }
}

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

[data-region="event-item"] .calendar-circle {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    margin-right: 6px;
    flex-shrink: 0;
    display: inline-block;
    background: currentColor
}

select#calendar-course-filter-1 {
    display: none
}

.special-date-banner::before {
    //  background-image: url(https://lewsdevbox.adaptivle.co.uk/pluginfile.php/369/mod_resource/content/1/Quidditch.jpg);
    content: "";
    display: block;
    background-size: cover;
    background-repeat: no-repeat;
    background-position: top center;
    height: 40px;
    margin-bottom: 8px
}