/* ==========================================================================
   Installationskollen – Global Search in Top Navbar & Order Detail Modal
   ========================================================================== */

/* Right Side Wrapper.
   z-index 1 (UNDER .nav-center-wrap som har 2 i theme.css): vid smala fönster
   kan sökrutan annars hamna ovanpå nav-länkarna (t.ex. Inställningar) och
   äta upp klick. Menyn vinner alltid vid överlapp; sökrutan är fortsatt
   klickbar överallt där den inte täcks. Dropdownen påverkas inte – den
   öppnas nedanför navbaren där menyn inte finns. */
.nav-right-wrap {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    position: relative;
    z-index: 1;
}

/* Search Container in Navbar */
.nav-search-wrap {
    position: relative;
    z-index: 1020;
}

.nav-search-box {
    position: relative;
    display: flex;
    align-items: center;
    width: 240px;
    height: 36px;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.14);
    border-radius: 20px;
    /* OBS: ingen bredd-animation vid fokus – en expanderande sökruta
       (särskilt med autofocus/scanner-läge) kan lägga sig över
       nav-länkarna (t.ex. Inställningar) och äta upp klick. */
    transition: background 0.22s ease, border-color 0.22s ease, box-shadow 0.22s ease;
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.25);
}

.nav-search-box:hover {
    background: rgba(255, 255, 255, 0.12);
    border-color: rgba(255, 255, 255, 0.25);
}

.nav-search-box:focus-within {
    background: rgba(15, 23, 42, 0.85);
    border-color: #38bdf8;
    box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.22), 0 4px 14px rgba(0, 0, 0, 0.35);
}

.nav-search-icon {
    position: absolute;
    left: 12px;
    color: #94a3b8;
    font-size: 0.85rem;
    pointer-events: none;
    transition: color 0.18s ease;
}

.nav-search-box:focus-within .nav-search-icon {
    color: #38bdf8;
}

.nav-search-input {
    width: 100%;
    height: 100%;
    padding: 0 34px 0 34px;
    background: transparent;
    border: none;
    outline: none;
    color: #f8fafc;
    font-size: 0.82rem;
    font-weight: 500;
}

.nav-search-input::placeholder {
    color: #94a3b8;
    opacity: 0.8;
}

.nav-search-clear {
    position: absolute;
    right: 8px;
    width: 20px;
    height: 20px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.18);
    border: none;
    border-radius: 50%;
    color: #cbd5e1;
    font-size: 0.9rem;
    line-height: 1;
    cursor: pointer;
    transition: all 0.15s ease;
}

.nav-search-clear:hover {
    background: rgba(239, 68, 68, 0.8);
    color: #ffffff;
}

.nav-search-kbd {
    position: absolute;
    right: 8px;
    padding: 2px 6px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.18);
    border-radius: 6px;
    color: #94a3b8;
    font-size: 0.65rem;
    font-family: inherit;
    pointer-events: none;
    user-select: none;
    transition: opacity 0.15s ease;
}

.nav-search-box:focus-within .nav-search-kbd,
.nav-search-box.has-query .nav-search-kbd {
    display: none;
}

/* Dropdown Results Menu - Aligned to right with generous padding */
.nav-search-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    left: auto;
    width: 480px;
    max-width: calc(100vw - 24px);
    max-height: 480px;
    background: #0f172a;
    background: rgba(15, 23, 42, 0.97);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.14);
    border-radius: 14px;
    box-shadow: 0 20px 45px rgba(0, 0, 0, 0.65), 0 0 0 1px rgba(255, 255, 255, 0.05);
    overflow-y: auto;
    overflow-x: hidden;
    z-index: 1100;
    padding: 10px 10px 12px;
}

.nav-search-dropdown::-webkit-scrollbar {
    width: 6px;
}

.nav-search-dropdown::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 3px;
}

.nav-search-dropdown-header {
    padding: 6px 8px 10px;
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #94a3b8;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    margin-bottom: 8px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.nav-search-dropdown-header .search-count {
    color: #38bdf8;
    font-weight: 700;
}

/* Individual Search Item Card */
.nav-search-item {
    display: block;
    width: 100%;
    padding: 12px 14px;
    margin-bottom: 8px;
    text-align: left;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 10px;
    color: #f1f5f9;
    cursor: pointer;
    transition: all 0.15s ease;
    text-decoration: none;
    box-sizing: border-box;
}

.nav-search-item:last-child {
    margin-bottom: 0;
}

.nav-search-item:hover,
.nav-search-item.active-item {
    background: rgba(56, 189, 248, 0.12);
    border-color: rgba(56, 189, 248, 0.35);
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.25);
}

.nav-search-item-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
    gap: 8px;
}

.nav-search-bb {
    font-size: 0.80rem;
    font-weight: 700;
    color: #38bdf8;
    background: rgba(56, 189, 248, 0.15);
    padding: 3px 8px;
    border-radius: 6px;
    border: 1px solid rgba(56, 189, 248, 0.28);
    white-space: nowrap;
    letter-spacing: 0.02em;
}

