/* ==========================================================================
   Asaka 1-son texnikumi — umumiy mobil/planshet tuzatishlari (2026-11-19)
   Asosiy sayt, admin, talaba va o'qituvchi panellariga ulangan.
   ========================================================================== */

/* Media elementlar konteynerdan chiqib ketmasin */
img, video, canvas, svg, iframe, embed, object { max-width: 100%; }
img, video { height: auto; }

/* JS o'ragan jadvallar uchun gorizontal skroll */
.rf-table-scroll {
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-x: contain;
}
.rf-table-scroll > table { min-width: 100%; }

/* Uzun so'z / havola / email matnni buzmasin */
h1, h2, h3, h4, p, li, label, .card, .a-card { overflow-wrap: anywhere; }
/* Jadval kataklari so'z o'rtasidan bo'linmasin — jadval kengaysin va yon tomonga suriladi */
td, th { overflow-wrap: normal; word-break: normal; }
td :where(p, li, label, h1, h2, h3, h4, a), th :where(p, li, label, a) { overflow-wrap: normal; }
pre, code { white-space: pre-wrap; word-break: break-word; }

@media (max-width: 900px) {
  /* Keng ikki ustunli maketlar planshetda bitta ustunga */
  [style*="grid-template-columns:360px 1fr"],
  [style*="grid-template-columns: 360px 1fr"],
  [style*="grid-template-columns:1fr 360px"],
  [style*="grid-template-columns: 1fr 360px"],
  [style*="grid-template-columns:220px 1fr"],
  [style*="grid-template-columns: 220px 1fr"],
  [style*="grid-template-columns:2fr 1fr"],
  [style*="grid-template-columns: 2fr 1fr"],
  [style*="grid-template-columns:1.2fr 1fr"],
  [style*="grid-template-columns: 1.2fr 1fr"],
  [style*="grid-template-columns:repeat(4"],
  [style*="grid-template-columns: repeat(4"] {
    grid-template-columns: 1fr 1fr !important;
  }
  [style*="grid-template-columns:360px 1fr"],
  [style*="grid-template-columns: 360px 1fr"],
  [style*="grid-template-columns:1fr 360px"],
  [style*="grid-template-columns: 1fr 360px"],
  [style*="grid-template-columns:220px 1fr"],
  [style*="grid-template-columns: 220px 1fr"] {
    grid-template-columns: 1fr !important;
  }
}

@media (max-width: 640px) {
  /* Inline yozilgan ko'p ustunli gridlar telefonda bitta ustun */
  [style*="grid-template-columns:1fr 1fr"],
  [style*="grid-template-columns: 1fr 1fr"],
  [style*="grid-template-columns:repeat(2"],
  [style*="grid-template-columns: repeat(2"],
  [style*="grid-template-columns:repeat(3"],
  [style*="grid-template-columns: repeat(3"],
  [style*="grid-template-columns:repeat(4"],
  [style*="grid-template-columns: repeat(4"],
  [style*="grid-template-columns:2fr 1fr"],
  [style*="grid-template-columns: 2fr 1fr"],
  [style*="grid-template-columns:1.2fr 1fr"],
  [style*="grid-template-columns: 1.2fr 1fr"] {
    grid-template-columns: 1fr !important;
  }
  /* grid-column: span 2 kabi elementlar bitta ustunda to'g'ri tursin */
  [style*="grid-column: span"], [style*="grid-column:span"],
  [style*="grid-column: 1 / -1"], [style*="grid-column:1 / -1"], [style*="grid-column:1/-1"] {
    grid-column: 1 / -1 !important;
  }

  /* iOS Safari input bosilganda sahifani kattalashtirmasin */
  input:not([type="checkbox"]):not([type="radio"]):not([type="range"]),
  select, textarea {
    font-size: 16px !important;
  }

  /* Flex qatorlardagi tugmalar sig'masa keyingi qatorga o'tsin */
  .a-page-head, .a-toolbar, .a-filters, .page-head, .toolbar, .filters,
  .tp-page-head, .tp-toolbar, .card-head, .a-card-head {
    flex-wrap: wrap;
    gap: 10px;
  }

  /* Modal oynalar ekranga sig'sin */
  .modal, .modal-content, .modal-box, .a-modal, .a-modal-box, .tp-modal, dialog {
    max-width: calc(100vw - 24px) !important;
    max-height: calc(100vh - 24px);
    overflow-y: auto;
  }

  /* Pastki o'ng burchakdagi suzuvchi tugma kontentni yopmasin */
  .md-fab { right: 16px; bottom: 16px; padding: 10px 16px; }
}

