/* ═══════════════════════════════════════════════════════════════════
   Customer panel UI kit (panel-ui.css)

   One set of parts for every in-panel page: page layout, summary tiles,
   card header, table, notice, status chip, buttons, form fields, empty
   state. Built on the --ep-* tokens from input.css, so dark and light
   follow automatically.

   Plain CSS, loaded after output.css by css_loader.php on the customer
   panel only (the admin has its own admin.css; the three surfaces keep
   separate designs). It is NOT compiled by Tailwind on purpose: the
   Tailwind config does not scan every folder that uses output.css, so a
   rebuild would silently drop live classes. Nothing here depends on a
   Tailwind utility existing.
   ═══════════════════════════════════════════════════════════════════ */

/* Tone palette. Light theme gets darker shades so coloured text on a white
   card keeps its contrast. */
:root {
  --ep-ok:    #10b981;
  --ep-warn:  #f59e0b;
  --ep-bad:   #ef4444;
  --ep-info:  #06b6d4;
  --ep-brand: #8b5cf6;
}
html:not(.dark) {
  --ep-ok:    #059669;
  --ep-warn:  #b45309;
  --ep-bad:   #dc2626;
  --ep-info:  #0e7490;
  --ep-brand: #7c3aed;
}

/* ── Page ─────────────────────────────────────────────────────────── */
.ep-page { display: flex; flex-direction: column; gap: 1rem; padding: 1rem; }
@media (min-width: 768px) { .ep-page { gap: 1.25rem; padding: 1.25rem; } }
.ep-grid-2 { display: grid; gap: 1rem; }
@media (min-width: 1024px) { .ep-grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.ep-ltr  { direction: ltr; unicode-bidi: isolate; }
.ep-mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; direction: ltr; unicode-bidi: isolate; }
.ep-muted { color: var(--ep-ink-4); }
.ep-strong { color: var(--ep-ink); font-weight: 800; }

