/* RanaHost panel — top header controls
   Command-bar search, currency and language menus.
   Scoped to .hd-*. Consumes the panel palette tokens (panel.css). */

/* Token fallbacks so this file also works on pages that do not load panel.css
   (auth screens). Values match panel.css exactly, so there is no override. */
:root {
    --panel-primary: #1a73e8;
    --panel-primary-dark: #1259b8;
    --panel-ink: #0b1b3a;
    --panel-muted: #5b6b85;
    --panel-card: #ffffff;
    --panel-soft: #e8f1ff;
    --panel-line: #dfe8f5;
    --panel-focus: 0 0 0 3px rgba(26, 115, 232, .18);
    --panel-sans: "Manrope", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
}

.dark {
    --panel-ink: #edf5ff;
    --panel-muted: #8aa3c4;
    --panel-card: #0b1f3a;
    --panel-soft: #0f2a4a;
    --panel-line: #183556;
}

/* ---------------- command-bar search ---------------- */

.hd-search {
    position: relative;
    flex: 1 1 280px;
    max-width: 460px;
    min-width: 0;
}

.hd-search-field {
    position: relative;
    display: flex;
    align-items: center;
    gap: 8px;
    height: 40px;
    padding: 0 10px 0 12px;
    border: 1px solid var(--panel-line);
    border-radius: 11px;
    background: var(--panel-soft);
    transition: background .16s ease, border-color .16s ease, box-shadow .16s ease;
}

.hd-search-field:focus-within {
    background: var(--panel-card);
    border-color: var(--panel-primary);
    box-shadow: var(--panel-focus);
}

.hd-search-icon {
    width: 16px;
    height: 16px;
    flex: 0 0 auto;
    color: var(--panel-muted);
}

.hd-search-input {
    flex: 1 1 auto;
    min-width: 0;
    height: 100%;
    border: 0;
    background: transparent;
    color: var(--panel-ink);
    font-family: var(--panel-sans);
    font-size: 13px;
    font-weight: 600;
    outline: none;
}

.hd-search-input::placeholder { color: var(--panel-muted); font-weight: 500; }
.hd-search-input::-webkit-search-cancel-button { display: none; }

.hd-kbd {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    padding: 2px 6px;
    border: 1px solid var(--panel-line);
    border-radius: 5px;
    background: var(--panel-card);
    color: var(--panel-muted);
    font-family: var(--panel-sans);
    font-size: 9.5px;
    font-weight: 800;
    letter-spacing: .03em;
    white-space: nowrap;
    pointer-events: none;
}

.hd-search-field:focus-within .hd-kbd { opacity: 0; }

.hd-spinner {
    width: 14px;
    height: 14px;
    flex: 0 0 auto;
    border: 2px solid var(--panel-line);
    border-top-color: var(--panel-primary);
    border-radius: 50%;
    animation: hd-spin .7s linear infinite;
    display: none;
}

.hd-search.is-loading .hd-spinner { display: block; }
.hd-search.is-loading .hd-kbd { display: none; }

@keyframes hd-spin { to { transform: rotate(360deg); } }

/* results panel */

.hd-results {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    right: 0;
    z-index: 70;
    max-height: min(70vh, 460px);
    overflow-y: auto;
    padding: 6px;
    border: 1px solid var(--panel-line);
    border-radius: 13px;
    background: var(--panel-card);
    box-shadow: 0 28px 60px -30px rgba(11, 63, 158, .45);
}

.hd-results[hidden] { display: none; }

.hd-group-label {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 10px 4px;
    color: var(--panel-muted);
    font-size: 9px;
    font-weight: 800;
    letter-spacing: .12em;
    text-transform: uppercase;
}

.hd-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    border-radius: 8px;
    text-decoration: none;
    cursor: pointer;
    transition: background .12s ease;
}

.hd-item:hover,
.hd-item.is-active { background: var(--panel-soft); }

.hd-item-icon {
    display: grid;
    place-items: center;
    width: 28px;
    height: 28px;
    flex: 0 0 auto;
    border-radius: 8px;
    background: rgba(26, 115, 232, .1);
    color: var(--panel-primary);
}

.hd-item-icon svg { width: 14px; height: 14px; }

.hd-item-main { min-width: 0; flex: 1 1 auto; }

