/* =====================================================================
   membership.css — styles only used by the Membership page
   (moved out of the old membershipcard.html; brand colours now come
   from app.css so the page matches the rest of the panel)
   ===================================================================== */
/* =========================================================
   BOOTSTRAP THEME / DESIGN TOKENS
   ========================================================= */
:root {
  /* Same colours as the rest of the panel (app.css) */
  --app-navy: var(--rts-navy);
  --app-bg: var(--rts-bg);
  --app-border: var(--rts-border);
  --app-shadow: 0 1px 2px rgba(16, 24, 40, 0.04);
}

/* Action controls in the members table. */
.action-buttons {
  display: flex;
  flex-wrap: nowrap;
  gap: 0.25rem;
}
.action-buttons .btn {
  min-width: 2.25rem;
  min-height: 2.25rem;
}
.table > :not(caption) > * > * {
  vertical-align: middle;
}

/* Bootstrap-friendly service multi-select checklist.
   Native <select multiple> requires Ctrl/Cmd on desktop, so a checkbox
   interface is used while a hidden multiple select preserves API format. */
.service-checklist {
  max-height: 300px;
  overflow-y: auto;
  background: #fff;
}
.service-checklist-group + .service-checklist-group {
  margin-top: 0.75rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--app-border);
}
.service-checklist-title {
  position: sticky;
  top: 0;
  z-index: 1;
  margin: 0 0 0.35rem;
  padding: 0.35rem 0.25rem;
  background: #fff;
  color: #53657a;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}
.service-checklist .form-check {
  margin: 0;
  padding: 0.45rem 0.5rem 0.45rem 2rem;
  border-radius: 0.55rem;
}
.service-checklist .form-check:hover {
  background: #f5f8fc;
}
.service-checklist .form-check-input {
  margin-top: 0.25rem;
}
.service-checklist .form-check-label {
  width: 100%;
  cursor: pointer;
}
.selected-services-summary {
  min-height: 1.8rem;
}
.selected-services-summary .badge {
  font-weight: 600;
}

/* Service cards generated by application JavaScript. */
.service-card {
  border: 0;
  border-radius: 1rem;
  box-shadow: 0 0.35rem 1rem rgba(0, 0, 0, 0.08);
}
.card-active {
  background: linear-gradient(135deg, #198754, #2aa96b);
  color: #fff;
}
.card-used {
  background: linear-gradient(135deg, #b02a37, #dc3545);
  color: #fff;
}
.card-expired {
  background: linear-gradient(135deg, #5c636a, #7c838a);
  color: #fff;
}
.card-empty {
  background: #eef1f5;
  color: #586371;
}
.small-label {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  opacity: 0.75;
}

/* Compact Service History / card actions. */
.service-history-table {
  table-layout: auto;
}
.service-history-table th,
.service-history-table td {
  vertical-align: middle;
}
.service-history-table .service-card-code,
.service-history-table .service-date,
.service-history-table .service-km,
.service-history-table .service-cost,
.service-history-table .service-actions {
  white-space: nowrap;
}
.service-history-table .service-summary {
  min-width: 150px;
  max-width: 270px;
}
.service-history-table .service-summary-main {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.service-history-table .service-actions {
  min-width: 220px;
}
.service-history-table .service-actions .service-action-toolbar {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.3rem;
  border: 1px solid var(--app-border);
  border-radius: 0.75rem;
  background: #f8fafc;
  box-shadow: 0 0.15rem 0.4rem rgba(15, 39, 64, 0.05);
}
.service-history-table .service-actions .service-action-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.3rem;
  min-width: 2.25rem;
  height: 2.15rem;
  padding: 0 0.55rem;
  border-radius: 0.55rem;
  font-size: 0.75rem;
  font-weight: 700;
  line-height: 1;
  transition:
    transform 0.15s ease,
    box-shadow 0.15s ease,
    background-color 0.15s ease;
}
.service-history-table .service-actions .service-action-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 0.25rem 0.55rem rgba(15, 39, 64, 0.1);
}
.service-history-table .service-actions .service-action-btn i {
  font-size: 0.9rem;
}
.service-history-table .service-actions .service-action-label {
  display: none;
}

@media (min-width: 1400px) {
  .service-history-table .service-actions .service-action-label {
    display: inline;
  }
  .service-history-table .service-actions {
    min-width: 300px;
  }
}

@media (max-width: 767.98px) {
  .service-history-table .service-actions {
    min-width: 210px;
  }
  .service-history-table .service-actions .service-action-toolbar {
    gap: 0.25rem;
  }
  .service-history-table .service-actions .service-action-btn {
    min-width: 2.1rem;
    height: 2rem;
    padding-inline: 0.45rem;
  }
}
@media (max-width: 767.98px) {
  .service-history-table {
    min-width: 720px;
  }
}

/* =====================================================================
   Member profile popup (.mp-*) — compact card design (26-Oct-2026)
   Markup: membership.js → loadProfile()
   ===================================================================== */
.mp {
  --mp-tier: linear-gradient(90deg, #a8673a, #e2a66f);
  --mp-line: var(--rts-border, #e3e7f0);
  --mp-muted: #687086;
}
/* 1. Hero card */
.mp-hero {
  position: relative;
  overflow: hidden;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 20px;
  align-items: center;
  padding: 20px 22px 24px;
  border-radius: 18px;
  color: #fff;
  background: radial-gradient(circle at 100% 0%, rgba(255, 255, 255, 0.14) 0 30%, transparent 31%),
    radial-gradient(circle at 0% 100%, rgba(255, 255, 255, 0.06) 0 34%, transparent 35%),
    linear-gradient(140deg, #1d1449 0%, var(--rts-navy) 45%, var(--rts-navy-2) 100%);
  box-shadow: 0 12px 28px rgba(38, 26, 92, 0.25);
}
.mp-hero::after {
  content: "";
  position: absolute;
  inset: auto 0 0 0;
  height: 5px;
  background: var(--mp-tier);
}
.mp-hero.t-Silver {
  --mp-tier: linear-gradient(90deg, #8d96a8, #e4e8ef);
}
.mp-hero.t-Gold {
  --mp-tier: linear-gradient(90deg, #c8961e, #f6d77a);
}
.mp-hero.t-Platinum {
  --mp-tier: linear-gradient(90deg, #6f7f95, #dfe7f2);
}
.mp-hero-main {
  min-width: 0;
}
.mp-lbl {
  font-size: 0.66rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  opacity: 0.72;
}
.mp-name {
  font-size: 1.45rem;
  font-weight: 800;
  line-height: 1.15;
  text-transform: uppercase;
  word-break: break-word;
  margin-top: 2px;
}
.mp-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}
.mp-tier,
.mp-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.74rem;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.14);
}
.mp-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--mp-tier);
}
.mp-status.on {
  background: #dcf5e8;
  color: #0b6b45;
}
.mp-status.off {
  background: #fde3e4;
  color: #a3131a;
}
.mp-id {
  font-size: clamp(1.6rem, 6vw, 2.2rem);
  font-weight: 800;
  letter-spacing: 0.14em;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}
.mp-facts {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid rgba(255, 255, 255, 0.18);
}
.mp-facts b {
  display: block;
  font-size: 0.95rem;
  word-break: break-word;
}
.mp-sub {
  font-size: 0.76rem;
  opacity: 0.78;
}
.mp-hero-qr {
  text-align: center;
  width: 190px;
}
.mp-hero .qr-wrap {
  width: 150px;
  height: 150px;
  margin: 0 auto;
  padding: 8px;
  background: #fff;
  border-radius: 14px;
  display: grid;
  place-items: center;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.18);
}
.mp-hero .qr-wrap img,
.mp-hero .qr-wrap canvas {
  width: 134px !important;
  height: 134px !important;
}
.mp-qr-note {
  font-size: 0.72rem;
  opacity: 0.8;
  margin-top: 6px;
}
.mp-share {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 5px;
  margin-top: 10px;
}
.mp-share .btn {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 5px;
  padding: 5px 6px;
  font-size: 0.74rem;
  line-height: 1.1;
  color: #fff;
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 10px;
}
.mp-share .btn i {
  font-size: 0.9rem;
}
.mp-share .btn:hover,
.mp-share .btn:focus-visible {
  background: #fff;
  color: var(--rts-navy);
}

/* 2. Stats */
.mp-stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin: 14px 0;
}
.mp-stat,
.mp-box {
  background: #fff;
  border: 1px solid var(--mp-line);
  border-radius: 14px;
  padding: 12px 14px;
}
.mp-stat-top {
  display: flex;
  align-items: center;
  gap: 8px;
}
.mp-stat-icon {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  font-size: 0.9rem;
  flex: none;
}
.mp-stat-lbl {
  font-size: 0.76rem;
  color: var(--mp-muted);
  font-weight: 600;
  line-height: 1.2;
}
.mp-stat-val {
  font-size: 1.4rem;
  font-weight: 800;
  color: var(--rts-navy);
  margin-top: 6px;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.mp-stat-val small {
  font-size: 0.8rem;
  color: var(--mp-muted);
  font-weight: 600;
}
.mp-sub-dark {
  font-size: 0.74rem;
  color: var(--mp-muted);
  margin-top: 4px;
}
.mp-bar {
  height: 6px;
  border-radius: 999px;
  background: #eceff6;
  overflow: hidden;
  margin-top: 8px;
}
.mp-bar span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--rts-navy-2);
}
.mp-bar.c-green span {
  background: #1f9d74;
}

/* Shared colour chips (stats + activity feed) */
.c-brand {
  background: #ece9fb;
  color: var(--rts-navy-2);
}
.c-green {
  background: #dcf5e8;
  color: #0b6b45;
}
.c-amber {
  background: #fff1d6;
  color: #8a5a00;
}
.c-blue {
  background: #e1efff;
  color: #1b5fb8;
}
.c-red {
  background: #fde3e4;
  color: #a3131a;
}
.mp-bar.c-brand,
.mp-bar.c-green {
  background: #eceff6;
}

/* 3. Details */
/* Full-width box inside the profile grid (gate pass visits, 27-Oct) */
.mp-grid .mp-wide { grid-column: 1 / -1; }

.mp-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}
.mp-box h3 {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.9rem;
  font-weight: 700;
  margin: 0 0 8px;
}
.mp-box h3 .bi {
  color: var(--rts-navy-2);
}
.mp-dl {
  display: grid;
  grid-template-columns: 84px minmax(0, 1fr);
  gap: 6px 10px;
  margin: 0;
  font-size: 0.86rem;
}
.mp-dl dt {
  color: var(--mp-muted);
  font-weight: 500;
}
.mp-dl dd {
  margin: 0;
  font-weight: 600;
  min-width: 0;
}
.mp-dl a {
  color: inherit;
  text-decoration: none;
  border-bottom: 1px dashed currentColor;
}
.mp-bill {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px 10px;
  margin-top: 12px;
  padding: 8px 10px;
  border-radius: 10px;
  background: #f4f2fd;
  font-size: 0.8rem;
  color: var(--mp-muted);
}
.mp-bill b {
  margin-left: auto;
  font-size: 1rem;
  color: var(--rts-navy);
}
.mp-scroll {
  max-height: 150px;
  overflow-y: auto;
}
.mp-log,
.mp-list li {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
  padding: 6px 0;
  border-top: 1px solid #eef1f6;
  font-size: 0.82rem;
}
.mp-log:first-child,
.mp-list li:first-child {
  border-top: 0;
}
.mp-list {
  list-style: none;
  margin: 0;
  padding: 0;
}
.mp-plate {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  padding: 0 5px;
  border: 1.5px solid #1b1f2a;
  border-radius: 4px;
  white-space: nowrap;
}
.mp-muted,
.mp-empty {
  color: var(--mp-muted);
  font-size: 0.8rem;
}

