/**
 * ProCoor Pro — shared layout (main navigation + sticky top stack).
 * Include on every page: <link rel="stylesheet" href="css/site.css">
 */

/*
 * Nav / dropdown strategy:
 * - JS-enhanced menus: use aria-expanded, Escape, and outside-click dismiss (best for desktop + touch).
 * - Zero-JS alternative: <details>/<summary> for simple disclosure.
 * - Keep overflow: visible on .site-header__inner and .site-header__nav so dropdown panels are not clipped.
 */

:root {
    --page-top-sticky-h: 160px;
}

.page-top-sticky {
    position: sticky;
    top: 0;
    z-index: 50;
    background: #ffffff;
    box-shadow: 0 2px 10px rgba(28, 37, 48, 0.08);
}

.site-header {
    /* Design tokens — tweak once for global header chrome */
    --site-header-bg: #ececec;
    --site-header-border: #d5d5d5;
    --site-header-link: #333333;
    --site-header-link-active: #0b5eb4;
    --site-header-inner-pad-y: 10px;
    --site-header-inner-pad-x: 20px;
    --site-header-inner-pad-left: 34px;
    --site-header-inner-gap: 12px;
    --site-header-search-radius: 10px;
    --site-header-search-border: #b0b8c4;
    --site-header-search-focus-ring: rgba(37, 99, 235, 0.2);
    --site-header-z-base: 100;
    --site-header-z-dropdown: 1200;

    position: relative;
    z-index: var(--site-header-z-base);
    background: var(--site-header-bg);
    border-bottom: 1px solid var(--site-header-border);
}

.site-header__inner {
    display: flex;
    flex-wrap: nowrap;
    align-items: center;
    justify-content: space-between;
    gap: var(--site-header-inner-gap);
    max-width: 100%;
    padding: var(--site-header-inner-pad-y) var(--site-header-inner-pad-x) var(--site-header-inner-pad-y)
        var(--site-header-inner-pad-left);
    box-sizing: border-box;
    overflow: visible;
}

.site-header__brand {
    display: flex;
    align-items: center;
    text-decoration: none;
    line-height: 0;
}

.site-header__brand:focus-visible {
    outline: 2px solid #7eb8ff;
    outline-offset: 3px;
    border-radius: 4px;
}

.site-header__logo {
    display: block;
    height: 42px;
    width: auto;
    max-width: min(240px, 55vw);
    object-fit: contain;
}

.site-header__nav {
    display: flex;
    flex: 1 1 auto;
    justify-content: center;
    align-items: center;
    min-width: 0;
    margin: 0 10px;
    position: relative;
    z-index: 2;
    overflow: visible;
}

/* Global order search + Admin (right cluster after main nav) */
.site-header__search-admin {
    display: flex;
    flex-direction: row;
    flex-wrap: nowrap;
    align-items: center;
    gap: 12px;
    flex: 0 1 auto;
    min-width: 0;
    margin-left: auto;
    margin-right: 8px;
}

.site-header__global-search {
    margin: 0;
    flex: 0 1 auto;
    min-width: 0;
    max-width: 28ch;
}

.site-header__search-shell {
    /* Block layout: input is the only flex participant; submit is position:absolute inside */
    position: relative;
    display: block;
    width: 100%;
    max-width: 28ch;
    min-width: 12ch;
}

