/* 
 * Bank Nkhonde - Shared Page Styles
 * Premium sub-page layout and components
 */

/* ============================================
   PAGE LAYOUT
   ============================================ */
body {
  background: var(--bn-gray-100);
  min-height: 100vh;
  padding-bottom: 80px;
}

/* ============================================
   PAGE HEADER
   ============================================ */
.page-header {
  background: var(--bn-gradient-primary);
  padding: var(--bn-space-6) var(--bn-space-6) var(--bn-space-10);
  position: relative;
  overflow: hidden;
}

.page-header::before {
  content: '';
  position: absolute;
  top: 0;
  right: 0;
  width: 60%;
  height: 100%;
  background: radial-gradient(ellipse at 70% 30%, rgba(201, 162, 39, 0.08) 0%, transparent 60%);
  pointer-events: none;
}

.page-header-container {
  max-width: 1200px;
  margin: 0 auto;
  position: relative;
  z-index: 1;
}

.page-header-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--bn-space-5);
}

.page-header-nav {
  display: flex;
  align-items: center;
  gap: var(--bn-space-4);
}

.page-back-btn {
  width: 44px;
  height: 44px;
  border-radius: var(--bn-radius-md);
  background: rgba(255, 255, 255, 0.1);
  border: none;
  color: var(--bn-white);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--bn-transition-fast);
}

.page-back-btn:hover {
  background: rgba(255, 255, 255, 0.2);
}

/* ============================================
   PAGE CONTENT TOOLBAR
   Used when a back button (and optional actions) sit directly
   inside .dashboard-content, against the light page background,
   rather than inside the dark .page-header gradient.
   ============================================ */
.page-content-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--bn-space-3);
  margin-bottom: var(--bn-space-5);
}

/* .page-back-btn is designed for the dark .page-header gradient
   (white icon on translucent white). When it appears standalone
   on the light .dashboard-content background, invert the treatment
   so it stays visible and matches the card/button visual language. */
.dashboard-content > .page-back-btn,
.page-content-toolbar .page-back-btn {
  background: var(--bn-white);
  color: var(--bn-dark);
  border: 1px solid var(--bn-gray-lighter);
  box-shadow: var(--bn-shadow-sm);
}

.dashboard-content > .page-back-btn:hover,
.page-content-toolbar .page-back-btn:hover {
  background: var(--bn-gray-100);
  border-color: var(--bn-gray-light);
}

.page-title {
  font-size: var(--bn-text-2xl);
  font-weight: 800;
  color: var(--bn-white);
  margin: 0;
}

.page-subtitle {
  font-size: var(--bn-text-sm);
  color: rgba(255, 255, 255, 0.7);
  margin-top: var(--bn-space-1);
}

.page-header-actions {
  display: flex;
  align-items: center;
  gap: var(--bn-space-3);
}

.page-header-btn {
  width: 44px;
  height: 44px;
  border-radius: var(--bn-radius-md);
  background: rgba(255, 255, 255, 0.1);
  border: none;
  color: var(--bn-white);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--bn-transition-fast);
  font-size: 1.25rem;
}

.page-header-btn:hover {
  background: rgba(255, 255, 255, 0.2);
}

/* Group Selector in Header */
.page-group-selector {
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: var(--bn-radius-lg);
  padding: var(--bn-space-3) var(--bn-space-4);
}

.page-group-selector select {
  width: 100%;
  background: transparent;
  border: none;
  color: var(--bn-white);
  font-size: var(--bn-text-sm);
  font-weight: 500;
  outline: none;
  cursor: pointer;
}

.page-group-selector select option {
  background: var(--bn-dark);
  color: var(--bn-white);
}

/* Stats Row in Header - Grid layout for consistent stacking */
.page-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: var(--bn-space-3);
  margin-top: var(--bn-space-5);
}

