@media (min-width: 768px) {
    main {
        padding-left: 14em;
    }
}

/* Sidebar */
.sidebar {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    padding: 58px 0 0; /* Height of navbar */
    /* box-shadow: 0 2px 5px 0 rgb(0 0 0 / 5%), 0 2px 10px 0 rgb(0 0 0 / 5%);*/
    width: 14em;
    z-index: 600;
}

@media (max-width: 768px) {
    .sidebar {
        width: 100%;
    }
}
.sidebar .active {
    border-radius: 5px;
    box-shadow: 0 2px 5px 0 rgb(0 0 0 / 16%), 0 2px 10px 0 rgb(0 0 0 / 12%);
}

.sidebar-sticky {
    position: relative;
    top: 0;
    height: calc(100vh - 48px);
    padding-top: 0.5rem;
    overflow-x: hidden;
    overflow-y: auto; /* Scrollable contents if viewport is shorter than content. */
}

.trix-button-row {
    .trix-button-group {
        border: var(--bs-border-width) solid var(--bs-border-color);
        margin-bottom: 0;
        .trix-button {
            border: 0;
        }
    }
}

[data-bs-theme=dark] {
    .trix-button-row {
        .trix-button-group {
            .trix-button {
                filter: invert(100%);
            }
           .trix-button.trix-active {
               background-color: #cc9a06;
           }

        }
    }

    div.trix-dialog.trix-active {
        background-color: var(--bs-body-bg);
        box-shadow: none;
    }

    input.trix-validate {
        background-color: var(--bs-danger-bg-subtle) !important;
    }

    input.trix-input.trix-input--dialog {
        background-color: rgba(var(--bs-body-bg), var(--bs-bg-opacity))
    }

    .ux-media {
        background-color: rgba(var(--bs-body-bg), var(--bs-bg-opacity)) !important;
    }

    button.btn.btn-light {
        filter: invert(80%)
    }

    a.btn.btn-light {
        filter: invert(80%)
    }
}

.fc th {
    background-color: var(--bs-border-color);
}

.trix-container:focus-within {
    border-color: #66afe9 !important;
    outline: 0;
    -webkit-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075), 0 0 8px rgba(102, 175, 233, 0.6);
    box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075), 0 0 8px rgba(102, 175, 233, 0.6);
}

trix-toolbar {
    display: none;
}

.trix-button-row {
    .trix-button-group {
        .trix-button.trix-active {
            background-color: #9ec5fe;
        }
    }
}

/* Reservation Status Classes - used by calendar and timeline events */
.reservation-backup {
    background: repeating-linear-gradient(-45deg, rgba(0, 0, 0, 0.0), rgba(0, 0, 0, 0.0) 5px, rgba(255, 255, 255, 0.5) 3px, rgba(200, 200, 250, 0.5) 15px);
    border-style: dotted !important;
    opacity: 0.8;
}

.reservation-maintenance {
    background-image: repeating-linear-gradient(45deg, rgba(0,0,0,0.5) 25%, transparent 25%, transparent 75%, rgba(0,0,0,0.5) 75%, rgba(0,0,0,0.5)), repeating-linear-gradient(45deg, rgba(0,0,0,0.5) 25%, rgba(255,255,255,0.0) 25%, rgba(255,255,255,0.0) 75%, rgba(0,0,0,0.5) 75%, rgba(0,0,0,0.5));
    background-position: 0 0, 14px 14px;
    background-size: 28px 28px;
    border-style: dashed !important;
}

.reservation-checked-in {
    opacity: 0.3;
    background-image: linear-gradient(0deg, rgba(0,0,0,0.0) 50%, rgba(0,0,0,0.5) 50%);
    background-size: 3px 3px;
}

#usage_report_form_minDate_day, #usage_report_form_maxDate_day {
    display: none;
}