/* Phone / tablet */
@media (max-width: 767.98px) {
  .mp-hero {
    grid-template-columns: 1fr;
    padding: 18px 18px 22px;
  }
  /* QR on the left, note + share buttons beside it */
  .mp-hero-qr {
    width: 100%;
    display: grid;
    grid-template-columns: 120px minmax(0, 1fr);
    column-gap: 12px;
    row-gap: 6px;
    text-align: left;
  }
  .mp-hero .qr-wrap {
    grid-column: 1;
    grid-row: 1 / span 2;
    width: 120px;
    height: 120px;
    padding: 6px;
    margin: 0;
  }
  .mp-hero .qr-wrap img,
  .mp-hero .qr-wrap canvas {
    width: 108px !important;
    height: 108px !important;
  }
  .mp-qr-note {
    grid-column: 2;
    grid-row: 1;
    align-self: end;
    margin: 0;
  }
  .mp-share {
    grid-column: 2;
    grid-row: 2;
    align-self: start;
    margin-top: 0;
    grid-template-columns: repeat(2, 1fr);
  }
  .mp-stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .mp-grid {
    grid-template-columns: 1fr;
  }
}

/* Phones: the five summary boxes stay small */
@media (max-width: 575.98px) {
  #dashboardCards .stat-card {
    padding: 10px 12px;
  }
  #dashboardCards .stat-icon {
    display: none;
  }
  #dashboardCards .stat-label {
    font-size: 0.66rem;
  }
  #dashboardCards .stat-value {
    font-size: 1.2rem;
    margin-top: 2px;
  }
}