.hd-item-title {
    display: block;
    color: var(--panel-ink);
    font-size: 12.5px;
    font-weight: 700;
    line-height: 1.3;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.hd-item-meta {
    display: block;
    margin-top: 1px;
    color: var(--panel-muted);
    font-size: 10.5px;
    font-weight: 500;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.hd-item-arrow {
    width: 12px;
    height: 12px;
    flex: 0 0 auto;
    color: var(--panel-muted);
    opacity: 0;
    transition: opacity .12s ease;
}

.hd-item:hover .hd-item-arrow,
.hd-item.is-active .hd-item-arrow { opacity: 1; }

.hd-results-foot {
    position: sticky;
    bottom: -6px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-top: 4px;
    padding: 9px 10px;
    border-top: 1px solid var(--panel-line);
    background: var(--panel-card);
    color: var(--panel-muted);
    font-size: 10.5px;
    font-weight: 700;
}

.hd-results-foot a {
    color: var(--panel-primary);
    font-weight: 800;
    text-decoration: none;
}

.hd-results-foot a:hover { text-decoration: underline; text-underline-offset: 2px; }

.hd-results-empty {
    padding: 22px 14px;
    text-align: center;
}

.hd-results-empty strong {
    display: block;
    color: var(--panel-ink);
    font-size: 12.5px;
    font-weight: 800;
}

.hd-results-empty span {
    display: block;
    margin-top: 3px;
    color: var(--panel-muted);
    font-size: 11px;
    font-weight: 500;
}

/* ---------------- currency & language menus ---------------- */

.hd-menu { position: relative; }

.hd-trigger {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    height: 36px;
    padding: 0 10px;
    border: 1px solid transparent;
    border-radius: 9px;
    background: transparent;
    color: var(--panel-muted);
    font-family: var(--panel-sans);
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
    transition: background .15s ease, border-color .15s ease, color .15s ease;
}

.hd-trigger:hover {
    background: var(--panel-soft);
    color: var(--panel-ink);
}

.hd-trigger[aria-expanded="true"] {
    background: var(--panel-soft);
    border-color: var(--panel-line);
    color: var(--panel-ink);
}

.hd-trigger svg { width: 14px; height: 14px; flex: 0 0 auto; }
.hd-trigger .hd-caret { width: 11px; height: 11px; transition: transform .16s ease; }
.hd-trigger[aria-expanded="true"] .hd-caret { transform: rotate(180deg); }

.hd-trigger-label {
    font-size: 11.5px;
    font-weight: 800;
    letter-spacing: .02em;
}

.hd-panel {
    position: absolute;
    top: calc(100% + 7px);
    inset-inline-end: 0;
    z-index: 70;
    min-width: 208px;
    max-height: 320px;
    overflow-y: auto;
    padding: 5px;
    border: 1px solid var(--panel-line);
    border-radius: 12px;
    background: var(--panel-card);
    box-shadow: 0 28px 60px -30px rgba(11, 63, 158, .45);
}

.hd-panel[hidden] { display: none; }

.hd-option {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 8px 9px;
    border-radius: 7px;
    color: var(--panel-ink);
    text-decoration: none;
    transition: background .12s ease;
}

.hd-option:hover { background: var(--panel-soft); }

.hd-option.is-active { background: var(--panel-soft); }

.hd-option-mark {
    display: grid;
    place-items: center;
    width: 26px;
    height: 26px;
    flex: 0 0 auto;
    border-radius: 7px;
    background: var(--panel-soft);
    color: var(--panel-primary-dark);
    font-size: 10px;
    font-weight: 800;
    letter-spacing: .01em;
}

.hd-option.is-active .hd-option-mark {
    background: var(--panel-primary);
    color: #fff;
}

.hd-option-main { min-width: 0; flex: 1 1 auto; }

.hd-option-title {
    display: block;
    font-size: 12px;
    font-weight: 700;
    line-height: 1.3;
    white-space: nowrap;
}

.hd-option-meta {
    display: block;
    margin-top: 1px;
    color: var(--panel-muted);
    font-size: 10px;
    font-weight: 500;
}

.hd-check {
    width: 13px;
    height: 13px;
    flex: 0 0 auto;
    color: var(--panel-primary);
    opacity: 0;
}

.hd-option.is-active .hd-check { opacity: 1; }

/* ---------------- dark ---------------- */

.dark .hd-search-field { background: var(--panel-soft); }
.dark .hd-kbd { background: var(--panel-card); }
.dark .hd-item-icon { background: rgba(26, 115, 232, .18); color: #8ec5ff; }
.dark .hd-results,
.dark .hd-panel { box-shadow: 0 28px 60px -30px rgba(0, 0, 0, .8); }
.dark .hd-option-mark { background: var(--panel-soft); color: #9dc4f5; }
.dark .hd-option.is-active .hd-option-mark { background: var(--panel-primary); color: #fff; }

/* ---------------- responsive ---------------- */

@media (max-width: 639px) {
    .hd-search { display: none; }
}

@media (max-width: 900px) {
    .hd-search { flex: 1 1 auto; max-width: none; }
    .hd-kbd { display: none; }
}

@media (prefers-reduced-motion: reduce) {
    .hd-spinner { animation: none; }
    .hd-trigger, .hd-item, .hd-option { transition: none; }
}