/* media upload */
.ux-media .img-preview > img {
    max-width: 200px;
}
.ux-media .btn-group.no-crop .btn-upload {
    border-top-left-radius: 4px;
    border-bottom-left-radius: 4px;
}

.ux-media-collection .sortable-ghost .ux-media {
    border: 2px solid #86b7fe !important;
}

.ux-media-collection .collection-error-message-button {
    display: inline-flex;
    align-items: center;
}

.editor-content {
    line-height: 1.5;
    overflow-wrap: break-word;
    word-break: break-word;

    * {
        box-sizing: border-box;
        margin: 0;
        padding: 0;
    }

    h1 {
        font-size: 1.2em;
        line-height: 1.2;
    }

    blockquote {
        border: 0 solid #ccc;
        border-left-width: 0.3em;
        margin-left: 0.3em;
        padding-left: 0.6em;
    }

    [dir=rtl] blockquote,
    blockquote[dir=rtl] {
        border-width: 0;
        border-right-width: 0.3em;
        margin-right: 0.3em;
        padding-right: 0.6em;
    }

    li {
        margin-left: 1em;
    }

    [dir=rtl] li {
        margin-right: 1em;
    }

    pre {
        display: inline-block;
        width: 100%;
        vertical-align: top;
        font-family: monospace;
        font-size: 0.9em;
        padding: 0.5em;
        white-space: pre;
        background-color: var(--bs-dark-bg-subtle);
        overflow-x: auto;
    }

    img {
        max-width: 100%;
        height: auto;
    }

    .attachment {
        display: inline-block;
        position: relative;
        max-width: 100%;
    }

    .attachment__caption {
        text-align: center;

        .attachment__name + .attachment__size {
            &::before {
                content: ' \2022 ';
            }
        }
    }

    .attachment--preview {
        width: 100%;
        text-align: center;

        .attachment__caption {
            font-size: 0.9em;
            line-height: 1.2;
        }
    }

    .attachment--file {
        line-height: 1;
        margin: 0 2px 2px 2px;
        padding: 0.4em 1em;
        border: var(--bs-border-width) var(--bs-border-style) var(--bs-border-color);
        border-radius: var(--bs-border-radius);
    }

    .attachment-gallery {
        display: flex;
        flex-wrap: wrap;
        position: relative;

        .attachment {
            flex: 1 0 33%;
            padding: 0 0.5em;
            max-width: 33%;
        }

        &.attachment-gallery--2,
        &.attachment-gallery--4 {
            .attachment {
                flex-basis: 50%;
                max-width: 50%;
            }
        }
    }
}

/* ============================================
   Custom Calendar Styles - Bootstrap 5 Dark Mode Compatible
   ============================================ */

.custom-calendar {
    background: var(--bs-body-bg);
    border: 1px solid var(--bs-border-color);
    border-radius: 0.375rem;
    overflow: hidden;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    display: flex;
    flex-direction: column;
}

/* Calendar Header */
.calendar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    background: var(--bs-secondary-bg);
    border-bottom: 1px solid var(--bs-border-color);
    flex-wrap: nowrap; /* Keep nav, title, views on one line */
    gap: 0.5rem;
}

.calendar-nav {
    display: flex;
    gap: 0.5rem;
    flex-shrink: 0; /* Don't shrink nav buttons */
}

.calendar-title {
    flex: 1 1 auto; /* Allow to grow and shrink */
    min-width: 0; /* Allow shrinking below content size */
    text-align: center;
}

.calendar-title h4 {
    margin: 0;
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--bs-body-color);
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.calendar-views {
    display: flex;
    gap: 0.25rem;
    flex-shrink: 0; /* Don't shrink view buttons */
}

/* Calendar Grid - shared between month and week views */
.calendar-grid,
.week-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    width: 100%;
    box-sizing: border-box;
    position: relative; /* Required for absolute positioning of multi-day events */
}

.calendar-grid {
    display: flex;
    flex-direction: column;
    flex: 1; /* Take remaining space after header */
}

