/* Header Search Dropdown Styles */

.admin-panel-header-search-container {
    position: relative;
}

.admin-header-search-dropdown {
    background: white;
    border: 1px solid #ddd;
    border-radius: 4px;
    max-height: 400px;
    overflow-y: auto;
    z-index: 1000;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    min-width: 100%;
}

.search-result-item {
    padding: 12px 16px;
    border-bottom: 1px solid #eee;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.search-result-item:hover {
    background-color: #f5f5f5;
}

.search-result-item.active {
    background-color: #e8f4f8;
    border-left: 3px solid #4B7C3D;
    padding-left: 13px;
}

.search-result-item:last-child {
    border-bottom: none;
}

.search-result-item div:first-child {
    font-weight: 500;
    color: #333;
    margin-bottom: 4px;
}

.search-result-item div:last-child {
    font-size: 12px;
    color: #424242;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 300px;
}

/* Loading state */
.search-loading {
    padding: 12px 16px;
    text-align: center;
    color: #424242;
}

/* No results state */
.search-no-results {
    padding: 12px 16px;
    text-align: center;
    color: #424242;
}

/* Error state */
.search-error {
    padding: 12px 16px;
    text-align: center;
    color: #d32f2f;
}

/* Scrollbar styling */
.admin-header-search-dropdown::-webkit-scrollbar {
    width: 8px;
}

.admin-header-search-dropdown::-webkit-scrollbar-track {
    background: #f1f1f1;
}

.admin-header-search-dropdown::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 4px;
}

.admin-header-search-dropdown::-webkit-scrollbar-thumb:hover {
    background: #555;
}

