/* Service Log Calendar & Kanban — v7 */

.nav-tabs-container .nav-tabs .nav-link {
    color: #495057;
    border: none;
    border-bottom: 2px solid transparent;
    padding: 0.65rem 1rem;
    font-weight: 500;
}

.nav-tabs-container .nav-tabs .nav-link:hover {
    color: #0d6efd;
    border-color: transparent;
}

.nav-tabs-container .nav-tabs .nav-link.active {
    color: #0d6efd;
    background: transparent;
    border-bottom-color: #0d6efd;
}

/* Calendar shell (workforce-calendar aligned) */
.sl-calendar-container {
    background: #fff;
    border-radius: 8px;
    padding: 1rem;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    overflow-x: auto;
    overflow-y: visible;
}

.sl-calendar-header {
    margin-bottom: 1rem;
}

.sl-calendar-navigation {
    display: flex;
    align-items: center;
}

.sl-calendar-grid {
    display: flex;
    flex-direction: column;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    overflow: visible;
}

.sl-calendar-week-header {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    gap: 1px;
    background: #dee2e6;
    border: 1px solid #dee2e6;
    border-radius: 4px 4px 0 0;
    width: 100%;
    min-width: 0;
}

.sl-calendar-day-header {
    background: #f8f9fa;
    padding: 0.75rem 0.25rem;
    text-align: center;
    font-weight: 600;
    font-size: 0.9rem;
    color: #495057;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.sl-calendar-day-header.weekend {
    background: #fff0f0;
    color: #dc3545;
}

.sl-calendar-week {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    gap: 1px;
    background: #dee2e6;
    border-left: 1px solid #dee2e6;
    border-right: 1px solid #dee2e6;
    width: 100%;
    min-width: 0;
    overflow: visible; /* Allow spanning ticket bars to extend across days */
}

.sl-calendar-week:last-child {
    border-bottom: 1px solid #dee2e6;
    border-radius: 0 0 4px 4px;
}

.sl-calendar-day {
    background: #fff;
    min-height: 140px;
    min-width: 0; /* Critical: allow 1fr columns to shrink without blowing the grid */
    max-width: 100%;
    padding: 0.4rem;
    display: flex;
    flex-direction: column;
    position: relative;
    border-bottom: 1px solid #dee2e6;
    overflow: visible; /* Allow spanning ticket bars to extend beyond cell */
    box-sizing: border-box;
}

.sl-calendar-day:hover {
    background: #f8f9fa;
}

.sl-calendar-day.other-month {
    background: #f8f9fa;
    color: #adb5bd;
}

/* Outline keeps today highlight without changing cell box size */
.sl-calendar-day.today {
    background: #e7f3ff;
    box-shadow: inset 0 0 0 2px #0d6efd;
    z-index: 1;
}

.sl-calendar-day.weekend,
.sl-calendar-day.bank-holiday {
    background: #fff0f0;
}

.sl-calendar-day.weekend .sl-calendar-day-number,
.sl-calendar-day.bank-holiday .sl-calendar-day-number {
    color: #dc3545;
}

.sl-calendar-day-number {
    font-weight: 600;
    font-size: 0.85rem;
    margin-bottom: 0.25rem;
    color: #495057;
    display: flex;
    align-items: center;
    gap: 0.25rem;
    flex-wrap: wrap;
    line-height: 1.3;
    min-width: 0;
    max-width: 100%;
}

.sl-bank-holiday-title {
    font-weight: 400;
    font-size: 0.65rem;
    color: #dc3545;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
    min-width: 0;
}

.sl-calendar-day-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    overflow: visible;
    min-width: 0;
    min-height: 0;
    position: relative;
    width: 100%;
}

.sl-cal-span-track {
    position: relative;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    flex-shrink: 0;
    overflow: visible;
}

.sl-cal-day-chips {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    min-width: 0;
    width: 100%;
    max-width: 100%;
}

/* Summarized ticket chip on calendar */
.sl-cal-ticket {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.2rem 0.3rem;
    border-radius: 4px;
    font-size: 0.68rem;
    line-height: 1.2;
    cursor: pointer;
    border: none;
    background: #f1f3f5;
    color: #212529;
    min-width: 0;
    width: 100%;
    max-width: 100%;
    height: 22px;
    box-sizing: border-box;
    overflow: hidden;
}