.nav-search-date-slot {
    font-size: 0.74rem;
    color: #cbd5e1;
    display: flex;
    align-items: center;
    gap: 5px;
    white-space: nowrap;
}

.nav-search-status-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-right: 4px;
}
.nav-search-status-dot.completed {
    background-color: #22c55e;
    box-shadow: 0 0 6px #22c55e;
}
.nav-search-status-dot.pending {
    background-color: #38bdf8;
    box-shadow: 0 0 6px #38bdf8;
}

.nav-search-actions {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-left: auto;
    flex-shrink: 0;
}

.btn-search-action {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    padding: 0;
    border-radius: 7px;
    border: 1px solid rgba(255, 255, 255, 0.18);
    background: rgba(255, 255, 255, 0.08);
    color: #cbd5e1;
    font-size: 0.78rem;
    cursor: pointer;
    transition: all 0.15s ease;
}

.btn-search-action:hover {
    transform: scale(1.08);
}

.btn-search-action.btn-action-orders {
    color: #38bdf8;
    background: rgba(56, 189, 248, 0.15);
    border-color: rgba(56, 189, 248, 0.35);
}

.btn-search-action.btn-action-orders:hover {
    background: #0284c7;
    border-color: #0284c7;
    color: #ffffff;
    box-shadow: 0 0 8px rgba(2, 132, 199, 0.6);
}

.btn-search-action.btn-action-backrep {
    color: #f87171;
    background: rgba(239, 68, 68, 0.15);
    border-color: rgba(239, 68, 68, 0.35);
}

.btn-search-action.btn-action-backrep:hover {
    background: #dc2626;
    border-color: #dc2626;
    color: #ffffff;
    box-shadow: 0 0 8px rgba(220, 38, 38, 0.6);
}

.btn-search-action.btn-action-utlev {
    color: #34d399;
    background: rgba(16, 185, 129, 0.15);
    border-color: rgba(16, 185, 129, 0.35);
}

.btn-search-action.btn-action-utlev:hover:not(:disabled) {
    background: #059669;
    border-color: #059669;
    color: #ffffff;
    box-shadow: 0 0 8px rgba(5, 150, 105, 0.6);
}

.btn-search-action.btn-action-utlev.is-done,
.btn-search-action.btn-action-utlev:disabled {
    color: #22c55e;
    background: rgba(34, 197, 94, 0.18);
    border-color: rgba(34, 197, 94, 0.35);
    opacity: 0.85;
    cursor: default;
    transform: none !important;
}

.nav-search-customer {
    font-size: 0.90rem;
    font-weight: 600;
    color: #ffffff;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 5px;
    line-height: 1.35;
}

.nav-search-phone {
    font-size: 0.78rem;
    font-weight: 500;
    color: #94a3b8;
    white-space: nowrap;
}

.nav-search-address {
    font-size: 0.78rem;
    color: #cbd5e1;
    margin-bottom: 6px;
    display: flex;
    align-items: center;
    gap: 6px;
    line-height: 1.35;
}

.nav-search-services {
    font-size: 0.74rem;
    color: #94a3b8;
    padding-top: 7px;
    margin-top: 6px;
    border-top: 1px dashed rgba(255, 255, 255, 0.08);
    display: flex;
    align-items: center;
    gap: 6px;
    line-height: 1.4;
    white-space: normal;
    word-break: break-word;
}

.nav-search-highlight {
    background-color: rgba(234, 179, 8, 0.28);
    color: #fef08a;
    border-radius: 3px;
    padding: 1px 3px;
    font-weight: 700;
}

.nav-search-empty {
    padding: 24px 16px;
    text-align: center;
    color: #94a3b8;
    font-size: 0.84rem;
}
.nav-search-empty i {
    font-size: 1.8rem;
    color: #64748b;
    margin-bottom: 8px;
    display: block;
}

/* ==========================================================================
   Order Detail Modal
   ========================================================================== */
.global-order-modal-card {
    max-width: 620px;
    width: 95%;
    background: #ffffff;
    border-radius: 18px;
    overflow: hidden;
    box-shadow: 0 25px 60px rgba(0, 0, 0, 0.45);
    display: flex;
    flex-direction: column;
    max-height: 90vh;
}