/* These tiles were originally authored to sit on the dark .page-header band
   (white text on a translucent-white fill). That band has since been retired
   from every page — the tiles now live inside the LIGHT .dashboard-content
   area, where white text/label rendered effectively invisible. Restyled as
   proper light-surface cards, using the AA-compliant `-dark` semantic tokens
   for the value colours. */
.page-stat {
  flex: 1;
  min-width: 100px;
  text-align: center;
  background: var(--bn-white);
  border: 1px solid var(--bn-gray-lighter);
  border-radius: var(--bn-radius-lg);
  box-shadow: var(--bn-shadow-xs);
  padding: var(--bn-space-4) var(--bn-space-3);
  transition:
    transform var(--bn-transition-base),
    box-shadow var(--bn-transition-base),
    border-color var(--bn-transition-base);
}

.page-stat-value {
  font-size: var(--bn-text-xl);
  font-weight: 800;
  color: var(--bn-dark);
  font-feature-settings: 'tnum' 1;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  line-height: 1.2;
}

.page-stat-value.success { color: var(--bn-success-dark); }
.page-stat-value.warning { color: var(--bn-warning-dark); }
.page-stat-value.danger  { color: var(--bn-danger-dark); }
.page-stat-value.info    { color: var(--bn-info); }

.page-stat-label {
  font-size: var(--bn-text-xs);
  font-weight: 600;
  color: var(--bn-gray);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-top: var(--bn-space-1);
}

/* ============================================
   PAGE CONTENT
   ============================================ */
.page-content {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 var(--bn-space-6);
  margin-top: calc(-1 * var(--bn-space-6));
  position: relative;
  z-index: 2;
}

/* ============================================
   CONTENT SECTIONS
   ============================================ */
.content-section {
  background: var(--bn-white);
  border-radius: var(--bn-radius-xl);
  box-shadow: var(--bn-shadow-lg);
  border: 1px solid var(--bn-gray-lighter);
  margin-bottom: var(--bn-space-6);
  overflow: hidden;
  transition: box-shadow var(--bn-transition-base), border-color var(--bn-transition-base);
}

.content-section:hover {
  box-shadow: var(--bn-shadow-xl);
}

.content-section-header {
  padding: var(--bn-space-5) var(--bn-space-6);
  border-bottom: 1px solid var(--bn-gray-lighter);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.content-section-title {
  font-size: var(--bn-text-lg);
  font-weight: 700;
  color: var(--bn-dark);
  margin: 0;
}

.content-section-body {
  padding: var(--bn-space-6);
  background: var(--bn-white);
  border-radius: 0 0 var(--bn-radius-xl) var(--bn-radius-xl);
}

/* Modern content-section-body with card-like inner padding */
.content-section-body.modern {
  display: grid;
  gap: var(--bn-space-4);
  padding: var(--bn-space-6);
  background: var(--bn-white);
  border-radius: 0 0 var(--bn-radius-xl) var(--bn-radius-xl);
}

.content-section-body.modern > .table-container {
  border: 1px solid var(--bn-gray-lighter);
  border-radius: var(--bn-radius-lg);
  overflow: hidden;
  box-shadow: var(--bn-shadow-xs);
  transition: box-shadow var(--bn-transition-base);
}

.content-section-body.modern > .table-container:hover {
  box-shadow: var(--bn-shadow-md);
}

.content-section-body.modern > .table-container .table th {
  background: var(--bn-gray-100);
  font-size: var(--bn-text-xs);
  font-weight: 700;
  color: var(--bn-gray);
  text-transform: uppercase;
  letter-spacing: var(--bn-tracking-wider);
  padding: var(--bn-space-3) var(--bn-space-4);
  border-bottom: 2px solid var(--bn-gray-lighter);
}

.content-section-body.modern > .table-container .table td {
  padding: var(--bn-space-3) var(--bn-space-4);
  font-size: var(--bn-text-sm);
  color: var(--bn-dark);
  border-bottom: 1px solid var(--bn-gray-100);
  vertical-align: middle;
}

.content-section-body.modern > .table-container .table tbody tr:last-child td {
  border-bottom: none;
}

.content-section-body.modern > .table-container .table tbody tr:hover {
  background: var(--bn-gray-50);
}

/* Mobile card-style rows inside modern content-section-body */
@media (max-width: 768px) {
  .content-section-body.modern > .table-container {
    border: none;
    background: transparent;
    box-shadow: none;
  }

  .content-section-body.modern > .table-container .table-responsive tbody tr {
    background: var(--bn-white);
    border: 1px solid var(--bn-gray-lighter);
    border-radius: var(--bn-radius-md);
    margin-bottom: var(--bn-space-3);
    padding: var(--bn-space-3) var(--bn-space-4);
    box-shadow: var(--bn-shadow-xs);
  }

  .content-section-body.modern > .table-container .table-responsive tbody tr:hover {
    box-shadow: var(--bn-shadow-md);
    border-color: var(--bn-accent);
  }
}

/* ============================================
   FILTER TABS
   Shared pattern (also used inline on manage_members.html;
   min-height added here for 44px touch targets)
   ============================================ */
.filter-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: var(--bn-space-2);
  padding: var(--bn-space-2);
  background: var(--bn-gray-100);
  border-radius: var(--bn-radius-full);
  margin-bottom: var(--bn-space-6);
  width: fit-content;
}

