/* ===========================================================
   Capio Commerce — app.css
   Page transitions, button loaders, auth screens, SPA shell
   =========================================================== */

/* ---------- button loader ---------- */
.btn.is-loading {
  pointer-events: none;
  opacity: 0.85;
  position: relative;
}
.btn.is-loading .spinner {
  display: inline-block;
  width: 14px;
  height: 14px;
  margin-right: 0.5rem;
  border: 2px solid currentColor;
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  vertical-align: -2px;
}
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* ---------- page transition (SPA) ---------- */
.page-enter {
  animation: pageIn 0.28s cubic-bezier(0.16, 0.8, 0.24, 1) both;
}
@keyframes pageIn {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ---------- thin progress bar for route changes ---------- */
.route-progress {
  position: fixed;
  top: 0;
  left: 0;
  height: 2px;
  width: 0;
  z-index: 9999;
  background: var(--primary);
  transition:
    width 0.25s ease,
    opacity 0.25s ease;
}
.route-progress.active {
  width: 70%;
  opacity: 1;
}
.route-progress.done {
  width: 100%;
  opacity: 0;
}

/* ---------- auth layout ---------- */
.auth-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem 1rem;
  background: var(--bg);
}
.auth-box {
  width: 100%;
  max-width: 440px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 2rem;
  box-shadow: var(--shadow-2);
}
.auth-box .brand-img {
  height: 26px;
  width: auto;
}
.otp-row {
  display: flex;
  gap: 0.5rem;
}
.otp-row .otp-digit {
  flex: 1;
  text-align: center;
  font-size: 1.3rem;
  font-family: var(--font-mono);
  padding: 0.7rem 0;
}

/* ---------- user app overrides ---------- */
.brand-mark {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 1.25rem 1.1rem;
  font-family: var(--font-display);
  font-weight: 700;
}
.brand-mark img {
  height: 24px;
  width: auto;
}
.app-sidebar .brand-mark {
  padding: 1.25rem 1.1rem;
}

.big-chart-wrap {
  height: 380px;
}
.chart-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}
.asset-row {
  cursor: pointer;
}
.asset-row.active td:first-child {
  box-shadow: inset 3px 0 0 var(--primary);
}
.wallet-card {
  padding: 1.25rem;
}
.qr-box {
  width: 120px;
  height: 120px;
  background: var(--bg-subtle);
  border-radius: var(--r-sm);
  border: 1px dashed var(--border-strong);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  color: var(--text-3);
  flex: 0 0 auto;
  overflow: hidden;
}
.qr-box img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}
.addr-box {
  background: var(--bg-subtle);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-sm);
  padding: 0.7rem 0.9rem;
  font-family: var(--font-mono);
  font-size: 0.82rem;
  word-break: break-all;
  flex: 1;
}
.balance-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}
.balance-strip .b-item {
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: 0.6rem 0.9rem;
  font-size: 0.8rem;
  color: var(--text-2);
}
.balance-strip .b-item b {
  color: var(--text-1);
  font-family: var(--font-mono);
  display: block;
  font-size: 0.95rem;
}
.pos-card {
  padding: 1.1rem;
}
.tab-strip {
  display: flex;
  gap: 0.25rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 1rem;
}
.tab-strip button {
  background: transparent;
  border: none;
  padding: 0.6rem 1rem;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-2);
  border-bottom: 2px solid transparent;
}
.tab-strip button.active {
  color: var(--text-1);
  border-color: var(--primary);
}
.indicator-menu {
  position: relative;
}
.indicator-panel {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-2);
  padding: 0.5rem;
  z-index: 20;
  min-width: 180px;
  display: none;
}
.indicator-panel.open {
  display: block;
}
.indicator-panel button {
  width: 100%;
  text-align: left;
  background: transparent;
  border: none;
  padding: 0.5rem 0.6rem;
  font-size: 0.85rem;
  border-radius: 6px;
  display: flex;
  justify-content: space-between;
  color: var(--text-1);
}
.indicator-panel button:hover {
  background: var(--bg-hover);
}
.indicator-panel button.on {
  color: var(--primary-deep);
  font-weight: 600;
}
.indicator-panel button[disabled] {
  color: var(--text-3);
  cursor: not-allowed;
}
.indicator-panel small {
  color: var(--text-3);
  font-size: 0.7rem;
}
.asset-detail-head {
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
  align-items: flex-start;
}

@media (max-width: 991px) {
  .app-sidebar {
    bottom: 62px;
  }
}

