/* Global checklist visual helpers */
.checklist-cell {
    position: relative;
}

.checklist-text {
    cursor: pointer;
}

.checklist-new-badge {
    position: absolute;
    top: 4px;
    right: 4px;
    font-size: 0.65rem;
    text-transform: uppercase;
}

.checklist-cell-highlight {
    animation: checklistPulse 1.5s ease;
    box-shadow: 0 0 0 2px rgba(255, 193, 7, 0.7) inset;
}

@keyframes checklistPulse {
    0% {
        box-shadow: 0 0 0 0 rgba(255, 193, 7, 0.7) inset;
    }
    100% {
        box-shadow: 0 0 0 8px rgba(255, 193, 7, 0) inset;
    }
}

body:not(.checklist-meta-visible) .checklist-meta {
    display: none !important;
}

#checklist-sortable .handle {
    cursor: grab;
}

#toast-container.toast-top-right {
    top: 70px;
    right: 20px;
}

/* Toast styling overrides */
.toast-info,
.toast-info .toast-message,
.toast-info .toast-title {
    color: #f9fafb;
}

.toast-info {
    background-color: #0d8cad;
    box-shadow: 0 10px 25px rgba(15, 18, 38, 0.2);
}

.toast-info .toast-message {
    font-size: 0.95rem;
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.toast-info .toast-message strong {
    color: #fff;
}

.toast-info .toast-assignment {
    display: block;
    margin-top: 0.2rem;
    color: #fff;
    font-weight: 600;
}

.toast-info .toast-assignment-state {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    margin-top: 0.1rem;
    color: rgba(255, 255, 255, 0.95);
    font-size: 0.9rem;
}

.toast-info .toast-assignment-state i {
    font-size: 1rem;
}

.toast-info .toast-action {
    display: flex;
    justify-content: flex-end;
    margin-top: 0.25rem;
}

.toast-info .toast-link {
    font-weight: 600;
    color: #0f172a;
    background-color: #fff;
    border: none;
    padding: 0.3rem 0.9rem;
    border-radius: 999px;
    cursor: pointer;
    transition: background-color 0.2s ease, color 0.2s ease;
}

.toast-info .toast-link:hover {
    color: #0d8cad;
    background-color: #f4f4f5;
    text-decoration: none;
}

.toast-info .toast-close-button {
    color: rgba(255, 255, 255, 0.8);
}

.toast-info .toast-progress {
    background-color: rgba(255, 255, 255, 0.6);
}

.select2-results__option[aria-disabled=true] {
    background-color: #f1f1f1 !important;
    color: #a0a0a0 !important;
    cursor: not-allowed;
}

.card.card-full-height {
    min-height: calc(100vh - 20px);
    max-height: calc(100vh - 20px);
    display: flex;
    flex-direction: column;
}

.card.card-full-height .card-body {
    flex: 1 1 auto;
    overflow: auto;
}

.compressor-due-cell {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.15rem;
    line-height: 1.2;
}

.compressor-due-cell .badge {
    font-size: 0.85rem;
    padding: 0.35rem 0.6rem;
}

.compressor-due-meta {
    font-size: 0.8rem;
    color: #6c757d;
}

.table-danger .compressor-due-meta {
    color: #3a3a3a;
}

.issue-part-row--flash {
    animation: issuePartFlash 1.2s ease-out;
    background-color: #fff8dc;
    box-shadow: 0 0 0 2px rgba(255, 174, 0, 0.35);
}

@keyframes issuePartFlash {
    0% {
        background-color: #ffe9a3;
        box-shadow: 0 0 0 0 rgba(255, 174, 0, 0.65);
    }
    100% {
        background-color: transparent;
        box-shadow: 0 0 0 18px rgba(255, 174, 0, 0);
    }
}

.open-issue-new {
    background-color: rgba(16, 185, 129, 0.08);
    border-left: 3px solid #10b981;
    transition: box-shadow 0.2s ease;
    animation: openIssuePulse 0.9s ease;
}

.open-issue-new-badge {
    font-size: 0.6rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-left: 0.4rem;
}

@keyframes openIssuePulse {
    0% {
        box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.45);
    }
    100% {
        box-shadow: 0 0 0 6px rgba(16, 185, 129, 0);
    }
}

.suggestion-wrapper {
    position: relative;
}