/* Popup buttons stay on one row on phones */
#profileModal .modal-footer {
  display: flex !important;
  flex-wrap: nowrap;
  gap: 8px;
}
#profileModal .modal-footer > .btn {
  flex: 1 1 0;
  width: auto;
  margin: 0;
}

/* =====================================================================
   Expiring soon + Recent activity (compact feed, scrolls inside)
   ===================================================================== */
.feed {
  max-height: 360px;
  overflow-y: auto;
  padding: 4px 14px !important;
}
.feed-item {
  display: grid;
  grid-template-columns: 32px minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  padding: 9px 0;
  border-top: 1px solid #eef1f6;
}
.feed-item:first-child {
  border-top: 0;
}
.feed-icon {
  width: 32px;
  height: 32px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  font-size: 0.95rem;
}
.feed-body {
  min-width: 0;
}
.feed-title {
  font-size: 0.86rem;
  font-weight: 600;
  line-height: 1.25;
}
.feed-sub {
  font-size: 0.76rem;
  color: #687086;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.feed-tag {
  font-size: 0.68rem;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 999px;
  background: #f2f4f9;
  color: #687086;
  margin-left: 4px;
}
.feed-time {
  font-size: 0.72rem;
  color: #687086;
  white-space: nowrap;
  text-align: right;
}
.feed-empty {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 18px 0;
  color: #687086;
  font-size: 0.85rem;
}
@media (max-width: 575.98px) {
  .feed-item {
    grid-template-columns: 32px minmax(0, 1fr);
  }
  .feed-time {
    grid-column: 2;
    text-align: left;
    margin-top: -4px;
  }
}
.min-w-0 {
  min-width: 0;
}

