/* Responsive overrides for the portal shell and current Razor screens. */

.app-topbar,
.topbar-actions,
.header-notifications,
.filter-bar,
.payments-filter-bar,
.page-heading,
.section-title,
.bank-cash-actions,
.cash-flow-filter-bar {
  min-width: 0;
}

.app-topbar {
  isolation: isolate;
}

.topbar-search {
  min-width: 0;
}

.topbar-actions {
  flex: 0 0 auto;
  max-width: 100%;
}

.topbar-actions > .dropdown,
.header-notifications > .dropdown {
  flex: 0 0 auto;
}

.header-action,
.icon-btn,
.quick-action-btn,
.nav-notification-btn,
.user-profile.header-action {
  flex: 0 0 auto;
}

.dropdown-menu-end {
  max-width: calc(100vw - 24px);
}

.table-responsive {
  display: block;
  width: 100%;
  max-width: 100%;
  overflow-x: auto !important;
  overflow-y: hidden !important;
  -webkit-overflow-scrolling: touch;
}

.table-responsive > table {
  margin-bottom: 0;
}

.table .btn,
.table button,
.table a.btn,
.action-buttons,
.inline-action-form {
  white-space: nowrap;
}

.action-buttons,
.table .actions-cell .d-flex,
.table .actions-cell .d-inline-flex,
.inline-action-form {
  flex-wrap: nowrap !important;
}

.chart-card,
.chart-panel,
.chart-panel canvas,
.bank-cash-chart,
.bank-breakdown-panel {
  max-width: 100%;
  min-width: 0;
}

.chart-panel {
  overflow: hidden;
}

.chart-panel canvas {
  display: block;
}

.auth-page {
  min-width: 0;
  overflow-x: hidden;
}

@media (min-width: 1200px) {
  .app-sidebar {
    flex: 0 0 var(--tb-sidebar-width);
  }
}

@media (max-width: 1199.98px) {
  .app-frame {
    display: block;
  }

  .app-sidebar.offcanvas-xl {
    width: min(88vw, var(--tb-sidebar-width));
    max-width: min(88vw, var(--tb-sidebar-width));
    transition: transform 0.24s ease-in-out, visibility 0.24s ease-in-out;
  }

  .app-sidebar .sidebar-header {
    padding-right: 14px;
  }

  .sidebar-nav {
    padding-bottom: 24px;
  }

  .sidebar-submenu.show {
    display: grid;
  }

  .app-content {
    width: 100%;
  }

  .app-topbar {
    width: 100%;
  }

  .topbar-search {
    max-width: min(34vw, 360px);
    flex-basis: 220px;
  }

  .user-profile-text strong {
    max-width: 120px;
  }

  .kpi-grid,
  .bank-cash-kpi-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .quick-action-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .payments-filter-bar .btn,
  .cash-flow-filter-bar .btn {
    flex: 0 0 auto;
  }
}

@media (max-width: 991.98px) {
  .app-topbar {
    gap: 10px;
  }

  .topbar-search {
    max-width: 280px;
    flex-basis: 180px;
  }

  .header-notifications {
    gap: 6px !important;
  }

  .notification-icon,
  .nav-notification-btn,
  .header-action,
  .quick-action-btn {
    min-width: 42px;
    min-height: 42px;
  }
}