/* Continuous multi-day bar (workforce leave-mode style) */
.sl-cal-ticket.sl-cal-ticket-spanning {
    position: absolute;
    left: 0;
    z-index: 5;
    width: auto;
    max-width: none; /* Width is set in JS from live cell geometry */
    justify-content: flex-start;
    white-space: nowrap;
    overflow: hidden;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.12);
    border-radius: 11px;
    padding-left: 0.4rem;
    padding-right: 0.5rem;
    pointer-events: auto;
}

.sl-cal-ticket:hover {
    filter: brightness(0.97);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.12);
}

.sl-cal-ticket .sl-cal-user-badge {
    flex-shrink: 0;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.55rem;
    font-weight: 700;
    color: #fff;
}

.sl-cal-ticket .sl-cal-mid-badge {
    flex-shrink: 0;
    background: rgba(0, 0, 0, 0.08);
    border-radius: 3px;
    padding: 0 3px;
    font-weight: 600;
    font-size: 0.62rem;
}

.sl-cal-ticket .sl-cal-ticket-text {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Align chip colours with table row colours */
.sl-cal-ticket.service-log-row-expired {
    background: #ffeaea;
}

.sl-cal-ticket.service-log-row-pending {
    background: #fffaca;
}

.sl-cal-ticket.service-log-row-expired.service-log-row-priority-low {
    background: #ffe0e0;
}

.sl-cal-ticket.service-log-row-expired.service-log-row-priority-medium {
    background: #ffcccc;
}

.sl-cal-ticket.service-log-row-expired.service-log-row-priority-high {
    background: #ffb3b3;
}

.sl-cal-ticket.service-log-row-expired.service-log-row-priority-critical {
    background: #ff9999;
}

.sl-cal-ticket.service-log-row-pending.service-log-row-priority-low {
    background: #fff8d6;
}

.sl-cal-ticket.service-log-row-pending.service-log-row-priority-medium {
    background: #fff3b0;
}

.sl-cal-ticket.service-log-row-pending.service-log-row-priority-high {
    background: #ffe066;
}

.sl-cal-ticket.service-log-row-pending.service-log-row-priority-critical {
    background: #ffd43b;
}

.sl-cal-ticket.sl-cal-active-work {
    background: #e8f5e9;
}

.sl-cal-ticket.sl-cal-active-work.service-log-row-priority-low {
    background: #e8f5e9;
}

.sl-cal-ticket.sl-cal-active-work.service-log-row-priority-medium {
    background: #fff8e1;
}

.sl-cal-ticket.sl-cal-active-work.service-log-row-priority-high {
    background: #fdecea;
}

.sl-cal-ticket.sl-cal-active-work.service-log-row-priority-critical {
    background: #f8d7da;
}

/* Kanban */
.sl-kanban-board {
    display: grid;
    grid-template-columns: repeat(5, minmax(200px, 1fr));
    gap: 0.75rem;
    overflow-x: auto;
    align-items: start;
}

.sl-kanban-lane {
    background: #f1f3f5;
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    min-height: 120px;
    height: auto;
    transition: box-shadow 0.15s ease, background-color 0.15s ease;
}

.sl-kanban-lane.sl-kanban-drop-target {
    background: #e7f1ff;
    box-shadow: inset 0 0 0 2px #0d6efd;
}

.sl-kanban-lane-header {
    padding: 0.75rem 0.9rem;
    font-weight: 700;
    font-size: 0.9rem;
    border-bottom: 1px solid #dee2e6;
    background: #e9ecef;
    border-radius: 8px 8px 0 0;
}

.sl-kanban-lane-body {
    padding: 0.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    overflow: visible;
}

.sl-kanban-card {
    background: #fff;
    border-radius: 6px;
    padding: 0.55rem 0.65rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
    cursor: grab;
    border-left: 4px solid #adb5bd;
    transition: box-shadow 0.15s ease, transform 0.15s ease, opacity 0.15s ease;
    user-select: none;
    -webkit-user-select: none;
    touch-action: none; /* Allow pointer drag without page scroll stealing the gesture */
    display: flex;
    align-items: flex-start;
    gap: 0.4rem;
}

.sl-kanban-card:hover {
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.14);
    transform: translateY(-1px);
}

