/* =========================================================
   List & detail page layout
   Applies to memo lists, trustee lists, financial
   institution lists, memo detail / death notification pages.
   ========================================================= */

/* Grid container used by list pages (overrides Bootstrap .row defaults
   to give us a modern responsive grid). */
.page-surface-inner > .row.justify-content-center,
.page-surface-inner > div > .row.justify-content-center {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 1.1rem;
  margin: 0;
}
.page-surface-inner > .row.justify-content-center > [class*="col-"],
.page-surface-inner > div > .row.justify-content-center > [class*="col-"] {
  max-width: none;
  flex: initial;
  width: 100%;
  padding: 0;
  margin: 0 !important;
}

/* Detail pages: single wide card — override the grid so it spans full width */
.page-surface-inner > .row.justify-content-center:has(> .col-md-12) {
  display: block;
}
.page-surface-inner > .row.justify-content-center > .col-md-12 {
  padding: 0;
  margin: 0 !important;
  max-width: none;
}

/* Subtle card decoration on list cards */
.page-surface-inner .row .card {
  position: relative;
  display: flex;
  flex-direction: column;
  height: 100%;
}
.page-surface-inner .row .card .card-body {
  display: flex;
  flex-direction: column;
  height: 100%;
}

/* List pages: create-new action row (single create button wrapped in
   .text-center that sits below the list). */
.page-surface-inner > .text-center.py-2 {
  display: flex;
  justify-content: center;
  margin-top: 1.75rem;
  padding: 1rem 0 0;
  border-top: 1px dashed var(--color-border);
}
.page-surface-inner > .text-center.py-2 small {
  font-size: 1rem;
  color: inherit;
}
.page-surface-inner > .text-center.py-2 small p { margin: 0; }

/* Pagination container tweak */
.pagination.justify-content-center {
  margin-top: 1.75rem;
}

/* Auto page-header: templates that simply render an <h1> followed by
   an intro <p> at the top of the content block get page-header styling
   automatically. Saves touching the 13 list templates that all do this. */
.page-surface-inner > h1:first-of-type {
  margin-bottom: 0.35rem;
}
.page-surface-inner > h1:first-of-type + p {
  color: var(--color-ink-muted);
  font-size: 0.98rem;
  margin: 0 0 1.35rem;
  padding-bottom: 1.1rem;
  border-bottom: 1px solid var(--color-border);
  max-width: 70ch;
}
.page-surface-inner > h1:first-of-type + p + br,
.page-surface-inner > h1:first-of-type + br { display: none; }

/* Raw <ul> used on financial-institution list */
.page-surface-inner > ul:not(.pagination):not(.HelvetiList) {
  list-style: none;
  padding: 0;
  margin: 0 0 1rem;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 0.6rem;
}
.page-surface-inner > ul:not(.pagination):not(.HelvetiList) > li {
  background: var(--color-surface-muted);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 0.75rem 1rem;
}
.page-surface-inner > ul:not(.pagination):not(.HelvetiList) > li p { margin: 0; }

/* Detail pages: section label + content rhythm */
.page-surface-inner .card-body > h6.card-subtitle {
  margin-top: 1.2rem !important;
}
.page-surface-inner .card-body > h6.card-subtitle:first-of-type {
  margin-top: 0.5rem !important;
}

/* "There are no X." legacy empty state */
.page-surface-inner > p:only-of-type {
  color: var(--color-ink-muted);
}

/* =========================================================
   Memo-list cards — proper vertical card with an accent
   strip, prominent icon, title/meta block, and a visible
   "View" action at the bottom.
   ========================================================= */
.memo-list-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1.2rem;
  margin: 0;
}

.memo-card {
  position: relative;
  display: flex;
  flex-direction: column;
  padding: 1.6rem 1.5rem 1.35rem;
  background: #ffffff;
  border: 1px solid var(--color-border);
  border-radius: 20px;
  box-shadow: 0 6px 18px rgba(15, 23, 42, 0.08);
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
  text-decoration: none;
  color: inherit;
  overflow: hidden;
  min-height: 200px;
}
.memo-card:hover,
.memo-card:focus-within {
  transform: translateY(-4px);
  box-shadow: 0 22px 45px rgba(15, 23, 42, 0.16);
  border-color: rgba(37, 99, 235, 0.28);
  text-decoration: none;
  color: inherit;
}

/* Accent strip along the top edge, per memo type. */
.memo-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: linear-gradient(90deg, #2563eb, #0ea5e9);
}

.memo-card-icon {
  width: 52px;
  height: 52px;
  border-radius: 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #2563eb, #0ea5e9);
  color: #ffffff;
  font-size: 1.3rem;
  margin-bottom: 0.95rem;
  box-shadow: 0 12px 22px rgba(37, 99, 235, 0.28);
  flex-shrink: 0;
}

