
/* =========================================================================
   Upasana Wellness - sctable.css
   Styles for the reusable SC_Table.razor component (table + inline edit +
   row action menu + totals + pager).

   Load order:  theme.css  ->  masterpages.css  ->  sctable.css
   Uses from theme.css:        colour / radius / font variables, .uw-input
   Uses from masterpages.css:  .uw-card (the flex-column parent), .uw-page (desktop height)

   Markup:
     <section class="uw-card">
       <div class="uw-card-header">...</div>
       <div class="uw-sc">                    <- SC_Table root
         <div class="uw-table-wrap"> <table class="uw-table"> ... </table> </div>
         <div class="uw-pager"> ... </div>
       </div>
     </section>
   ========================================================================= */

.uw-sc {
  --sc-head-h: 46px;                 /* header row height; the filter row sticks right below it */
  display: flex; flex-direction: column; flex: 1; min-height: 0;
}


/* ---------- Scroll area ----------
   Small screens: scrolls inside its own box (never less than ~5 rows); page may scroll.
   !important so an inline style from _styleTag / old .tableDIV rules can't override it. */
.uw-table-wrap {
  flex: 1; min-height: 0;
  overflow: auto !important;
  max-height: max(22rem, 70dvh) !important;
}
/* Desktop: card = viewport height; table area stretches and scrolls INSIDE the card. */
@media (min-width: 992px) {
  .uw-table-wrap { flex: 1 1 0; height: auto !important; max-height: none !important; }
}


/* ---------- Table ---------- */
.uw-table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: .95rem; }

.uw-table thead th {
  position: sticky; top: 0; z-index: 2;
  height: var(--sc-head-h); padding: 0 1rem; text-align: left; white-space: nowrap;
  color: #fff; font-weight: 600;
  background: linear-gradient(120deg, var(--uw-moss), var(--uw-forest));
}

/* Search / filter row (sticks under the header) */
.uw-table .uw-filter-row td {
  position: sticky; top: var(--sc-head-h); z-index: 2;
  padding: .6rem 1rem; background: var(--uw-mist); border-bottom: 1px solid var(--uw-line);
}
.uw-filter-row .uw-input { padding: .5rem .75rem; font-size: .9rem; border-radius: 10px; }

/* Body */
.uw-table tbody td { padding: .7rem 1rem; border-bottom: 1px solid var(--uw-line); }
.uw-table tbody tr { transition: background .15s; }
.uw-table tbody tr:nth-child(even) { background: #fafcf9; }
.uw-table tbody tr:hover { background: var(--uw-mist); }

/* Columns */
.uw-table .col-no,
.uw-table .col-id { width: 92px; }
.uw-table .name { font-weight: 600; color: var(--uw-ink); }          /* main heading column */
.uw-table th.num,
.uw-table td.num { text-align: right; font-variant-numeric: tabular-nums; }

/* Empty state */
.uw-empty { text-align: center; color: var(--uw-ink-soft); padding: 2.2rem 1rem !important; }

/* Totals row (sticks to the bottom of the scroll area) */
.uw-table tfoot td {
  position: sticky; bottom: 0; z-index: 2; padding: .7rem 1rem;
  background: var(--uw-mist); border-top: 2px solid var(--uw-sage);
  font-weight: 700; color: var(--uw-forest);
}


/* ---------- Inline-editable cells (look like text until hovered / focused) ---------- */
.uw-cell-input {
  width: 100%; min-width: 90px; box-sizing: border-box;
  font: inherit; color: var(--uw-ink);
  padding: .4rem .6rem; background: transparent;
  border: 1.5px solid transparent; border-radius: 9px;
  transition: border-color .2s, box-shadow .2s, background .2s;
}
.uw-cell-input.num { text-align: right; }
.uw-cell-input:hover { border-color: var(--uw-line); background: #fff; }
.uw-cell-input:focus { outline: none; border-color: var(--uw-moss); background: #fff; box-shadow: 0 0 0 3px rgba(62,122,90,.15); }


/* ---------- Status pill (for cells that render a badge) ---------- */
.uw-badge { display: inline-flex; align-items: center; gap: .4rem; padding: .25rem .7rem; border-radius: 999px; font-size: .82rem; font-weight: 600; }
.uw-badge::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.uw-badge.active   { background: #e3f1e7; color: var(--uw-forest); }
.uw-badge.inactive { background: #fbeedd; color: #a2601f; }


/* ---------- Row action dropdown ---------- */
.uw-menu-host { position: relative; display: inline-block; }

.uw-row-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .3rem;
  min-width: 52px; padding: .35rem .6rem; border: 0; border-radius: 9px;
  background: var(--uw-teal); color: #fff; font: 600 .85rem var(--uw-font-body);
  cursor: pointer; transition: background .2s;
}
.uw-row-btn:hover,
.uw-row-btn[aria-expanded="true"] { background: var(--uw-forest); }

.uw-menu {
  position: absolute; left: 0; top: calc(100% + 6px); z-index: 10; min-width: 168px; padding: .35rem;
  background: #fff; border: 1px solid var(--uw-line); border-radius: 12px;
  box-shadow: 0 16px 36px -14px rgba(21,58,44,.45); animation: uw-menu-in .15s ease;
}
.uw-menu.up { top: auto; bottom: calc(100% + 6px); }          /* last rows open upwards */

.uw-menu button {
  width: 100%; display: flex; align-items: center; gap: .6rem; padding: .55rem .7rem;
  border: 0; border-radius: 8px; background: none; text-align: left; cursor: pointer;
  font: 500 .9rem var(--uw-font-body); color: var(--uw-ink);
}
.uw-menu button:hover { background: var(--uw-mist); }
.uw-menu button svg { color: var(--uw-teal); flex: none; }
.uw-menu button.danger,
.uw-menu button.danger svg { color: var(--uw-terracotta); }

.uw-backdrop { position: fixed; inset: 0; z-index: 9; }       /* click-away layer behind the open menu */

@keyframes uw-menu-in { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }


/* ---------- Pager bar ---------- */
.uw-pager {
  flex: none; display: flex; flex-wrap: wrap; align-items: center; gap: .6rem 1.25rem;
  padding: .7rem 1.25rem; background: var(--uw-mist); border-top: 1px solid var(--uw-line);
  font-size: .88rem; color: var(--uw-ink-soft);
}
.uw-pager-size { display: inline-flex; align-items: center; gap: .5rem; font-weight: 600; }
.uw-pager .uw-input { width: auto; padding: .35rem 2rem .35rem .65rem; font-size: .88rem; border-radius: 9px; }
.uw-pager-info { font-weight: 600; color: var(--uw-forest); }
.uw-pager-nav { margin-left: auto; display: inline-flex; gap: .3rem; }

.uw-pg {
  min-width: 36px; height: 36px; display: inline-grid; place-items: center; padding: 0 .5rem;
  border: 1px solid var(--uw-line); border-radius: 10px; background: #fff; color: var(--uw-ink);
  font: 600 .88rem var(--uw-font-body); cursor: pointer;
  transition: background .2s, color .2s, border-color .2s;
}
.uw-pg:hover:not(:disabled) { background: var(--uw-mist); border-color: var(--uw-sage); }
.uw-pg.current,
.uw-pg.current:hover { background: var(--uw-forest); border-color: var(--uw-forest); color: #fff; }
.uw-pg:disabled { opacity: .4; cursor: not-allowed; }

@media (max-width: 575.98px) {
  .uw-pager-nav { margin-left: 0; width: 100%; justify-content: center; }
}