.suggestion-wrapper .suggestion-list {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    z-index: 2000;
    max-height: 260px;
    overflow-y: auto;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.parts-sort-icon {
    font-size: 0.8rem;
    transition: color 0.2s ease;
}

.card-max-page {
    max-height: 85vh;
}

.issue-description-cell {
    max-width: 420px;
}

.issue-description-text {
    white-space: normal !important;
    overflow: hidden;
    display: block;
    line-height: 1.35;
    max-height: calc(1.35em * 3);
}

.issue-description-title {
    display: block;
    font-weight: 600;
    margin-bottom: 0.15rem;
}

.issue-description-body {
    display: block;
    color: #6c757d;
}

.issues-plant-pill-group .issues-plant-toggle {
    margin-right: 0.5rem;
    margin-bottom: 0.5rem;
}

/* Keep sidebar nav-header spacing when collapsed so icons don't jump. */
@media (min-width: 992px) {
    .sidebar-mini.sidebar-collapse .nav-sidebar .nav-header {
        display: block !important;
        visibility: hidden;
        height: auto;
        padding: 0.5rem 0.75rem;
        pointer-events: none;
    }

    .sidebar-mini.sidebar-collapse .main-sidebar:hover .nav-sidebar .nav-header {
        visibility: visible;
    }
}

/* Keep dashboard card/table headers visually compact and consistent. */
#project-performance-card .card-header {
    padding-top: 0.5rem;
    padding-bottom: 0.5rem;
}

#project-performance-card .table-sm thead th {
    padding-top: 0.4rem;
    padding-bottom: 0.4rem;
}

.maintenance-due-card .table-sm thead th {
    padding-top: 0.4rem;
    padding-bottom: 0.4rem;
}

/* Prevent sidebar labels from wrapping; clip with ellipsis on expand. */
.nav-sidebar .nav-link p {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
}

@media (max-width: 991.98px) {
    [data-widget="fullscreen"] {
        display: none !important;
    }
}

.avatar-group {
    display: flex;
    align-items: center;
    flex-wrap: nowrap;
}

.avatar-group .avatar-item {
    display: inline-flex;
    width: 28px;
    height: 28px;
    align-items: center;
    justify-content: center;
    border-radius: 999px;
    border: 2px solid #fff;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.12);
}

.avatar-group .avatar-item + .avatar-item {
    margin-left: -12px;
}

.avatar-group .avatar-item img,
.avatar-group .avatar-list-img {
    width: 28px;
    height: 28px;
    border-radius: 999px;
    object-fit: cover;
    display: block;
}

.avatar-group .avatar-item {
    position: relative;
    z-index: 1;
}

.avatar-group .avatar-item:hover {
    z-index: 3;
}

.avatar-group .avatar-more {
    margin-left: -12px;
    position: relative;
    z-index: 1;
    display: inline-flex;
}

.avatar-group .avatar-more:hover {
    z-index: 3;
}

.avatar-group .avatar-more-btn {
    width: 28px;
    height: 28px;
    padding: 0;
    background: #f8f9fa;
    color: #6c757d;
    font-size: 0.75rem;
    font-weight: 600;
    border: 2px solid #fff;
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.12);
}

.avatar-group .avatar-more-btn:hover {
    opacity: 0.85;
}

.avatar-group .avatar-more-btn::after {
    display: none !important;
}

@media (hover: hover) {
    .avatar-group .avatar-more:hover > .dropdown-menu {
        display: block;
    }
}

.avatar-group .avatar-list-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 6px;
}

.avatar-group .avatar-list-name {
    font-size: 0.875rem;
}

@media (min-width: 992px) {
    .sidebar-mini.sidebar-collapse .main-sidebar:hover .nav-sidebar .nav-link p {
        overflow: visible;
        text-overflow: clip;
        max-width: none;
        visibility: visible;
        opacity: 1;
    }
}

#checklist-sortable .checklist-handle {
    cursor: grab;
    touch-action: none;
    width: 40px;
    min-width: 40px;
    vertical-align: middle;
}

#checklist-sortable .checklist-handle .handle {
    display: inline-block;
    padding: 0.5rem 0;
}

.checklist-actions {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 0.5rem;
    white-space: nowrap;
}

@supports (-webkit-line-clamp: 1) {
    .issue-description-text {
        display: -webkit-box;
        -webkit-box-orient: vertical;
        -webkit-line-clamp: 3;
        max-height: none;
    }
}

@media (max-width: 576px) {
    .issue-description-text {
        max-height: calc(1.35em * 2);
    }
}

@supports (-webkit-line-clamp: 1) {
    @media (max-width: 576px) {
        .issue-description-text {
            -webkit-line-clamp: 2;
        }
    }
}
/* Hide footer link for the project users navbar dropdown unless enabled. */
#project-users-navbar .dropdown-footer {
    display: none;
}
body.navbar-users-footer-enabled #project-users-navbar .dropdown-footer {
    display: block;
}