/* Telefon gorizontal skrolli: sahifa yon tomonga siljimasin */
@media (max-width: 1024px) {
  html, body { max-width: 100%; overflow-x: clip; }
}

/* ==========================================================================
   v2 (2026-11-19): panellarning yuqori qatori, inline flex qatorlar,
   tor telefonlar (320–414px) uchun professional moslashuv
   ========================================================================== */

/* ---------- Umumiy: inline flex qatorlar telefonda sig'masa o'raladi ---------- */
@media (max-width: 640px) {
  [style*="display:flex"]:not([style*="flex-direction:column"]):not([style*="nowrap"]),
  [style*="display: flex"]:not([style*="flex-direction: column"]):not([style*="nowrap"]) {
    flex-wrap: wrap;
  }
  /* Yuqori panel ichidagi qatorlar o'ralmasin */
  .a-top [style*="display:flex"], .a-top [style*="display: flex"],
  .tp-topbar [style*="display:flex"], .tp-topbar [style*="display: flex"] {
    flex-wrap: nowrap;
  }
  /* Flex bolalari torayib ketishi mumkin bo'lsin (matn ekrandan chiqmasin) */
  [style*="display:flex"] > div, [style*="display: flex"] > div { min-width: 0; }
}

/* Katta minimal kenglikli auto-fit/auto-fill kartalar tor telefonda bitta ustun */
@media (max-width: 480px) {
  [style*="minmax(240px"], [style*="minmax(250px"], [style*="minmax(260px"],
  [style*="minmax(270px"], [style*="minmax(280px"], [style*="minmax(290px"],
  [style*="minmax(300px"], [style*="minmax(320px"], [style*="minmax(340px"],
  [style*="minmax(350px"], [style*="minmax(360px"], [style*="minmax(380px"],
  [style*="minmax(400px"] {
    grid-template-columns: 1fr !important;
  }
}

/* ---------- ADMIN PANEL ---------- */
@media (max-width: 900px) {
  .a-top { padding: 0 14px; gap: 10px; }
  .a-top-left { gap: 10px; flex: 1 1 auto; min-width: 0; }
  .a-top-title { min-width: 0; }
  .a-top-title h1 {
    font-size: 17px; line-height: 1.2; margin: 0;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  }
  .a-top-crumb { display: none; }
  .a-top-actions { gap: 8px; flex-shrink: 0; }
  .a-top-link-btn { padding: 8px; }
  .a-top-link-btn > span:not(.material-symbols-outlined) { display: none; }
  /* Direktor tugmasi: faqat ikonka + badge */
  .a-top-actions > a.btn > span:nth-child(2) { display: none; }
  .a-top-actions > a.btn { padding: 8px !important; }
}
@media (max-width: 640px) {
  .a-top { height: 60px; padding: 0 10px; gap: 6px; }
  .a-menu-btn { padding: 6px; }
  .a-top-title h1 { font-size: 15px; }
  .a-top-actions { gap: 5px; }
  .a-top-icon-btn { width: 34px; height: 34px; border-radius: 10px; }
  .a-top-icon-btn .material-symbols-outlined { font-size: 19px; }
  .a-top-link-btn, .tp-voice-top-btn#adminVoiceTopBtn { display: none !important; }
  .a-user { padding: 2px; gap: 0; }
  .a-content { padding: 14px 12px 88px !important; }
  .a-card { padding: 16px; border-radius: 14px; }
  .a-grid-2 { gap: 16px; }
  .a-stats { gap: 10px; margin-bottom: 18px; }
}
@media (max-width: 400px) {
  /* Juda tor telefonlar: ikkinchi darajali tugmalarni yashirish */
  #adminThemeToggleBtn { display: none !important; }
  .a-stats { grid-template-columns: 1fr !important; }
}

/* ---------- TALABA va O'QITUVCHI PANELLARI ---------- */
@media (max-width: 900px) {
  .tp-topbar { padding: 0 14px; gap: 10px; }
  .tp-topbar-left { gap: 10px; min-width: 0; flex: 1 1 auto; }
  .tp-page-title {
    font-size: 17px; min-width: 0;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  }
  .tp-topbar-right { gap: 8px; flex-shrink: 0; }
  .tp-content { padding: 18px; }
}
@media (max-width: 640px) {
  .tp-topbar { padding: 0 10px; gap: 6px; }
  .tp-page-title { font-size: 15px; }
  .tp-topbar-right { gap: 5px; }
  .tp-icon-btn { width: 34px !important; height: 34px !important; }
  /* Hamyon chiplari: faqat bitta, ixcham */
  .tp-topbar-right > a[href="hamyon.php#shop"] { display: none !important; }
  .tp-topbar-right > a[href="hamyon.php"] { padding: 4px 8px !important; font-size: 12px !important; }
  .tp-chip-gpa { padding: 5px 9px; font-size: 12px; }
  .tp-content { padding: 12px 12px 88px; }
  .tp-pwa-action > span:not(.material-symbols-outlined) { display: none; }
}
@media (max-width: 480px) {
  #portalInstallButton, #portalPushButton,
  .tp-topbar .tp-voice-top-btn,
  .tp-chip-gpa { display: none !important; }
}

