/* ============================================================
   OpenFinClaw Compute — Billing Page Stylesheet
   Dashboard layout: fixed sidebar + billing content
   Plan card, usage bars, billing history
   ============================================================ */

/* --- Dashboard Layout ------------------------------------- */
.dashboard {
  display: flex;
  min-height: 100vh;
}

/* --- Sidebar ---------------------------------------------- */
.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: 240px;
  background: #0e0e16;
  border-right: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  z-index: 100;
  overflow-y: auto;
  transition: transform var(--transition-normal);
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 20px 24px;
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-primary);
  text-decoration: none;
  border-bottom: 1px solid var(--border-subtle);
  flex-shrink: 0;
}

.sidebar-nav {
  flex: 1;
  padding: 16px 12px;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-secondary);
  text-decoration: none;
  transition: background var(--transition-fast), color var(--transition-fast);
  margin-bottom: 2px;
}

.sidebar-link:hover {
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-primary);
  opacity: 1;
}

.sidebar-link.active {
  background: var(--accent-glow);
  color: var(--accent);
}

.sidebar-link svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  opacity: 0.7;
}

.sidebar-link.active svg {
  opacity: 1;
}

.sidebar-user {
  padding: 16px;
  border-top: 1px solid var(--border-subtle);
  flex-shrink: 0;
}

.sidebar-user-info {
  display: flex;
  align-items: center;
  gap: 10px;
}

.sidebar-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, #2a2a4a, #3a3a5a);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--accent);
  flex-shrink: 0;
  border: 1px solid var(--border-card);
}

.sidebar-user-name {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.2;
}

.sidebar-user-email {
  font-size: 0.7rem;
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 150px;
}

/* Mobile sidebar toggle */
.sidebar-mobile-toggle {
  display: none;
  position: fixed;
  top: 16px;
  left: 16px;
  z-index: 200;
  background: var(--bg-card);
  border: 1px solid var(--border-card);
  color: var(--text-primary);
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  align-items: center;
  justify-content: center;
}

.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  z-index: 90;
}

/* --- Main Content ----------------------------------------- */
.main-content {
  flex: 1;
  margin-left: 240px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.content-header {
  padding: 28px 40px;
  border-bottom: 1px solid var(--border-subtle);
  background: var(--bg-primary);
  position: sticky;
  top: 0;
  z-index: 50;
}

.content-header h1 {
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.content-body {
  padding: 32px 40px 60px;
  max-width: 960px;
  flex: 1;
}

/* --- Card ------------------------------------------------- */
.settings-card {
  background: var(--bg-card);
  border: 1px solid var(--border-card);
  border-radius: var(--radius-md);
  padding: 28px;
  margin-bottom: 24px;
  transition: border-color var(--transition-normal);
}

.settings-card:hover {
  border-color: rgba(255, 255, 255, 0.1);
}

.settings-card h2 {
  font-size: 1rem;
  font-weight: 600;
}

.settings-card p {
  font-size: 0.875rem;
  color: var(--text-secondary);
  line-height: 1.6;
}

/* --- Billing: Plan Card ----------------------------------- */
.plan-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 24px 28px;
  background: linear-gradient(135deg, rgba(0, 212, 170, 0.05), rgba(0, 184, 148, 0.03));
  border: 1px solid rgba(0, 212, 170, 0.15);
  border-radius: var(--radius-md);
  margin-bottom: 24px;
  position: relative;
  overflow: hidden;
}

.plan-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(90deg, var(--accent), var(--accent-end));
}

.plan-badge-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 4px;
}

.plan-info h3 {
  font-size: 1.15rem;
  font-weight: 700;
  margin-bottom: 0;
}

.plan-name {
  font-family: var(--font-mono);
  color: var(--accent);
}

.plan-badge {
  display: inline-flex;
  padding: 3px 10px;
  border-radius: 100px;
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.plan-badge-free {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-muted);
}

.plan-badge-lite {
  background: rgba(0, 212, 170, 0.12);
  color: var(--accent);
}