/* ── Summary tiles ────────────────────────────────────────────────── */
.ep-stats { display: grid; gap: .75rem; grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (min-width: 1024px) { .ep-stats { grid-template-columns: repeat(var(--ep-cols, 4), minmax(0, 1fr)); } }
.ep-stat {
  background: var(--ep-surface); border: 1px solid var(--ep-border); border-radius: 1rem;
  padding: .875rem 1rem; display: flex; flex-direction: column; gap: .375rem; min-width: 0;
}
.ep-stat-label { display: flex; align-items: center; gap: .375rem; font-size: .6875rem; font-weight: 700; color: var(--ep-ink-4); }
.ep-stat-label > i { color: var(--c, var(--ep-accent-2)); font-size: .75rem; }
.ep-stat-value { font-size: 1.375rem; line-height: 1.25; font-weight: 900; color: var(--c, var(--ep-ink)); font-variant-numeric: tabular-nums; }
.ep-stat-unit  { font-size: .6875rem; font-weight: 600; color: var(--ep-ink-4); margin-inline-start: .25rem; }

/* ── Card header / body (on .ep-card) ─────────────────────────────── */
.ep-card-head { display: flex; align-items: center; gap: .75rem; padding: .875rem 1rem; border-bottom: 1px solid var(--ep-border); flex-wrap: wrap; }
.ep-card-head:last-child { border-bottom: 0; }
.ep-card-icon {
  width: 2.25rem; height: 2.25rem; border-radius: .625rem; flex: none;
  display: grid; place-items: center; font-size: .875rem;
  color: var(--c, var(--ep-accent-2));
  background: var(--ep-surface-2);
  background: color-mix(in srgb, var(--c, var(--ep-accent)) 14%, transparent);
}
.ep-card-titles  { flex: 1; min-width: 10rem; }
.ep-card-titles .ep-sub { margin-top: .125rem; }
.ep-card-actions { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }
.ep-card-body    { padding: 1rem; }
.ep-card-body.flush { padding: 0; }

/* ── Table ────────────────────────────────────────────────────────── */
.ep-table-wrap { overflow-x: auto; }
.ep-table { width: 100%; border-collapse: collapse; font-size: .8125rem; }
.ep-table th {
  text-align: start; white-space: nowrap; padding: .625rem 1rem;
  font-size: .6875rem; font-weight: 700; color: var(--ep-ink-4);
  background: var(--ep-inset); border-bottom: 1px solid var(--ep-border);
}
.ep-table td { padding: .75rem 1rem; color: var(--ep-ink-2); border-bottom: 1px solid var(--ep-border); vertical-align: middle; }
.ep-table tbody tr:last-child td { border-bottom: 0; }
.ep-table tbody tr { transition: background .15s; }
.ep-table tbody tr:hover { background: var(--ep-surface); }
.ep-table .num { font-variant-numeric: tabular-nums; white-space: nowrap; }
.ep-table tr.is-me td { background: color-mix(in srgb, var(--ep-accent) 8%, transparent); }
/* Below md every row becomes a small card: label on one side, value on the
   other. Cells carry their column name in data-label. */
@media (max-width: 767px) {
  .ep-table.stack thead { display: none; }
  .ep-table.stack, .ep-table.stack tbody, .ep-table.stack tr, .ep-table.stack td { display: block; width: 100%; }
  .ep-table.stack tr { padding: .75rem 1rem; border-bottom: 1px solid var(--ep-border); }
  .ep-table.stack tbody tr:last-child { border-bottom: 0; }
  /* The label takes the free space, so a value made of several pieces
     (amount + unit, chip + text) stays together on the other side. */
  .ep-table.stack td { display: flex; align-items: center; flex-wrap: wrap; gap: .3125rem; padding: .25rem 0; border: 0; }
  .ep-table.stack td::before { content: attr(data-label); font-size: .6875rem; font-weight: 600; color: var(--ep-ink-4); flex: none; margin-inline-end: auto; padding-inline-end: .75rem; }
  .ep-table.stack td[data-label=""]::before { content: none; }
}

/* ── Notice ───────────────────────────────────────────────────────── */
.ep-note {
  --c: var(--ep-info);
  display: flex; align-items: flex-start; gap: .75rem;
  padding: .875rem 1rem; border-radius: .875rem;
  font-size: .8125rem; line-height: 1.9; color: var(--ep-ink-2);
  background: var(--ep-surface);
  background: color-mix(in srgb, var(--c) 8%, transparent);
  border: 1px solid var(--ep-border-2);
  border-color: color-mix(in srgb, var(--c) 26%, transparent);
}
.ep-note > i { color: var(--c); margin-top: .4rem; flex: none; }
.ep-note-body { flex: 1; min-width: 0; }
.ep-note-title { display: block; font-weight: 800; color: var(--ep-ink); }
.ep-note strong, .ep-note b { color: var(--ep-ink); }
.ep-note .ep-card-actions { margin-inline-start: auto; align-self: center; }
.ep-note.ok    { --c: var(--ep-ok); }
.ep-note.warn  { --c: var(--ep-warn); }
.ep-note.bad   { --c: var(--ep-bad); }
.ep-note.brand { --c: var(--ep-brand); }

/* ── Status chip ──────────────────────────────────────────────────── */
.ep-chip {
  --c: var(--ep-ink-4);
  display: inline-flex; align-items: center; gap: .3125rem; white-space: nowrap;
  padding: .1875rem .5625rem; border-radius: 9999px;
  font-size: .6875rem; font-weight: 700; line-height: 1.5;
  color: var(--c);
  background: var(--ep-surface-2);
  background: color-mix(in srgb, var(--c) 12%, transparent);
  border: 1px solid var(--ep-border);
  border-color: color-mix(in srgb, var(--c) 24%, transparent);
}
.ep-chip.neutral { --c: var(--ep-ink-3); }
.ep-chip.ok    { --c: var(--ep-ok); }
.ep-chip.warn  { --c: var(--ep-warn); }
.ep-chip.bad   { --c: var(--ep-bad); }
.ep-chip.info  { --c: var(--ep-info); }
.ep-chip.brand { --c: var(--ep-brand); }
.ep-chip.mono  { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; direction: ltr; }

/* ── Buttons ──────────────────────────────────────────────────────── */
.ep-button {
  display: inline-flex; align-items: center; justify-content: center; gap: .4375rem;
  padding: .5625rem 1rem; border-radius: .75rem; border: 1px solid var(--ep-border);
  font-size: .8125rem; font-weight: 700; line-height: 1.4; white-space: nowrap; cursor: pointer;
  color: var(--ep-ink); background: var(--ep-surface-2);
  transition: background .18s, border-color .18s, color .18s, filter .18s, transform .12s;
  text-decoration: none;
}
.ep-button:hover { border-color: color-mix(in srgb, var(--ep-accent) 40%, transparent); }
.ep-button:active:not(:disabled) { transform: scale(.97); }
.ep-button:focus-visible { outline: 2px solid var(--ep-accent-2); outline-offset: 2px; }
.ep-button:disabled, .ep-button[aria-disabled="true"] { opacity: .5; cursor: not-allowed; }
.ep-button.primary { color: var(--ep-on-accent); background: var(--ep-accent); border-color: transparent; }
.ep-button.primary:hover { filter: brightness(1.08); }
.ep-button.danger {
  color: var(--ep-bad); border-color: color-mix(in srgb, var(--ep-bad) 26%, transparent);
  background: color-mix(in srgb, var(--ep-bad) 9%, transparent);
}
.ep-button.danger:hover { background: color-mix(in srgb, var(--ep-bad) 15%, transparent); }
.ep-button.ghost { background: transparent; border-color: transparent; color: var(--ep-ink-3); }
.ep-button.ghost:hover { color: var(--ep-ink); background: var(--ep-surface-2); }
.ep-button.sm { padding: .375rem .75rem; font-size: .75rem; border-radius: .625rem; }
.ep-button.lg { padding: .75rem 1.25rem; font-size: .875rem; }
.ep-button.block { width: 100%; }
.ep-button > i { font-size: .8em; }

/* ── Form fields ──────────────────────────────────────────────────── */
.ep-field { display: flex; flex-direction: column; gap: .375rem; }
.ep-label { font-size: .75rem; font-weight: 700; color: var(--ep-ink-2); }
.ep-hint  { font-size: .6875rem; line-height: 1.8; color: var(--ep-ink-4); }
.ep-input, .ep-select, .ep-textarea {
  width: 100%; padding: .625rem .875rem; border-radius: .75rem;
  font-size: .8125rem; color: var(--ep-ink);
  background: var(--ep-inset); border: 1px solid var(--ep-border-2);
  transition: border-color .18s, box-shadow .18s; outline: none;
}
.ep-input::placeholder, .ep-textarea::placeholder { color: var(--ep-ink-5); }
.ep-input:focus, .ep-select:focus, .ep-textarea:focus {
  border-color: var(--ep-accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--ep-accent) 18%, transparent);
}
.ep-textarea { min-height: 7rem; resize: vertical; line-height: 1.9; }
.ep-select {
  appearance: none; -webkit-appearance: none; padding-left: 2.25rem; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%239ca3af' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: left .75rem center;
}
.ep-input-icon { position: relative; }
.ep-input-icon > i { position: absolute; top: 50%; transform: translateY(-50%); inset-inline-start: .875rem; color: var(--ep-ink-4); font-size: .75rem; pointer-events: none; }
.ep-input-icon > .ep-input { padding-inline-start: 2.25rem; }

