/* ============================================================
   BILLING-SPECIFIC STYLES
   ============================================================ */

/* Page intro */
.bill-intro { font-size: 15px; margin-top: 12px; color: #555; }

/* Stage management — only one visible at a time, controlled by main[data-state] */
.bill-stage { display: none; }
main[data-state="loading"] .bill-stage[data-stage="loading"],
main[data-state="login"] .bill-stage[data-stage="login"],
main[data-state="loggedIn"] .bill-stage[data-stage="loggedIn"],
main[data-state="success"] .bill-stage[data-stage="success"],
main[data-state="canceled"] .bill-stage[data-stage="canceled"] { display: block; }

/* Loading spinner */
.bill-loading { text-align: center; padding: 60px 20px; }
.bill-loading-dot { width: 32px; height: 32px; border: 3px solid rgba(116, 213, 179, 0.25); border-top-color: var(--primary-dark); border-radius: 50%; margin: 0 auto; animation: bill-spin 0.8s linear infinite; }
@keyframes bill-spin { to { transform: rotate(360deg); } }

/* ===== LOGIN STAGE ===== */
.bill-login-form { display: flex; flex-direction: column; gap: 14px; max-width: 420px; margin: 24px auto 0; }
.bill-field { position: relative; display: flex; flex-direction: column; }
.bill-label { font-size: 12px; font-weight: 500; color: #555; margin-bottom: 6px; margin-inline-start: 4px; }
.bill-input { width: 100%; padding: 12px 14px; font-size: 15px; font-family: inherit; color: #1a1a1a; background: rgba(255, 255, 255, 0.7); border: 1px solid rgba(0, 0, 0, 0.08); border-radius: 10px; outline: none; transition: all 0.2s ease; box-sizing: border-box; }
.bill-input:hover { background: rgba(255, 255, 255, 0.95); border-color: rgba(0, 0, 0, 0.12); }
.bill-input:focus { background: #fff; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(116, 213, 179, 0.18); }
.bill-input::placeholder { color: #b0b0b0; }

.bill-error { font-size: 13px; color: var(--danger); background: rgba(231, 76, 60, 0.08); border: 1px solid rgba(231, 76, 60, 0.25); border-radius: 10px; padding: 10px 14px; margin: 4px 0 0; display: none; }
.bill-error.visible { display: block; }

.bill-hint { font-size: 12px; color: #888; text-align: center; margin-top: 4px; }

.bill-submit { display: flex; align-items: center; justify-content: center; gap: 8px; padding: 14px 28px; font-size: 15px; font-weight: 600; font-family: inherit; color: #fff; background: #1a1a1a; border: none; border-radius: 999px; cursor: pointer; transition: all 0.25s ease; margin-top: 8px; align-self: center; min-width: 200px; }
.bill-submit:hover:not(:disabled) { transform: translateY(-2px); box-shadow: 0 10px 24px rgba(0, 0, 0, 0.15); background: #000; }
.bill-submit:active { transform: translateY(0); }
.bill-submit:disabled { opacity: 0.6; cursor: not-allowed; }

.bill-submit .spinner { width: 14px; height: 14px; border: 2px solid rgba(255, 255, 255, 0.3); border-top-color: #fff; border-radius: 50%; animation: bill-spin 0.7s linear infinite; display: none; }
.bill-submit.loading .spinner { display: block; }
.bill-submit.loading .submit-text { opacity: 0.7; }

/* ===== USER BAR (logged in) ===== */
.bill-user-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; background: rgba(116, 213, 179, 0.1); border: 1px solid rgba(116, 213, 179, 0.25); border-radius: 12px; padding: 12px 16px; margin-top: 20px; flex-wrap: wrap; }
.bill-user-info { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.bill-user-email { font-size: 14px; font-weight: 600; color: #1a1a1a; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 60vw; }
.bill-user-meta { font-size: 12px; color: #555; display: flex; gap: 12px; flex-wrap: wrap; }
.bill-user-meta strong { color: var(--primary-dark); font-weight: 600; }
.bill-logout-btn { background: transparent; border: 1px solid rgba(0, 0, 0, 0.15); color: #555; padding: 6px 14px; border-radius: 999px; font-size: 12px; font-weight: 500; cursor: pointer; transition: all 0.2s ease; font-family: inherit; }
.bill-logout-btn:hover { background: rgba(0, 0, 0, 0.05); border-color: rgba(0, 0, 0, 0.25); }

/* ===== TABS ===== */
.bill-tabs { display: flex; gap: 4px; background: rgba(0, 0, 0, 0.04); border-radius: 12px; padding: 4px; margin: 28px 0 16px; }
.bill-tab { flex: 1; padding: 10px 14px; background: transparent; border: none; border-radius: 8px; font-size: 14px; font-weight: 600; color: #777; cursor: pointer; transition: all 0.2s ease; font-family: inherit; }
.bill-tab.active { background: #fff; color: var(--primary-dark); box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06); }
.bill-tab:hover:not(.active) { color: #333; }

/* ===== PRODUCT GRID ===== */
.bill-products { display: none; }
.bill-products.active { display: grid; }

.bill-tab-info { display: none; font-size: 13px; color: #666; margin: 4px 4px 20px; line-height: 1.55; }
.bill-tab-info.active { display: block; }
.bill-tab-info strong { color: #333; }
.bill-products { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; margin-bottom: 28px; }

.bill-product { background: #fff; border: 2px solid rgba(0, 0, 0, 0.06); border-radius: 14px; padding: 18px 16px; cursor: pointer; transition: all 0.2s ease; position: relative; text-align: start; font-family: inherit; display: flex; flex-direction: column; align-items: flex-start; gap: 4px; }
.bill-product:hover { border-color: rgba(116, 213, 179, 0.45); transform: translateY(-2px); box-shadow: 0 8px 18px rgba(0, 0, 0, 0.05); }
.bill-product.selected { border-color: var(--primary); background: rgba(116, 213, 179, 0.06); box-shadow: 0 4px 14px rgba(116, 213, 179, 0.18); }
.bill-product-name { font-size: 14px; font-weight: 600; color: #1a1a1a; }
.bill-product-price-usd { font-size: 22px; font-weight: 700; color: #1a1a1a; letter-spacing: -0.5px; margin-top: 2px; }
.bill-product-price-dzd { font-size: 12px; color: #888; font-weight: 500; }
.bill-product-perk { font-size: 11px; color: var(--primary-dark); font-weight: 600; margin-top: 4px; }
/* SCOPED to membership grid only — guarantees the Best Value badge can
   never accidentally render on a coin card even if JS regresses. */
.bill-products[data-products="membership"] .bill-product-badge {
  position: absolute;
  top: -10px;
  inset-inline-end: 12px;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: #fff;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.6px;
  text-transform: uppercase;
  padding-block: 5px;
  padding-inline: 9px 12px;
  border-radius: 999px;
  box-shadow: 0 4px 12px rgba(116, 213, 179, 0.45), 0 1px 3px rgba(0, 0, 0, 0.08);
  z-index: 2;
}
.bill-products[data-products="membership"] .bill-product-badge::before {
  content: "\2605"; /* ★ */
  display: inline-block;
  margin-inline-end: 4px;
  font-size: 12px;
  vertical-align: -1px;
}

/* The card that bears the Best Value badge gets a quiet premium lift.
   Scoped to membership grid (same defense as the badge rule above). */
.bill-products[data-products="membership"] .bill-product:has(.bill-product-badge) {
  border-color: var(--primary);
  background: linear-gradient(180deg, rgba(116, 213, 179, 0.06) 0%, #fff 60%);
  box-shadow: 0 10px 28px rgba(116, 213, 179, 0.18), 0 2px 8px rgba(0, 0, 0, 0.04);
}
.bill-products[data-products="membership"] .bill-product:has(.bill-product-badge):hover {
  border-color: var(--primary-dark);
  box-shadow: 0 14px 34px rgba(116, 213, 179, 0.28), 0 2px 8px rgba(0, 0, 0, 0.06);
}

/* ===== PAYMENT METHODS ===== */
.bill-methods { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; margin-bottom: 24px; }
.bill-method { background: #fff; border: 2px solid rgba(0, 0, 0, 0.06); border-radius: 14px; padding: 16px; cursor: pointer; transition: all 0.2s ease; text-align: start; font-family: inherit; display: flex; align-items: flex-start; gap: 12px; }
.bill-method:hover { border-color: rgba(116, 213, 179, 0.45); transform: translateY(-1px); }
.bill-method.selected { border-color: var(--primary); background: rgba(116, 213, 179, 0.06); }
.bill-method-icon { width: 36px; height: 36px; flex-shrink: 0; border-radius: 8px; background: rgba(116, 213, 179, 0.15); display: flex; align-items: center; justify-content: center; color: var(--primary-dark); }
.bill-method-icon svg { width: 22px; height: 22px; }
.bill-method-text { flex: 1; min-width: 0; }
.bill-method-name { font-size: 14px; font-weight: 600; color: #1a1a1a; }
.bill-method-desc { font-size: 12px; color: #777; margin-top: 2px; }

/* ===== CHECKOUT BUTTON ===== */
.bill-checkout { display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%; padding: 16px 28px; font-size: 16px; font-weight: 600; font-family: inherit; color: #fff; background: linear-gradient(135deg, var(--primary), var(--primary-dark)); border: none; border-radius: 14px; cursor: pointer; transition: all 0.25s ease; }
.bill-checkout:hover:not(:disabled) { transform: translateY(-2px); box-shadow: 0 12px 28px rgba(116, 213, 179, 0.35); }
.bill-checkout:disabled { opacity: 0.5; cursor: not-allowed; }
.bill-checkout .spinner { width: 16px; height: 16px; border: 2px solid rgba(255, 255, 255, 0.3); border-top-color: #fff; border-radius: 50%; animation: bill-spin 0.7s linear infinite; display: none; }
.bill-checkout.loading .spinner { display: block; }
.bill-checkout.loading .checkout-text { opacity: 0.8; }

/* ===== RATE NOTE ===== */
.bill-rate-note { font-size: 11px; color: #999; text-align: center; margin-top: 14px; line-height: 1.5; }
.bill-rate-attrib { color: #aaa; text-decoration: none; white-space: nowrap; }
.bill-rate-attrib:hover { color: #888; text-decoration: underline; }

/* ===== REFUND / CANCELLATION FINEPRINT ===== */
.bill-fineprint { font-size: 12px; color: #666; background: rgba(0, 0, 0, 0.025); border: 1px solid rgba(0, 0, 0, 0.06); border-radius: 10px; padding: 12px 14px; margin-top: 16px; line-height: 1.55; }
.bill-fineprint p { margin: 0; color: #666; }
.bill-fineprint strong { color: #333; }
.bill-fineprint a { color: var(--primary-dark); text-decoration: none; font-weight: 600; }
.bill-fineprint a:hover { text-decoration: underline; }

/* ===== STATUS STAGES (success / canceled) ===== */
.bill-status { text-align: center; padding: 32px 16px; }
.bill-status-icon { width: 72px; height: 72px; margin: 0 auto 16px; border-radius: 50%; display: flex; align-items: center; justify-content: center; animation: bill-pop 0.5s cubic-bezier(0.34, 1.56, 0.64, 1); }
.bill-status-icon.success { background: var(--primary); color: #fff; }
.bill-status-icon.canceled { background: rgba(231, 76, 60, 0.15); color: var(--danger); }
.bill-status-icon svg { width: 36px; height: 36px; }
.bill-status-title { font-size: 22px; font-weight: 700; color: #1a1a1a; margin-bottom: 8px; }
.bill-status-text { font-size: 14px; color: #555; max-width: 480px; margin: 0 auto 20px; }
.bill-status-btn { background: #1a1a1a; color: #fff; border: none; padding: 12px 24px; border-radius: 999px; font-size: 14px; font-weight: 600; cursor: pointer; font-family: inherit; transition: all 0.2s ease; }
.bill-status-btn:hover { background: #000; transform: translateY(-1px); }
@keyframes bill-pop { 0% { transform: scale(0.6); opacity: 0; } 100% { transform: scale(1); opacity: 1; } }

/* RTL adjustments specific to billing */
html[dir="rtl"] .bill-input { text-align: start; }
html[dir="rtl"] .bill-product, html[dir="rtl"] .bill-method { text-align: start; }

/* Disable details toggling on Arabic — fonts use Cairo/Tajawal natively */
html[dir="rtl"] body { font-family: "Cairo", "Tajawal", "Geeza Pro", -apple-system, BlinkMacSystemFont, sans-serif; }

/* ===== PRO INFO BANNER ON SUCCESS STAGE ===== */
.bill-success-pro-info {
  background: rgba(116, 213, 179, 0.1);
  border: 1px solid rgba(116, 213, 179, 0.3);
  border-radius: 10px;
  padding: 12px 16px;
  margin: 4px auto 20px;
  max-width: 480px;
  font-size: 14px;
  color: #333;
  line-height: 1.5;
  text-align: center;
}
.bill-success-pro-info strong {
  color: var(--primary-dark);
  font-weight: 700;
  white-space: nowrap;
}

/* ===== PER-DAY price line on Pro plan cards ===== */
/* Sits right under the DZD approximation. Small grey, informational. */
.bill-product-perday {
  font-size: 12px;
  color: #888;
  font-weight: 500;
  margin-top: -2px; /* tighten gap with DZD line above */
}

/* ===== SAVE X% chip on multi-month Pro plans ===== */
/* Small mint pill to make savings visually pop without being shouty. */
.bill-product-savings {
  display: inline-block;
  background: rgba(116, 213, 179, 0.18);
  color: var(--primary-dark);
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.4px;
  text-transform: uppercase;
  margin-top: 2px;
  align-self: flex-start;
}

/* ===== Coin purchase success banner (parallel to .bill-success-pro-info) ===== */
.bill-success-coin-info {
  background: rgba(116, 213, 179, 0.1);
  border: 1px solid rgba(116, 213, 179, 0.3);
  border-radius: 10px;
  padding: 12px 16px;
  margin: 12px auto 0;
  max-width: 480px;
  font-size: 14px;
  color: #1a1a1a;
  text-align: center;
  line-height: 1.5;
}
.bill-success-coin-info strong {
  color: var(--primary-dark);
  font-weight: 700;
  white-space: nowrap;
}