.sl-kanban-card:active,
body.sl-kanban-drag-active {
    cursor: grabbing;
}

.sl-kanban-card.sl-kanban-dragging {
    opacity: 0.35;
}

.sl-kanban-drag-hint {
    color: #adb5bd;
    font-size: 0.85rem;
    line-height: 1.2;
    padding-top: 0.15rem;
    flex-shrink: 0;
    cursor: grab;
}

.sl-kanban-card-body {
    min-width: 0;
    flex: 1;
}

.sl-kanban-drag-ghost {
    position: fixed;
    z-index: 2000;
    margin: 0;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.2);
    opacity: 0.95;
    pointer-events: none;
    transform: rotate(1.5deg);
}

.sl-kanban-card.priority-low {
    background: #d4edda;
    border-left-color: #28a745;
}

.sl-kanban-card.priority-medium {
    background: #fff3cd;
    border-left-color: #ffc107;
}

.sl-kanban-card.priority-high {
    background: #f8d7da;
    border-left-color: #dc3545;
}

.sl-kanban-card.priority-critical {
    background: #f5c6cb;
    border-left-color: #721c24;
}

.sl-kanban-card-title {
    font-weight: 600;
    font-size: 0.85rem;
    margin-bottom: 0.4rem;
    line-height: 1.3;
    word-break: break-word;
}

.sl-kanban-card-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0.3rem;
    margin-bottom: 0.35rem;
    align-items: center;
}

.sl-kanban-user-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.2rem;
    background: rgba(0, 0, 0, 0.08);
    border-radius: 10px;
    padding: 0.1rem 0.4rem;
    font-size: 0.68rem;
    font-weight: 600;
}

.sl-kanban-card-due {
    font-size: 0.72rem;
    color: #495057;
}

.sl-kanban-card-due.overdue {
    color: #dc3545;
    font-weight: 600;
}

.sl-kanban-empty {
    color: #adb5bd;
    font-size: 0.8rem;
    text-align: center;
    padding: 1rem 0.5rem;
}

@media (max-width: 1200px) {
    .sl-calendar-day {
        min-height: 120px;
        padding: 0.3rem;
    }

    .sl-cal-ticket {
        font-size: 0.62rem;
        padding: 0.15rem 0.25rem;
        gap: 0.15rem;
    }

    .sl-cal-ticket .sl-cal-user-badge {
        width: 16px;
        height: 16px;
        font-size: 0.5rem;
    }

    .sl-cal-ticket:not(.sl-cal-ticket-spanning) .sl-cal-mid-badge {
        display: none;
    }
}

@media (max-width: 992px) {
    .sl-kanban-board {
        grid-template-columns: repeat(2, minmax(220px, 1fr));
    }

    .sl-calendar-container {
        padding: 0.5rem;
    }

    .sl-calendar-day {
        min-height: 110px;
        padding: 0.25rem;
    }

    .sl-calendar-day-header {
        padding: 0.5rem 0.15rem;
        font-size: 0.75rem;
    }

    .sl-calendar-day-number {
        font-size: 0.75rem;
    }

    .sl-bank-holiday-title {
        font-size: 0.55rem;
        display: block;
        width: 100%;
    }

    .sl-cal-ticket:not(.sl-cal-ticket-spanning) .sl-cal-ticket-text {
        display: none;
    }

    .sl-cal-ticket:not(.sl-cal-ticket-spanning) {
        width: auto;
        max-width: 100%;
        justify-content: center;
        padding: 0.15rem;
    }
}

@media (max-width: 576px) {
    .sl-kanban-board {
        grid-template-columns: 1fr;
    }

    .sl-calendar-day-header {
        padding: 0.35rem 0.1rem;
        font-size: 0.65rem;
    }

    .sl-calendar-day {
        min-height: 90px;
        padding: 0.2rem;
    }

    .sl-cal-ticket.sl-cal-ticket-spanning .sl-cal-mid-badge {
        display: none;
    }
}