.filter-tab {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: var(--bn-space-2) var(--bn-space-4);
  border: none;
  background: transparent;
  border-radius: var(--bn-radius-full);
  font-size: var(--bn-text-sm);
  font-weight: 600;
  color: var(--bn-gray);
  cursor: pointer;
  transition: all var(--bn-transition-fast);
}

.filter-tab.active {
  background: var(--bn-white);
  color: var(--bn-dark);
  box-shadow: var(--bn-shadow-sm);
}

.filter-tab:hover:not(.active) {
  color: var(--bn-dark);
}

.filter-tab:focus-visible {
  outline: 2px solid var(--bn-accent);
  outline-offset: 2px;
}

/* ============================================
   LIST ITEMS
   ============================================ */
.list-item {
  display: flex;
  align-items: center;
  gap: var(--bn-space-4);
  padding: var(--bn-space-4);
  border-radius: var(--bn-radius-lg);
  transition: background var(--bn-transition-fast);
  cursor: pointer;
}

.list-item:hover {
  background: var(--bn-gray-100);
}

.list-item-avatar {
  width: 44px;
  height: 44px;
  border-radius: var(--bn-radius-full);
  background: var(--bn-gradient-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: var(--bn-text-sm);
  color: var(--bn-white);
  flex-shrink: 0;
}

.list-item-content {
  flex: 1;
  min-width: 0;
}

.list-item-title {
  font-size: var(--bn-text-sm);
  font-weight: 600;
  color: var(--bn-dark);
  margin-bottom: var(--bn-space-1);
}

.list-item-subtitle {
  font-size: var(--bn-text-xs);
  color: var(--bn-gray);
}

.list-item-value {
  text-align: right;
}

.list-item-amount {
  font-size: var(--bn-text-base);
  font-weight: 700;
  color: var(--bn-dark);
  font-feature-settings: 'tnum' 1;
}

.list-item-meta {
  font-size: var(--bn-text-xs);
  color: var(--bn-gray);
}

.list-item-actions {
  display: flex;
  gap: var(--bn-space-2);
}

.list-action-btn {
  width: 44px;
  height: 44px;
  border-radius: var(--bn-radius-md);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--bn-transition-fast);
  font-size: 1rem;
}

.list-action-btn-approve {
  background: var(--bn-success-light);
  color: var(--bn-success);
}

.list-action-btn-approve:hover {
  background: var(--bn-success);
  color: var(--bn-white);
}

.list-action-btn-reject {
  background: var(--bn-danger-light);
  color: var(--bn-danger);
}

