/**
 * Oyuncakhobi — native-like mobile layout.
 * Desktop styles stay as-is; these rules only apply on narrow viewports.
 * Page must not scroll horizontally; wide tables scroll inside themselves.
 */

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

html, body {
  max-width: 100%;
  overflow-x: clip;
}

img, video, canvas, svg, iframe, embed, object {
  max-width: 100%;
}

iframe, video, embed, object {
  height: auto;
}

@media (max-width: 900px) {
  html, body {
    width: 100% !important;
    max-width: 100% !important;
    overflow-x: clip !important;
    overscroll-behavior-x: none;
    min-height: 100%;
    min-height: 100dvh;
  }

  body {
    padding-left: env(safe-area-inset-left, 0px);
    padding-right: env(safe-area-inset-right, 0px);
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }

  *, *::before, *::after {
    box-sizing: border-box;
  }

  .shell, .app-shell, .wrap, .page, .main, .layout, .content,
  .topbar, .app-nav, .hero, .card, .modal, .modalbox {
    max-width: 100%;
    min-width: 0;
  }

  .shell, .app-shell {
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
  }

  .topbar-inner, .app-nav-inner, .main, .layout, .page, .wrap,
  .hero, .toolbar, .dtbar, .filters, .formgrid {
    padding-left: max(12px, env(safe-area-inset-left, 0px)) !important;
    padding-right: max(12px, env(safe-area-inset-right, 0px)) !important;
    max-width: 100% !important;
    min-width: 0 !important;
  }

  .topbar {
    height: auto !important;
    min-height: 56px;
    padding-top: env(safe-area-inset-top, 0px);
  }

  .topbar-inner {
    flex-wrap: wrap;
    height: auto !important;
    row-gap: 8px;
    padding-top: 8px !important;
    padding-bottom: 8px !important;
  }

  .brand-block, .user-panel, .hub-tools, .user-card, .brand-block > div {
    min-width: 0;
  }

  .brand-block p,
  .user-card small,
  .hub-tool-label,
  .welcome-paper-row .sub {
    display: none !important;
  }

  .user-panel {
    flex-wrap: wrap !important;
    justify-content: flex-end;
    gap: 6px !important;
    overflow: visible !important;
  }

  .user-card {
    max-width: min(42vw, 160px);
    padding: 6px 10px 6px 6px !important;
  }

  .user-card b,
  .brand-block h1 {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 100%;
  }

  .hub-nav-session {
    max-width: min(46vw, 180px) !important;
  }

  .hub-layout-switch {
    display: none !important;
  }

  /* —— Master-detail: liste + detay (açılınca aşağı kayma düzeltmesi) —— */
  .wrap:not(.full),
  .rapor {
    display: flex !important;
    flex-direction: column !important;
    grid-template-columns: none !important;
    min-height: 0 !important;
    max-width: 100% !important;
    overflow: hidden;
  }

  .wrap:not(.full) > .side,
  .wrap:not(.full) > .filtre,
  .rapor > .filtre:not(.filtre-top) {
    width: 100% !important;
    max-width: 100% !important;
    border-right: 0 !important;
    flex-shrink: 0;
    max-height: min(44vh, 360px);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    min-height: 0;
  }

  .rapor > .filtre.filtre-top {
    width: 100% !important;
    max-width: 100% !important;
    border-right: 0 !important;
    flex-shrink: 0;
    max-height: none;
    overflow: visible;
  }

  .wrap:not(.full) > .side .sidelist,
  .wrap:not(.full) > .filtre:not(.filtre-top),
  .rapor > .filtre:not(.filtre-top) {
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  .wrap:not(.full) > .maincol,
  .rapor > .liste-wrap,
  .wrap:not(.full) > .main {
    flex: 1 1 auto;
    min-height: 0;
    min-width: 0 !important;
    width: 100% !important;
    overflow: auto;
    -webkit-overflow-scrolling: touch;
  }

  .wrap:not(.full).ic-mobil-detail-open > .side,
  .wrap:not(.full).ic-mobil-detail-open > .filtre,
  .rapor.ic-mobil-detail-open > .filtre {
    display: none !important;
  }

  .wrap:not(.full).ic-mobil-detail-open > .maincol,
  .rapor.ic-mobil-detail-open > .liste-wrap {
    max-height: none;
    flex: 1 1 auto;
  }

  .ic-mobil-back {
    display: none;
    align-items: center;
    gap: 6px;
    margin: 0 0 10px;
    width: auto;
    min-height: 40px;
    font-size: 0.82rem;
    font-weight: 700;
  }

  .ic-mobil-detail-open .ic-mobil-back {
    display: inline-flex;
  }

  /* —— details / summary (açılı panel kayması) —— */
  details {
    max-width: 100%;
    overflow: hidden;
  }

  details > summary {
    list-style: none;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    cursor: pointer;
    min-height: 44px;
    padding: 8px 0;
  }

  details > summary::-webkit-details-marker {
    display: none;
  }

  details[open] > :not(summary) {
    margin-top: 0;
    padding-top: 8px;
  }

  details.rapor-panel > summary,
  .wvx-details-sum,
  .dash-head {
    min-height: 44px;
  }

  /* —— Tablolar: yatay kaydırma kapsayıcıda —— */
  .table-card,
  .table-wrap,
  .table-scroll,
  .sayim-table-wrap,
  .termin-scroll,
  .liste-scroll,
  .dt-wrap,
  .oh-table-wrap,
  .card:has(> table),
  .card:has(> .table-responsive) {
    overflow-x: auto !important;
    overflow-y: visible;
    -webkit-overflow-scrolling: touch;
    max-width: 100% !important;
  }

  table {
    width: 100% !important;
    min-width: 0 !important;
    max-width: 100% !important;
  }

  table.min-width-table,
  table.oh-table,
  table.termin-table,
  table.pt,
  table.kalem-table {
    min-width: 640px;
  }

  thead, tbody, tfoot, tr {
    width: 100%;
  }

  th, td {
    word-break: break-word;
    overflow-wrap: anywhere;
    white-space: normal !important;
  }

  /* —— Grid / filtre —— */
  .module-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 10px !important;
  }

  #hubView #moduleGrid.module-grid {
    display: flex !important;
    flex-direction: column !important;
    grid-template-columns: none !important;
    gap: 12px !important;
  }

  #hubView .mod-cat-grid {
    display: flex !important;
    flex-wrap: wrap !important;
    gap: 6px 4px !important;
    justify-content: flex-start;
  }

  #hubView .mod-card {
    width: calc(33.333% - 6px);
    min-width: 88px;
    max-width: 110px;
    min-height: 86px;
  }

  .filter-grid,
  .filter-row,
  .formgrid,
  .form-grid,
  .grid2,
  .grid3,
  .detailgrid,
  .detay-grid,
  .split,
  .thh-subgrid,
  .ayar-grid,
  .hub-ayar-grid,
  .chat-org-grid,
  .pch-body,
  .durum-cards,
  .onay-strip,
  .btns,
  .stats,
  .stat-grid,
  .cards,
  .eniyi,
  .carrier-row,
  .eta,
  .termin-ozet,
  .termin-filters {
    grid-template-columns: 1fr !important;
  }

  .filter-grid {
    grid-template-columns: 1fr 1fr !important;
  }

  .durum-cards {
    grid-template-columns: 1fr 1fr !important;
  }

  .app-nav-inner, .navs, .filters, .toolbar, .dtbar, .chips, .hub-tools {
    flex-wrap: wrap !important;
    max-width: 100%;
  }

  .navbtn, .btn, .btn2, .qbtn, .chip {
    max-width: 100%;
    min-height: 40px;
  }

  input, select, textarea, button {
    max-width: 100%;
  }

  input[type="text"], input[type="search"], input[type="email"],
  input[type="password"], input[type="number"], input[type="date"],
  input[type="tel"], textarea, select {
    width: 100%;
    min-width: 0 !important;
    font-size: 16px;
  }

  .search, .module-search, .module-search input {
    flex: 1 1 100% !important;
    min-width: 0 !important;
    width: 100% !important;
  }

  .modal {
    padding: 8px !important;
    align-items: flex-end !important;
  }

  .modalbox, .pch-modal .modalbox, .notif-modal-box {
    max-width: 100% !important;
    width: 100% !important;
    margin: 0;
    border-radius: 16px 16px 12px 12px !important;
    max-height: min(96dvh, 100%) !important;
  }

  .ic-desktop-toast-stack {
    left: 12px !important;
    right: 12px !important;
    width: auto !important;
    max-width: none !important;
  }

  .pch-fab {
    right: max(14px, env(safe-area-inset-right, 0px)) !important;
    bottom: max(14px, env(safe-area-inset-bottom, 0px)) !important;
  }

  body.hub-dock-on .pch-fab {
    bottom: max(72px, calc(52px + env(safe-area-inset-bottom, 0px))) !important;
  }

  .home-bar, .app-home-bar {
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }

  /* —— Modül merkezi gömülü panel (iframe) —— */
  .hub-panel-embed .hub-panel-frames,
  .hub-panel-embed .hub-panel-frame {
    inset: 0 0 calc(52px + env(safe-area-inset-bottom, 0px)) 0 !important;
  }

  .hub-session-dock {
    padding-bottom: calc(8px + env(safe-area-inset-bottom, 0px)) !important;
  }

  .hub-sidebar {
    width: min(var(--sidebar-w, 248px), 88vw) !important;
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }

  .hub-desk-main {
    min-width: 0;
    width: 100%;
  }

  pre, code {
    max-width: 100%;
    overflow-x: auto;
    white-space: pre-wrap;
    word-break: break-word;
  }

  .tabs, .settings-tabs, .hub-atab-row {
    width: 100% !important;
    max-width: 100% !important;
    flex-wrap: wrap !important;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    gap: 6px !important;
  }

  .tab, .stab, .hub-atab {
    flex: 0 0 auto;
    min-height: 40px;
    white-space: nowrap;
  }

  .page {
    padding-left: max(12px, env(safe-area-inset-left, 0px)) !important;
    padding-right: max(12px, env(safe-area-inset-right, 0px)) !important;
  }

  .grid {
    grid-template-columns: 1fr !important;
  }

  .section-head {
    flex-direction: column !important;
    align-items: stretch !important;
  }

  .module-toolbar {
    width: 100%;
    justify-content: stretch !important;
  }

  /* Mobilde ikincil sütunları gizle (veri kısıtlama) */
  .oh-table th:nth-child(n+8),
  .oh-table td:nth-child(n+8),
  table.compact-mobile th:nth-child(n+7),
  table.compact-mobile td:nth-child(n+7) {
    display: none;
  }
}

@media (max-width: 480px) {
  .module-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  }

  #hubView #moduleGrid.module-grid {
    display: flex !important;
    flex-direction: column !important;
    grid-template-columns: none !important;
  }

  #hubView .mod-card {
    width: calc(50% - 6px);
    min-width: 80px;
    min-height: 80px;
  }

  .filter-grid {
    grid-template-columns: 1fr !important;
  }

  .durum-cards {
    grid-template-columns: 1fr !important;
  }

  .stats, .stat-grid, .cards {
    grid-template-columns: 1fr 1fr !important;
  }

  .btn-ghost-danger, #btnLogout {
    width: auto;
  }

  .brand-mark {
    width: 36px !important;
    height: 36px !important;
  }

  .brand-block h1 {
    font-size: .95rem !important;
  }

  .wrap:not(.full) > .side,
  .wrap:not(.full) > .filtre,
  .rapor > .filtre:not(.filtre-top) {
    max-height: min(38vh, 280px);
  }
  .rapor > .filtre.filtre-top {
    max-height: none;
  }
}