/* Validation integrates custom rules with Bootstrap invalid state. */
.required-mark {
  color: var(--bs-danger);
  font-weight: 700;
}
.field-error {
  display: none;
  width: 100%;
  margin-top: 0.25rem;
  color: var(--bs-danger);
  font-size: 0.8rem;
}
.field-error.show,
.is-invalid ~ .field-error {
  display: block;
}

/* Better modal/footer behavior.
   In scrollable Bootstrap modals, keep actions visible while only the body scrolls. */
.modal-content {
  border: 0;
  border-radius: 1rem;
}
#memberModal .modal-content {
  max-height: calc(100dvh - 3.5rem);
  overflow: hidden;
}
#memberModal .modal-body {
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
}
#memberModal .modal-header,
#memberModal .modal-footer {
  flex: 0 0 auto;
  position: relative;
  z-index: 2;
}
#memberModal .modal-footer {
  border-top: 1px solid var(--app-border);
  box-shadow: 0 -0.35rem 1rem rgba(15, 39, 64, 0.06);
}
@media (max-width: 575.98px) {
  #memberModal .modal-content {
    max-height: 100dvh;
  }
  .modal-footer {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0.5rem;
  }
  .modal-footer .btn {
    width: 100%;
    margin: 0 !important;
  }
  .action-buttons .btn {
    flex: 1 1 2.5rem;
  }
}