/* Per-memo-type accent (affects both the icon and the top strip). */
.memo-card[data-memo-type="bankaccount"]::before    { background: linear-gradient(90deg, #2563eb, #0ea5e9); }
.memo-card[data-memo-type="bankaccount"]    .memo-card-icon { background: linear-gradient(135deg, #2563eb, #0ea5e9); box-shadow: 0 12px 22px rgba(37, 99, 235, 0.28); }

.memo-card[data-memo-type="loancreditcard"]::before { background: linear-gradient(90deg, #0ea5e9, #14b8a6); }
.memo-card[data-memo-type="loancreditcard"] .memo-card-icon { background: linear-gradient(135deg, #0ea5e9, #14b8a6); box-shadow: 0 12px 22px rgba(20, 184, 166, 0.28); }

.memo-card[data-memo-type="mortgage"]::before       { background: linear-gradient(90deg, #0891b2, #22d3ee); }
.memo-card[data-memo-type="mortgage"]       .memo-card-icon { background: linear-gradient(135deg, #0891b2, #22d3ee); box-shadow: 0 12px 22px rgba(34, 211, 238, 0.28); }

.memo-card[data-memo-type="pension"]::before        { background: linear-gradient(90deg, #059669, #84cc16); }
.memo-card[data-memo-type="pension"]        .memo-card-icon { background: linear-gradient(135deg, #059669, #84cc16); box-shadow: 0 12px 22px rgba(5, 150, 105, 0.28); }

.memo-card[data-memo-type="cryptoaccount"]::before  { background: linear-gradient(90deg, #f59e0b, #f97316); }
.memo-card[data-memo-type="cryptoaccount"]  .memo-card-icon { background: linear-gradient(135deg, #f59e0b, #f97316); box-shadow: 0 12px 22px rgba(245, 158, 11, 0.28); }

.memo-card[data-memo-type="cryptowallet"]::before   { background: linear-gradient(90deg, #ea580c, #dc2626); }
.memo-card[data-memo-type="cryptowallet"]   .memo-card-icon { background: linear-gradient(135deg, #ea580c, #dc2626); box-shadow: 0 12px 22px rgba(220, 38, 38, 0.28); }

.memo-card[data-memo-type="realestate"]::before     { background: linear-gradient(90deg, #9333ea, #c026d3); }
.memo-card[data-memo-type="realestate"]     .memo-card-icon { background: linear-gradient(135deg, #9333ea, #c026d3); box-shadow: 0 12px 22px rgba(147, 51, 234, 0.28); }

.memo-card[data-memo-type="otherfinancial"]::before { background: linear-gradient(90deg, #475569, #64748b); }
.memo-card[data-memo-type="otherfinancial"] .memo-card-icon { background: linear-gradient(135deg, #475569, #64748b); box-shadow: 0 12px 22px rgba(71, 85, 105, 0.28); }

.memo-card[data-memo-type="written"]::before        { background: linear-gradient(90deg, #7c3aed, #ec4899); }
.memo-card[data-memo-type="written"]        .memo-card-icon { background: linear-gradient(135deg, #7c3aed, #ec4899); box-shadow: 0 12px 22px rgba(124, 58, 237, 0.28); }

.memo-card[data-memo-type="will"]::before           { background: linear-gradient(90deg, #1e40af, #7c3aed); }
.memo-card[data-memo-type="will"]           .memo-card-icon { background: linear-gradient(135deg, #1e40af, #7c3aed); box-shadow: 0 12px 22px rgba(30, 64, 175, 0.28); }

.memo-card[data-memo-type="videoimage"]::before     { background: linear-gradient(90deg, #db2777, #f43f5e); }
.memo-card[data-memo-type="videoimage"]     .memo-card-icon { background: linear-gradient(135deg, #db2777, #f43f5e); box-shadow: 0 12px 22px rgba(236, 72, 153, 0.28); }

.memo-card[data-memo-type="trustee"]::before        { background: linear-gradient(90deg, #0f766e, #14b8a6); }
.memo-card[data-memo-type="trustee"]        .memo-card-icon { background: linear-gradient(135deg, #0f766e, #14b8a6); box-shadow: 0 12px 22px rgba(15, 118, 110, 0.28); }

.memo-card-body {
  flex: 1 1 auto;
  min-width: 0;
}

.memo-card-title {
  margin: 0 0 0.75rem;
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--color-ink);
  line-height: 1.3;
  letter-spacing: -0.01em;
  word-break: break-word;
  /* allow up to two lines, then ellipsis */
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.memo-card-meta {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  margin: 0 0 1.1rem;
  font-size: 0.88rem;
  color: var(--color-ink-muted);
}

.memo-card-meta-item {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}
.memo-card-meta-item i {
  color: var(--color-ink-faint);
  font-size: 0.8rem;
  width: 14px;
  text-align: center;
}

/* Trustee pill list shown on the memo card. */
.memo-card-trustees {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  margin: 0 0 0.9rem;
}
.memo-card-meta-label {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--color-ink-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.memo-card-meta-label i {
  font-size: 0.8rem;
  color: var(--color-ink-faint);
}
.trustee-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
}
.trustee-pill {
  display: inline-flex;
  align-items: center;
  padding: 0.15rem 0.65rem;
  background: var(--color-primary-soft);
  color: var(--color-primary-hover);
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 600;
  white-space: nowrap;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
}
.memo-card-muted {
  color: var(--color-ink-faint);
  font-size: 0.85rem;
  font-style: italic;
}

/* "View details" action row — sits at the bottom of the card. */
.memo-card-action {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  margin-top: auto;
  padding-top: 1rem;
  border-top: 1px solid var(--color-border);
  color: var(--color-primary);
  font-weight: 600;
  font-size: 0.88rem;
  letter-spacing: 0.01em;
  text-decoration: none;
}
.memo-card-action i {
  transition: transform 0.15s ease;
}
.memo-card:hover .memo-card-action i,
.memo-card:focus-within .memo-card-action i {
  transform: translateX(3px);
}

/* Click target covering the full card. Keep below text but above accent. */
.memo-card-link {
  position: absolute;
  inset: 0;
  z-index: 1;
  border-radius: inherit;
  background: transparent;
}
.memo-card-link:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 3px;
}
/* Hide the legacy chevron pill — the bottom action replaces it. */
.memo-card-chev { display: none; }

@media (max-width: 575.98px) {
  .memo-card { padding: 1.3rem 1.25rem 1.15rem; min-height: auto; }
  .memo-card-icon { width: 46px; height: 46px; font-size: 1.15rem; }
  .memo-card-title { font-size: 1.05rem; }
}
