/* ===== RESPONSIVE HEADER STYLES (Facebook-inspired) ===== */

/* Mobile Search Button - Hidden on desktop */
.custom-mobile-search-btn {
    display: none;
    background: transparent;
    border: none;
    cursor: pointer;
    padding: var(--px-8);
    border-radius: 50%;
    width: var(--px-40);
    height: var(--px-40);
    align-items: center;
    justify-content: center;
}

    .custom-mobile-search-btn i {
        font-size: var(--px-20);
        color: var(--bs-text);
    }

    .custom-mobile-search-btn:hover {
        background-color: var(--bs-body-bg);
    }

/* Mobile Search Overlay (Facebook-style) */
.custom-mobile-search-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: var(--bs-surface-bg);
    z-index: 9999;
    display: none;
    flex-direction: column;
}

    .custom-mobile-search-overlay.active {
        display: flex;
    }

.custom-mobile-search-header {
    display: flex;
    align-items: center;
    padding: var(--px-8) var(--px-12);
    gap: var(--px-12);
    border-bottom: 1px solid var(--bs-border-color);
    background-color: var(--bs-surface-bg);
}

.custom-mobile-search-back {
    background: transparent;
    border: none;
    cursor: pointer;
    padding: var(--px-8);
    border-radius: 50%;
    width: var(--px-40);
    height: var(--px-40);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

    .custom-mobile-search-back i {
        font-size: var(--px-20);
        color: var(--bs-text);
    }

    .custom-mobile-search-back:hover {
        background-color: var(--bs-body-bg);
    }

.custom-mobile-search-input-wrapper {
    flex: 1;
    display: flex;
    align-items: center;
    background-color: var(--bs-body-bg);
    border-radius: var(--px-24);
    padding: var(--px-8) var(--px-16);
    gap: var(--px-8);
    height: var(--px-40);
}

    .custom-mobile-search-input-wrapper i {
        font-size: var(--px-16);
        color: var(--bs-text-muted);
    }

.custom-mobile-search-field {
    border: none;
    background: transparent;
    flex: 1;
    font: normal normal 400 var(--s-16);
    color: var(--bs-text);
    height: 100%;
}

    .custom-mobile-search-field:focus {
        outline: none;
    }

    .custom-mobile-search-field::placeholder {
        color: var(--bs-text-muted);
    }

/* Update right header container */
.custom-right-header {
    display: flex;
    align-items: center;
    gap: var(--px-8);
    z-index: 1;
}

.custom-profile-container {
    display: contents;
}

/* ===== RESPONSIVE BREAKPOINTS ===== */

/* Tablet and below (iPad and smaller) */
@media (max-width: 1024px) {
    .custom-header {
        padding: var(--px-8) var(--px-12);
    }

    .custom-nav-item {
        min-width: var(--px-80);
        margin: 0 var(--px-4);
    }

    .custom-nav-btn {
        font-size: var(--px-20);
    }

    .custom-search-container {
        max-width: 300px;
    }
}

/* Large mobile devices */
@media (max-width: 768px) {
    .custom-header {
        overflow-x: clip;
    }

    .custom-left-header {
        flex: 0 1 auto;
        min-width: 0;
    }

    .custom-nav {
        flex: 1 1 auto;
        min-width: 0;
    }

    .custom-nav-list {
        width: 100%;
        justify-content: center;
        overflow-x: auto;
        overflow-y: hidden;
        scrollbar-width: none;
    }

    .custom-nav-list::-webkit-scrollbar {
        display: none;
    }

    .custom-right-header {
        margin-left: 0;
        flex-shrink: 0;
    }

    /* Hide desktop search, show mobile search button */
    .custom-search-container {
        display: none;
    }

    .custom-mobile-search-btn {
        display: flex;
    }

    /* Adjust navigation */
    .custom-nav {
        position: relative;
        width: auto;
    }

    .custom-nav-list {
        gap: var(--px-4);
    }

    .custom-nav-item {
        min-width: var(--px-60);
        margin: 0;
    }

    .custom-nav-btn {
        height: var(--px-40);
        font-size: var(--px-18);
        padding: var(--px-4);
    }

    /* Adjust header spacing */
    .custom-left-header {
        gap: var(--px-8);
    }

    .custom-logo {
        height: 32px;
    }

    /* Profile avatar smaller */
    .custom-profile-avatar {
        width: 32px;
        height: 32px;
        font-size: 12px;
    }
}

/* Small mobile devices */
@media (max-width: 576px) {
    .custom-header {
        padding: 0 var(--px-8);
        max-height: var(--px-48);
    }

    .custom-left-header {
        gap: var(--px-4);
    }

    .custom-logo {
        height: 28px;
    }

    .custom-mobile-search-btn {
        width: var(--px-36);
        height: var(--px-36);
        padding: var(--px-6);
    }

        .custom-mobile-search-btn i {
            font-size: var(--px-18);
        }

    /* Compact navigation */
    .custom-nav-list {
    }

    .custom-nav-item {
    }

    .custom-nav-btn {
        height: var(--px-36);
        font-size: var(--px-20);
        padding: var(--px-2);
    }

    /* Hide nav item text/labels on smallest screens */
    .custom-nav-item[data-bs-toggle="tooltip"] .custom-nav-btn {
        width: var(--px-48);
    }

    .custom-right-header .custom-nav-btn[aria-label="Management Attendance"] {
        display: none;
    }

    /* Profile avatar even smaller */
    .custom-profile-avatar {
        width: 28px;
        height: 28px;
        font-size: 11px;
    }

    /* Active indicator thinner */
    .custom-nav-item.active {
    }
}

/* Extra small devices (very small phones) */
@media (max-width: 390px) {
    .custom-logo {
        height: 24px;
    }

    .custom-nav-item {
        min-width: var(--px-40);
    }

    .custom-nav-btn {
        height: var(--px-32);
        font-size: var(--px-14);
        width: var(--px-40);
    }

    .custom-profile-avatar {
        width: 24px;
        height: 24px;
        font-size: 10px;
    }
}

/* Landscape orientation adjustments for mobile */
@media (max-height: 500px) and (orientation: landscape) {
    .custom-header {
        max-height: var(--px-44);
        padding: var(--px-2) var(--px-8);
    }

    .custom-nav-btn {
        height: var(--px-32);
    }

    .custom-logo {
        height: 24px;
    }
}

/* Nav tooltips (e.g. "Quick Sale") clip under the header / safe areas on phones. */
@media (max-width: 768px) {
    /* iOS Safari zooms the page when a focused form control uses text smaller than 16px. */
    input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="button"]):not([type="submit"]):not([type="reset"]),
    select,
    textarea {
        font-size: 16px !important;
    }

    :root {
        --mobile-nav-height: 48px;
        --mobile-footer-height: 24px;
        --mobile-bottom-inset: calc(var(--mobile-nav-height) + env(safe-area-inset-bottom, 0px));
    }

    body:has(.custom-header) {
        padding-bottom: var(--mobile-bottom-inset);
        box-sizing: border-box;
    }

    .custom-header ~ .container-body-layout {
        min-height: 0 !important;
    }

    .custom-header ~ footer {
        flex: 0 0 var(--mobile-footer-height);
        min-height: var(--mobile-footer-height);
        max-height: var(--mobile-footer-height);
        padding: 0 8px;
        gap: 0;
        box-shadow: none;
        border-top: 1px solid rgb(148 163 184 / 14%);
        color: var(--bs-text-muted);
        font-size: 9px;
        line-height: 12px;
        letter-spacing: 0;
    }

    #footer-timline-id .col-info {
        gap: 5px;
        justify-content: center;
    }

    #footer-timline-id strong {
        font-size: 10px;
        font-weight: 500;
        color: var(--bs-text);
    }

    #footer-timline-id .footer-meta {
        gap: 8px;
    }

    #footer-timline-id .footer-powered-by {
        gap: 4px;
        font-size: 9px;
    }

    #footer-timline-id .footer-powered-by img {
        width: 16px;
        height: 16px;
        object-fit: contain;
    }

    .custom-header .custom-nav {
        position: fixed;
        inset: auto 0 0;
        height: var(--mobile-bottom-inset);
        padding: 0 max(4px, env(safe-area-inset-right, 0px)) env(safe-area-inset-bottom, 0px) max(4px, env(safe-area-inset-left, 0px));
        background: var(--bs-surface-bg);
        border-top: 1px solid rgb(148 163 184 / 18%);
        box-sizing: border-box;
        z-index: 100;
        pointer-events: auto;
    }

    .custom-header .custom-nav-list {
        display: grid;
        grid-template-columns: repeat(5, minmax(0, 1fr));
        gap: 4px;
        overflow: visible;
    }

    .custom-header .custom-nav-item {
        min-width: 0;
        margin: 0;
    }

    .custom-header .custom-nav .custom-nav-btn {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 4px;
        width: 100%;
        height: 50px;
        min-height: 44px;
        padding: 4px 0;
        border-radius: 8px;
    }

    .custom-header .custom-nav .custom-nav-btn::after {
        content: attr(aria-label);
        font-size: 9px;
        line-height: 12px;
        letter-spacing: 0;
        color: var(--bs-text-muted);
    }

    .custom-header .custom-nav .custom-nav-btn i {
        font-size: 18px;
    }

    .custom-header .custom-nav-item.active::after {
        display: none;
    }

    .custom-header .custom-nav-item.active .custom-nav-btn {
        /* background: var(--bs-main-100); */
    }

    .custom-header .custom-nav .custom-nav-btn:focus-visible {
        outline: 2px solid var(--bs-main);
        outline-offset: -2px;
    }

    .custom-header .custom-nav-item.active .custom-nav-btn::after {
        color: var(--bs-main);
    }
}

@media (max-width: 480px) {
    #footer-timline-id .footer-powered-by > span {
        display: none;
    }
}

@media (max-width: 767.98px) {
    .tooltip {
        display: none !important;
        visibility: hidden !important;
        opacity: 0 !important;
        pointer-events: none !important;
    }
}