/* Service modal: keep Update / Complete button visible at all times.
   Only the modal body scrolls; header/footer remain fixed inside viewport. */
#useServiceModal .modal-dialog {
  height: auto;
  max-height: calc(100dvh - 1rem);
  margin-top: 0.5rem;
  margin-bottom: 0.5rem;
}

#useServiceModal .modal-content {
  max-height: calc(100dvh - 1rem);
  overflow: hidden;
}

#useServiceModal #useServiceForm {
  display: flex;
  flex-direction: column;
  width: 100%;
  min-height: 0;
  max-height: calc(100dvh - 1rem);
}

#useServiceModal .modal-header,
#useServiceModal .modal-footer {
  flex: 0 0 auto;
  position: relative;
  z-index: 5;
  background: #fff;
}

#useServiceModal .modal-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
  padding-bottom: 1rem;
}

#useServiceModal .modal-footer {
  border-top: 1px solid var(--app-border);
  box-shadow: 0 -0.4rem 1rem rgba(15, 39, 64, 0.08);
  padding: 0.75rem 1rem;
}

#useServiceModal #submitServiceBtn {
  min-width: 150px;
}

@media (max-height: 700px) {
  #useServiceModal .service-checklist {
    max-height: 210px;
  }

  #useServiceModal .modal-body {
    padding-top: 0.75rem;
    padding-bottom: 0.75rem;
  }
}

@media (max-width: 575.98px) {
  #useServiceModal .modal-dialog,
  #useServiceModal .modal-content,
  #useServiceModal #useServiceForm {
    max-height: 100dvh;
    height: 100dvh;
    margin: 0;
  }

  #useServiceModal .modal-footer {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem;
  }

  #useServiceModal .modal-footer .btn {
    width: 100%;
    margin: 0 !important;
  }
}

/* Printing is handled in a dedicated clean print window.
   These rules are a fallback when the browser prints the current page. */
@media print {
  body {
    background: #fff !important;
  }
  main,
  .modal-backdrop,
  .no-print {
    display: none !important;
  }

  #profileModal {
    display: block !important;
    position: static !important;
    overflow: visible !important;
  }
  #profileModal .modal-dialog {
    max-width: none !important;
    width: 100% !important;
    margin: 0 !important;
  }
  #profileModal .modal-content {
    box-shadow: none !important;
    border: 0 !important;
  }
  #profileModal .modal-body {
    overflow: visible !important;
    padding: 0 !important;
  }
  .print-area {
    display: block !important;
    width: 100% !important;
    background: #fff !important;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition: none !important;
    animation: none !important;
  }
}
#memberShare .btn {
  font-size: 0.8rem;
}
@media print {
  #memberShare {
    display: none !important;
  }
}