/* ---------- admin app overrides ---------- */
:root {
  --admin-accent: var(--info);
}
body.admin {
  background: var(--bg-subtle);
}
.admin .brand-mark {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 1.1rem;
  font-family: var(--font-display);
  font-weight: 700;
  border-bottom: 1px solid var(--border);
}
.admin .brand-mark img {
  height: 22px;
}
.role-tag {
  background: var(--info-soft);
  color: var(--info);
  border-radius: 6px;
  padding: 0.15rem 0.5rem;
  font-size: 0.72rem;
  font-weight: 600;
}
/* Admin sidebar follows the active theme */
.admin .app-sidebar {
  background: var(--bg-card);
  border-right: 1px solid var(--border);
}
.admin .app-sidebar .brand-mark {
  color: var(--text-1);
  border-color: var(--border);
}
.admin .app-sidebar .side-link {
  color: var(--text-2);
}
.admin .app-sidebar .side-link:hover {
  background: var(--bg-hover);
  color: var(--text-1);
}
.admin .app-sidebar .side-link.active {
  background: var(--primary-soft);
  color: var(--primary-deep);
}
.admin .app-sidebar .side-foot {
  border-color: var(--border);
}
.admin .status-select {
  font-size: 0.78rem;
  padding: 0.25rem 0.5rem;
  border-radius: 6px;
  border: 1px solid var(--border-strong);
  background: var(--bg-card);
}
.kpi-chart {
  height: 60px;
}
.search-c {
  max-width: 260px;
}
.wallet-edit-row {
  padding: 1rem;
  border-bottom: 1px solid var(--border);
}
.wallet-edit-row:last-child {
  border-bottom: none;
}
.settings-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.9rem 0;
  border-bottom: 1px solid var(--border);
}
.settings-row:last-child {
  border-bottom: none;
}

/* ---------- skeleton loading ---------- */
.skel {
  background: linear-gradient(
    90deg,
    var(--bg-subtle) 25%,
    var(--bg-hover) 50%,
    var(--bg-subtle) 75%
  );
  background-size: 200% 100%;
  animation: skel 1.4s infinite;
  border-radius: 6px;
}
@keyframes skel {
  from {
    background-position: 200% 0;
  }
  to {
    background-position: -200% 0;
  }
}

/* =========================================================
   Password field with show/hide toggle
   ========================================================= */
.password-wrap {
  position: relative;
  display: block;
}
.password-wrap .form-control-c {
  padding-right: 2.75rem;
}
.password-toggle {
  position: absolute;
  top: 50%;
  right: 0.4rem;
  transform: translateY(-50%);
  background: transparent;
  border: none;
  padding: 0.4rem;
  border-radius: 6px;
  color: var(--text-3);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition:
    background 0.15s,
    color 0.15s;
}
.password-toggle:hover {
  background: var(--bg-hover);
  color: var(--text-1);
}
.password-toggle:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}
.password-toggle svg {
  display: block;
}

/* =========================================================
   Row action menu — matches the admin topbar dropdown
   ========================================================= */
.row-menu-wrap {
  display: inline-flex;
  justify-content: flex-end;
}

.row-menu-btn {
  width: 32px;
  height: 32px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  border-radius: 8px;
  color: var(--text-3);
  cursor: pointer;
  transition:
    background 0.15s var(--ease),
    color 0.15s var(--ease);
}
.row-menu-btn:hover {
  background: var(--bg-hover);
  color: var(--text-1);
}
.row-menu-btn:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}
.row-menu-btn.is-open {
  background: var(--primary-soft);
  color: var(--primary-deep);
}
.row-menu-btn svg {
  display: block;
  width: 16px;
  height: 16px;
}

