/*
 * O'ng chekkadagi suzuvchi ikonkalar paneli (`SideRailAsset`).
 *
 * Markup — `views/layouts/main.php`. Bandlar tuzilmasi (`.right .item`
 * > `.icon` + `.show`) shablondan qolgan va O'ZGARTIRILMAGAN, chunki
 * unga JS ulanadi; bu fayl faqat ko'rinishni yangilaydi.
 *
 * Eski qoidalar `web/gorom/css/style.css` da `.page-wrapper .right`
 * selektori bilan yozilgan. Ularning ustidan yozish uchun bu yerda
 * `.page-wrapper .side-rail ...` ishlatiladi — aniqlik yuqoriroq, ya'ni
 * fayllar tartibiga bog'liq emas. Shablonning boshqa `.right`
 * elementlariga tegilmaydi.
 */

.side-rail {
    --rail-accent: #1f57e0;
    --rail-accent-hover: #2f6bff;
    --rail-surface: rgba(11, 22, 54, 0.55);
    --rail-border: rgba(74, 128, 255, 0.55);
    --rail-icon: #eaf0ff;
    --rail-tooltip: #0a1230;

    position: fixed;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    z-index: 999;
}

.side-rail__panel {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 9px;
    border: 1px solid var(--rail-border);
    border-radius: 22px;
    background-color: var(--rail-surface);
    box-shadow: 0 14px 34px rgba(3, 10, 30, 0.35);
    /* Fon rasmi ustida panel o'qilishi uchun — qo'llab-quvvatlanmasa fon rangi yetarli */
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
}

/* ---- Eski `position: fixed` tizimini bekor qilish ---- */

.page-wrapper .side-rail .right,
.page-wrapper .side-rail .right.first,
.page-wrapper .side-rail .right.second,
.page-wrapper .side-rail .right.third,
.page-wrapper .side-rail .right.fourth,
.page-wrapper .side-rail .right.fifth {
    position: static;
    min-width: 0;
    margin: 0;
    padding: 0;
    border-radius: 0;
    background-color: transparent;
}

/* "Ko'rish imkoniyati" — alohida guruh, referensdagidek ajratgich bilan */
.page-wrapper .side-rail .right.fifth {
    margin-top: 7px;
    padding-top: 7px;
    border-top: 1px solid rgba(255, 255, 255, 0.16);
}

/* ---- Band ---- */

.page-wrapper .side-rail .right .item {
    position: relative;
    display: flex;
    align-items: center;
    margin: 0;
    font-size: inherit;
}

.page-wrapper .side-rail .right .item .icon {
    display: flex;
    color: var(--rail-icon);
}

/* Ikonka maydoni — tugma ham, oddiy belgi ham bir xil ko'rinadi */
.side-rail__btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    padding: 0;
    border: 0;
    border-radius: 13px;
    background-color: transparent;
    color: inherit;
    cursor: pointer;
    transition: background-color 0.18s ease, color 0.18s ease, transform 0.18s ease;
}

.side-rail__btn,
.side-rail__btn:hover,
.side-rail__btn:focus {
    text-decoration: none;
}

.side-rail__btn svg {
    display: block;
}

/*
 * Faol holat: butun band ustiga kelinganda ham, ichidagi element
 * fokusda bo'lganda ham bir xil ko'rinadi — sichqoncha bilan ham,
 * klaviatura bilan ham natija bir xil.
 */
.page-wrapper .side-rail .right .item:hover .side-rail__btn,
.page-wrapper .side-rail .right .item:focus-within .side-rail__btn,
.page-wrapper .side-rail .right .item.is-open .side-rail__btn {
    background-color: var(--rail-accent);
    color: #fff;
}

.side-rail__btn:hover {
    background-color: var(--rail-accent-hover);
}

/* Klaviatura fokusi ko'rinib tursin */
.side-rail__btn:focus-visible {
    outline: 2px solid #fff;
    outline-offset: 2px;
}

/* ---- Tooltip (`.show`) ---- */

/*
 * Tooltip ikonkaning CHAPIDA va oqimdan TASHQARIDA turadi: panel
 * ekranning o'ng chekkasida, shuning uchun o'ngga ochilsa ekrandan
 * chiqib ketardi; oqim ichida qolsa esa ochilganda panelning o'zini
 * kengaytirib yuborardi.
 */
