@use '~flux/components/css/mixin';

.calendar {
    flex-grow: 1;
}

.calendarView {
    contain: paint;

    display: flex;
    flex-flow: column;
    flex-grow: 1;
}

.calendarItemRegistry {
    display: none;
}

.calendarActions {
    align-items: center;
}

.layerPane .calendarActions {
    border: 0;
}

.calendarLoader {
    composes: basePaneLoader from './base/Pane.module.scss';
}

.calendarCurrent {
    display: flex;
    gap: 9px;
}

.calendarCurrentValue {
    padding: 0;
    background: none;
    border: 0;
    cursor: pointer;
    font-size: 30px;
    letter-spacing: -.05em;
    line-height: 1.5em;
    text-transform: capitalize;

    @include mixin.hover {
        color: var(--primary-600);
    }
}

.calendarCurrentMonth {
    composes: calendarCurrentValue;

    color: var(--foreground-prominent);
    font-weight: 700;
}

.calendarCurrentYear {
    composes: calendarCurrentValue;

    color: var(--foreground);
}

.calendarRangeLabel {
    composes: calendarCurrentValue;

    color: var(--foreground-prominent);
    font-weight: 700;
}

.calendarItem {
    display: block;
    padding: 0;
    background: transparent;
    border: 0;
    cursor: default;
    text-align: left;

    @include mixin.focus-ring;

    &.isClickable {
        cursor: pointer;
    }

    &.isDraggable {
        cursor: grab;

        &:active {
            cursor: grabbing;
        }
    }

    &.isGrabbed {
        outline: 2px solid var(--primary-500);
        outline-offset: 2px;
    }
}

.calendarCells {
    display: grid;
    flex-grow: 1;
    gap: 1px;
    grid-template-columns: repeat(7, minmax(180px, 1fr));
    grid-template-rows: min-content repeat(6, auto);
    background: var(--gray-100);
    overflow-x: auto;
}

.calendarCell {
    padding: 9px;
    background: var(--gray-25);
}

.calendarDay {
    composes: calendarCell;

    // The 30px line box is the cell height.
    @include mixin.text(xsmall, $line-height: 30px);

    padding-left: 0;
    padding-right: 0;
    color: var(--foreground-secondary);
    font-weight: 500;
    text-align: center;
    text-transform: capitalize;
}

.calendarEntry {
    composes: calendarCell;

    position: relative;
    min-height: 90px;
    padding-top: 33px;
    outline: 2px dashed transparent;
    outline-offset: -2px;
    transition: 210ms var(--swift-out);
    transition-property: background, outline-color, z-index;
    z-index: 0;

    &.isDisabled {
        background: var(--gray-50);
        color: var(--foreground-secondary);

        .calendarEntryDate {
            opacity: .25;
        }

        .calendarEvents {
            opacity: .75;
            pointer-events: none;
        }
    }

    &.isFocused,
    &.isDropTarget {
        z-index: 1;
    }

    &.isFocused {
        box-shadow: inset 0 0 0 2px var(--primary-200);
    }

    &.isDropTarget {
        background: var(--primary-50);
        outline-color: var(--primary-600);
    }

    &.isToday .calendarEntryDate {
        color: var(--primary-600);
    }
}

.calendarEntryDate {
    @include mixin.text(2xsmall, $line-height: 1em);

    position: absolute;
    top: 12px;
    left: 12px;
    color: var(--foreground);
    font-weight: 700;
}

.calendarEvents {
    display: grid;
    grid-auto-rows: auto;
    gap: 3px;
}

.timeGrid {
    display: flex;
    flex-flow: column;
    flex-grow: 1;
    overflow: hidden;
    background: var(--gray-25);
}

.timeGridInner {
    display: flex;
    flex-flow: column;
    flex-grow: 1;
    overflow: hidden;
}

.timeGridHeader {
    display: grid;
    grid-template-columns: 64px 1fr;
    background: var(--gray-25);
    border-bottom: 1px solid var(--gray-100);
}

.timeGridHeaderGutter {
    background: var(--gray-25);
}

.timeGridHeaderDays {
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: minmax(0, 1fr);
    gap: 1px;
    background: var(--gray-100);
}

.timeGridHeaderDay {
    @include mixin.text(2xsmall, $line-height: 1em);

    padding: 9px 12px;
    background: var(--gray-25);
    color: var(--foreground-secondary);
    font-weight: 600;
    text-align: center;
    text-transform: capitalize;

    &.isToday {
        color: var(--primary-600);
    }
}

.timeGridAllDay {
    display: grid;
    grid-template-columns: 64px 1fr;
    background: var(--gray-25);
    border-bottom: 1px solid var(--gray-100);
}

.timeGridAllDayLabel {
    @include mixin.text(2xsmall, $line-height: 1em);

    align-self: stretch;
    padding: 6px 9px;
    color: var(--foreground-secondary);
    font-weight: 500;
    text-align: right;
}

.timeGridAllDayDays {
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: minmax(0, 1fr);
    gap: 1px;
    min-height: 36px;
    background: var(--gray-100);
}

.timeGridAllDayCell {
    display: flex;
    flex-flow: column;
    gap: 3px;
    padding: 6px;
    background: var(--gray-25);

    &.isDropTarget {
        box-shadow: inset 0 0 0 2px var(--primary-300);
    }
}

.timeGridBody {
    display: grid;
    grid-template-columns: 64px 1fr;
    flex-grow: 1;
    overflow-y: auto;
    overflow-x: hidden;
    position: relative;
}

.timeGridHours {
    display: flex;
    flex-flow: column;
    background: var(--gray-25);
}

.timeGridHourLabel {
    @include mixin.text(2xsmall, $line-height: 1em);

    position: relative;
    box-sizing: border-box;
    padding-right: 9px;
    color: var(--foreground-secondary);
    font-weight: 500;
    text-align: right;
}

.timeGridHourLabelText {
    position: absolute;
    top: 0;
    right: 9px;
    transform: translateY(-50%);
    background: var(--gray-25);
    padding: 0 2px;
}

.timeGridDays {
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: minmax(0, 1fr);
    gap: 1px;
    background: var(--gray-100);
}

.timeGridDay {
    position: relative;
    background: var(--gray-25);
    background-image: repeating-linear-gradient(
        to bottom,
        transparent,
        transparent calc(var(--hour-height, 48px) - 1px),
        var(--gray-100) calc(var(--hour-height, 48px) - 1px),
        var(--gray-100) var(--hour-height, 48px)
    );

    &.isDropTarget {
        box-shadow: inset 0 0 0 2px var(--primary-300);
    }
}

.timeGridDayItem {
    position: absolute;
    box-sizing: border-box;
    overflow: hidden;
    padding: 2px;

    &.isClippedTop {
        border-top: 2px dashed var(--warning-300);
    }

    &.isClippedBottom {
        border-bottom: 2px dashed var(--warning-300);
    }

    &.isResizing {
        opacity: .8;
    }
}

.timeGridDayItemBody {
    position: relative;
    height: 100%;
    width: 100%;

    > button {
        display: block;
        width: 100%;
        height: 100%;
    }
}

.timeGridDayItemHandle {
    position: absolute;
    left: 0;
    right: 0;
    height: 6px;
    cursor: ns-resize;
    z-index: 2;
    background: transparent;

    @include mixin.hover {
        background: var(--primary-300);
    }

    &.isTop {
        top: 0;
    }

    &.isBottom {
        bottom: 0;
    }
}

.timeGridDropIndicator {
    position: absolute;
    left: 0;
    right: 0;
    height: 2px;
    background: var(--primary-500);
    z-index: 5;
    pointer-events: none;
}
