/*
 * VERTEX Hub — Admin Panel Styles (RTL, 375px mobile-ready, #128B99 palette)
 */

*, *::before, *::after {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.55;
  direction: rtl;
  overflow-x: clip;
  max-width: 100vw;
}

.skip-link {
  position: absolute;
  top: -100px;
  right: 16px;
  background: var(--brand);
  color: #fff;
  padding: 8px 16px;
  z-index: 1000;
  border-radius: var(--radius-sm);
}
.skip-link:focus { top: 8px; }

[hidden] { display: none !important; }

.boot {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

.app {
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr);
  min-height: 100vh;
}
.app[hidden] { display: none !important; }

.sidebar {
  background: var(--surface);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 16px 12px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px 16px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 12px;
}
.brand-mark {
  object-fit: cover;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: var(--brand);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 16px;
  flex-shrink: 0;
}
.brand-name {
  font-weight: 800;
  font-size: 17px;
  color: var(--brand);
}

.nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
}
.nav-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  color: var(--text);
  text-decoration: none;
  font-weight: 500;
}
.nav-item:hover {
  background: var(--surface-muted);
}
.nav-item.active {
  background: var(--brand-soft);
  color: var(--brand);
  font-weight: 700;
}
.nav-count {
  background: var(--brand);
  color: #fff;
  font-size: 12px;
  padding: 1px 7px;
  border-radius: 999px;
}

.sidebar-foot {
  border-top: 1px solid var(--border);
  padding-top: 12px;
  margin-top: 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.main-area {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 12px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  position: sticky;
  top: 0;
  z-index: 20;
}
.topbar-title {
  margin: 0;
  font-size: 19px;
  font-weight: 700;
}
#menu-toggle {
  display: none;
}

.env-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--warn-soft);
  color: var(--warn);
  font-size: 12px;
  font-weight: 700;
  text-decoration: none;
}

.content {
  padding: 20px;
  max-width: 1240px;
  width: 100%;
  margin: 0 auto;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: 16px;
  box-shadow: var(--shadow);
}
.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}
.card-title {
  margin: 0;
  font-size: 17px;
  font-weight: 700;
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}
.kpi-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
}
.kpi-label {
  color: var(--text-muted);
  font-size: 13px;
}
.kpi-value {
  font-size: 24px;
  font-weight: 800;
  color: var(--brand);
  margin-top: 4px;
}

/* Buttons & mandatory explanation sentence under every button (README rule 13) */
.acts {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  align-items: flex-start;
  margin-top: 12px;
}
.act {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  max-width: 280px;
}
.act-note {
  margin: 4px 0 0;
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.4;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 16px;
  font-size: 14px;
  font-weight: 600;
  font-family: inherit;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  text-decoration: none;
}
.btn:hover:not(:disabled) {
  background: var(--surface-muted);
}
.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}
.btn-primary {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
}
.btn-primary:hover:not(:disabled) {
  background: var(--brand-hover);
}
.btn-danger {
  background: var(--danger);
  border-color: var(--danger);
  color: #fff;
}
.btn-ghost {
  background: transparent;
}
.btn-link {
  background: none;
  border: none;
  color: var(--brand);
  padding: 4px 8px;
  cursor: pointer;
}
.btn-block {
  width: 100%;
}
.btn-icon {
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 6px 10px;
  cursor: pointer;
  font-size: 16px;
}

/* Forms & disabled fields (greyed out, never hidden — README rule 13) */
.form-group {
  margin-bottom: 14px;
}
.form-label {
  display: block;
  font-weight: 600;
  margin-bottom: 4px;
  font-size: 14px;
}
.form-input {
  width: 100%;
  padding: 9px 12px;
  font-size: 16px;
  font-family: inherit;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
}
.form-input:disabled,
.form-disabled .form-input {
  background: var(--surface-muted);
  color: var(--text-muted);
  cursor: not-allowed;
}
.form-help {
  margin: 4px 0 0;
  font-size: 12px;
  color: var(--text-muted);
}
.req { color: var(--danger); }

/* Tabs */
.tabs {
  display: flex;
  gap: 6px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 16px;
  overflow-x: auto;
  padding-bottom: 4px;
}
.tab-btn {
  padding: 8px 14px;
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  border: none;
  background: transparent;
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
}
.tab-btn.active {
  color: var(--brand);
  background: var(--brand-soft);
}

/* Tables */
.table-wrap {
  width: 100%;
  overflow-x: auto;
}
table {
  width: 100%;
  border-collapse: collapse;
}
th, td {
  padding: 10px 8px;
  border-bottom: 1px solid var(--border);
  text-align: right;
  font-size: 14px;
}
th {
  color: var(--text-muted);
  font-weight: 600;
  background: var(--surface-muted);
}

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  background: var(--surface-muted);
  color: var(--text);
}
.badge-ok, .badge-status-active, .badge-status-paid, .badge-status-signed {
  background: var(--ok-soft);
  color: var(--ok);
}
.badge-warn, .badge-status-pending, .badge-status-pending_payment, .badge-status-trial, .badge-status-paid_pending_setup, .badge-status-past_due {
  background: var(--warn-soft);
  color: var(--warn);
}
.badge-danger, .badge-status-failed, .badge-status-suspended, .badge-status-cancelled {
  background: var(--danger-soft);
  color: var(--danger);
}

.ltr {
  direction: ltr;
  unicode-bidi: isolate;
  display: inline-block;
}
.muted { color: var(--text-muted); }
.small { font-size: 12px; }

.alert {
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  margin-bottom: 12px;
  font-size: 14px;
}
.alert-danger { background: var(--danger-soft); color: var(--danger); }
.alert-info { background: var(--brand-soft); color: var(--brand-hover); }
.alert-warn { background: var(--warn-soft); color: var(--warn); }

