/* Credits page — pack selection & history */

.page.page-credits {
  --credits-sidebar-width: 350px;
  --credits-sidebar-gap: 24px;
  width: 100%;
  min-height: 100vh;
  margin: 0;
  padding: 60px 24px 42px calc(var(--credits-sidebar-width) + var(--credits-sidebar-gap));
  background:
    radial-gradient(circle at top left, rgba(73, 115, 172, 0.16), transparent 26%),
    #0d0d12;
  transition: padding-left 0.3s ease;
}

.page.page-credits.is-sidebar-collapsed {
  padding-left: 24px;
}

/* Sidebar card */
.credits-sidebar-card {
  position: fixed;
  top: 60px;
  left: 0;
  bottom: 0;
  width: var(--credits-sidebar-width);
  overflow: visible;
  border-right: 1px solid rgba(138, 163, 196, 0.22);
  background-color: #0d0d12;
  box-shadow: 0 22px 56px rgba(0, 0, 0, 0.28);
  display: flex;
  flex-direction: column;
  transition: left 0.3s ease;
  z-index: 100;
  animation: builderSlideInLeft 640ms cubic-bezier(0.22, 1, 0.36, 1) 120ms backwards;
}

.credits-sidebar-card.is-collapsed {
  left: calc(-1 * var(--credits-sidebar-width));
}

.credits-sidebar-inner {
  flex: 1;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 26px 16px 10px;
}

/* Sidebar menu items */
.credits-sidebar-head {
  padding: 0 0 20px;
}

.credits-sidebar-head h2 {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 700;
  color: #ecf4ff;
}

.credits-sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.credits-sidebar-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-radius: 10px;
  font-size: 0.85rem;
  font-weight: 500;
  color: rgba(200, 215, 240, 0.6);
  text-decoration: none;
  transition: background 0.12s, color 0.12s;
}

.credits-sidebar-item:hover {
  background: rgba(255, 255, 255, 0.04);
  color: rgba(220, 230, 250, 0.85);
}

.credits-sidebar-item.is-active {
  background: rgba(139, 92, 246, 0.12);
  color: #c4b5fd;
  font-weight: 600;
}

.credits-sidebar-item svg {
  flex-shrink: 0;
  opacity: 0.6;
}

.credits-sidebar-item.is-active svg {
  opacity: 1;
  color: #a78bfa;
}

.credits-layout {
  max-width: 960px;
  margin: 0 auto;
  display: grid;
  gap: 28px;
}

@media (max-width: 768px) {
  .page.page-credits {
    padding-left: 24px;
  }
  /* Hide the left sidebar entirely on mobile — the nav links are
     already reachable from the global header menu, so re-showing them
     here wastes vertical real estate. */
  .credits-sidebar-card,
  .credits-sidebar-inner {
    display: none;
  }
}

/* ── Header ── */
.credits-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.credits-head h1 {
  margin: 0;
  color: #f7f9ff;
  font-size: 1.4rem;
}

/* ── Balance card ── */
.credits-balance-card {
  border: 1px solid rgba(138, 163, 196, 0.22);
  border-radius: 20px;
  padding: 28px 32px;
  background:
    radial-gradient(circle at top right, rgba(101, 18, 179, 0.2), transparent 50%),
    rgba(13, 13, 18, 0.95);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}
.credits-balance-info {
  display: grid;
  gap: 6px;
}
.credits-balance-label {
  color: #9fb0cc;
  font-size: 0.85rem;
}
.credits-balance-value {
  display: flex;
  align-items: center;
  gap: 10px;
  color: #f7f9ff;
  font-size: 2.2rem;
  font-weight: 500;
  line-height: 1;
}
.credits-balance-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #ffb01f;
  box-shadow: 0 0 0 3px rgba(255, 176, 31, 0.15);
}
.credits-balance-tier {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border: 1px solid rgba(101, 18, 179, 0.4);
  border-radius: 999px;
  background: rgba(101, 18, 179, 0.15);
  color: #c4b5fd;
  font-size: 0.82rem;
  font-weight: 500;
}

.credits-balance-tier.is-pro {
  border-color: rgba(250, 204, 21, 0.5);
  background: linear-gradient(135deg, rgba(124, 58, 237, 0.25), rgba(250, 204, 21, 0.15));
  color: #fde047;
}

.credits-payment-banner {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 14px 18px;
  border-radius: 12px;
  font-size: 0.92rem;
  font-weight: 600;
}

.credits-payment-banner.is-success {
  background: rgba(5, 150, 105, 0.15);
  border: 1px solid rgba(16, 185, 129, 0.4);
  color: #6ee7b7;
}