.list-action-btn-reject:hover {
  background: var(--bn-danger);
  color: var(--bn-white);
}

.list-action-btn-view {
  background: var(--bn-gray-100);
  color: var(--bn-gray-700);
}

.list-action-btn-view:hover {
  background: var(--bn-gray-lighter);
  color: var(--bn-dark);
}

/* ============================================
   CARD GRID
   ============================================ */
.card-grid,
.charts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: var(--bn-space-4);
}

.info-card {
  background: var(--bn-gray-100);
  border-radius: var(--bn-radius-lg);
  padding: var(--bn-space-5);
  transition: all var(--bn-transition-base);
  border: 1px solid transparent;
}

.info-card:hover {
  background: var(--bn-white);
  border-color: var(--bn-accent);
  box-shadow: var(--bn-shadow-md);
}

.info-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--bn-space-3);
}

.info-card-header .badge {
  flex-shrink: 0;
}

.info-card-title {
  font-size: var(--bn-text-sm);
  font-weight: 600;
  color: var(--bn-dark);
  min-width: 0;
  overflow-wrap: break-word;
  word-break: break-word;
}

.info-card-value {
  font-size: var(--bn-text-2xl);
  font-weight: 800;
  color: var(--bn-dark);
  font-feature-settings: 'tnum' 1;
  letter-spacing: var(--bn-tracking-tight);
  overflow-wrap: break-word;
  word-break: break-word;
}

.info-card-footer {
  margin-top: var(--bn-space-3);
  padding-top: var(--bn-space-3);
  border-top: 1px solid var(--bn-gray-lighter);
}

.info-card-meta {
  font-size: var(--bn-text-xs);
  color: var(--bn-gray);
}

/* ============================================
   EMPTY STATE
   ============================================ */
.empty-state {
  text-align: center;
  padding: var(--bn-space-12) var(--bn-space-6);
}

.empty-state-icon {
  font-size: 56px;
  margin-bottom: var(--bn-space-4);
  opacity: 0.4;
}

.empty-state-title {
  font-size: var(--bn-text-lg);
  font-weight: 600;
  color: var(--bn-dark);
  margin-bottom: var(--bn-space-2);
}

.empty-state-text {
  font-size: var(--bn-text-sm);
  color: var(--bn-gray);
  max-width: 320px;
  margin: 0 auto;
}

/* ============================================
   MOBILE BOTTOM NAV
   ============================================ */
.mobile-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--bn-white);
  border-top: 1px solid var(--bn-gray-lighter);
  display: flex;
  justify-content: space-around;
  padding: var(--bn-space-2) 0;
  z-index: var(--z-fixed);
}

.mobile-nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--bn-space-1);
  padding: var(--bn-space-2) var(--bn-space-4);
  text-decoration: none;
  color: var(--bn-gray);
  font-size: var(--bn-text-xs);
  font-weight: 500;
  transition: color var(--bn-transition-fast);
}

.mobile-nav-item.active {
  color: var(--bn-accent);
}

.mobile-nav-icon {
  font-size: 1.25rem;
}

/* ============================================
   TABS
   ============================================ */
.tabs {
  display: flex;
  gap: var(--bn-space-1);
  background: var(--bn-gray-100);
  padding: var(--bn-space-1);
  border-radius: var(--bn-radius-lg);
}

.tab {
  padding: var(--bn-space-2) var(--bn-space-4);
  font-size: var(--bn-text-sm);
  font-weight: 600;
  color: var(--bn-gray);
  background: transparent;
  border: none;
  border-radius: var(--bn-radius-md);
  cursor: pointer;
  transition: all var(--bn-transition-fast);
  min-height: 44px;
  display: inline-flex;
  align-items: center;
}

.tab:hover {
  color: var(--bn-dark);
}

.tab:focus-visible {
  outline: 2px solid var(--bn-accent);
  outline-offset: 2px;
}