.empty {
  text-align: center;
  padding: 28px 16px;
  color: var(--text-muted);
}

.legend {
  list-style: none;
  padding: 10px 12px;
  margin: 0 0 12px;
  background: var(--surface-muted);
  border-radius: var(--radius-sm);
  font-size: 12px;
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}
.legend li b { margin-left: 4px; }

/* Modal */
dialog.modal {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 0;
  max-width: 540px;
  width: calc(100% - 24px);
  background: var(--surface);
  color: var(--text);
}
dialog.modal.modal-wide { max-width: 780px; }
dialog.modal::backdrop { background: rgba(16, 33, 38, 0.45); }
.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
}
.modal-title { margin: 0; font-size: 17px; }
.modal-body { padding: 18px; }
.modal-foot {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 12px 18px;
  border-top: 1px solid var(--border);
}

/* Toasts */
.toasts {
  position: fixed;
  bottom: 20px;
  left: 20px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
  border: none;
  background: transparent;
  padding: 0;
  margin: 0;
}
.toast {
  background: var(--text);
  color: #fff;
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
  font-size: 14px;
}
.toast-error { background: var(--danger); }
.toast-success { background: var(--ok); }

/* Login page */
.auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.auth-hero {
  width: 100%;
  max-width: 400px;
}
.auth-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 28px 22px;
  box-shadow: var(--shadow);
}
.auth-title {
  margin: 12px 0 4px;
  font-size: 22px;
  text-align: center;
}
.auth-sub {
  margin: 0 0 20px;
  text-align: center;
  color: var(--text-muted);
  font-size: 14px;
}

.tabbar { display: none; }
.drawer-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(16, 33, 38, 0.4);
  z-index: 35;
}

/* Mobile 375px responsiveness */
@media (max-width: 900px) {
  .app {
    grid-template-columns: 1fr;
    padding-bottom: 64px;
  }
  #menu-toggle {
    display: inline-flex;
  }
  .sidebar {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: 260px;
    z-index: 40;
    transform: translateX(105%);
    transition: transform 0.2s ease;
  }
  .app.drawer-open .sidebar {
    transform: translateX(0);
  }
  .content {
    padding: 14px 12px;
  }
  .acts {
    flex-direction: column;
    align-items: stretch;
  }
  .act {
    max-width: 100%;
  }
  .act .btn {
    width: 100%;
  }
  .tabbar {
    position: fixed;
    bottom: 0;
    right: 0;
    left: 0;
    background: var(--surface);
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: space-around;
    padding: 6px 4px;
    z-index: 30;
  }
  .tab-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    font-size: 11px;
    color: var(--text-muted);
    text-decoration: none;
    background: none;
    border: none;
    padding: 4px 6px;
    cursor: pointer;
    font-family: inherit;
  }
  .tab-item.active {
    color: var(--brand);
    font-weight: 700;
  }
}

/* Layout helpers and terms form (added in the Claude pass, T-603 follow-up) */
.stack { display: flex; flex-direction: column; gap: 12px; }
.stack-sm { display: flex; flex-direction: column; gap: 6px; }
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; }
.callout {
  background: var(--brand-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  line-height: 1.6;
}
.fieldset {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 14px 4px;
  margin: 0 0 14px;
}
/* Test accounts list (settings → checkout mode, T-712) */
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 10px; }
.chip {
  display: inline-flex; align-items: center; gap: 4px; max-width: 100%;
  background: var(--surface-muted); border: 1px solid var(--border); border-radius: 999px;
  padding: 2px 4px 2px 10px; font-size: 13px; overflow-wrap: anywhere;
}
.btn.btn-sm { padding: 2px 8px; font-size: 12px; min-height: 0; }
.fieldset legend { padding: 0 6px; font-weight: 600; font-size: 14px; }
.form-error { color: var(--danger); font-size: 14px; min-height: 1em; margin: 8px 0 0; }
.form-check label { display: inline-flex; align-items: center; gap: 6px; }
.row-inline { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; font-size: 14px; }
.form-input.qty { width: 72px; }
.ok { color: var(--ok); }
@media (max-width: 900px) {
  table.table { display: block; overflow-x: auto; }
}

/* Jump-to bar at the top of a screen (addSectionNav in ui.js) */
.secnav {
  position: sticky;
  top: var(--topbar-h, 58px);
  z-index: 15;
  display: flex;
  gap: 6px;
  align-items: center;
  overflow-x: auto;
  white-space: nowrap;
  background: var(--bg);
  padding: 8px 0;
  margin: 0 0 12px;
  border-bottom: 1px solid var(--border);
}
.secnav-label { flex: none; font-size: 12px; color: var(--text-muted); }
.secnav button {
  flex: none;
  font: inherit;
  font-size: 13px;
  padding: 4px 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
}
.secnav button:hover,
.secnav button:focus-visible { border-color: var(--brand); color: var(--brand); outline: none; }
.card[id^="sec-"] { scroll-margin-top: calc(var(--topbar-h, 58px) + 56px); }
.steps { margin: 0 0 12px; padding-inline-start: 22px; font-size: 14px; }
.steps li { margin: 3px 0; }
.help-box { background: var(--brand-soft); border-radius: var(--radius-sm); padding: 10px 14px; margin: 0 0 14px; font-size: 14px; }
.help-box h3 { margin: 0 0 4px; font-size: 14px; }
.help-box dl { margin: 0; display: grid; grid-template-columns: max-content 1fr; gap: 4px 12px; }
.help-box dt { font-weight: 600; }
.help-box dd { margin: 0; color: var(--text); }
@media (max-width: 640px) { .help-box dl { grid-template-columns: 1fr; } .help-box dd { margin-bottom: 4px; } }