.page-wrapper .side-rail .right .item .show {
    position: absolute;
    right: calc(100% + 10px);
    top: 50%;
    display: flex;
    align-items: center;
    height: 40px;
    max-width: none;
    padding: 0 14px;
    border-radius: 10px;
    background-color: var(--rail-tooltip);
    color: #fff;
    white-space: nowrap;
    /*
     * Ilgari `max-width: 0` + `overflow: hidden` bilan ochilardi; fon va
     * ichki bo'shliq qo'shilgach bu usul yopiq holatda ham yupqa chiziq
     * qoldirardi. Endi ko'rinish `opacity` bilan boshqariladi.
     *
     * `visibility: hidden` ATAYLAB ISHLATILMAGAN: u ichidagi havola va
     * qidiruv maydonini tab tartibidan butunlay chiqarib yuborardi, ya'ni
     * klaviatura bilan Telegram/telefon/email havolalariga yetib
     * bo'lmasdi. `opacity: 0` da element fokuslanadi, fokus tushishi
     * bilan `:focus-within` orqali ko'rinadi.
     */
    opacity: 0;
    pointer-events: none;
    transform: translateY(-50%) translateX(6px);
    transition: opacity 0.18s ease, transform 0.18s ease;
}

/*
 * Ikonka bilan tooltip orasidagi 10px bo'shliqni to'ldiradigan ko'rinmas
 * "ko'prik": usiz sichqoncha tooltipga yetib borguncha hover uzilib,
 * tooltip yopilib qolardi.
 */
.page-wrapper .side-rail .right .item .show::before {
    position: absolute;
    right: -12px;
    top: 0;
    bottom: 0;
    width: 12px;
    content: "";
}

/* Tooltip uchi — ikonkaga qaragan kichik uchburchak */
.page-wrapper .side-rail .right .item .show::after {
    position: absolute;
    right: -4px;
    top: 50%;
    width: 10px;
    height: 10px;
    margin-top: -5px;
    border-radius: 2px;
    background-color: var(--rail-tooltip);
    transform: rotate(45deg);
    content: "";
}

.page-wrapper .side-rail .right .item:hover .show,
.page-wrapper .side-rail .right .item:focus-within .show,
.page-wrapper .side-rail .right .item.is-open .show {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(-50%) translateX(0);
}

/* ---- Tooltip ichidagi matn va qidiruv maydoni ---- */

/*
 * Tooltip ichida endi HAVOLA yo'q — u faqat yozuv. Havolaning o'zi
 * ikonkada, shuning uchun tooltip klaviatura tartibiga kirmaydi.
 */
.page-wrapper .side-rail .right .item .show span {
    color: #fff;
    font-size: 14px;
    font-weight: 500;
    line-height: 1;
}

.page-wrapper .side-rail .right .item .show input {
    width: 190px;
    border: 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.35);
    background-color: transparent;
    color: #fff;
    font-size: 14px;
}

.page-wrapper .side-rail .right .item .show input:focus {
    border-bottom-color: #fff;
    outline: none;
}

.page-wrapper .side-rail .right .item .show input::placeholder {
    color: rgba(255, 255, 255, 0.6);
}

/* ============================================================
   Tor ekranlar
   ============================================================ */

/*
 * Planshet: panel kichrayadi, lekin joyida qoladi.
 */
@media (min-width: 768px) and (max-width: 991.98px) {
    .side-rail {
        right: 8px;
    }

    .side-rail__panel {
        gap: 2px;
        padding: 6px;
        border-radius: 18px;
    }

    .side-rail__btn {
        width: 38px;
        height: 38px;
        border-radius: 11px;
    }

    .page-wrapper .side-rail .right .item .show input {
        width: 150px;
    }
}

/*
 * Mobil: panel butunlay yashiriladi — MAVJUD XULQ shunday edi
 * (`web/gorom/css/responsive.css` da `@media (max-width: 767px)` ichida
 * `.page-wrapper .right { display: none }`). O'sha qoida endi faqat
 * bandlarni yashirardi, tashqi ramka esa ekran chetida yupqa chiziq
 * bo'lib qolardi — shuning uchun ramka ham shu yerda yashiriladi.
 * Aloqa ma'lumotlari mobilda footerdan mavjud.
 */
@media (max-width: 767.98px) {
    .side-rail {
        display: none;
    }
}

/* Harakatni kamaytirish so'ralgan bo'lsa — o'tishlarsiz */
@media (prefers-reduced-motion: reduce) {
    .side-rail__btn,
    .page-wrapper .side-rail .right .item .show {
        transition: none;
    }
}
