/* assets/css/mobile.css - mobil moslashuv qatlami (2026-10). Breakpointlar: 480 / 640 / 768 / 1024.
   1024px va undan kengda faqat toshish (overflow) tuzatishlari ishlaydi, ko'rinish o'zgarmaydi. Ba'zi view'lar o'z <style> blokini bu fayldan
   keyin e'lon qiladi, shuning uchun ularning qoidalarini bosish uchun selektor "body" bilan kuchaytiriladi. */

/* Har qanday kenglikda: .page-actions (flex-shrink:0) tugmalari ko'p bo'lsa ota elementdan chiqib ketmasin */
.page-actions { max-width: 100%; }

/* Public portfolio navbar: tugmalar brend yonida sig'maydi, pastki qatorga o'tadi */
@media screen and (max-width: 640px) {
    body .public-navbar { flex-wrap: wrap; gap: 10px; padding: 12px 16px; }
    body .public-navbar .nav-actions { width: 100%; justify-content: flex-start; }
    body .public-navbar .nav-actions .btn-modern { flex: 1 1 auto; justify-content: center; }
}

/* Integratsiyalar sahifasi sarlavhasi: ikon + sarlavha + badge bir qatorga sig'maydi */
@media screen and (max-width: 640px) {
    body .integration-hero { padding: 20px 18px; }
    body .integration-hero-main { flex-wrap: wrap; gap: 12px; }
    body .integration-hero-main > div { min-width: 0; flex: 1 1 100%; }
    body .integration-hero-title { flex-wrap: wrap; font-size: 20px; gap: 8px; }
}

/* iOS Safari 16px dan kichik maydonga fokus berilganda sahifani kattalashtiradi */
@media screen and (max-width: 768px) {
    input:not([type=checkbox]):not([type=radio]):not([type=range]):not([type=hidden]), select, textarea { font-size: 16px !important; }
}

/* Mayda matn: telefonda o'qiladigan minimal o'lcham (11px) */
@media screen and (max-width: 768px) {
    .badge, .badge-q, .citescore-pill, .doi-pill, .pub-year, .r-degree-pill, .sync-hour, .dir-pill,
    .pub-cits-lbl, .comp-label, .tab-badge, .podium-mini-lbl, .admin-vip-badge, .network-hud-lbl,
    .conf-cal-month, .conf-cal-year, .cm-countdown-label, .cm-cd-lbl, .mobile-nav-item span { font-size: 11px !important; }
    .pub-authors-small, .sync-date, .palette-item-sub { font-size: 12px !important; }
}

/* Bosish nishonlari: barmoq uchun kamida 24px (WCAG 2.5.8) */
@media screen and (max-width: 768px) {
    a.badge, .doi-pill, .doi-pill-box, .badge-cits, .id-tag, .metric-link { min-height: 28px; display: inline-flex; align-items: center; }
    .pub-row-title, .pub-link { display: inline-block; padding: 4px 0; line-height: 1.4; }
    .btn-sm { min-width: 32px; min-height: 32px; }
    .user-name { min-height: 32px; display: inline-flex; align-items: center; }
}

/* View'lardagi inline font-size (8-10.5px) ham telefonda 11px dan kichik bo'lmasin */
@media screen and (max-width: 768px) {
    [style*="font-size:8px"], [style*="font-size: 8px"], [style*="font-size:8.5px"], [style*="font-size: 8.5px"],
    [style*="font-size:9px"], [style*="font-size: 9px"], [style*="font-size:9.5px"], [style*="font-size: 9.5px"],
    [style*="font-size:10px"], [style*="font-size: 10px"], [style*="font-size:10.5px"], [style*="font-size: 10.5px"],
    .cm-meta small { font-size: 11px !important; }
}

/* Alohida qatordagi havolalar (matn ichida emas): balandligi kamida 24px */
@media screen and (max-width: 768px) {
    .r-name a, .r-dept a, .profile-dept-title a, .cm-crumbs a, .meta-chip-item a { display: inline-flex; align-items: center; min-height: 24px; }
}