.credits-payment-banner.is-cancel {
  background: rgba(220, 38, 38, 0.12);
  border: 1px solid rgba(248, 113, 113, 0.35);
  color: #fca5a5;
  color: #fde047;
}

/* ── Section ── */
.credits-section {
  display: grid;
  gap: 16px;
}
.credits-section-title {
  margin: 0;
  color: #f7f9ff;
  font-size: 1.1rem;
  font-weight: 500;
}

/* ── Pack grid ── */
.credits-pack-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 14px;
}
.credits-pack-card {
  position: relative;
  border: 2px solid rgba(138, 163, 196, 0.18);
  border-radius: 16px;
  padding: 24px 20px;
  background: rgba(16, 24, 36, 0.6);
  display: grid;
  gap: 12px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.18s, transform 0.12s, box-shadow 0.18s;
}
.credits-pack-card:hover {
  border-color: rgba(101, 18, 179, 0.6);
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
}
.credits-pack-card.is-popular {
  border-color: rgba(101, 18, 179, 0.7);
  background:
    radial-gradient(circle at top, rgba(101, 18, 179, 0.12), transparent 60%),
    rgba(16, 24, 36, 0.6);
}
.credits-pack-badge {
  position: absolute;
  top: -10px;
  left: 50%;
  transform: translateX(-50%);
  padding: 2px 12px;
  border-radius: 999px;
  background: #6d28d9;
  color: #fff;
  font-size: 0.7rem;
  font-weight: 500;
  white-space: nowrap;
}
.credits-pack-amount {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: #f7f9ff;
  font-size: 1.6rem;
  font-weight: 500;
}
.credits-pack-amount-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #ffb01f;
}
.credits-pack-label {
  color: #9fb0cc;
  font-size: 0.78rem;
}
.credits-pack-price {
  color: #f7f9ff;
  font-size: 1.1rem;
  font-weight: 500;
}
.credits-pack-price-old {
  color: #9fb0cc;
  font-size: 0.82rem;
  text-decoration: line-through;
  margin-right: 6px;
}
.credits-pack-buy-btn {
  width: 100%;
  min-height: 40px;
  border: 1px solid rgba(101, 18, 179, 0.5);
  border-radius: 12px;
  background: #6d28d9;
  color: #fff;
  font: inherit;
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
}
.credits-pack-buy-btn:hover {
  background: #7c3aed;
  transform: translateY(-1px);
}

/* ── History table ── */
.credits-history-card {
  border: 1px solid rgba(138, 163, 196, 0.18);
  border-radius: 16px;
  overflow: hidden;
  background: rgba(16, 24, 36, 0.6);
}
.credits-history-table {
  width: 100%;
  border-collapse: collapse;
}
.credits-history-table th {
  padding: 12px 16px;
  background: rgba(0, 0, 0, 0.3);
  color: #9fb0cc;
  font-size: 0.78rem;
  font-weight: 500;
  text-align: left;
  border-bottom: 1px solid rgba(138, 163, 196, 0.12);
}
.credits-history-table td {
  padding: 12px 16px;
  color: #d0d8e8;
  font-size: 0.82rem;
  border-bottom: 1px solid rgba(138, 163, 196, 0.08);
}
.credits-history-table tr:last-child td {
  border-bottom: none;
}
.credits-history-amount {
  font-weight: 500;
}
.credits-history-amount.is-add {
  color: #34d399;
}
.credits-history-amount.is-use {
  color: #f87171;
}
.credits-history-empty {
  padding: 32px 16px;
  text-align: center;
  color: #9fb0cc;
  font-size: 0.85rem;
}

/* ── Responsive ── */
@media (max-width: 720px) {
  .page.page-credits {
    padding: 80px 12px 32px;
  }
  .credits-pack-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
  }
  .credits-balance-card {
    flex-direction: column;
    text-align: center;
    padding: 20px;
  }
  .credits-balance-value {
    font-size: 1.8rem;
    justify-content: center;
  }
}

/* Pagination */
.credits-pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 14px 0 4px;
}

.credits-pagination-btn {
  border: 1px solid rgba(138, 163, 196, 0.2);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.03);
  color: #c4d4ec;
  font-family: inherit;
  font-size: 0.82rem;
  font-weight: 500;
  padding: 7px 16px;
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s;
}

.credits-pagination-btn:hover:not(:disabled) {
  background: rgba(139, 92, 246, 0.1);
  border-color: rgba(139, 92, 246, 0.35);
}

.credits-pagination-btn:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

.credits-pagination-info {
  font-size: 0.8rem;
  color: rgba(180, 200, 230, 0.5);
  min-width: 60px;
  text-align: center;
}