/* ---------- ASOSIY SAYT ---------- */
@media (max-width: 480px) {
  .container { padding-left: 14px; padding-right: 14px; }
  .stats-strip .inner { padding: 0 8px; }
  .strip-item { padding: 18px 8px; }
  .cta-banner { padding: 28px 16px !important; }
  .cta-actions { flex-direction: column; align-items: stretch; }
  .cta-actions > * { justify-content: center; }
}

/* ==========================================================================
   v3 (2026-11-19): ASOSIY SAYT MOBIL HEADER — bitta qator:
   logo + nom | Kirish, maxsus imkoniyatlar, menyu. Til, bildirishnoma va
   ilova tugmalari menyu (drawer) ichiga ko'chirildi.
   ========================================================================== */
.m-quick { display: none; }
@media (max-width: 640px) {
  .header .inner {
    flex-wrap: nowrap !important; height: auto; min-height: 60px;
    padding: 8px 10px 8px 12px !important; gap: 8px;
  }
  .header-brand { flex: 1 1 auto; min-width: 0; gap: 8px; }
  .header-brand .logo-img { width: 40px !important; height: 40px !important; flex-shrink: 0; }
  .header-brand .brand-text .name {
    font-size: .875rem; line-height: 1.2; white-space: normal;
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
  }
  .header-actions {
    flex: 0 0 auto !important; width: auto !important; margin-left: 0;
    gap: 6px !important; flex-wrap: nowrap !important;
  }
  .header-actions .lang-switcher,
  .header-actions #pushSubscribeButton,
  .header-actions #pwaInstallButton { display: none !important; }
  .header-actions .portal-entry-wrap { margin: 0; position: static; }
  .header-actions .btn-portal-entry-topbar {
    height: 40px; padding: 0 12px !important; font-size: 13px; border-radius: 20px;
  }
  .header-actions .btn-portal-entry-topbar > span:last-child { display: none; }
  .header-actions .access-hamburg-btn {
    width: 40px !important; height: 40px !important; flex: 0 0 40px; border-radius: 12px;
  }
  .header-actions .hamburger { width: 40px; height: 40px; flex: 0 0 40px; }

  /* Kirish menyusi: ekran kengligida, header ostida (chetdan chiqmaydi) */
  .portal-entry-menu {
    position: fixed !important;
    top: var(--rf-pe-top, 68px) !important;
    left: 12px !important; right: 12px !important;
    min-width: 0 !important; width: auto !important; max-width: none !important;
    max-height: calc(100vh - var(--rf-pe-top, 68px) - 12px);
    overflow-y: auto;
  }
  .portal-entry-item { min-width: 0; }
  .portal-entry-item .pe-info { min-width: 0; flex: 1 1 auto; }
  .portal-entry-item .pe-title, .portal-entry-item .pe-desc { white-space: normal; }

  /* Drawer ichidagi tez tugmalar */
  .m-quick {
    display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
    padding: 0 16px 12px; margin-bottom: 4px;
    border-bottom: 1px solid var(--md-sys-color-outline-variant, rgba(0,0,0,.08));
  }
  .m-quick .m-lang a { height: 38px; padding: 0 14px; display: inline-flex; align-items: center; font-weight: 700; font-size: .85rem; }
  .m-quick-btn {
    width: 40px; height: 40px; border-radius: 12px; cursor: pointer;
    display: inline-flex; align-items: center; justify-content: center;
    border: 1px solid var(--md-sys-color-outline-variant, rgba(0,0,0,.12));
    background: transparent; color: var(--md-sys-color-on-surface-variant, #475569);
  }
  .m-quick-btn[hidden] { display: none !important; }
  .mobile-nav { max-width: 88vw; }
}
@media (max-width: 380px) {
  /* Juda tor: Kirish tugmasi faqat ikonka */
  .header-actions .btn-portal-entry-topbar { width: 40px; padding: 0 !important; justify-content: center; }
  .header-actions .btn-portal-entry-topbar > span:nth-child(2) { display: none; }
  .header-brand .logo-img { width: 36px !important; height: 36px !important; }
  .header-brand .brand-text .name { font-size: .8rem; }
}

/* v3: qolgan inline uch ustunli gridlar, maxsus imkoniyatlar paneli, uzun email/havolalar */
@media (max-width: 640px) {
  [style*="grid-template-columns:1fr 1fr 1fr"], [style*="grid-template-columns: 1fr 1fr 1fr"],
  [style*="grid-template-columns:repeat(5"], [style*="grid-template-columns: repeat(5"],
  [style*="grid-template-columns:repeat(6"], [style*="grid-template-columns: repeat(6"] {
    grid-template-columns: 1fr 1fr !important;
  }
}
@media (max-width: 420px) {
  [style*="grid-template-columns:1fr 1fr 1fr"], [style*="grid-template-columns: 1fr 1fr 1fr"] {
    grid-template-columns: 1fr !important;
  }
  .access-gems-grid { grid-template-columns: repeat(3, 1fr) !important; }
  .access-drawer { max-width: 100vw !important; }
}
a[href^="mailto:"], a[href^="tel:"], .email, [class*="email"] { overflow-wrap: anywhere; word-break: break-word; }

/* v3: planshet (641–900px) — header ham bitta qatorda qolsin */
@media (min-width: 641px) and (max-width: 900px) {
  .header .inner { flex-wrap: nowrap !important; gap: 10px; }
  .header-brand { flex: 1 1 auto; min-width: 0; }
  .header-brand .brand-text .sub { display: none; }
  .header-brand .brand-text .name {
    white-space: normal; line-height: 1.2;
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
  }
  .header-actions { flex: 0 0 auto; gap: 6px; flex-wrap: nowrap; }
  .header-actions .portal-entry-wrap { margin: 0; }
}

/* ==========================================================================
   v4 (2026-11-20): JADVALLAR telefonda — so'zlar butun, sarlavhalar bir qatorda,
   jadval kengligi bo'yicha gorizontal skroll; talaba/o'qituvchi topbar
   ========================================================================== */
@media (max-width: 900px) {
  .rf-table-scroll th, [style*="overflow-x:auto"] > table th, [style*="overflow-x: auto"] > table th,
  .table-responsive th, .a-table-wrap th, .tp-table-wrap th {
    white-space: nowrap;
  }
  /* Skroll borligini ko'rsatuvchi ingichka chiziq */
  .rf-table-scroll, [style*="overflow-x:auto"], [style*="overflow-x: auto"] {
    scrollbar-width: thin; -webkit-overflow-scrolling: touch;
  }
}

/* Talaba / o'qituvchi topbar: menyu tugmasi har doim ko'rinsin, o'ng tomon ixcham */
@media (max-width: 1024px) {
  .tp-topbar { gap: 8px; }
  .tp-topbar-left { flex: 1 1 auto; min-width: 0; gap: 8px; }
  .tp-hamburger { flex: 0 0 auto; display: inline-flex !important; align-items: center; justify-content: center;
                  width: 40px; height: 40px; padding: 0; border-radius: 12px; }
  .tp-topbar-right { flex: 0 1 auto; min-width: 0; }
}
@media (max-width: 900px) {
  .tp-user-info { display: none !important; }
  .tp-user-pill { padding: 2px !important; gap: 0 !important; background: transparent !important; }
}
@media (max-width: 640px) {
  .rf-coin-label { display: none; }
  .tp-topbar-right > a[href="hamyon.php"] { padding: 5px 10px !important; white-space: nowrap; flex-shrink: 0; }
  .tp-topbar-right > * { flex-shrink: 0; }
  .tp-page-title { flex: 1 1 auto; }
}
@media (max-width: 360px) {
  .tp-page-title { display: none; }
}
@media (max-width: 1024px) {
  .tp-burger-btn { flex: 0 0 auto; }
  .tp-topbar-left > div { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
}

/* v5 (2026-11-20): emoji o'rnidagi tizim ikonkalari */
.material-symbols-outlined.ui-ic {
  font-size: 1.2em; line-height: 1; width: 1em; height: 1em;
  display: inline-flex; align-items: center; justify-content: center;
  vertical-align: -0.2em; margin: 0 .08em;
  font-variation-settings: 'FILL' 0, 'wght' 500, 'GRAD' 0, 'opsz' 24;
  overflow: hidden; flex-shrink: 0; user-select: none;
}
.material-symbols-outlined.ui-ic.ui-ic-fill { font-variation-settings: 'FILL' 1, 'wght' 500, 'GRAD' 0, 'opsz' 24; }
.ui-ic-green  { color: #16a34a; }
.ui-ic-amber  { color: #d97706; }
.ui-ic-red    { color: #dc2626; }
.ui-ic-orange { color: #ea580c; }
.ui-ic-blue   { color: #2563eb; }
.ui-ic-grey   { color: #94a3b8; }
.ui-ic-gold   { color: #eab308; }
.ui-ic-silver { color: #94a3b8; }
.ui-ic-bronze { color: #b45309; }
.ui-ic-circle { font-size: .9em; }
/* Rangli fonda (gradient tugma/chip) turgan ikonkalar rangini meros oladi */
[style*="linear-gradient"] .ui-ic:not(.ui-ic-gold):not(.ui-ic-silver):not(.ui-ic-bronze),
.btn .ui-ic, button .ui-ic, .btn-primary .ui-ic { color: inherit; }
html[data-theme-mode="dark"] .ui-ic-amber { color: #fbbf24; }
html[data-theme-mode="dark"] .ui-ic-blue  { color: #60a5fa; }

/* v5: qattiq kenglikdagi inputlar/bloklar telefon ekranidan oshmasin */
input, select, textarea { max-width: 100%; }
@media (max-width: 640px) {
  [style*="width:260px"], [style*="width:280px"], [style*="width:300px"], [style*="width:320px"], [style*="width:340px"],
  [style*="width: 260px"], [style*="width: 280px"], [style*="width: 300px"], [style*="width: 320px"], [style*="width: 340px"] {
    max-width: 100% !important;
  }
}

/* ==========================================================================
   v6 (2026-11-20): telefon/planshetda TAB qatorlari — bitta qatorda,
   yon tomonga suriladigan segment-tablar (o'ralib, har xil o'lchamda tushmaydi)
   ========================================================================== */
@media (max-width: 760px) {
  :is(div, nav, ul):has(> :is(.game-tab-btn, .settings-tab-btn, .kpi-tab, .cr-tab, .tab-btn, .lib-tab-btn, .nav-tab, .filter-btn):nth-child(3)),
  .settings-tabs, .kpi-tabs, .rf-tabs {
    display: flex !important;
    flex-wrap: nowrap !important;
    overflow-x: auto;
    overflow-y: hidden;
    gap: 8px !important;
    padding: 4px 2px 8px !important;
    margin-left: -2px; margin-right: -2px;
    scroll-snap-type: x proximity;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
    mask-image: linear-gradient(to right, #000 calc(100% - 28px), transparent);
    -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 28px), transparent);
  }
  :is(div, nav, ul):has(> :is(.game-tab-btn, .settings-tab-btn, .kpi-tab, .cr-tab, .tab-btn, .lib-tab-btn, .nav-tab, .filter-btn):nth-child(3))::-webkit-scrollbar,
  .settings-tabs::-webkit-scrollbar, .kpi-tabs::-webkit-scrollbar { display: none; }
  .rf-tabs-end { mask-image: none !important; -webkit-mask-image: none !important; }
  :is(.game-tab-btn, .settings-tab-btn, .kpi-tab, .cr-tab, .tab-btn, .lib-tab-btn, .nav-tab, .filter-btn) {
    flex: 0 0 auto !important;
    white-space: nowrap !important;
    scroll-snap-align: start;
    padding: 9px 14px !important;
    font-size: 13px !important;
    border-radius: 999px !important;
    min-height: 40px;
  }
  :is(.game-tab-btn, .settings-tab-btn, .kpi-tab, .cr-tab, .tab-btn, .lib-tab-btn) .material-symbols-outlined {
    font-size: 18px !important;
  }
}

/* ---------- Talaba/o'qituvchi topbar: telefonda faqat asosiylar ---------- */
@media (max-width: 640px) {
  /* Push va ilova o'rnatish — sozlamalar sahifasida bor; topbarda ortiqcha (ikki qo'ng'iroq ko'rinardi) */
  #portalInstallButton, #portalPushButton { display: none !important; }
  .tp-chip-gpa { display: none !important; }
  .tp-topbar .tp-voice-top-btn { display: none !important; }
  .tp-topbar-right { gap: 6px !important; }
  .tp-topbar-right > a[href="hamyon.php"] { height: 34px; padding: 0 10px !important; border-radius: 17px !important; }
  .tp-topbar-right > a[href="hamyon.php"] .ui-ic { color: #fff !important; }
}
/* Planshet: GPA bo'sh ("—") bo'lsa chip ko'rsatilmaydi */
.tp-chip-gpa.rf-empty { display: none !important; }