.week-grid {
    gap: 1px;
    background: var(--bs-border-color);
    min-height: auto;
}

/* Week row container - each week is its own grid */
.calendar-week-row {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    position: relative; /* Required for absolute positioning of multi-day events */
    min-height: 120px;
    box-sizing: border-box;
}

/* Weekday headers */
.calendar-weekdays {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
}

.calendar-weekday {
    padding: 0.75rem;
    background: var(--bs-tertiary-bg);
    text-align: center;
    font-weight: 600;
    font-size: 0.875rem;
    color: var(--bs-body-color);
    border-right: 1px solid var(--bs-border-color);
    height: var(--weekday-height, 30px);
    box-sizing: content-box;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.calendar-weekday:last-child {
    border-right: none;
}

/* Day cells - unified for month and week views */
.calendar-day {
    position: relative;
    min-height: 120px;
    border-right: 1px solid var(--bs-border-color);
    border-bottom: 1px solid var(--bs-border-color);
    background: var(--bs-body-bg);
    box-sizing: border-box;
    min-width: 0;
    height: auto;
    display: flex;
    flex-direction: column;
}

.calendar-day:hover {
    background: var(--bs-secondary-bg);
}

.calendar-day.other-month {
    background: var(--bs-tertiary-bg);
    color: var(--bs-secondary-color);
}

.calendar-day.today {
    background: var(--bs-info-bg-subtle);
}

.calendar-day:last-child {
    border-right: none;
}

/* Week view day header (week view only shows day name + date in header) */
.calendar-day-header {
    padding: 0.75rem;
    background: var(--bs-tertiary-bg);
    border-bottom: 1px solid var(--bs-border-color);
    text-align: center;
}

.calendar-day-name {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--bs-body-color);
    margin-bottom: 0.25rem;
}

.calendar-day-number {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--bs-body-color);
}

.calendar-day.today .calendar-day-number {
    color: var(--bs-info-text-emphasis);
}

/* Month view date number (positioned in corner) */
.calendar-date {
    position: absolute;
    top: 0.25rem;
    right: 0.5rem;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--bs-body-color);
    z-index: 10;
}

.calendar-day.other-month .calendar-date {
    color: var(--bs-secondary-color);
}

.calendar-day.today .calendar-date {
    color: var(--bs-info-text-emphasis);
}

/* Events container - unified for month and week views */
.calendar-events {
    padding: 0 0.25rem 0.5rem 0.25rem;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    flex: 1;
    /* padding-top is set dynamically via inline style when needed */
}

/* Calendar Event - base class for ALL events (single-day, multi-day, and timeline) */
.calendar-event {
    padding: 0.125rem 0.375rem;
    border-radius: 0.25rem;
    font-size: 0.75rem;
    font-weight: 500;
    color: white;
    cursor: pointer;
    transition: all 0.2s ease;
    border: 1px solid;
    overflow: hidden;
    height: 20px;
    min-height: 20px;
    max-height: 20px;
    box-sizing: border-box;
    display: flex;
    align-items: center;
    line-height: 1.2;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}

.calendar-event:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(var(--bs-emphasis-color-rgb), 0.1);
}

/* Positioned modifier for multi-day/spanning events */
.calendar-event.positioned {
    position: absolute;
    z-index: 5;
    box-shadow: 0 1px 3px rgba(var(--bs-emphasis-color-rgb), 0.2);
    left: 0;
    right: 0;
    margin: 0 2px;
}

.calendar-event.positioned:hover {
    box-shadow: 0 3px 6px rgba(var(--bs-emphasis-color-rgb), 0.3);
    z-index: 15;
}

/* Event content styles */
.calendar-event .event-time {
    font-size: 0.6875rem;
    opacity: 0.9;
    margin-right: 0.25rem;
}