.row-menu {
  position: fixed;
  z-index: 3000;
  width: 240px;
  padding: 0.35rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-2);
  animation: rowMenuIn 0.14s var(--ease) both;
  font-family: var(--font-body);
}
[data-theme="dark"] .row-menu {
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.55);
}
@keyframes rowMenuIn {
  from {
    opacity: 0;
    transform: translateY(-6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.row-menu .menu-head {
  padding: 0.55rem 0.7rem 0.6rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 0.35rem;
}
.row-menu .menu-head .lbl {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-3);
  font-weight: 600;
}
.row-menu .menu-head .name {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 0.92rem;
  color: var(--text-1);
  margin-top: 0.15rem;
  line-height: 1.2;
}
.row-menu .menu-head .sub {
  font-size: 0.72rem;
  color: var(--text-3);
  margin-top: 0.15rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.row-menu button {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  width: 100%;
  background: transparent;
  border: none;
  padding: 0.55rem 0.7rem;
  border-radius: 8px;
  color: var(--text-1);
  font-size: 0.875rem;
  font-weight: 500;
  text-align: left;
  cursor: pointer;
  transition:
    background 0.12s var(--ease),
    color 0.12s var(--ease);
}
.row-menu button:hover {
  background: var(--bg-hover);
}
.row-menu button:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: -2px;
}
.row-menu button .ico {
  flex: 0 0 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text-3);
}
.row-menu button:hover .ico {
  color: var(--text-1);
}
.row-menu button.danger {
  color: var(--loss);
}
.row-menu button.danger .ico {
  color: var(--loss);
}
.row-menu button.danger:hover {
  background: var(--loss-soft);
}
.row-menu button.danger:hover .ico {
  color: var(--loss);
}

.row-menu .divider {
  height: 1px;
  background: var(--border);
  margin: 0.35rem 0.25rem;
}

/* =========================================================
   Fix: invisible toast intercepting taps on the mobile bottom nav
   ========================================================= */
.toast-c {
  pointer-events: none;
}
.toast-c.show {
  pointer-events: auto;
}

/* Defensive: the bottom nav is the highest interactive layer on mobile */
@media (max-width: 991px) {
  .bottom-nav {
    z-index: 999;
  }
}

/* =========================================================
   Learn page
   ========================================================= */
.article-content h1,
.article-content h2,
.article-content h3,
.article-content h4 {
  font-family: var(--font-display);
  color: var(--text-1);
  margin-top: 1.75em;
  margin-bottom: 0.6em;
  line-height: 1.25;
}
.article-content h2 {
  font-size: 1.5rem;
}
.article-content h3 {
  font-size: 1.2rem;
}
.article-content p {
  margin: 0 0 1.1em;
}
.article-content ul,
.article-content ol {
  margin: 0 0 1.1em;
  padding-left: 1.5em;
}
.article-content li {
  margin-bottom: 0.4em;
}
.article-content a {
  color: var(--primary-deep);
  text-decoration: underline;
}
.article-content code {
  font-family: var(--font-mono);
  font-size: 0.88em;
  background: var(--bg-subtle);
  padding: 0.15em 0.45em;
  border-radius: 4px;
}
.article-content pre {
  background: var(--bg-subtle);
  padding: 1rem 1.15rem;
  border-radius: var(--r-sm);
  overflow-x: auto;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  margin: 0 0 1.1em;
}
.article-content blockquote {
  border-left: 3px solid var(--primary);
  padding-left: 1rem;
  margin: 0 0 1.1em;
  color: var(--text-2);
  font-style: italic;
}
.article-content img {
  max-width: 100%;
  border-radius: var(--r-sm);
  margin: 0.5em 0;
}
.article-content hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 1.5em 0;
}

/* =========================================================
   In-site video modal (YouTube embed)
   ========================================================= */
.video-modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 4000;
  background: rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  animation: videoModalFadeIn 0.18s var(--ease);
}
@keyframes videoModalFadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}
.video-modal-inner {
  width: 100%;
  max-width: 1000px;
  background: var(--bg-card);
  border-radius: var(--r-lg);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.5);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  animation: videoModalScaleIn 0.22s var(--ease);
}
@keyframes videoModalScaleIn {
  from {
    transform: scale(0.96);
    opacity: 0;
  }
  to {
    transform: scale(1);
    opacity: 1;
  }
}
.video-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.85rem 1rem 0.85rem 1.15rem;
  border-bottom: 1px solid var(--border);
}
.video-modal-title {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--text-1);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
  min-width: 0;
}
.video-modal-actions {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  flex-shrink: 0;
}
.video-modal-yt-link,
.video-modal-close {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text-2);
  background: transparent;
  border: none;
  cursor: pointer;
  text-decoration: none;
  transition:
    background 0.15s,
    color 0.15s;
}
.video-modal-yt-link:hover {
  background: var(--bg-hover);
  color: #ff0000;
}
.video-modal-close:hover {
  background: var(--loss-soft);
  color: var(--loss);
}
.video-modal-frame {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  background: #000;
}
.video-modal-frame iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
  display: block;
}
.video-modal-meta {
  padding: 0.75rem 1.15rem;
  font-size: 0.78rem;
  color: var(--text-3);
  border-top: 1px solid var(--border);
}
.video-modal-meta a {
  color: var(--primary-deep);
  text-decoration: underline;
}

/* Hover effect shared by every video card */
.yt-video-card {
  transition:
    transform 0.18s var(--ease),
    border-color 0.18s;
}
.yt-video-card:hover {
  transform: translateY(-3px);
  border-color: var(--border-strong);
}
.yt-video-card .yt-play {
  transition:
    transform 0.18s var(--ease),
    background 0.18s;
}
.yt-video-card:hover .yt-play {
  transform: scale(1.08);
  background: rgba(255, 0, 0, 0.85) !important;
}

@media (max-width: 640px) {
  .video-modal-backdrop {
    padding: 0;
  }
  .video-modal-inner {
    max-width: none;
    height: 100%;
    border-radius: 0;
    justify-content: center;
  }
}