.tab.active {
  background: var(--bn-white);
  color: var(--bn-dark);
  box-shadow: var(--bn-shadow-sm);
}

/* ============================================
   RADIO OPTION
   ============================================ */
.radio-option {
  display: flex;
  align-items: center;
  gap: var(--bn-space-2);
  cursor: pointer;
}

/* ============================================
   PROGRESS BAR
   ============================================ */
.progress-bar {
  height: 8px;
  background: var(--bn-gray-100);
  border-radius: var(--bn-radius-full);
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  background: var(--bn-gradient-accent);
  border-radius: var(--bn-radius-full);
  transition: width 0.5s var(--bn-ease-out);
}

.progress-bar-fill.success { background: var(--bn-success); }
.progress-bar-fill.warning { background: var(--bn-warning); }
.progress-bar-fill.danger { background: var(--bn-danger); }

/* ============================================
   ADMIN EDIT-MEMBER FORM (JS-built modal content —
   manage_members_new_sql.js buildEditFields/buildKycDetails)
   ============================================ */
.modal-body .form-section {
  margin-bottom: var(--bn-space-6);
  padding-bottom: var(--bn-space-6);
  border-bottom: 1px solid var(--bn-gray-lighter);
}

.modal-body .form-section:last-child {
  border-bottom: none;
  margin-bottom: 0;
  padding-bottom: 0;
}

.modal-body .form-section-title {
  font-size: var(--bn-text-lg);
  font-weight: 700;
  color: var(--bn-dark);
  margin-bottom: var(--bn-space-4);
}

/* KYC details disclosure — native <details>/<summary>, no CSS existed for it. */
.modal-body details.form-section {
  border: 1px solid var(--bn-gray-lighter);
  border-radius: var(--bn-radius-lg);
  padding: var(--bn-space-4) var(--bn-space-5);
  background: var(--bn-gray-100);
}

.modal-body details.form-section[open] {
  background: var(--bn-white);
}

.modal-body details.form-section summary.form-section-title {
  cursor: pointer;
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--bn-space-3);
  min-height: 44px;
  margin-bottom: 0;
  padding: var(--bn-space-2) 0;
  color: var(--bn-dark);
  user-select: none;
}

.modal-body details.form-section summary.form-section-title::-webkit-details-marker {
  display: none;
}

.modal-body details.form-section summary.form-section-title::after {
  content: '';
  width: 10px;
  height: 10px;
  flex-shrink: 0;
  border-right: 2px solid var(--bn-gray-700);
  border-bottom: 2px solid var(--bn-gray-700);
  transform: rotate(-45deg);
  transition: transform var(--bn-transition-fast);
}

.modal-body details.form-section[open] summary.form-section-title::after {
  transform: rotate(45deg);
}

.modal-body details.form-section summary.form-section-title:focus-visible {
  outline: 2px solid var(--bn-accent);
  outline-offset: 2px;
  border-radius: var(--bn-radius-sm);
}

.modal-body details.form-section[open] summary.form-section-title {
  margin-bottom: var(--bn-space-2);
}

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 1024px) {
  .page-stats {
    grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  }
}