.site-header__search-input {
    box-sizing: border-box;
    display: block;
    width: 100%;
    height: 36px;
    padding: 6px 40px 6px 12px;
    border: 1px solid var(--site-header-search-border, #b0b8c4);
    border-radius: var(--site-header-search-radius, 10px);
    -webkit-border-radius: var(--site-header-search-radius, 10px);
    background: #fff;
    font-size: 14px;
    font-family: "Trebuchet MS", "Segoe UI", "Avenir Next", sans-serif;
    color: #1f2937;
    /* Normalize Safari / iOS search control so radii and borders match Chrome */
    appearance: none;
    -webkit-appearance: none;
    position: relative;
    z-index: 0;
}

.site-header__search-input::-webkit-search-decoration,
.site-header__search-input::-webkit-search-cancel-button,
.site-header__search-input::-webkit-search-results-button,
.site-header__search-input::-webkit-search-results-decoration {
    -webkit-appearance: none;
}

.site-header__search-input::placeholder {
    color: #6b7280;
}

.site-header__search-input:hover {
    border-color: #94a3b8;
}

.site-header__search-input:focus {
    outline: none;
    border-color: #2563eb;
    box-shadow: 0 0 0 2px var(--site-header-search-focus-ring, rgba(37, 99, 235, 0.2));
}

.site-header__search-submit {
    position: absolute;
    top: 50%;
    right: 4px;
    transform: translateY(-50%);
    z-index: 2;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    padding: 0;
    border: none;
    border-radius: 8px;
    background: transparent;
    color: #475569;
    cursor: pointer;
    margin: 0;
}

.site-header__search-submit:hover {
    background: #e2e8f0;
    color: #1e293b;
}

.site-header__search-submit:focus-visible {
    outline: 2px solid #2563eb;
    outline-offset: 2px;
}

.site-header__search-icon {
    display: block;
}

.site-header__admin-wrap {
    display: flex;
    align-items: center;
    flex: 0 0 auto;
    flex-shrink: 0;
}

.site-header__admin-link {
    white-space: nowrap;
}

.site-header__auth {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    flex: 0 0 auto;
    margin-left: auto;
    align-self: center;
    z-index: 3;
}

.site-header__signin-link {
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    height: 36px;
    min-height: 36px;
    padding: 0 16px;
    border-radius: 9999px !important;
    border: 2px solid #60a5fa !important;
    background: #dbeafe !important;
    color: #1d4ed8 !important;
    font-size: 14px;
    font-family: "Trebuchet MS", "Segoe UI", "Avenir Next", sans-serif;
    font-weight: 700;
    letter-spacing: 0.02em;
    text-decoration: none !important;
    box-shadow: 0 1px 4px rgba(29, 78, 216, 0.18);
    line-height: 1;
}

.site-header__signin-link:hover {
    border-color: #3b82f6 !important;
    color: #1e40af !important;
    background: #cfe1ff !important;
}

.site-header__signin-link:focus-visible {
    outline: 2px solid #2563eb;
    outline-offset: 2px;
}

.site-header__user-badge {
    width: 38px;
    height: 38px;
    min-width: 38px;
    min-height: 38px;
    border-radius: 50% !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    background: #dbeafe !important;
    color: #1d4ed8 !important;
    font-size: 12px;
    font-weight: 800;
    letter-spacing: 0.03em;
    text-decoration: none !important;
    border: 2px solid #60a5fa !important;
    box-shadow: 0 1px 4px rgba(29, 78, 216, 0.18);
    line-height: 1;
    box-sizing: border-box;
}

.site-header__user-badge:hover {
    background: #cfe1ff !important;
    border-color: #3b82f6 !important;
}

.site-header__user-badge:focus-visible {
    outline: 2px solid #2563eb;
    outline-offset: 2px;
}

.site-header__nav-list {
    display: flex;
    flex-wrap: nowrap;
    align-items: center;
    justify-content: center;
    gap: 18px;
    margin: 0;
    padding: 0;
    list-style: none;
    min-width: 0;
}

.site-header__link {
    display: inline-block;
    padding: 0;
    font-size: 14px;
    font-weight: 600;
    color: var(--site-header-link, #333333);
    text-decoration: none;
    transition: color 0.15s;
    white-space: nowrap;
}

.site-header__link:hover {
    color: var(--site-header-link-active, #0b5eb4);
    text-decoration: underline;
}

.site-header__link.is-active,
.site-header__link[aria-current="page"] {
    color: var(--site-header-link-active, #0b5eb4);
    text-decoration: underline;
}

.site-header__dropdown {
    position: relative;
}

.site-header__dropdown-toggle {
    position: relative;
    padding-right: 13px;
    border: 0;
    background: transparent;
    cursor: pointer;
    font-family: inherit;
    line-height: inherit;
    color: inherit;
}

.site-header__dropdown-toggle.site-header__link {
    vertical-align: baseline;
}

.site-header__dropdown-toggle::after {
    content: "▼";
    position: absolute;
    right: 0;
    top: 50%;
    transform: translateY(-48%);
    font-size: 9px;
    color: #4b5563;
    transition: transform 0.16s ease;
}

.site-header__dropdown:hover .site-header__dropdown-toggle::after,
.site-header__dropdown:focus-within .site-header__dropdown-toggle::after,
.site-header__dropdown.is-open .site-header__dropdown-toggle::after {
    transform: translateY(-48%) rotate(180deg);
}

.site-header__dropdown-menu {
    position: absolute;
    left: 0;
    top: calc(100% + 8px);
    min-width: 190px;
    background: #ffffff;
    border: 1px solid #d7e1ee;
    border-radius: 8px;
    box-shadow: 0 6px 18px rgba(15, 23, 42, 0.18);
    padding: 6px 0;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-8px);
    transition: opacity 0.16s ease, transform 0.16s ease, visibility 0.16s ease;
    z-index: var(--site-header-z-dropdown, 1200);
}

.site-header__dropdown:hover .site-header__dropdown-menu,
.site-header__dropdown:focus-within .site-header__dropdown-menu,
.site-header__dropdown.is-open .site-header__dropdown-menu {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.site-header__dropdown-item {
    display: block;
    padding: 8px 12px;
    color: #333333;
    text-decoration: none;
    font-size: 13px;
    font-weight: 500;
    white-space: nowrap;
}

.site-header__dropdown-item:hover {
    background: #f3f7fc;
    color: #0b5eb4;
    text-decoration: none;
}

.site-header__dropdown-item.is-active {
    color: #0b5eb4;
    background: #eef5ff;
    font-weight: 600;
}

/* Shared production filter tabs (departments + statuses) */
.tab-toolbar {
    background: #ffffff;
    padding: 8px 12px 0;
}

.tab-toolbar--with-aside {
    display: flex;
    align-items: stretch;
    gap: 10px 14px;
    padding-right: 12px;
    box-sizing: border-box;
}

.tab-toolbar--with-aside .tab-toolbar__tabs {
    flex: 1 1 auto;
    min-width: 0;
}

.tab-toolbar--with-aside .tab-toolbar__aside {
    flex: 0 0 auto;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    justify-content: flex-start;
    padding-top: 2px;
    padding-bottom: 6px;
}

.folder-rail {
    display: flex;
    align-items: flex-end;
    border-bottom: none;
    background: transparent;
    padding: 0 10px 0;
    border-radius: 0;
    margin-bottom: 6px;
}

.folder-rail--status {
    margin-bottom: 10px;
}

.folder-tabs {
    display: inline-flex;
    align-items: flex-end;
    gap: 2px;
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
    min-height: 34px;
    border-bottom: 2px solid #6b7f94;
}

.folder-tab {
    display: inline-block;
    padding: 10px 20px 9px;
    font-size: 13px;
    font-weight: 600;
    color: #2a3542;
    text-decoration: none;
    background: #9eb0c4;
    border: 1px solid #5d6f82;
    border-bottom: none;
    border-radius: 10px 10px 0 0;
    white-space: nowrap;
    position: relative;
    z-index: 1;
    margin-bottom: -2px;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.35);
    transition: background 0.12s, color 0.12s, box-shadow 0.12s;
}

.folder-tab:hover {
    background: #b6c4d4;
    color: #152028;
}

.folder-tab--active {
    background: #fff;
    color: #0d3d66;
    border-color: #5d6f82;
    z-index: 4;
    padding-bottom: 11px;
    margin-bottom: -4px;
    box-shadow: 0 -3px 10px rgba(0, 0, 0, 0.08), inset 0 1px 0 #fff;
}

.folder-tab--active:hover {
    background: #fff;
    color: #0d3d66;
}

.folder-rail--status .folder-tab {
    font-size: 12px;
    padding: 8px 16px 7px;
    border-radius: 8px 8px 0 0;
}

.folder-rail--status .folder-tabs {
    border-bottom-color: #5d6f82;
}

.folder-rail--status .folder-tab--active {
    padding-bottom: 9px;
    color: #1a4d2e;
}

@media (max-width: 1120px) {
    .site-header__inner {
        flex-wrap: wrap;
        justify-content: flex-start;
        gap: 10px 14px;
        overflow: visible;
    }
    .site-header__nav {
        order: 3;
        width: 100%;
        justify-content: flex-start;
        margin: 0;
        overflow: visible;
    }
    .site-header__nav-list {
        flex-wrap: wrap;
        justify-content: flex-start;
        gap: 12px 14px;
    }
    /* Dropdowns open downward; when nav wraps, panels stay above page content */
    .site-header__dropdown .site-header__dropdown-menu {
        max-width: min(100vw - 24px, 320px);
    }
    .site-header__search-admin {
        order: 2;
        margin-left: auto;
        margin-right: 0;
        /* Stay one row: search | Admin (do not grow to full width and stack) */
        flex: 0 1 auto;
        max-width: calc(100% - 16px);
        min-width: 0;
        justify-content: flex-end;
        flex-wrap: nowrap;
    }
    .site-header__auth {
        order: 2;
    }
    .site-header__search-shell {
        max-width: min(28ch, 100%);
    }
}

/* SMS inbox unread badge (Messages link in main nav). Inline style on #nav-sms-unread is primary (see site_nav.php). */
#nav-sms-unread.site-header__sms-badge,
.site-header__sms-badge {
    margin-left: 6px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
    min-width: 20px;
    height: 20px;
    padding: 0 6px;
    border-radius: 999px;
    background: #dc2626;
    background-color: #dc2626;
    color: #fff;
    -webkit-text-fill-color: #fff;
    font-size: 11px;
    font-weight: 700;
    line-height: 1;
    text-align: center;
    vertical-align: middle;
    box-shadow: 0 0 0 2px #ffffff;
    flex-shrink: 0;
    white-space: nowrap;
    text-decoration: none;
}

.site-header__sms-badge--empty,
#nav-sms-unread.site-header__sms-badge--empty {
    display: none !important;
}

/* SMS inbox live refresh: new bubble pulse + “scroll to new” pill */
.bubble--new {
    animation: smsBubbleFlash 1.2s ease-out 1;
}

@keyframes smsBubbleFlash {
    0% {
        box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.6);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(220, 38, 38, 0);
    }
}

.timeline-newpill {
    position: sticky;
    bottom: 6px;
    align-self: center;
    padding: 4px 10px;
    border-radius: 999px;
    background: #dc2626;
    color: #fff;
    font-size: 12px;
    cursor: pointer;
    z-index: 2;
}