/* Keep KPI icons visible on mobile for AdminLTE small-box cards. */
@media (max-width: 767.98px) {
    .small-box {
        text-align: center;
    }

    .small-box > .inner {
        padding-left: 3.75rem;
        padding-right: 3.75rem;
    }

    .small-box .icon {
        display: block !important;
        right: 0.75rem;
        top: 0.5rem;
    }

    .small-box .icon > i {
        font-size: 52px;
        top: 14px;
    }
}

/* Mobile/PWA: keep top navbar fixed and reserve room for Safari-style history bar. */
@media (max-width: 991.98px) {
    :root {
        --app-mobile-header-offset: calc(56px + env(safe-area-inset-top, 0px));
    }

    .main-header.navbar {
        position: fixed !important;
        top: 0 !important;
        left: 0 !important;
        right: 0 !important;
        z-index: 1045 !important;
        background-color: #fff !important;
        border-bottom: 1px solid rgba(17, 24, 39, 0.1) !important;
        padding-top: env(safe-area-inset-top, 0px) !important;
    }

    body:not(.layout-top-nav) .content-wrapper {
        margin-top: var(--app-mobile-header-offset) !important;
        padding-bottom: calc(18px + env(safe-area-inset-bottom, 0px)) !important;
    }

    body:not(.layout-top-nav) .content {
        padding-bottom: calc(8px + env(safe-area-inset-bottom, 0px)) !important;
    }

    body.mobile-history-nav-enabled {
        padding-bottom: 0 !important;
    }

    body.mobile-history-nav-enabled .content-wrapper {
        padding-bottom: calc(76px + env(safe-area-inset-bottom, 0px)) !important;
    }

    body.mobile-history-nav-enabled .content {
        padding-bottom: calc(18px + env(safe-area-inset-bottom, 0px)) !important;
    }

    body.mobile-history-nav-enabled .main-footer {
        margin-bottom: calc(68px + env(safe-area-inset-bottom, 0px)) !important;
    }

    #mobile-history-nav {
        position: fixed;
        left: 0;
        right: 0;
        bottom: 0;
        z-index: 1050;
        pointer-events: auto;
        background: #fff;
        border-top: 1px solid rgba(15, 23, 42, 0.12);
        border-top-left-radius: 18px;
        border-top-right-radius: 18px;
        box-shadow: 0 -6px 18px rgba(15, 23, 42, 0.08);
        padding: 6px 10px calc(6px + env(safe-area-inset-bottom, 0px));
    }

    #mobile-history-nav .pwa-bottom-shell {
        display: grid;
        grid-template-columns: minmax(88px, 1fr) auto minmax(88px, 1fr);
        align-items: center;
        gap: 8px;
        min-height: 52px;
    }

    #mobile-history-nav .pwa-bottom-left,
    #mobile-history-nav .pwa-bottom-center,
    #mobile-history-nav .pwa-bottom-right {
        display: flex;
        align-items: center;
    }

    #mobile-history-nav .pwa-bottom-left {
        justify-content: flex-start;
    }

    #mobile-history-nav .pwa-bottom-center {
        justify-content: center;
    }

    #mobile-history-nav .pwa-bottom-right {
        justify-content: flex-end;
    }

    #mobile-history-nav .pwa-nav-group {
        display: inline-flex;
        align-items: center;
        height: 36px;
        border-radius: 12px;
        border: 1px solid rgba(15, 23, 42, 0.14);
        background: #f8fafc;
        overflow: hidden;
    }

    #mobile-history-nav .pwa-nav-btn {
        width: 42px;
        height: 36px;
        border: 0;
        background: transparent;
        color: #1f2937;
        font-size: 16px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        transition: opacity 0.18s ease;
    }

    #mobile-history-nav .pwa-nav-divider {
        width: 1px;
        height: 22px;
        background: rgba(15, 23, 42, 0.18);
        display: block;
    }

    #mobile-history-nav .pwa-home-btn {
        width: 42px;
        height: 42px;
        border-radius: 999px;
        border: 1px solid rgba(15, 23, 42, 0.16);
        background: #fff;
        color: #0f172a;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        font-size: 17px;
        box-shadow: 0 2px 6px rgba(15, 23, 42, 0.08);
    }

    #mobile-history-nav .pwa-quick-issue-btn {
        width: 42px;
        height: 42px;
        border-radius: 999px;
        border: 1px solid rgba(22, 163, 74, 0.28);
        background: #ecfdf3;
        color: #15803d;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        font-size: 17px;
    }

    #mobile-history-nav .pwa-bottom-placeholder {
        width: 42px;
        height: 42px;
        display: inline-block;
    }

    #mobile-history-nav button:focus {
        outline: 2px solid rgba(59, 130, 246, 0.6);
        outline-offset: 1px;
    }
}