@media (max-width: 768px) {
  .page-header {
    padding: var(--bn-space-4) var(--bn-space-4) var(--bn-space-8);
  }

  .page-content {
    padding: 0 var(--bn-space-4);
  }

  .page-title {
    font-size: var(--bn-text-xl);
  }

  /* Stats grid: 2 columns on mobile for balanced layout */
  .page-stats {
    grid-template-columns: repeat(2, 1fr);
    gap: var(--bn-space-3);
  }

  .page-stat {
    min-width: auto;
  }

  /* Figures were overflowing their tile: "MWK 505,100.00" measured 143px inside
     an 88px content box, spilling out both sides and running under the "i"
     toggle. `white-space: nowrap` (set above) meant it could only overflow,
     never wrap — so release it here and let the break fall after the currency.
     Reads as "MWK / 505,100.00" instead of bleeding past the card edge, and the
     figure stays legible rather than being shrunk until it fits.
     This lives in pages.css deliberately: admin-layout.css loads BEFORE this
     file, so the same rule there loses to the nowrap above it. */
  .page-stat-value,
  .dashboard-content .page-stat-value {
    font-size: var(--bn-text-base);
    white-space: normal;
    overflow-wrap: anywhere;
  }

  .content-section-header,
  .content-section-body {
    padding: var(--bn-space-4);
  }

  /* Two-up, not one-up. .card-grid holds .info-card figure tiles (title,
     one value, one line of meta) — at full width they wasted most of a
     phone screen per card and turned the Financial Reports / Interest &
     Penalties summaries into a long scroll of near-empty boxes.
     minmax(0, 1fr) so a long "MWK 1,250,000" can't widen its own track
     past the viewport. */
  .card-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: var(--bn-space-3);
  }

  /* Quick actions: 2 columns on mobile */
  .quick-action-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: var(--bn-space-3);
  }
}

@media (max-width: 480px) {
  .card-grid {
    gap: var(--bn-space-2);
  }

  .info-card {
    padding: var(--bn-space-3);
  }

  /* text-2xl in a half-width tile breaks a currency figure over three
     lines; one step down keeps it to one or two. */
  .info-card-value {
    font-size: var(--bn-text-lg);
  }

  /* Stats: single column on very small screens */
  .page-stats {
    grid-template-columns: 1fr;
  }

  /* Quick actions: compact 2-column on small phones */
  .quick-action-grid {
    gap: var(--bn-space-2);
  }

  .quick-action-card {
    padding: var(--bn-space-3);
  }
}

/* ============================================
   QUICK ACTION GRID (Shared)
   ============================================ */
.quick-action-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: var(--bn-space-4);
  margin-bottom: var(--bn-space-6);
}

.quick-action-card {
  padding: var(--bn-space-5);
  background: var(--bn-white);
  border: 1px solid var(--bn-gray-lighter);
  border-radius: var(--bn-radius-xl);
  text-align: center;
  cursor: pointer;
  transition: all var(--bn-transition-fast);
  font: inherit;
  color: inherit;
  width: 100%;
  display: block;
}

.quick-action-card:hover {
  border-color: var(--bn-accent);
  box-shadow: var(--bn-shadow-md);
  transform: translateY(-2px);
}

.quick-action-card:focus-visible {
  outline: 2px solid var(--bn-accent);
  outline-offset: 2px;
  border-color: var(--bn-accent);
}

.quick-action-icon {
  font-size: 2rem;
  margin-bottom: var(--bn-space-3);
}

.quick-action-title {
  font-weight: 600;
  color: var(--bn-dark);
}

.quick-action-desc {
  font-size: var(--bn-text-xs);
  color: var(--bn-gray);
  margin-top: var(--bn-space-1);
}

/* Tablet: 3 columns for quick actions */
@media (max-width: 1024px) and (min-width: 769px) {
  .quick-action-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

/* ============================================
   ANIMATIONS
   ============================================ */
.content-section {
  animation: fadeInUp 0.5s var(--bn-ease-out) backwards;
}

.content-section:nth-child(1) { animation-delay: 0.1s; }
.content-section:nth-child(2) { animation-delay: 0.2s; }
.content-section:nth-child(3) { animation-delay: 0.3s; }

.list-item {
  animation: fadeInUp 0.4s var(--bn-ease-out) backwards;
}

.list-item:nth-child(1) { animation-delay: 0.05s; }
.list-item:nth-child(2) { animation-delay: 0.1s; }
.list-item:nth-child(3) { animation-delay: 0.15s; }
.list-item:nth-child(4) { animation-delay: 0.2s; }
.list-item:nth-child(5) { animation-delay: 0.25s; }