@media (max-width: 767.98px) {
  .app-body,
  .app-frame,
  .app-content,
  .app-page,
  main {
    max-width: 100%;
  }

  .app-topbar {
    min-height: 60px;
    flex-wrap: nowrap;
    gap: 8px;
    padding: 10px 12px;
  }

  .topbar-search {
    display: none;
  }

  .app-topbar.is-search-open {
    margin-bottom: 58px;
  }

  .app-topbar.is-search-open .topbar-search {
    position: absolute;
    left: 12px;
    right: 12px;
    top: calc(100% + 8px);
    z-index: 3;
    display: block;
    max-width: none;
    padding: 0;
    flex: none;
  }

  .app-topbar.is-search-open .topbar-search .form-control {
    min-height: 44px;
    background: #fff;
    box-shadow: 0 12px 28px rgba(15, 23, 42, 0.16);
  }

  .mobile-search-toggle {
    display: inline-grid !important;
  }

  .topbar-actions {
    gap: 6px;
    margin-left: 0;
  }

  .header-notifications {
    display: flex;
    gap: 6px !important;
  }

  .notification-icon,
  .nav-notification-btn,
  .header-action,
  .quick-action-btn,
  .icon-btn,
  .user-profile.header-action {
    width: 40px;
    height: 40px;
    min-width: 40px;
    min-height: 40px;
  }

  .user-profile.header-action {
    padding: 4px;
  }

  .notification-badge,
  .notification-count {
    top: -5px;
    right: -5px;
  }

  .page-heading {
    display: flex;
    align-items: stretch;
    flex-direction: column;
    gap: 12px;
  }

  .page-heading > .d-flex,
  .page-heading > a.btn {
    width: 100%;
  }

  .page-heading > .d-flex .btn,
  .page-heading > a.btn {
    width: 100%;
  }

  .kpi-grid,
  .bank-cash-kpi-grid,
  .quick-action-grid,
  .section-grid,
  .analytics-grid,
  .bank-cash-detail-grid,
  .profile-layout,
  .contact-layout {
    grid-template-columns: 1fr;
  }

  .kpi-card,
  .quick-action,
  .surface,
  .card-soft {
    max-width: 100%;
  }

  .kpi-value {
    overflow-wrap: anywhere;
  }

  .filter-bar,
  .payments-filter-bar,
  .cash-flow-filter-bar,
  .bank-cash-actions {
    display: grid;
    grid-template-columns: 1fr;
    align-items: stretch;
    width: 100%;
  }

  .filter-bar .btn,
  .payments-filter-bar .btn,
  .cash-flow-filter-bar .btn,
  .bank-cash-actions .btn,
  .cash-flow-repair-form .btn,
  .search-field,
  .payments-filter-bar .filter-field,
  .payments-filter-bar .filter-date-field,
  .filter-bar .form-control,
  .filter-bar .form-select {
    width: 100%;
    min-width: 0;
    max-width: 100%;
  }

  .payments-filter-bar .btn,
  .cash-flow-filter-bar .btn {
    justify-self: stretch;
  }

  .cash-flow-repair-form {
    width: 100%;
  }

  .table-responsive > .table {
    min-width: 700px;
  }

  .table-responsive > .table-sm {
    min-width: 560px;
  }

  .table td {
    max-width: 280px;
  }

  .table .actions-cell {
    min-width: max-content;
  }

  .chart-card,
  .bank-cash-chart,
  .bank-breakdown-panel {
    min-height: 0;
  }

  .chart-panel,
  .chart-panel canvas {
    min-height: 220px;
    height: 220px !important;
  }

  .chart-panel-compact,
  .chart-panel-compact canvas {
    min-height: 190px;
    height: 190px !important;
  }

  .chart-panel-donut {
    width: 100%;
    max-width: 260px;
  }

  .auth-shell {
    min-height: calc(100dvh - 54px);
    padding: 20px 12px;
  }

  .auth-card {
    width: min(100%, 430px);
  }

  .auth-card .d-flex.justify-content-between {
    align-items: flex-start !important;
    flex-direction: column;
  }
}

@media (max-width: 479.98px) {
  .app-sidebar.offcanvas-xl {
    width: min(94vw, var(--tb-sidebar-width));
    max-width: min(94vw, var(--tb-sidebar-width));
  }

  .app-topbar {
    padding-inline: 8px;
  }

  .app-page {
    padding-inline: 10px;
  }

  .header-notifications {
    gap: 4px !important;
  }

  .notification-icon,
  .nav-notification-btn,
  .header-action,
  .quick-action-btn,
  .icon-btn,
  .user-profile.header-action {
    width: 38px;
    height: 38px;
    min-width: 38px;
    min-height: 38px;
  }

  .user-avatar {
    width: 28px;
    height: 28px;
  }

  .notification-menu,
  .profile-menu,
  .dropdown-menu-end {
    width: calc(100vw - 16px);
    min-width: 0;
  }

  .kpi-card {
    padding: 14px;
  }

  .table-responsive > .table {
    min-width: 640px;
  }

  .table-responsive > .table-sm {
    min-width: 520px;
  }

  .chart-panel,
  .chart-panel canvas {
    min-height: 200px;
    height: 200px !important;
  }

  .auth-card {
    padding: 20px;
  }
}