/* ── Empty state ──────────────────────────────────────────────────── */
.ep-empty { text-align: center; padding: 2.5rem 1rem; font-size: .8125rem; line-height: 1.9; color: var(--ep-ink-4); }
.ep-empty > i { display: block; font-size: 1.75rem; margin-bottom: .75rem; color: var(--ep-ink-5); }
.ep-empty > b { display: block; margin-bottom: .25rem; font-size: .9375rem; color: var(--ep-ink-2); }

/* ── Copy field (codes, IPs) ──────────────────────────────────────── */
.ep-copy {
  display: flex; align-items: center; gap: .5rem; width: 100%; min-width: 0;
  padding: .5rem .75rem; border-radius: .625rem; cursor: pointer;
  color: var(--ep-accent-2); background: color-mix(in srgb, var(--ep-accent) 10%, transparent);
  border: 1px solid color-mix(in srgb, var(--ep-accent) 24%, transparent);
  font: 800 .75rem/1.4 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  transition: background .18s;
}
.ep-copy:hover { background: color-mix(in srgb, var(--ep-accent) 16%, transparent); }
.ep-copy:focus-visible { outline: 2px solid var(--ep-accent-2); outline-offset: 2px; }
.ep-copy > span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; direction: ltr; text-align: start; }
html:not(.dark) .ep-copy { color: var(--ep-accent); }

@media (prefers-reduced-motion: reduce) {
  .ep-button, .ep-table tbody tr, .ep-copy { transition: none; }
  .ep-button:active:not(:disabled) { transform: none; }
}

/* ── Numbered text list (rules / terms) ───────────────────────────── */
.ep-terms { list-style: none; margin: 0; padding: 0; }
.ep-terms > li { display: flex; gap: .875rem; padding: 1rem; border-bottom: 1px solid var(--ep-border); }
.ep-terms > li:last-child { border-bottom: 0; }
.ep-terms h3 { font-size: .875rem; font-weight: 800; color: var(--ep-ink); margin: .25rem 0 .375rem; }
.ep-terms p  { font-size: .8125rem; line-height: 2; color: var(--ep-ink-3); margin: 0; }

/* ── Two-step verification (phone / email code) ───────────────────── */
.ep-verify { display: flex; flex-direction: column; gap: 1rem; max-width: 28rem; }
.ep-verify-step { display: flex; align-items: flex-end; gap: .75rem; }
.ep-verify-num {
  width: 1.75rem; height: 1.75rem; border-radius: 9999px; flex: none; margin-bottom: .375rem;
  display: grid; place-items: center; font-size: .75rem; font-weight: 800;
  color: var(--ep-ink-3); background: var(--ep-surface-2); border: 1px solid var(--ep-border);
}
.ep-verify-step:first-child { align-items: center; }
.ep-verify-step:first-child .ep-verify-num { margin-bottom: 0; }
.ep-otp { text-align: center; letter-spacing: .5em; font-size: 1rem; font-weight: 800; }
.ep-otp::-webkit-outer-spin-button, .ep-otp::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.ep-otp[type=number] { -moz-appearance: textfield; }

