/* Explain: Global styles for layout and responsive design, including staff portal elements and print optimizations. */
.process-line {
    position: relative;
}

@media (min-width: 1024px) {
    .process-line::before {
        content: "";
        position: absolute;
        left: 8%;
        right: 8%;
        top: 3.5rem;
        height: 1px;
        background: linear-gradient(90deg, transparent, color-mix(in srgb, var(--yellow-color) 72%, transparent), transparent);
    }

    .process-line > article {
        z-index: 1;
    }
}

@media (max-width: 640px) {
    .hero-cinematic h1 {
        text-wrap: balance;
    }

    .service-card,
    .project-card,
    .timeline-card,
    .price-card {
        min-height: auto;
    }
}

/* Staff Portal Mobile Optimizations */
@media (min-width: 1024px) {
    aside.lg\:sticky details > nav {
        display: flex !important;
    }
    aside.lg\:sticky details::details-content {
        display: block !important;
    }
}

/* Portal Full-Screen Layout overrides */
body.portal-body {
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

body.portal-body > main#top,
body.portal-body section[id$="App"],
body.portal-body section[id$="App"] > div[id$="AppContent"],
body.portal-body > div#adminApp {
    min-height: 0;
    overflow: hidden;
    flex: 1;
}

body.portal-body section[id$="App"] > div[id$="AppContent"] > div.flex-1 {
    min-height: 0 !important;
    min-width: 0;
    align-items: stretch !important;
}

body.portal-body section[id$="App"] > div[id$="AppContent"] > div.flex-1 > main,
body.portal-body #adminAppContent {
    min-height: 0 !important;
    overflow-y: auto !important;
    overflow-x: hidden;
    min-width: 0;
}

@media (min-width: 1024px) {
    body.portal-body section[id$="App"] > div[id$="AppContent"] > div.flex-1 > aside {
        max-height: 100%;
        overflow-y: auto;
    }
}

/* Ensure horizontal scrolling for tables does not break page width */
body.portal-body .overflow-x-auto {
    max-width: 100%;
}

@media (max-width: 767px) {
    .md\:hidden.flex-wrap.gap-2 {
        flex-wrap: nowrap !important;
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        padding-bottom: 0.25rem !important;
    }
    .md\:hidden.flex-wrap.gap-2::-webkit-scrollbar {
        display: none;
    }
    .md\:hidden.flex-wrap.gap-2 > * {
        flex-shrink: 0 !important;
    }
}

@media print {
    body.portal-body {
        height: auto !important;
        overflow: visible !important;
        display: block !important;
        background: white !important;
    }
    body.portal-body > header,
    body.portal-body > footer,
    .print\:hidden {
        display: none !important;
    }
    body.portal-body > main#top {
        display: block !important;
        height: auto !important;
        overflow: visible !important;
    }
    body.portal-body section[id$="App"] {
        display: none !important;
    }
    dialog.modal[open] {
        position: absolute !important;
        top: 0 !important;
        left: 0 !important;
        right: auto !important;
        bottom: auto !important;
        display: block !important;
        width: 100% !important;
        height: auto !important;
        max-height: none !important;
        overflow: visible !important;
        background: white !important;
        padding: 0 !important;
        margin: 0 !important;
        border: none !important;
    }
    dialog.modal[open] .modal-box {
        width: 100% !important;
        max-width: none !important;
        height: auto !important;
        max-height: none !important;
        overflow: visible !important;
        box-shadow: none !important;
        padding: 0 !important;
        margin: 0 !important;
        background: white !important;
        transform: none !important;
    }
    dialog.modal[open] .overflow-auto,
    dialog.modal[open] .overflow-y-auto {
        overflow: visible !important;
        height: auto !important;
        max-height: none !important;
        display: block !important;
    }
    dialog.modal[open] .modal-box {
        display: block !important;
    }
    dialog.modal[open] .modal-box > div,
    dialog.modal[open] .modal-box > div > div {
        display: block !important;
        height: auto !important;
        max-height: none !important;
        overflow: visible !important;
    }
    dialog.modal[open] #quotePrintArea,
    dialog.modal[open] #costingPrintArea {
        display: block !important;
        min-height: 0 !important;
        width: 100% !important;
        max-width: none !important;
        margin: 0 !important;
        padding: 0 !important;
        border-radius: 0 !important;
        box-shadow: none !important;
    }
    dialog.modal[open] #quotePrintArea > div,
    dialog.modal[open] #costingPrintArea > div {
        break-inside: auto;
        page-break-inside: auto;
    }
    dialog.modal[open] #quotePrintArea,
    dialog.modal[open] #quotePrintArea > div {
        display: block !important;
    }
    #quotePrintArea .quote-page-break,
    dialog.modal[open] #quotePrintArea .quote-page-break {
        display: block !important;
        break-before: page !important;
        page-break-before: always !important;
        break-inside: auto !important;
        page-break-inside: auto !important;
        margin-top: 0 !important;
        padding-top: 0 !important;
        border-top: 0 !important;
    }
}