/* Gorizontal scroll bor jadval: chetida soya, qo'shimcha ustunlar borligini bildiradi */
@media screen and (max-width: 768px) {
    .table-responsive.has-scroll-hint {
        background:
            linear-gradient(to right, var(--bg-card, var(--public-card, #fff)) 30%, transparent) left / 24px 100% no-repeat local,
            linear-gradient(to left, var(--bg-card, var(--public-card, #fff)) 30%, transparent) right / 24px 100% no-repeat local,
            radial-gradient(farthest-side at 0 50%, rgba(15, 23, 42, .22), transparent) left / 12px 100% no-repeat scroll,
            radial-gradient(farthest-side at 100% 50%, rgba(15, 23, 42, .22), transparent) right / 12px 100% no-repeat scroll;
    }
    .table-responsive.has-scroll-hint > table { background: transparent; }
}

/* .table-stack: telefonda har qator karta, har katak ustiga ustun nomi */
@media screen and (max-width: 640px) {
    .table-responsive > table.table-stack { min-width: 0 !important; }
    /* Sarlavha yashirilmaydi: saralanadigan ustunlar (onclick .sortable-th yoki havola) chip qatori bo'ladi */
    table.table-stack thead { display: block; margin-bottom: 10px; }
    table.table-stack thead tr {
        display: flex !important; flex-wrap: wrap; align-items: center; gap: 6px;
        border: 0 !important; padding: 0 !important; margin: 0 !important; background: transparent !important;
    }
    table.table-stack thead tr::before {
        content: "Saralash:"; font-size: 12px; font-weight: 700; color: var(--text-muted, var(--public-muted, #64748b));
    }
    table.table-stack thead th { display: none; }
    table.table-stack thead th.sortable-th, table.table-stack thead th:has(a) {
        display: block; width: auto !important; padding: 5px 10px !important; font-size: 12px !important;
        border: 1px solid var(--border-color, var(--public-border, #e2e8f0)) !important; border-radius: 999px;
        background: var(--bg-card, var(--public-card, #fff)) !important; white-space: nowrap;
    }
    table.table-stack thead th > div, table.table-stack thead th > a { gap: 6px; }
    table.table-stack, table.table-stack tbody { display: block; width: 100% !important; }
    /* Karta: 2 ustunli grid; uzun matnli katak (JS .stack-full qo'yadi) to'liq kenglikni oladi */
    table.table-stack tr {
        display: grid; grid-template-columns: 1fr 1fr; column-gap: 12px; row-gap: 6px;
        border: 1px solid var(--border-color, var(--public-border, #e2e8f0)); border-radius: 12px; padding: 12px;
        margin-bottom: 10px; background: var(--bg-card, var(--public-card, #fff)) !important;
    }
    table.table-stack td {
        display: block; width: auto !important; min-width: 0; padding: 2px 0 !important; border: 0 !important;
        text-align: left !important; background: transparent !important; overflow-wrap: anywhere;
    }
    table.table-stack td.stack-full, table.table-stack td[colspan] { grid-column: 1 / -1; }
    table.table-stack td[data-label]::before {
        content: attr(data-label); display: block; font-size: 11px; font-weight: 700;
        text-transform: uppercase; letter-spacing: .03em; color: var(--text-muted, var(--public-muted, #64748b)); margin-bottom: 2px;
    }
    table.table-stack td[colspan]::before, table.table-stack td.stack-no-label::before { display: none; }
}
@media print {
    table.table-stack thead { display: table-header-group !important; }
    table.table-stack tr { display: table-row !important; }
    table.table-stack td { display: table-cell !important; }
    table.table-stack td::before { display: none !important; }
}

/* "Yana ko'rsatish": data-show-more="N" bilan belgilangan ro'yxatning birinchi N ta elementi */
@media screen and (max-width: 768px) {
    .sm-more-hidden { display: none !important; }
    .sm-more-btn {
        display: flex; width: 100%; justify-content: center; align-items: center; gap: 8px;
        min-height: 44px; margin: 10px 0; border: 1px dashed var(--border-color, var(--public-border, #e2e8f0)); border-radius: 12px;
        background: var(--bg-card, var(--public-card, #fff)); color: var(--primary, var(--public-primary, #247879)); font-weight: 700; font-size: 14px; cursor: pointer;
    }
}
@media screen and (min-width: 769px) { .sm-more-btn { display: none !important; } }
@media print { .sm-more-btn, .sm-filter-toggle { display: none !important; } }

/* Filtr formalari: telefonda "Filtrlar" tugmasi ostiga yig'iladi (mobile.js qo'shadi) */
.sm-filter-toggle { display: none; }
@media screen and (max-width: 768px) {
    .sm-filter-toggle {
        display: flex; align-items: center; justify-content: space-between; width: 100%; min-height: 44px;
        padding: 10px 14px; margin-bottom: 10px; border: 1px solid var(--border-color, var(--public-border, #e2e8f0)); border-radius: 12px;
        background: var(--bg-card, var(--public-card, #fff)); color: var(--text-main, var(--public-text, #0f172a)); font-weight: 700; font-size: 15px; cursor: pointer;
    }
    .sm-filter-toggle i { margin-right: 8px; color: var(--primary, var(--public-primary, #247879)); }
    .sm-filter-toggle .sm-filter-count {
        min-width: 22px; padding: 2px 8px; border-radius: 999px; background: var(--primary, var(--public-primary, #247879)); color: #fff;
        font-size: 12px; text-align: center;
    }
    form.filter-form.sm-filter-collapsed { display: none !important; }
}

/* Ochiq menyu qorong'ilashtiruvchi qatlam (z 1040) ustida. Qorong'i rejimda "html.dark-theme .sidebar" (kuchliroq selektor) z-index ni
   100 ga qaytarardi — menyu qatlam ostida xira bo'lib qolardi; #id bilan tuzatiladi (planshetdagi chap panel ham) */
@media screen and (max-width: 1024px) {
    #main-navigation { z-index: 1060; }
}

/* Pastki menyu (≤768px): bandlar NavigationService::bottomBar() dan (rolga qarab). "Menyu" bandi yon menyuni (#main-navigation)
   pastdan ochiladigan panel qilib ochadi — telefonda yuqoridagi ☰ tugma yo'q. iPhone pastki chizig'i uchun safe-area. */
.mobile-bottom-nav { display: none; }
@media screen and (max-width: 768px) {
    .mobile-bottom-nav {
        display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 998;
        height: calc(64px + env(safe-area-inset-bottom, 0px)); padding: 0 4px env(safe-area-inset-bottom, 0px);
        align-items: stretch; justify-content: space-around;
        background: var(--bg-surface, #fff); border-top: 1px solid var(--border-color, #e2e8f0); box-shadow: 0 -4px 16px rgba(15, 23, 42, .06);
    }
    html.dark-theme .mobile-bottom-nav, body.dark-theme .mobile-bottom-nav { box-shadow: 0 -4px 16px rgba(0, 0, 0, .35); }
    .mobile-nav-item {
        flex: 1 1 0; min-width: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
        padding: 6px 2px; border: 0; background: transparent; font: inherit; font-size: 11px; font-weight: 600; line-height: 1.2;
        color: var(--text-muted, #64748b); text-decoration: none; cursor: pointer; -webkit-tap-highlight-color: transparent;
    }
    .mobile-nav-item > span:last-child { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
    .mobile-nav-item i { font-size: 18px; }
    .mobile-nav-item.active, .mobile-nav-item[aria-expanded="true"] { color: var(--primary, #247879); }
    .mobile-nav-item:focus-visible { outline: 2px solid var(--primary, #247879); outline-offset: -4px; border-radius: 10px; }
    .mobile-nav-icon { position: relative; display: inline-flex; }
    .mobile-nav-badge {
        position: absolute; top: -7px; left: calc(100% - 6px); min-width: 18px; height: 18px; padding: 0 5px; border-radius: 999px;
        background: var(--danger, #dc2626); color: #fff; font-size: 11px; font-weight: 700; line-height: 18px; text-align: center;
        box-shadow: 0 0 0 2px var(--bg-surface, #fff);
    }
    .mobile-nav-circle {
        width: 44px; height: 44px; margin-top: -18px; border-radius: 50%; display: flex; align-items: center; justify-content: center;
        background: var(--primary-gradient, var(--primary, #247879)); color: #fff; box-shadow: var(--primary-glow, none);
        border: 3px solid var(--bg-surface, #fff); transition: transform .2s ease;
    }
    .mobile-nav-circle i { font-size: 19px; }
    .mobile-nav-action:active .mobile-nav-circle { transform: scale(.92); }
    .content-container { padding-bottom: calc(88px + env(safe-area-inset-bottom, 0px)) !important; }

    /* Yon menyu -> pastki panel. #id: qorong'i rejimdagi "html.dark-theme .sidebar" qoidalaridan kuchliroq bo'lishi uchun */
    .topbar-sidebar-toggle { display: none !important; }
    #main-navigation {
        top: auto; left: 0; right: 0; bottom: calc(64px + env(safe-area-inset-bottom, 0px));
        /* 80%: tepada qorong'i joy qoladi — unga bosib yopish oson */
        width: 100%; max-width: none; height: auto; max-height: min(80dvh, calc(100dvh - var(--header-height, 56px) - 64px - 16px));
        border-right: 0 !important; border-top: 1px solid var(--border-color, #e2e8f0); border-radius: 18px 18px 0 0;
        box-shadow: 0 -12px 32px rgba(15, 23, 42, .18); overscroll-behavior: contain;
        transform: translateY(calc(100% + 64px + env(safe-area-inset-bottom, 0px))); visibility: hidden;
        transition: transform .28s cubic-bezier(.33, 1, .68, 1), visibility 0s linear .28s;
    }
    #main-navigation.open { transform: translateY(0); visibility: visible; transition: transform .28s cubic-bezier(.33, 1, .68, 1), visibility 0s; }
    #main-navigation::before {
        content: ""; display: block; width: 40px; height: 4px; margin: 8px auto 0; border-radius: 999px; background: var(--border-color, #cbd5e1);
    }
    #main-navigation .sidebar-nav { padding-top: 6px; padding-bottom: 16px; }
    /* Bosh sahifa va Kiruvchilar pastki menyuning o'zida bor — panelda takrorlanmaydi */
    #main-navigation .nav-top-link { display: none; }
    /* Panel ochiq: pastki menyu qorong'ilashtiruvchi qatlam ustida qoladi — "Menyu" qayta bosilsa yopiladi, boshqa bandlar ishlaydi */
    body.nav-sheet-open .mobile-bottom-nav { z-index: 1070; }
}
@media screen and (max-width: 768px) and (prefers-reduced-motion: reduce) {
    #main-navigation, #main-navigation.open { transition: none; }
}
@media print { .mobile-bottom-nav { display: none !important; } }

/* Eng tor ekranlar (360px): uzun matnli tugma qatorga o'raladi, qotirilgan grid ustuni torayadi */
@media screen and (max-width: 480px) {
    .btn { white-space: normal; }
    body .scientometrics-grid { grid-template-columns: minmax(0, 1fr); }
}