.calendar-event .event-title {
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.calendar-event .event-compact {
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-size: 0.75rem;
    line-height: 1.2;
    margin: 0;
    flex: 1;
}

/* Responsive Design for Calendar */
@media (max-width: 768px) {
    .calendar-header {
        padding: 0.75rem;
        gap: 0.375rem;
    }

    .calendar-title h4 {
        font-size: 1rem;
    }

    .calendar-day {
        min-height: 80px;
    }

    .calendar-events {
        padding: 0 0.125rem 0.25rem 0.125rem;
    }

    .calendar-event {
        padding: 0.125rem 0.25rem;
        font-size: 0.6875rem;
        height: 18px;
        min-height: 18px;
        max-height: 18px;
    }

    .calendar-event .event-compact {
        font-size: 0.6875rem;
    }

    .calendar-week-row {
        min-height: 80px;
    }

    /* Week view days need more height for events list */
    .week-view .calendar-day {
        min-height: 200px;
    }
}

@media (max-width: 576px) {
    .calendar-header {
        padding: 0.5rem;
        gap: 0.25rem;
    }

    .calendar-title h4 {
        font-size: 0.875rem;
    }

    .calendar-nav .btn,
    .calendar-views .btn {
        padding: 0.25rem 0.5rem;
        font-size: 0.75rem;
    }

    .calendar-grid {
        font-size: 0.875rem;
    }

    .calendar-day {
        min-height: 60px;
    }

    .calendar-date {
        font-size: 0.75rem;
        top: 0.25rem;
        right: 0.25rem;
    }

    .calendar-events {
        padding: 0 0.125rem 0.125rem 0.125rem;
    }

    .calendar-event {
        height: 16px;
        min-height: 16px;
        max-height: 16px;
        font-size: 0.625rem;
        padding: 0 2px;
    }

    .calendar-event .event-compact {
        font-size: 0.625rem;
    }

    .calendar-event .event-multiday-dates {
        display: none;
    }

    .calendar-week-row {
        min-height: 60px;
    }

    .week-view .calendar-day {
        min-height: 150px;
    }

    .calendar-weekday {
        padding: 0.25rem 0.125rem;
        font-size: 0.75rem;
    }

    /* Week view day headers */
    .calendar-day-header {
        padding: 0.25rem 0.125rem;
    }

    .calendar-day-name {
        font-size: 0.75rem;
        margin-bottom: 0.125rem;
    }

    .calendar-day-number {
        font-size: 0.875rem;
    }
}

/* Smooth transitions */
.custom-calendar * {
    transition: background-color 0.2s ease, color 0.2s ease;
}

/* ============================================
   Resource Timeline Styles - Bootstrap 5 Theme Compatible
   ============================================ */

.resource-timeline {
    width: 100%;
    overflow: hidden;
    position: relative;
}

.timeline-header-row {
    display: flex;
    background: var(--bs-secondary-bg);
    border-bottom: 2px solid var(--bs-border-color);
    position: sticky;
    top: 0;
    z-index: 100;
    min-width: max-content;
}

.timeline-airplane-header {
    width: 100px;
    font-style: italic;
    background: var(--bs-secondary-bg);
    opacity: 80%;
    position: sticky;
    left: 0;
    z-index: 101;
    display: flex;
    justify-content: end;
    color: var(--bs-info);
}

.timeline-grid-container {
    overflow-x: auto;
    overflow-y: visible;
    position: relative;
    max-height: none;
    min-height: auto;
    max-width: 100%;
    background: var(--bs-body-bg);
    user-select: none; /*Prevent text selection during drag */
    cursor: grab;
}

.timeline-grid {
    display: flex;
    flex-direction: column;
    min-width: max-content;
}

/* Header section with date and hour labels */
.timeline-header {
    display: flex;
    background: var(--bs-secondary-bg);
    border-bottom: 2px solid var(--bs-border-color);
    position: sticky;
    top: 0;
    z-index: 100;
}

/* Hours track container for positioning hour labels */
.timeline-hours-track {
    position: relative;
    height: 3em;
    background-color: var(--bs-secondary-bg);
    /* Grid lines for hour track */
    background-image:
        /* Hour boundaries every 80px */
        repeating-linear-gradient(to right,
            rgba(128,128,128,0.5) 0px,
            rgba(128,128,128,0.5) 1px,
            transparent 1px,
            transparent 80px);
    background-position: calc(var(--grid-offset, 0px) * -1) 0;
    background-size: 80px 100%;
    background-repeat: repeat;
}

/* Individual hour labels */
.timeline-hour-label {
    position: absolute;
    top: 50%;
    transform: translate(-50%, -50%);
    font-size: 0.8em;
    font-weight: 700;
    color: var(--bs-emphasis-color);
    white-space: nowrap;
    background: var(--bs-secondary-bg);
    padding: 0 4px;
}

/* Airplane row container */
.timeline-airplane-row {
    display: flex;
    border-bottom: 1px solid var(--bs-border-color);
}

.timeline-airplane-label {
    position: sticky;
    left: 0;
    width: 100px;
    min-width: 100px;
    background: var(--bs-secondary-bg);
    border-right: 2px solid var(--bs-border-color);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 50;
    color: var(--bs-emphasis-color);
    min-height: 50px;
}

.airplane-tailno {
    font-weight: bold;
    color: var(--bs-emphasis-color);
    font-size: 1.1em;
}

/* Single lane div per airplane - replaces many slot divs */
.timeline-lane {
    position: relative;
    min-height: 50px;
    background-color: var(--bs-body-bg);
    /* Grid lines via CSS gradients - hour/half-hour/15-min marks */
    background-image:
        /* Hour boundaries every 80px */
        repeating-linear-gradient(to right,
            rgba(128,128,128,0.6) 0px,
            rgba(128,128,128,0.6) 1px,
            transparent 1px,
            transparent 80px),
        /* Half-hour every 40px */
        repeating-linear-gradient(to right,
            rgba(128,128,128,0.35) 0px,
            rgba(128,128,128,0.35) 1px,
            transparent 1px,
            transparent 40px),
        /* 15-min every 20px */
        repeating-linear-gradient(to right,
            rgba(128,128,128,0.2) 0px,
            rgba(128,128,128,0.2) 1px,
            transparent 1px,
            transparent 20px);
    /* Offset grid lines based on timeline start time */
    background-position:
        calc(var(--grid-offset, 0px) * -1) 0,
        calc(var(--grid-offset, 0px) * -1) 0,
        calc(var(--grid-offset, 0px) * -1) 0;
    background-size: 80px 100%, 40px 100%, 20px 100%;
    background-repeat: repeat;
}

/* Day boundary marker - positioned element at midnight */
.timeline-day-boundary {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 2px;
    background: var(--bs-emphasis-color);
    z-index: 5;
    pointer-events: none;
    opacity: 0.7;
}

/* Current time marker - vertical line */
.timeline-current-marker {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 2px;
    background: var(--bs-warning);
    z-index: 10;
    pointer-events: none;
    opacity: 0.7;
}

/* Timeline events use .calendar-event.positioned from calendar styles above */

.timeline-loading {
    padding: 40px;
    text-align: center;
    color: var(--bs-secondary-color);
}

.timeline-error {
    padding: 20px;
}

/* Scrollbar styling */
.timeline-grid-container::-webkit-scrollbar {
    height: 10px;
}

.timeline-grid-container::-webkit-scrollbar-track {
    background: var(--bs-secondary-bg);
}

.timeline-grid-container::-webkit-scrollbar-thumb {
    background: var(--bs-secondary);
    border-radius: 5px;
}

.timeline-grid-container::-webkit-scrollbar-thumb:hover {
    background: var(--bs-secondary-color);
}

/* Drag scroll active state */
.timeline-grid-container.active {
    cursor: grabbing !important;
}