/* Mobile Staff Portal system switcher */
.portal-system-menu-button {
    display: inline-flex;
    min-height: 2.5rem;
    align-items: center;
    justify-content: center;
    gap: 0.45rem;
    border: 1px solid var(--border-color);
    border-radius: 9999px;
    background: var(--navy-color);
    color: var(--white-color);
    box-shadow: var(--shadow-card);
    font-size: 0.75rem;
    font-weight: 800;
    line-height: 1;
    padding: 0.55rem 0.85rem;
    white-space: nowrap;
    position: relative;
    z-index: 130;
}

.portal-system-menu-button .portal-system-current {
    display: inline-flex;
    min-width: 2.25rem;
    align-items: center;
    justify-content: center;
    border-radius: 9999px;
    background: var(--yellow-color);
    color: var(--navy-color);
    padding: 0.2rem 0.45rem;
    font-size: 0.68rem;
    font-weight: 900;
}

.portal-system-menu-overlay {
    position: fixed;
    inset: 0;
    z-index: 100000;
    display: flex;
    align-items: flex-start;
    justify-content: flex-end;
    background: rgba(0, 62, 50, 0.34);
    backdrop-filter: blur(6px);
    padding: 0.75rem;
}

.portal-system-menu-overlay.hidden {
    display: none !important;
}

.portal-system-menu-panel {
    width: min(100%, 24rem);
    max-height: calc(100dvh - 1.5rem);
    overflow: hidden;
    border: 1px solid var(--border-color);
    border-radius: 1.5rem;
    background: var(--white-color);
    box-shadow: 0 30px 90px rgba(0, 0, 0, 0.28);
    display: flex;
    flex-direction: column;
}

.portal-system-menu-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    border-bottom: 1px solid var(--border-color);
    background: var(--pale-blue);
    padding: 1rem;
}

.portal-system-menu-head h2 {
    margin: 0;
    color: var(--navy-color);
    font-family: var(--font-heading);
    font-size: 1.15rem;
    font-weight: 900;
}

.portal-system-menu-kicker,
.portal-system-menu-subtitle {
    margin: 0;
    color: var(--text-muted);
    font-size: 0.68rem;
    font-weight: 700;
}

.portal-system-menu-kicker {
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.portal-system-menu-close {
    display: inline-flex;
    min-height: 2.5rem;
    min-width: 2.5rem;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--border-color);
    border-radius: 9999px;
    background: var(--white-color);
    color: var(--navy-color);
    cursor: pointer;
}

.portal-system-menu-list {
    display: grid;
    gap: 0.55rem;
    overflow-y: auto;
    padding: 0.85rem;
}

.portal-system-home-link,
.portal-system-menu-link {
    display: flex;
    min-height: 3rem;
    align-items: center;
    gap: 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: 1rem;
    background: var(--white-color);
    color: var(--navy-color);
    padding: 0.65rem 0.75rem;
    text-decoration: none;
    transition: border-color 180ms ease, background 180ms ease, transform 180ms ease;
}

.portal-system-home-link:hover,
.portal-system-menu-link:hover,
.portal-system-home-link:focus-visible,
.portal-system-menu-link:focus-visible {
    border-color: var(--yellow-color);
    background: var(--pale-blue);
    transform: translateY(-1px);
}

.portal-system-home-link {
    background: var(--navy-color);
    color: var(--white-color);
    font-size: 0.85rem;
    font-weight: 900;
}

.portal-system-menu-link.is-active {
    border-color: var(--yellow-color);
    background: var(--pale-blue);
    box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--yellow-color) 55%, transparent);
}

.portal-system-menu-link.is-active .portal-system-menu-icon {
    background: var(--yellow-color);
    color: var(--navy-color);
}

.portal-system-menu-icon {
    display: inline-flex;
    height: 2.1rem;
    width: 2.1rem;
    flex: 0 0 auto;
    align-items: center;
    justify-content: center;
    border-radius: 0.8rem;
    background: var(--pale-blue);
    color: var(--navy-color);
}

.portal-system-menu-link strong {
    display: block;
    color: var(--navy-color);
    font-size: 0.82rem;
    font-weight: 900;
}

.portal-system-menu-link small {
    display: block;
    color: var(--text-muted);
    font-size: 0.68rem;
    font-weight: 600;
    line-height: 1.25;
}

@media (min-width: 768px) {
    .portal-system-menu-button {
        display: none;
    }
}

@media (max-width: 767px) {
    body.portal-body [id$="AppContent"] > .mb-6,
    body.portal-body #adminAppContent > .grid:first-child {
        padding-right: 0;
    }

    body.portal-body .btnStaffLogout,
    body.portal-body a[href="staff-admin.html"].btn {
        min-height: 2.5rem;
        font-size: 0.68rem;
        padding-left: 0.7rem;
        padding-right: 0.7rem;
    }

    .portal-system-menu-button {
        flex-shrink: 0;
    }

    .portal-system-menu-text {
        display: none;
    }
}

@media (max-width: 360px) {
    .portal-system-menu-overlay {
        padding: 0.45rem;
    }

    .portal-system-menu-panel {
        max-height: calc(100dvh - 0.9rem);
        border-radius: 1.1rem;
    }

    .portal-system-menu-head {
        padding: 0.85rem;
    }

    .portal-system-menu-list {
        padding: 0.65rem;
    }

    .portal-system-home-link,
    .portal-system-menu-link {
        min-height: 2.75rem;
        padding: 0.55rem 0.65rem;
    }
}
