/**
 * Paragam mobile shell (v9)
 * Desktop (≥1025px) is untouched — all rules live inside max-width queries
 * or html.pg-mobile / html.sidebar-open helpers.
 *
 * Model: hamburger top bar + off-canvas drawer (NOT Hope UI sidebar-mini).
 */

html{ -webkit-text-size-adjust:100%; }
img,svg,video{ max-width:100%; height:auto; }
button,.btn,a.nav-link,.form-control,.form-select{ touch-action:manipulation; }

/* ---- Mobile chrome (hidden on desktop) ---- */
.pg-mobile-bar{
  display:none;
  position:sticky;
  top:0;
  z-index:1300;
  align-items:center;
  gap:.65rem;
  padding:.55rem .75rem;
  padding-top:calc(.55rem + env(safe-area-inset-top, 0px));
  background:var(--pg-surface,#fff);
  border-bottom:1px solid var(--pg-border,rgba(16,42,67,.08));
  backdrop-filter:blur(8px);
  pointer-events:auto;
}
#mobile-nav-toggle{
  appearance:none;
  border:1px solid var(--pg-border,rgba(16,42,67,.12));
  background:var(--pg-surface-2,#f8fafc);
  color:var(--pg-text,#111827);
  width:2.75rem;height:2.75rem;min-height:2.75rem;border-radius:.7rem;
  display:inline-flex;align-items:center;justify-content:center;
  cursor:pointer;flex:0 0 auto;
  pointer-events:auto;
  position:relative;
  z-index:1301;
}
#mobile-nav-toggle svg{ width:1.25rem;height:1.25rem; }
.pg-mobile-bar-title{
  font-weight:700;font-size:.95rem;color:var(--pg-text,#111827);
  white-space:nowrap;overflow:hidden;text-overflow:ellipsis;min-width:0;flex:1;
}
.pg-mobile-bar-right{
  display:flex;align-items:center;gap:.45rem;margin-left:auto;pointer-events:auto;
}
.pg-sidebar-backdrop{
  display:none;
  position:fixed;inset:0;z-index:1200;
  background:rgba(15,23,42,.48);
  backdrop-filter:blur(2px);
  pointer-events:none;
  border:0;padding:0;margin:0;
}
.pg-sidebar-backdrop.is-visible{
  display:block;
  pointer-events:auto;
}

/* Kill Hope UI offcanvas dimmer — we use .pg-sidebar-backdrop */
.screen-darken,
.screen-darken.active{
  pointer-events:none!important;
  width:0!important;opacity:0!important;visibility:hidden!important;
}
body.offcanvas-active{ overflow:auto!important; }

/* Class helpers (set early in theme_head) */
html.pg-mobile .pg-mobile-bar{ display:flex!important; }
html.pg-mobile body,
html.pg-mobile{ overflow-x:hidden; }

/* =========================================================
   Shell ≤1024.98px — primary mobile/tablet layout
   ========================================================= */
@media (max-width:1024.98px){
  .pg-mobile-bar{ display:flex; }

  /* Full-width content; desktop margin-left must not remain */
  .main-content,
  .sidebar.sidebar-mini + .main-content,
  .sidebar + .main-content,
  html.sidebar-collapsed .main-content{
    margin-left:0!important;
    width:100%!important;
    max-width:100vw;
    position:relative;
    z-index:1;
    pointer-events:auto!important;
  }
  .wrapper{ overflow-x:hidden; }

  /* Drawer: always in layout tree, slid off-canvas when closed */
  .sidebar.sidebar-default,
  .sidebar.sidebar-base,
  .sidebar.sidebar-mini,
  .sidebar.on-resize,
  aside#app-sidebar{
    display:flex!important;
    flex-direction:column!important;
    position:fixed!important;
    top:0!important;left:0!important;right:auto!important;bottom:0!important;
    width:min(18.5rem,86vw)!important;
    max-width:86vw!important;
    min-width:0!important;
    height:100%!important;
    height:100dvh!important;
    max-height:100dvh!important;
    margin:0!important;
    z-index:1250!important;
    transform:translate3d(-105%,0,0)!important;
    -webkit-transform:translate3d(-105%,0,0)!important;
    visibility:hidden;
    pointer-events:none!important;
    box-shadow:none!important;
    transition:transform .22s ease, visibility 0s linear .22s;
  }
  html.sidebar-open .sidebar.sidebar-default,
  html.sidebar-open .sidebar.sidebar-base,
  html.sidebar-open .sidebar.sidebar-mini,
  html.sidebar-open .sidebar.on-resize,
  html.sidebar-open aside#app-sidebar{
    transform:translate3d(0,0,0)!important;
    -webkit-transform:translate3d(0,0,0)!important;
    visibility:visible;
    pointer-events:auto!important;
    box-shadow:12px 0 40px rgba(0,0,0,.28)!important;
    transition:transform .22s ease, visibility 0s;
  }
  html.sidebar-open{ overflow:hidden; }
  html.sidebar-open body{ overflow:hidden!important; }

  .sidebar .sidebar-collapse-btn{ display:none!important; }

  /* Always show full labels in drawer (defeat Hope UI mini styles) */
  .sidebar .nav-link .item-name,
  .sidebar .menu-section-title,
  .sidebar .section-label,
  .sidebar .logo-title,
  .sidebar .brand-logo-full{
    display:initial!important;
    opacity:1!important;
    visibility:visible!important;
    width:auto!important;
    max-width:none!important;
    height:auto!important;
    overflow:visible!important;
    position:static!important;
    transform:none!important;
    -webkit-transform:none!important;
  }
  .sidebar .brand-logo-mark{ display:none!important; }
  .sidebar .nav-link{
    justify-content:flex-start!important;
    gap:.7rem!important;
    padding:.7rem 1rem!important;
  }
  .sidebar .sidebar-header{
    flex-direction:row!important;
    justify-content:space-between!important;
    padding:.85rem .75rem!important;
  }

  .main-content > .content-inner,
  .main-content .content-inner,
  .iq-banner:not(.hide)+.content-inner{
    padding:.65rem .75rem 1.25rem!important;
  }
  body.page-dashboard .main-content > .content-inner,
  body.page-dashboard .content-inner{
    padding:0!important;
  }

  .panel-toolbar{
    flex-direction:column;
    align-items:stretch!important;
    gap:.55rem!important;
    margin-bottom:.85rem;
  }
  .panel-toolbar .panel-title{ font-size:1.15rem!important; line-height:1.3; }
  .panel-toolbar-right{
    margin-left:0!important;
    width:100%;
    justify-content:flex-start;
    flex-wrap:wrap;
    gap:.5rem!important;
  }
  .panel-toolbar .panel-user{ order:3; width:100%; font-size:.8rem; }
  .panel-toolbar div.page-actions{
    width:100%;display:flex;flex-wrap:wrap;gap:.45rem;
  }
  .panel-toolbar div.page-actions .btn{
    flex:1 1 auto;min-width:calc(50% - .3rem);
  }

  .stat-grid{
    grid-template-columns:repeat(2,minmax(0,1fr))!important;
    gap:.55rem!important;
  }
  .stat-grid .stat{ padding:.75rem .8rem; }
  .stat-grid .stat .val{ font-size:1.05rem; }

  .filter-bar{
    flex-direction:column;
    align-items:stretch!important;
    gap:.65rem!important;
  }
  .filter-bar .field{ width:100%; }
  .filter-bar .form-control,
  .filter-bar .form-select{
    min-width:0!important;
    max-width:none!important;
    width:100%!important;
  }
  .filter-bar > .btn{ width:100%; }

  .pay-filter{
    display:grid!important;
    grid-template-columns:1fr!important;
    gap:.65rem!important;
  }
  .pay-filter .field,
  .pay-filter .form-control,
  .pay-filter .form-select,
  .pay-filter .btn{
    width:100%!important;max-width:none!important;min-width:0!important;
  }

  .modal-dialog{
    margin:.5rem;
    max-width:calc(100vw - 1rem)!important;
  }
  .modal-content{ border-radius:.9rem; }
  .modal-body{ padding:1rem; }
  .modal-footer{ flex-wrap:wrap; gap:.45rem; }
  .modal-footer .btn{ flex:1 1 auto; }

  .cms-ticker{
    max-width:100%!important;width:100%!important;min-width:0!important;
    order:2;position:relative;overflow:hidden!important;height:1.55rem;
  }
  .cms-ticker-track{ position:absolute;left:0;top:0;will-change:transform; }
  .cms-msg-wrap{ margin-left:auto; }
  .cms-msg-panel{ width:min(340px,calc(100vw - 1.5rem))!important;right:0; }
  .cms-dash-head{
    flex-direction:column!important;align-items:stretch!important;
    max-width:100%;min-width:0;
  }
  .cms-dash-head > *{ min-width:0;max-width:100%; }
  .dash-board,.bo-dash{ padding:1rem .85rem 1.5rem!important; }
  .dash-grid,.bo-grid{ grid-template-columns:repeat(2,minmax(0,1fr))!important; }
  .user-card,.site-card,.totp-card,.card{ max-width:100%; }

  /* Tables: soft scroll on tablet; phone gets card layout below */
  .table-responsive{
    margin-left:0;margin-right:0;
    border-radius:.65rem;
    -webkit-overflow-scrolling:touch;
    overflow-x:auto;
  }
  .table-responsive > .table{
    min-width:0;
    font-size:.84rem;
  }
  .table th,.table td{
    padding:.55rem .6rem!important;
    white-space:normal;
    vertical-align:top;
  }
  .pg-clip,.pg-clip-stack{ max-width:100%; }
  td.pg-clip-cell{ max-width:none; }
}

/* =========================================================
   Phone ≤767.98px — card rows for primary data tables
   ========================================================= */
@media (max-width:767.98px){
  .stat-grid{ grid-template-columns:1fr!important; }
  .panel-toolbar div.page-actions .btn{
    min-width:100%;width:100%;
  }
  .form-control,.form-select,input,textarea,select,.btn{
    font-size:16px!important; /* iOS zoom guard */
  }
  .btn-sm{ font-size:.9rem!important; padding:.5rem .75rem!important; }
  .auto-refresh-row{
    justify-content:space-between;width:100%;
  }

  /* Cardify standard panel tables (skip nested / special tables) */
  .table-responsive > table.table:not(.settle-detail-table):not(.pg-keep-table){
    min-width:0!important;
    width:100%!important;
    border-collapse:separate;
    border-spacing:0 .65rem;
    background:transparent!important;
  }
  .table-responsive > table.table:not(.settle-detail-table):not(.pg-keep-table) > thead{
    position:absolute!important;
    width:1px;height:1px;padding:0;margin:-1px;
    overflow:hidden;clip:rect(0,0,0,0);border:0;
  }
  .table-responsive > table.table:not(.settle-detail-table):not(.pg-keep-table) > tbody{
    display:block;width:100%;
  }
  .table-responsive > table.table:not(.settle-detail-table):not(.pg-keep-table) > tbody > tr{
    display:block;
    width:100%;
    margin:0;
    padding:.7rem .85rem .8rem;
    border:1px solid var(--pg-border,rgba(16,42,67,.12))!important;
    border-radius:.85rem;
    background:var(--pg-surface,#fff)!important;
    box-shadow:0 1px 2px rgba(16,42,67,.04);
  }
  .table-responsive > table.table:not(.settle-detail-table):not(.pg-keep-table) > tbody > tr > td,
  .table-responsive > table.table:not(.settle-detail-table):not(.pg-keep-table) > tbody > tr > th{
    display:flex!important;
    align-items:flex-start;
    justify-content:space-between;
    gap:.85rem;
    width:100%!important;
    max-width:100%!important;
    border:0!important;
    border-bottom:1px dashed var(--pg-border,rgba(16,42,67,.1))!important;
    padding:.4rem 0!important;
    white-space:normal!important;
    text-align:right!important;
    background:transparent!important;
    box-shadow:none!important;
  }
  .table-responsive > table.table:not(.settle-detail-table):not(.pg-keep-table) > tbody > tr > td:last-child,
  .table-responsive > table.table:not(.settle-detail-table):not(.pg-keep-table) > tbody > tr > th:last-child{
    border-bottom:0!important;
    padding-bottom:0!important;
  }
  .table-responsive > table.table:not(.settle-detail-table):not(.pg-keep-table) > tbody > tr > td::before,
  .table-responsive > table.table:not(.settle-detail-table):not(.pg-keep-table) > tbody > tr > th::before{
    content:attr(data-label);
    flex:0 0 38%;
    max-width:42%;
    text-align:left;
    font-size:.72rem;
    font-weight:700;
    letter-spacing:.03em;
    text-transform:uppercase;
    color:var(--pg-text-muted,#627d98);
    line-height:1.35;
    padding-top:.1rem;
  }
  .table-responsive > table.table:not(.settle-detail-table):not(.pg-keep-table) > tbody > tr > td:not([data-label])::before,
  .table-responsive > table.table:not(.settle-detail-table):not(.pg-keep-table) > tbody > tr > th:not([data-label])::before{
    content:none;
    display:none;
  }
  .table-responsive > table.table:not(.settle-detail-table):not(.pg-keep-table) > tbody > tr > td > *,
  .table-responsive > table.table:not(.settle-detail-table):not(.pg-keep-table) > tbody > tr > td .pg-clip,
  .table-responsive > table.table:not(.settle-detail-table):not(.pg-keep-table) > tbody > tr > td .pg-clip-stack{
    max-width:100%;
    text-align:right;
  }
  .table-responsive > table.table:not(.settle-detail-table):not(.pg-keep-table) td.page-actions,
  .table-responsive > table.table:not(.settle-detail-table):not(.pg-keep-table) td.pg-actions{
    flex-wrap:wrap;
    justify-content:flex-end!important;
    gap:.4rem;
  }
  .table-responsive > table.table:not(.settle-detail-table):not(.pg-keep-table) td.page-actions .btn,
  .table-responsive > table.table:not(.settle-detail-table):not(.pg-keep-table) td.page-actions a.btn{
    margin:0!important;
  }
  .table-responsive > table.table:not(.settle-detail-table):not(.pg-keep-table) .empty-row{
    text-align:center!important;
    justify-content:center!important;
  }
  .table-responsive > table.table:not(.settle-detail-table):not(.pg-keep-table) .empty-row::before{
    content:none!important;display:none!important;
  }

  .dash-grid,.bo-grid{ grid-template-columns:1fr!important; }

  /* ---- Yatırım / Çekim: fit phone viewport ---- */
  .pg-m-hide{ display:none!important; }

  .pg-pay-stats{
    grid-template-columns:repeat(2,minmax(0,1fr))!important;
    gap:.45rem!important;
    margin-bottom:.75rem!important;
  }
  .pg-pay-stats .stat{
    padding:.55rem .65rem!important;
    border-radius:.65rem;
  }
  .pg-pay-stats .stat .lbl{
    font-size:.7rem!important;
    line-height:1.25;
  }
  .pg-pay-stats .stat .val{
    font-size:.98rem!important;
    margin-top:.1rem!important;
  }

  details.pg-filter-drawer{
    margin:0 0 .85rem;
    border:1px solid var(--pg-border,rgba(16,42,67,.12));
    border-radius:.75rem;
    background:var(--pg-surface,#fff);
    overflow:hidden;
  }
  details.pg-filter-drawer > summary{
    list-style:none;
    cursor:pointer;
    user-select:none;
    padding:.8rem .9rem;
    font-weight:700;
    font-size:.92rem;
    color:var(--pg-text,#111827);
    display:flex;
    align-items:center;
    justify-content:space-between;
    gap:.5rem;
  }
  details.pg-filter-drawer > summary::-webkit-details-marker{ display:none; }
  details.pg-filter-drawer > summary::after{
    content:"▼";
    font-size:.65rem;
    opacity:.55;
    transition:transform .15s ease;
  }
  details.pg-filter-drawer[open] > summary::after{ transform:rotate(180deg); }
  details.pg-filter-drawer .pg-pay-filters,
  details.pg-filter-drawer .pay-filter{
    padding:.15rem .85rem .9rem;
    margin-bottom:0!important;
  }

  .pg-pay-filters{
    display:grid!important;
    grid-template-columns:1fr 1fr;
    align-items:end!important;
    gap:.55rem!important;
  }
  .pg-pay-filters .field{ width:100%!important; min-width:0!important; }
  .pg-pay-filters .field:first-child,
  .pg-pay-filters > .btn,
  .pg-pay-filters > a.btn,
  .pg-pay-filters .pg-excel-btn,
  .pg-pay-filters button[type="submit"]{
    grid-column:1 / -1;
  }
  .pg-pay-filters .form-control,
  .pg-pay-filters .form-select{
    min-width:0!important;
    max-width:none!important;
    width:100%!important;
  }

  /* Compact payment cards */
  .pg-pay-table-wrap > table.pg-pay-table{
    border-spacing:0 .55rem!important;
  }
  .pg-pay-table-wrap > table.pg-pay-table > tbody > tr{
    padding:.65rem .75rem .7rem!important;
  }
  .pg-pay-table-wrap > table.pg-pay-table > tbody > tr > td{
    padding:.32rem 0!important;
  }
  .pg-pay-table-wrap > table.pg-pay-table > tbody > tr > td.pg-m-hide{
    display:none!important;
  }
  .pg-pay-table-wrap > table.pg-pay-table td.pg-pay-amount{
    font-weight:800!important;
    font-size:1.05rem!important;
    color:var(--pg-text,#111827);
  }
  .pg-pay-table-wrap > table.pg-pay-table td.pg-pay-status{
    align-items:center!important;
  }
  .pg-pay-table-wrap > table.pg-pay-table td.pg-pay-actions{
    display:grid!important;
    grid-template-columns:1fr 1fr;
    gap:.4rem!important;
    padding-top:.55rem!important;
    border-top:1px solid var(--pg-border,rgba(16,42,67,.1))!important;
    border-bottom:0!important;
    margin-top:.25rem;
  }
  .pg-pay-table-wrap > table.pg-pay-table td.pg-pay-actions::before{
    content:attr(data-label);
    grid-column:1 / -1;
    text-align:left;
    font-size:.72rem;
    font-weight:700;
    letter-spacing:.03em;
    text-transform:uppercase;
    color:var(--pg-text-muted,#627d98);
    margin-bottom:.1rem;
  }
  .pg-pay-table-wrap > table.pg-pay-table td.pg-pay-actions .btn,
  .pg-pay-table-wrap > table.pg-pay-table td.pg-pay-actions a.btn{
    width:100%;
    justify-content:center;
    margin:0!important;
  }
  .pg-pay-table-wrap > table.pg-pay-table td.pg-pay-actions .payment-operator{
    grid-column:1 / -1;
    text-align:right;
    margin:0!important;
  }
  .pg-pay-table-wrap .pg-clip,
  .pg-pay-table-wrap .pg-clip-stack{
    max-width:100%!important;
  }
}

@media (max-width:575.98px){
  .main-content > .content-inner.panel-shell{
    padding:.55rem .6rem 1.1rem!important;
  }
  .panel-toolbar .panel-title{ font-size:1.05rem!important; }
  .cms-msg-panel{ width:calc(100vw - 1rem)!important; }
  .login-shell{ padding:.85rem!important; }
  .login-card{ padding:1.35rem 1.1rem 1.15rem!important; border-radius:1rem!important; }
  .login-brand-logo{ height:2rem!important; }
}

@media (max-width:480px){
  .shell .chips{ gap:.35rem; }
  .shell .chip{ padding:.4rem .55rem; font-size:.78rem; }
}