/* A card that holds one short form reads better at a fixed width than
   stretched across a wide screen. */
.ep-narrow { width: 100%; max-width: 40rem; }

/* Tailwind's .hidden (in output.css) has the same weight as these parts and
   loads earlier, so `class="hidden ep-field"` would show. Scoped to the
   kit's own display-setting parts; a global !important .hidden would break
   the panel's `hidden lg:grid` responsive patterns. */
.ep-field.hidden, .ep-button.hidden, .ep-note.hidden, .ep-empty.hidden, .ep-card.hidden,
.ep-stat.hidden, .ep-copy.hidden, .ep-chip.hidden, .ep-input-icon.hidden, .ep-verify-step.hidden { display: none; }

/* Chips take arbitrary colours (plan tiers, account levels). Some are pale
   (silver, light gold) and vanish on a white card, so in light theme the
   text is pulled toward the ink colour. */
html:not(.dark) .ep-chip { color: color-mix(in srgb, var(--c) 62%, #0f172a); }

/* Same reason as chips: pale accent colours (platinum, diamond) disappear
   as an icon on a white card. */
html:not(.dark) .ep-card-icon { color: color-mix(in srgb, var(--c, var(--ep-accent)) 62%, #0f172a); }

/* ── Legacy classes, customer panel only ──────────────────────────────
   Older markup (settings, dashboard widgets, the purchase popup, server
   list) still uses btn-primary / btn-ghost / field / badge-* / mini-stat.
   Rather than chase every occurrence, they take the kit's look here.
   Scoped to body.ep-app (only panel/index.php has it), so the login,
   register and admin pages that load the same css_loader are untouched.
   body.ep-app X ties html:not(.dark) X on specificity and loads later, so
   the light-theme overrides in output.css do not win. glass-card is left
   alone on purpose: it is also the opaque surface of popups. */
body.ep-app .btn-primary {
  background: var(--ep-accent); color: var(--ep-on-accent); border: 0;
  box-shadow: none; font-weight: 700; transition: filter .18s, transform .12s;
}
body.ep-app .btn-primary:hover { filter: brightness(1.08); box-shadow: none; transform: none; }
body.ep-app .btn-primary:active { transform: scale(.97); }
body.ep-app .btn-ghost {
  background: var(--ep-surface-2); color: var(--ep-ink); border: 1px solid var(--ep-border);
  font-weight: 700; transition: border-color .18s, transform .12s;
}
body.ep-app .btn-ghost:hover { background: var(--ep-surface-2); color: var(--ep-ink); border-color: color-mix(in srgb, var(--ep-accent) 40%, transparent); }
body.ep-app .btn-ghost:active { transform: scale(.97); }
body.ep-app .field {
  background: var(--ep-inset); border: 1px solid var(--ep-border-2); color: var(--ep-ink);
  border-radius: .75rem; box-shadow: none;
}
body.ep-app .field::placeholder { color: var(--ep-ink-5); }
body.ep-app .field:focus {
  background: var(--ep-inset); border-color: var(--ep-accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--ep-accent) 18%, transparent);
}
body.ep-app :is(.badge-green, .badge-red, .badge-yellow, .badge-blue, .badge-purple) {
  --c: var(--ep-ink-4);
  display: inline-flex; align-items: center; gap: .3125rem; padding: .1875rem .5625rem; border-radius: 9999px;
  font-size: .6875rem; font-weight: 700; line-height: 1.5; white-space: nowrap;
  color: var(--c); background: color-mix(in srgb, var(--c) 12%, transparent);
  border: 1px solid color-mix(in srgb, var(--c) 24%, transparent);
}
body.ep-app .badge-green  { --c: var(--ep-ok); }
body.ep-app .badge-red    { --c: var(--ep-bad); }
body.ep-app .badge-yellow { --c: var(--ep-warn); }
body.ep-app .badge-blue   { --c: var(--ep-info); }
body.ep-app .badge-purple { --c: var(--ep-brand); }
body.ep-app .mini-stat {
  background: var(--ep-surface); border: 1px solid var(--ep-border); box-shadow: none;
}
body.ep-app .mini-stat:hover { background: var(--ep-surface); transform: none; box-shadow: none; }
@media (prefers-reduced-motion: reduce) {
  body.ep-app :is(.btn-primary, .btn-ghost):active { transform: none; }
}