/* ===== Header search (RTL / Urdu) ===== */
.hs { direction: rtl; display: flex; align-items: center; gap: 6px; max-width: 480px; height: 52px; padding: 0 8px 0 8px; border: 1.5px solid #d9e3d4; border-radius: 30px; background: linear-gradient(180deg, #fff, #fbfdfa); box-shadow: 0 1px 2px rgba(40,60,30,.05), 0 4px 14px rgba(40,60,30,.06); transition: border-color .2s, box-shadow .2s; }
.hs:hover { border-color: #bcd0b5; }
.hs:focus-within { border-color: #4C7C3C; box-shadow: 0 0 0 4px rgba(76,124,60,.15), 0 6px 18px rgba(40,60,30,.10); }
.hs .admin-panel-header-search-icon { position: static; transform: none; flex: 0 0 auto; box-sizing: content-box; width: 20px; height: 20px; padding: 7px; margin: 0; border-radius: 50%; background: #eaf2e6; color: #3a5f2d; transition: background .2s, color .2s; }
.hs:focus-within .admin-panel-header-search-icon { background: #4C7C3C; color: #fff; }
.hs .admin-panel-header-search-box { direction: rtl; text-align: right; flex: 1 1 auto; min-width: 0; width: auto; height: 46px; margin: 0; padding: 0 6px 7px; border: 0 !important; border-radius: 0; background: transparent !important; box-shadow: none !important; font-size: 19px; line-height: 1.6; color: #212121; outline: none; }
/* The pill itself shows the focus ring: no second outline on the input */
.hs .admin-panel-header-search-box:focus, .hs .admin-panel-header-search-box:focus-visible { outline: none !important; border: 0 !important; box-shadow: none !important; }
.hs .admin-panel-header-search-box::placeholder { color: #757575; opacity: 1; }
.hs .admin-panel-header-search-box::-webkit-search-cancel-button { display: none; }
.hs-clear { flex: 0 0 auto; display: inline-flex; align-items: center; justify-content: center; width: 28px; height: 28px; margin: 0; padding: 0; border: 0; border-radius: 50%; background: #eef1ec; color: #424242; line-height: 0; cursor: pointer; transition: background .15s, transform .1s; }
.hs-clear:hover { background: #dfe6db; }
.hs-clear:active { transform: scale(.92); }
.hs-clear[hidden] { display: none; }
.hs-scope { flex: 0 0 auto; position: relative; display: inline-flex; align-items: center; gap: 6px; height: 36px; margin: 0; padding: 0 12px 4px 12px; border: 1.5px solid #d7e8d1; border-radius: 18px; background: #f4f8f2; color: #3a5f2d; font-size: 16px; line-height: 1.6; cursor: pointer; white-space: nowrap; transition: background .15s, color .15s, border-color .15s; }
.hs-scope svg { flex: 0 0 auto; margin-bottom: -4px; }
.hs-scope-text { display: inline-block; }
.hs-scope:hover { background: #e8f1e4; }
.hs-scope.is-on, .hs-scope.has-scope { background: #4C7C3C; border-color: #4C7C3C; color: #fff; }
.hs-scope-count { display: inline-flex; align-items: center; justify-content: center; min-width: 20px; height: 20px; margin-bottom: -4px; padding: 0 5px; border-radius: 10px; background: #fff; color: #3a5f2d; font: 700 12px/1 Arial, sans-serif !important; }
.hs-scope-count[hidden] { display: none; }
.hs-scope:focus-visible, .hs-clear:focus-visible { outline: 2px solid #4C7C3C; outline-offset: 2px; }

.hs .admin-header-search-dropdown { direction: rtl; position: absolute; top: calc(100% + 10px); left: 50%; right: auto; transform: translateX(-50%); width: max(100%, 420px); max-width: calc(100vw - 24px); box-sizing: border-box; min-width: 0; max-height: min(70vh, 460px); overflow-y: auto; padding: 8px; border: 1px solid #e2e8df; border-radius: 22px; background: #fff; box-shadow: 0 18px 44px rgba(30,50,25,.20); z-index: 1000; text-align: right; animation: hsPop .16s ease; }
@keyframes hsPop { from { opacity: 0; margin-top: -6px; } to { opacity: 1; margin-top: 0; } }

.hs-scope-row { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: 0 0 6px; padding: 8px 10px; border-radius: 14px; background: #f1f6ee; }
.hs-scope-label { font-size: 14px; line-height: 1.8; color: #5f6f58; }
.hs-chip { display: inline-flex; align-items: center; gap: 6px; max-width: 100%; height: 30px; padding: 0 5px 0 12px; border-radius: 15px; background: #4C7C3C; color: #fff; font-size: 15px; line-height: 1; }
.hs-chip-text { display: block; padding-bottom: 5px; line-height: 1.6; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hs-chip button { flex: 0 0 auto; display: inline-flex; align-items: center; justify-content: center; width: 22px; height: 22px; margin: 0; padding: 0; border: 0; border-radius: 50%; background: rgba(255,255,255,.2); color: #fff; line-height: 0; cursor: pointer; }
.hs-chip button:hover { background: rgba(255,255,255,.35); }

.search-count { padding: 4px 12px 6px; font-size: 14px; line-height: 1.8; color: #5f6f58; }
.search-count b { margin-left: 4px; font-family: Arial, sans-serif !important; font-size: 13px; color: #3a5f2d; }

.hs .search-result-item { display: flex; align-items: center; gap: 12px; padding: 9px 10px; border: 0; border-radius: 14px; cursor: pointer; transition: background .12s; }
.hs .search-result-item + .search-result-item { margin-top: 2px; }
.hs .search-result-item:hover, .hs .search-result-item.active { background: #eef4ec; border-left: 0; padding-left: 10px; box-shadow: inset -3px 0 0 #4C7C3C; }
.search-ico { flex: 0 0 auto; display: inline-flex; align-items: center; justify-content: center; width: 38px; height: 38px; border-radius: 12px; background: #eaf2e6; color: #4C7C3C; }
.search-body { flex: 1 1 auto; min-width: 0; text-align: right; }
.hs .search-result-title { font-size: 18px; font-weight: 500; line-height: 1.8; color: #212121; }
.search-path { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; font-size: 14px; line-height: 1.7; color: #5f6f58; }
.search-path .hs-sep { flex: 0 0 auto; color: #9aa894; }
.search-hit { padding: 0 2px; border-radius: 5px; background: #fff0b3; color: inherit; font-weight: 700; }

.hs .search-no-results { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 22px 16px 18px; color: #424242; }
.search-empty-ico { display: inline-flex; align-items: center; justify-content: center; width: 52px; height: 52px; margin-bottom: 6px; border-radius: 50%; background: #eef4ec; color: #4C7C3C; }
.hs .search-no-results b { font-size: 18px; font-weight: 600; line-height: 1.8; }
.hs .search-no-results small { font-size: 15px; color: #5f6f58; }
.hs .search-loading { display: flex; align-items: center; justify-content: center; gap: 10px; padding: 18px 16px; color: #424242; }
.search-spin { width: 18px; height: 18px; border: 2.5px solid #d7e8d1; border-top-color: #4C7C3C; border-radius: 50%; animation: hsSpin .7s linear infinite; }
@keyframes hsSpin { to { transform: rotate(360deg); } }
.search-foot { display: flex; flex-wrap: wrap; justify-content: center; gap: 4px 16px; margin-top: 6px; padding: 8px 8px 2px; border-top: 1px solid #eef1ec; font-size: 13px; line-height: 1.8; color: #5f6f58; }
.search-foot kbd { display: inline-block; min-width: 20px; margin: 0 2px; padding: 0 5px; border: 1px solid #d5ddd1; border-bottom-width: 2px; border-radius: 5px; background: #f7f9f6; color: #424242; font: 600 11px/1.6 Arial, sans-serif !important; text-align: center; }

@media (max-width: 767px) {
    .hs { height: 46px; padding: 0 6px; gap: 4px; }
    .hs .admin-panel-header-search-icon { width: 17px; height: 17px; padding: 6px; }
    .hs .admin-panel-header-search-box { height: 40px; font-size: 16px; }
    .hs-scope-text { display: none; }
    .hs-scope { width: 36px; padding: 0; justify-content: center; }
    .hs-scope svg { margin-bottom: 0; }
    .hs-scope-count { position: absolute; top: -6px; left: -4px; margin: 0; }
    .search-foot { display: none; }
    .hs .search-result-title { font-size: 17px; }
}

/* ===== Scoped search: tick parent topics in the sidebar tree (only while choosing) ===== */
.ss-box { position: relative; display: none; align-items: center; justify-content: center; flex: 0 0 auto; width: 20px; height: 20px; margin: 0 2px 0 6px; cursor: pointer; }
body.ss-mode .ss-box, .ss-box.is-on { display: inline-flex; }
.ss-box input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer; z-index: 1; }
.ss-mark { width: 17px; height: 17px; border: 1.5px solid #757575; border-radius: 5px; background: #fff; transition: background .15s, border-color .15s; position: relative; }
.ss-box:hover .ss-mark { border-color: #4C7C3C; }
.ss-box input:checked + .ss-mark { background: #4C7C3C; border-color: #4C7C3C; }
.ss-box input:checked + .ss-mark::after { content: ""; position: absolute; left: 50%; top: 45%; width: 4px; height: 8px; border: solid #fff; border-width: 0 2px 2px 0; transform: translate(-50%, -50%) rotate(45deg); }
.ss-box input:focus-visible + .ss-mark { outline: 2px solid #4C7C3C; outline-offset: 2px; }
.ss-bar { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: 6px 20px 8px; padding: 6px 10px 6px 8px; border-radius: 12px; background: #eef4ec; border: 1px solid #d7e8d1; }
.ss-bar[hidden] { display: none; }
.ss-bar-text { font-size: 15.5px; line-height: 1.9; color: #3a5f2d; }
.ss-bar-actions { display: inline-flex; gap: 6px; }
.ss-bar-actions button { height: 30px; padding: 0 12px; border: 0; border-radius: 15px; background: #fff; color: #3a5f2d; font-size: 15px; line-height: 1.9; cursor: pointer; }
.ss-bar-actions .ss-done { background: #4C7C3C; color: #fff; }

/* ===== Mobile header: everything on ONE line (logo, narrow search, bell, avatar) ===== */
@media (max-width: 767px) {
    .admin-panel-header { padding: 4px 8px !important; }
    .admin-panel-header-container { flex-wrap: nowrap !important; justify-content: space-between !important; gap: 6px !important; padding-right: 56px; /* room for the fixed menu button, even if the logo is missing */ }
    .admin-panel-header-right { order: 0; flex: 0 0 auto; }
    .admin-panel-header-right, .admin-panel-header-right-logo { width: auto !important; max-width: none !important; }
    .admin-panel-header-right-logo { padding-right: 0 !important; }
    .admin-panel-header-right-logo img { height: 20px !important; width: auto !important; max-width: 80px; display: block; }
    .admin-panel-header-left .header-right, .admin-panel-header-left .profile-img, .admin-panel-header-profile-dropdown { width: auto !important; flex: 0 0 auto !important; }
    .admin-panel-header-center { order: 1; flex: 0 1 180px !important; min-width: 0 !important; width: auto !important; margin: 0 !important; }
    .admin-panel-header-left { order: 2; flex: 0 0 auto !important; gap: 6px; }
    .admin-panel-header-left .notification-icon { width: 26px; height: 26px; }
    .admin-panel-header-left .notification-icon svg { width: 20px; height: 22px; }
    .profile-img img { height: 34px !important; width: 34px !important; }
    .user-name { display: none !important; }

    .hs { height: 40px; min-height: 0; padding: 0 6px; gap: 2px; border-radius: 22px; box-shadow: none; }
    .hs .admin-panel-header-search-icon { width: 16px; height: 16px; padding: 0; margin: 0 2px; background: transparent !important; color: #4C7C3C !important; }
    .hs .admin-panel-header-search-box { height: 34px; padding: 0 2px 6px; font-size: 15px; }
    .hs-clear { width: 22px; height: 22px; }
    .hs-clear svg { width: 11px; height: 11px; }
    .hs-scope { width: 30px; height: 30px; padding: 0; }
    .hs-scope svg { width: 16px; height: 16px; }
    .hs-scope-count { top: -7px; left: -5px; }

    /* the narrow pill must not squeeze the results: they open as a full-width sheet under the header */
    .hs .admin-header-search-dropdown { position: fixed; top: 72px; left: 8px; right: 8px; transform: none; width: auto; min-width: 0; max-width: none; max-height: calc(100dvh - 88px); }

    .hamburger-admin-panel { top: 15px !important; right: 8px !important; }
    body { padding-top: 82px !important; }
}

@media (max-width: 359px) {
    .admin-panel-header-right-logo img { max-width: 64px; height: 17px !important; }
    .admin-panel-header-left { gap: 4px; }
    .admin-panel-header-left .notification-icon { width: 22px; height: 22px; }
    .profile-img img { height: 30px !important; width: 30px !important; }
    .hs .admin-panel-header-search-icon { display: none; }
}

/* ===== Profile (sign out) dropdown: anchored to the avatar, never off-screen ===== */
.admin-panel-header-profile-dropdown { position: relative; }
.admin-panel-header-profile-dropdown .admin-panel-header-dropdown-menu {
    display: none; position: absolute; top: calc(100% + 8px); left: 0; right: auto;
    width: max-content; min-width: 170px; max-width: calc(100vw - 16px); padding: 6px; box-sizing: border-box;
    border: 1px solid #e2e8df; border-radius: 16px; background: #fff; box-shadow: 0 14px 34px rgba(30,50,25,.18);
    direction: rtl; text-align: right; z-index: 1001; animation: hsPop .16s ease;
}
.admin-panel-header-profile-dropdown .admin-panel-header-dropdown-menu.show { display: block; }
@media (hover: hover) and (min-width: 992px) {
    .admin-panel-header-profile-dropdown:hover .admin-panel-header-dropdown-menu { display: block; }
}
.admin-panel-header-dropdown-menu form { margin: 0; }
.admin-panel-header-logout-btn { display: flex !important; align-items: center; justify-content: flex-start; gap: 10px; width: 100%; padding: 8px 12px 10px !important; border: 0; border-radius: 11px; background: none; color: #424242; font-size: 17px; line-height: 1.7; text-align: right !important; cursor: pointer; white-space: nowrap; }
.admin-panel-header-logout-btn:hover, .admin-panel-header-logout-btn:focus-visible { background: #fdecec; color: #a31515; }
.admin-panel-header-logout-btn svg { flex: 0 0 auto; margin-bottom: -3px; }
@media (max-width: 767px) {
    /* open as a small sheet under the header, aligned to the avatar side, clear of the screen edge */
    .admin-panel-header-profile-dropdown .admin-panel-header-dropdown-menu { position: fixed; top: 72px; left: 8px; min-width: 180px; }
}

/* result rows: the generic ":first-child/:last-child" rules above must not shrink or truncate titles */
.hs .search-result-item .search-body { max-width: none; overflow: visible; white-space: normal; font-size: inherit; margin: 0; }
.hs .search-result-item .search-result-title { max-width: none; overflow: visible; text-overflow: clip; white-space: normal; overflow-wrap: anywhere; font-size: 18px; margin: 0; color: #212121; }
.hs .search-result-item .search-path { max-width: none; overflow: visible; white-space: normal; font-size: 14px; color: #5f6f58; }
@media (max-width: 767px) { .hs .search-result-item .search-result-title { font-size: 17px; } }

/* invisible bridge over the 8px gap, so the menu does not close while the mouse travels from the avatar to it */
.admin-panel-header-profile-dropdown .admin-panel-header-dropdown-menu::before { content: ""; position: absolute; top: -24px; left: 0; right: 0; height: 24px; }

/* header avatar: crop to the round frame instead of stretching a non-square photo */
.admin-panel-header-profile-toggle img { object-fit: cover; }