.plan-badge-pro {
  background: rgba(99, 102, 241, 0.15);
  color: #818cf8;
  border: 1px solid rgba(99, 102, 241, 0.2);
}

.plan-badge-max {
  background: rgba(245, 158, 11, 0.12);
  color: #fbbf24;
  border: 1px solid rgba(245, 158, 11, 0.2);
}

.plan-price {
  display: flex;
  align-items: baseline;
  gap: 2px;
  margin-bottom: 4px;
}

.plan-price-amount {
  font-size: 1.5rem;
  font-weight: 800;
  font-family: var(--font-mono);
  color: var(--text-primary);
  letter-spacing: -0.02em;
}

.plan-price-period {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.plan-renew {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.text-secondary {
  color: var(--text-secondary);
}

.plan-actions {
  display: flex;
  gap: 10px;
  flex-shrink: 0;
}

/* --- Usage Progress Bars ---------------------------------- */
.usage-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-top: 16px;
}

.usage-item {
  padding: 16px;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  transition: border-color var(--transition-fast);
}

.usage-item:hover {
  border-color: var(--border-card);
}

.usage-icon-label {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.usage-icon-label svg {
  color: var(--text-muted);
  flex-shrink: 0;
}

.usage-icon-label span {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.usage-numbers {
  display: flex;
  align-items: baseline;
  gap: 4px;
  margin-bottom: 10px;
}

.usage-current {
  font-size: 1.1rem;
  font-weight: 700;
  font-family: var(--font-mono);
  color: var(--text-primary);
  letter-spacing: -0.02em;
}

.usage-limit {
  font-size: 0.78rem;
  font-family: var(--font-mono);
  color: var(--text-muted);
}

.usage-bar {
  height: 6px;
  background: rgba(255, 255, 255, 0.06);
  border-radius: 3px;
  overflow: hidden;
}

.usage-bar-fill {
  height: 100%;
  border-radius: 3px;
  transition: width 0.8s cubic-bezier(0.4, 0, 0.2, 1), background 0.3s ease;
  background: var(--accent);
  position: relative;
}

.usage-bar-fill.warn {
  background: linear-gradient(90deg, #eab308, #f59e0b);
}

.usage-bar-fill.critical {
  background: linear-gradient(90deg, #f43f5e, #e11d48);
}

.usage-pct {
  font-size: 0.7rem;
  font-family: var(--font-mono);
  color: var(--text-muted);
  margin-top: 4px;
  text-align: right;
}

/* --- Tables ----------------------------------------------- */
.data-table-wrapper {
  overflow-x: auto;
  border: 1px solid var(--border-card);
  border-radius: var(--radius-sm);
  margin-top: 16px;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 560px;
}

.data-table th,
.data-table td {
  padding: 11px 16px;
  text-align: left;
  font-size: 0.825rem;
  border-bottom: 1px solid var(--border-subtle);
  white-space: nowrap;
}

.data-table thead th {
  background: rgba(255, 255, 255, 0.02);
  font-weight: 600;
  color: var(--text-muted);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  cursor: pointer;
  user-select: none;
  transition: color var(--transition-fast);
}

.data-table thead th:hover {
  color: var(--text-secondary);
}

.data-table thead th.sorted-asc::after {
  content: ' \25B2';
  font-size: 0.6rem;
}

.data-table thead th.sorted-desc::after {
  content: ' \25BC';
  font-size: 0.6rem;
}

.data-table tbody td {
  color: var(--text-secondary);
}

.data-table tbody td.td-name {
  color: var(--text-primary);
  font-weight: 500;
}

.data-table tbody tr:last-child td {
  border-bottom: none;
}

.data-table tbody tr {
  transition: background var(--transition-fast);
}

.data-table tbody tr:hover {
  background: rgba(255, 255, 255, 0.02);
}

/* --- Status Badges ---------------------------------------- */
.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 100px;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.badge-success {
  background: rgba(0, 212, 170, 0.12);
  color: var(--accent);
}

.badge-warning {
  background: rgba(230, 168, 23, 0.12);
  color: #e6a817;
}

.badge-error {
  background: rgba(244, 63, 94, 0.12);
  color: #f43f5e;
}

/* --- Pagination ------------------------------------------- */
.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 0;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.pagination-controls {
  display: flex;
  gap: 6px;
}

.pagination-btn {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-card);
  color: var(--text-secondary);
  padding: 5px 12px;
  border-radius: var(--radius-sm);
  font-size: 0.78rem;
  font-family: var(--font-sans);
  cursor: pointer;
  transition: border-color var(--transition-fast), color var(--transition-fast);
}

.pagination-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

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

.pagination-btn.active {
  background: var(--accent-glow);
  border-color: var(--accent);
  color: var(--accent);
}

/* --- Inline link ------------------------------------------ */
.link-accent {
  color: var(--accent);
  font-size: 0.84rem;
  font-weight: 500;
  text-decoration: none;
  transition: opacity var(--transition-fast);
}

.link-accent:hover {
  opacity: 0.8;
}

/* --- Button loading spinner ------------------------------- */
.btn-spinner {
  display: none;
  width: 16px;
  height: 16px;
  border: 2px solid transparent;
  border-top-color: currentColor;
  border-radius: 50%;
  animation: btnSpin 0.6s linear infinite;
}

.btn.loading .btn-text {
  opacity: 0.6;
}

.btn.loading .btn-spinner {
  display: inline-block;
}

.btn.loading {
  pointer-events: none;
}

@keyframes btnSpin {
  to { transform: rotate(360deg); }
}

/* --- Toast Notification ----------------------------------- */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 20px;
  background: var(--bg-card);
  border: 1px solid var(--border-card);
  border-radius: var(--radius-sm);
  font-size: 0.84rem;
  color: var(--text-primary);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
  animation: toastIn 0.3s ease, toastOut 0.3s ease 2.7s forwards;
  max-width: 360px;
  pointer-events: auto;
}

.toast-icon {
  flex-shrink: 0;
  width: 18px;
  height: 18px;
}

.toast.toast-success {
  border-color: rgba(0, 212, 170, 0.3);
}

.toast.toast-success .toast-icon {
  color: var(--accent);
}

.toast.toast-error {
  border-color: rgba(244, 63, 94, 0.3);
}

.toast.toast-error .toast-icon {
  color: #f43f5e;
}

@keyframes toastIn {
  from { opacity: 0; transform: translateY(12px) translateX(8px); }
  to { opacity: 1; transform: translateY(0) translateX(0); }
}

@keyframes toastOut {
  from { opacity: 1; }
  to { opacity: 0; transform: translateY(-8px); }
}

/* --- Footer ----------------------------------------------- */
.account-footer {
  padding: 20px 40px;
  border-top: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.75rem;
  color: var(--text-muted);
  flex-shrink: 0;
}

.account-footer-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.account-footer .lang-toggle {
  font-size: 0.7rem;
  padding: 4px 10px;
}

.footer-tagline {
  font-family: var(--font-mono);
  font-size: 0.7rem;
}

/* --- Responsive ------------------------------------------- */
@media (max-width: 1024px) {
  .usage-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .sidebar-mobile-toggle {
    display: flex;
  }

  .sidebar-overlay.visible {
    display: block;
  }

  .main-content {
    margin-left: 0;
  }

  .content-header {
    padding: 70px 20px 28px;
  }

  .content-body {
    padding: 24px 20px 48px;
  }

  .plan-card {
    flex-direction: column;
    align-items: flex-start;
    gap: 16px;
  }

  .plan-actions {
    width: 100%;
  }

  .plan-actions .btn {
    flex: 1;
  }

  .account-footer {
    flex-direction: column;
    gap: 8px;
    text-align: center;
    padding: 16px 20px;
  }
}

@media (max-width: 480px) {
  .plan-badge-row {
    flex-wrap: wrap;
  }
}