.global-order-modal-header {
    background: #0f172a;
    color: #ffffff;
    padding: 16px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.global-order-modal-body {
    padding: 20px;
    overflow-y: auto;
}

.global-order-info-section {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: 14px 16px;
    margin-bottom: 14px;
}

.global-order-info-section:last-child {
    margin-bottom: 0;
}

.global-order-section-title {
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #64748b;
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.global-order-field-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 5px 0;
    font-size: 0.86rem;
    border-bottom: 1px dashed #e2e8f0;
}
.global-order-field-row:last-child {
    border-bottom: none;
}

.global-order-field-label {
    color: #64748b;
    font-weight: 500;
}

.global-order-field-val {
    color: #0f172a;
    font-weight: 600;
    text-align: right;
}

.global-order-modal-footer {
    background: #f8fafc;
    padding: 12px 20px;
    border-top: 1px solid #e2e8f0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
}

/* ==========================================================================
   Responsive: smalare desktopfönster – förhindra att sökrutan och den
   centrerade nav-menyn överlappar (sökrutan har högre z-index och skulle
   annars äta klick på t.ex. Inställningar).
   ========================================================================== */
@media (max-width: 1400px) {
    .nav-search-box {
        width: 200px;
    }
    .nav-search-kbd {
        display: none !important;
    }
}

@media (max-width: 1100px) {
    .nav-search-box {
        width: 170px;
    }
}

/* ==========================================================================
   Responsive Adjustments: Surfplatta (Tablet: 768px - 1024px)
   ========================================================================== */
@media (max-width: 1024px) {
    .nav-search-wrap {
        margin-left: 10px;
    }
    .nav-search-box {
        width: 210px;
        height: 36px;
    }
    .nav-search-box:focus-within {
        width: 210px;
    }
    .nav-search-dropdown {
        width: 440px;
        max-width: calc(100vw - 32px);
        max-height: calc(85vh - 70px);
        padding: 10px;
    }
    .btn-search-action {
        width: 32px;
        height: 32px;
        font-size: 0.82rem;
        border-radius: 8px;
    }
    .global-order-modal-card {
        max-width: 92vw;
        width: 580px;
        max-height: 88vh;
    }
}

/* ==========================================================================
   Responsive Adjustments: Mobil & Små skärmar (< 768px)
   ========================================================================== */
@media (max-width: 767px) {
    /* Säkerställ att sökrutan syns i mobilen och inte döljs */
    .top-navbar .nav-right-wrap {
        display: flex !important;
        align-items: center;
        margin-left: auto;
        position: relative;
    }

    .nav-search-wrap {
        margin-left: 6px;
    }

    .nav-search-box {
        width: 135px;
        height: 34px;
        padding-left: 30px;
        padding-right: 28px;
        border-radius: 20px;
        transition: width 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    }

    .nav-search-box:focus-within,
    .nav-search-box.has-query {
        width: 175px;
        background: rgba(15, 23, 42, 0.96);
        border-color: #38bdf8;
    }

    .nav-search-icon {
        left: 10px;
        font-size: 0.80rem;
    }

    .nav-search-clear {
        right: 4px;
        width: 26px;
        height: 26px;
        font-size: 1.1rem;
    }

    /* iOS Safari: font-size 16px förhindrar oönskad auto-zoom */
    .nav-search-input {
        font-size: 16px !important;
        padding-right: 24px;
    }

    .nav-search-kbd {
        display: none !important;
    }

    /* Dropdown som fullbredds-ark strax under navbar */
    .nav-search-dropdown {
        position: fixed;
        top: 54px;
        left: 8px;
        right: 8px;
        width: auto;
        max-width: none;
        max-height: calc(100vh - 68px);
        border-radius: 14px;
        box-shadow: 0 16px 40px rgba(0, 0, 0, 0.75);
        padding: 8px;
        z-index: 1100;
        -webkit-overflow-scrolling: touch;
    }

    .nav-search-item {
        padding: 10px 12px;
        margin-bottom: 8px;
        border-radius: 10px;
    }

    .nav-search-item-top {
        margin-bottom: 6px;
    }

    /* Touch targets för snabbknappar i mobil: bekväm träffyta för fingrar */
    .btn-search-action {
        width: 36px;
        height: 36px;
        font-size: 0.88rem;
        border-radius: 8px;
    }

    .nav-search-actions {
        gap: 8px;
    }

    .nav-search-customer {
        font-size: 0.88rem;
    }

    .nav-search-address {
        font-size: 0.78rem;
    }

    .nav-search-services {
        font-size: 0.72rem;
    }

    /* Modal-anpassning för mobil */
    .global-order-modal-card {
        width: 95vw;
        max-width: 95vw;
        max-height: 92vh;
        border-radius: 14px;
        margin: auto;
    }

    .global-order-modal-header {
        padding: 12px 16px;
    }

    .global-order-modal-body {
        padding: 14px 16px;
        -webkit-overflow-scrolling: touch;
    }

    .global-order-info-section {
        padding: 10px 12px;
        margin-bottom: 10px;
    }

    .global-order-field-row {
        font-size: 0.82rem;
        padding: 4px 0;
    }

    .global-order-modal-footer {
        flex-direction: column-reverse;
        gap: 8px;
        padding: 12px 14px;
    }

    .global-order-modal-footer > button {
        width: 100%;
        min-height: 40px;
    }

    .global-order-modal-footer .d-flex {
        width: 100%;
        flex-wrap: wrap;
        gap: 6px;
    }

    .global-order-modal-footer .d-flex button {
        flex: 1 1 45%;
        min-height: 40px;
        font-size: 0.82rem;
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }
}

