/* Preview-only UX polish v2 — canlıya gitmez */

/* ---- Perf (hafif; flash yapmayacak kadar) ---- */
.ph-card,
.tx-table-card,
.tx-filters-card,
.toolbar-card,
.list-card,
.group-card {
  content-visibility: auto;
  contain-intrinsic-size: 1px 240px;
}
.ph-main img,
.tx-table img,
.bank-logo img {
  decoding: async;
}

/* ---- Built-in empty / loading (TransactionsView) ---- */
.tx-state {
  min-height: 11rem;
  padding: 2rem 1.25rem !important;
  gap: 0.35rem;
}
.tx-state--empty .tx-state__icon {
  background: rgba(148, 163, 184, 0.12) !important;
  border-style: dashed !important;
}
.tx-state--loading .tx-spinner {
  width: 2.25rem !important;
  height: 2.25rem !important;
}
.tx-state h3 {
  font-size: 1.05rem !important;
  font-weight: 750 !important;
}
.tx-state p {
  opacity: 0.9;
}

/* ---- Recon / report empty + loading ---- */
.empty-note,
.partner-empty {
  display: block;
  margin: 0.85rem 0;
  padding: 1.15rem 1rem;
  text-align: center;
  border: 1px dashed var(--ph-border, rgba(148, 163, 184, 0.4));
  border-radius: 12px;
  background: rgba(148, 163, 184, 0.06);
  color: var(--ph-text-muted, #64748b);
  font-size: 0.88rem;
  line-height: 1.45;
}
.loading-block {
  min-height: 8rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.65rem;
  color: var(--ph-text-muted, #64748b);
}
.loading-block__spinner {
  width: 1.65rem !important;
  height: 1.65rem !important;
}

/* Generic empty/error (non-tx pages) */
.ph-ux-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  min-height: 9rem;
  padding: 1.5rem 1rem;
  text-align: center;
  color: var(--ph-text-muted, #64748b);
  border: 1px dashed var(--ph-border, rgba(148, 163, 184, 0.35));
  border-radius: 12px;
  background: rgba(148, 163, 184, 0.06);
  margin: 0.75rem;
}
.ph-ux-empty__title {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 650;
  color: var(--ph-text, #0f172a);
}
html[data-theme="dark"] .ph-ux-empty__title {
  color: #e2e8f0;
}
.ph-ux-empty__desc {
  margin: 0;
  font-size: 0.82rem;
  max-width: 28rem;
  line-height: 1.45;
}
.ph-ux-error,
.err:not(input):not(textarea):not(select) {
  display: block;
  margin: 0 0 0.85rem;
  padding: 0.75rem 0.9rem;
  border-radius: 10px;
  border: 1px solid rgba(248, 113, 113, 0.35);
  background: rgba(239, 68, 68, 0.1);
  color: #fecaca;
  font-size: 0.86rem;
  line-height: 1.4;
}
html[data-theme="light"] .ph-ux-error,
html[data-theme="light"] .err:not(input):not(textarea):not(select) {
  color: #991b1b;
  background: #fef2f2;
  border-color: #fecaca;
}
.tx-alert {
  border-radius: 10px !important;
}

/* ---- Desktop niceties ---- */
.tx-table-wrap,
.ph-card__body:has(table) {
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-x: contain;
  scrollbar-gutter: stable;
}
.tx-table th {
  backdrop-filter: blur(6px);
}
.tx-act {
  min-height: 1.85rem;
}

/* Sticky toolbars on long report pages */
.toolbar-card .toolbar,
.report-filters,
.list-filters {
  position: sticky;
  top: 0;
  z-index: 4;
  backdrop-filter: blur(8px);
}
/* Preview banner offset (banner only on preview index) */
body:has(#ph-preview-banner) .toolbar-card .toolbar,
body:has(#ph-preview-banner) .report-filters,
body:has(#ph-preview-banner) .list-filters,
body:has(#ph-preview-banner) .ph-topbar {
  top: 32px;
}

/* ---- Mobile / tablet ---- */
@media (max-width: 1023px) {
  #ph-preview-banner {
    font-size: 11px;
    padding: 5px 10px;
    line-height: 1.3;
  }

  .ph-main,
  .ph-main-col,
  .ph-page,
  .tx-page {
    padding-left: 0.7rem !important;
    padding-right: 0.7rem !important;
  }

  .ph-page-header {
    flex-wrap: wrap;
    gap: 0.5rem;
  }
  .ph-page-header__title {
    font-size: 1.12rem !important;
    line-height: 1.25;
  }
  .ph-page-header__actions {
    width: 100%;
    display: flex;
    flex-wrap: wrap;
    gap: 0.45rem;
  }
  .ph-page-header__actions .ph-btn {
    flex: 1 1 auto;
    min-height: 2.45rem;
  }

  /* Filters: denser, full-width controls */
  .tx-filters {
    grid-template-columns: 1fr 1fr !important;
    gap: 0.5rem !important;
  }
  .tx-search {
    grid-column: 1 / -1 !important;
  }
  .tx-filter-actions {
    grid-column: 1 / -1;
    width: 100%;
  }
  .tx-filter-actions .ph-btn,
  .tx-filter-actions button {
    flex: 1 1 calc(50% - 0.35rem);
    min-height: 2.45rem;
  }

  /* Report / recon toolbars */
  .toolbar,
  .report-filters,
  .list-filters,
  .filter-row {
    display: flex !important;
    flex-wrap: wrap !important;
    gap: 0.5rem !important;
  }
  .toolbar__dates,
  .toolbar__presets,
  .toolbar__actions,
  .report-filters__actions,
  .filter-actions,
  .toolbar-actions,
  .form-actions {
    width: 100%;
    display: flex;
    flex-wrap: wrap;
    gap: 0.45rem;
  }
  .toolbar__actions .ph-btn,
  .toolbar__actions button,
  .report-filters__actions .ph-btn,
  .filter-actions .ph-btn,
  .form-actions .ph-btn,
  .toolbar-actions .ph-btn {
    flex: 1 1 calc(50% - 0.35rem);
    min-height: 2.45rem;
  }

  .kpi-grid,
  .group-grid,
  .hero-strip__stats {
    grid-template-columns: 1fr 1fr !important;
  }

  .form-grid,
  .ph-form-grid {
    grid-template-columns: 1fr !important;
  }
  .span-2 {
    grid-column: 1 / -1 !important;
  }

  /* Table scroll with hint shadow */
  .tx-table-wrap,
  .ph-card__body:has(> .tx-table),
  .ph-card__body:has(table) {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  .tx-table,
  table.ph-table,
  .totals-table {
    min-width: 700px;
  }

  /* Action chips: easier thumb targets */
  .tx-acts,
  .row-actions,
  .actions {
    gap: 0.4rem !important;
    flex-wrap: wrap;
  }
  .tx-act,
  .row-actions .ph-btn,
  .actions .btn,
  .actions .ph-btn {
    min-height: 2rem;
    padding: 0.4rem 0.7rem !important;
    font-size: 0.74rem !important;
  }

  /* Pager sticky at bottom of viewport within page */
  .tx-pager,
  .list-pager {
    position: sticky;
    bottom: 0;
    z-index: 5;
    padding: 0.55rem 0.35rem;
    margin: 0 -0.25rem;
    background: color-mix(in srgb, var(--ph-surface, #fff) 92%, transparent);
    backdrop-filter: blur(8px);
    border-top: 1px solid var(--ph-border, rgba(148, 163, 184, 0.25));
  }

  /* Modals — bottom sheet feel */
  .detail-modal-backdrop,
  .reject-modal-backdrop,
  .manual-backdrop {
    padding: 0.5rem !important;
    align-items: flex-end !important;
  }
  .detail-modal,
  .reject-modal,
  .manual-modal {
    width: 100% !important;
    max-height: min(92dvh, 920px) !important;
    border-radius: 16px 16px 10px 10px !important;
  }
  .detail-grid {
    grid-template-columns: 88px 1fr !important;
  }

  /* Drawer dim */
  .ph-shell--drawer-open .ph-main::before {
    content: "";
    position: fixed;
    inset: 0;
    z-index: 40;
    background: rgba(2, 6, 23, 0.48);
    pointer-events: none;
  }
}

@media (max-width: 640px) {
  .tx-filters {
    grid-template-columns: 1fr !important;
  }
  .kpi-grid,
  .group-grid,
  .hero-strip__stats {
    grid-template-columns: 1fr !important;
  }
  .tx-meta {
    font-size: 0.78rem;
  }
  .tx-table {
    font-size: 0.78rem !important;
  }
  .tx-table th,
  .tx-table td {
    padding: 0.55rem 0.6rem !important;
  }
  .tx-user {
    max-width: 6.5rem !important;
  }
  .preset-chip {
    font-size: 0.72rem !important;
    padding: 0.35rem 0.55rem !important;
  }
}

@media (max-width: 480px) {
  .ph-page-header__desc {
    display: none !important;
  }
  .tx-table,
  table.ph-table,
  .totals-table {
    min-width: 620px;
  }
}

/* Dark theme tweaks */
html[data-theme="dark"] .tx-pager,
html[data-theme="dark"] .list-pager {
  background: color-mix(in srgb, var(--ph-surface, #0f172a) 90%, transparent);
}
html[data-theme="dark"] .tx-state--empty .tx-state__icon,
html[data-theme="dark"] .empty-note,
html[data-theme="dark"] .partner-empty {
  background: rgba(148, 163, 184, 0.1) !important;
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  .ph-card,
  .tx-table-card,
  .tx-filters-card,
  .toolbar-card,
  .list-card,
  .group-card {
    content-visibility: visible;
  }
  .tx-pager,
  .list-pager,
  .toolbar-card .toolbar,
  .report-filters,
  .list-filters {
    backdrop-filter: none;
  }
}
