:root {
  /* Common Brand Colors */
  --accent-gold: #d4af37;
  --primary-gradient: linear-gradient(135deg, #5b22e5 0%, #8f3bf8 100%);
  
  /* Light Mode Variables */
  --bg: #f9fafe;
  --bg-radial: radial-gradient(1200px 420px at 50% -60%, rgba(116, 80, 255, 0.22), transparent 60%);
  --text: #171925;
  --text-secondary: #6f7488;
  --card-bg: #ffffff;
  --card-border: rgba(90, 34, 225, 0.12);
  --panel-glass: rgba(255, 255, 255, 0.88);
  --panel-shadow: 0 30px 60px rgba(90, 34, 229, 0.08), 0 0 0 10px rgba(255, 255, 255, 0.4);
  --input-bg: #f8f9fc;
  --input-border: #eef0f7;
  --input-focus: #fff;
  --logo-bg: #fff;
  --logo-shadow: 0 12px 24px rgba(90, 34, 229, 0.15);
  --btn-shadow: 0 12px 24px rgba(90, 34, 229, 0.25);
  --btn-hover-shadow: 0 16px 32px rgba(90, 34, 229, 0.35);
  --title-glow: rgba(90, 34, 229, 0.2);
  --header-bg: rgba(246, 247, 251, 0.92);
}

body.dark-mode {
  --bg: #10111a;
  --bg-radial: radial-gradient(1200px 420px at 50% -60%, rgba(124, 58, 237, 0.12), transparent 60%);
  --text: #f0f2fb;
  --text-secondary: #a0a4b8;
  --card-bg: #161824;
  --card-border: rgba(143, 59, 248, 0.15);
  --panel-glass: rgba(22, 24, 36, 0.7);
  --panel-shadow: 0 30px 60px rgba(0, 0, 0, 0.5), 0 0 0 8px rgba(22, 24, 36, 0.3);
  --input-bg: #1a1d2b;
  --input-border: #24283b;
  --input-focus: #1f2334;
  --logo-bg: #1a1d2b;
  --logo-shadow: 0 12px 24px rgba(0, 0, 0, 0.4);
  --btn-shadow: 0 12px 24px rgba(0, 0, 0, 0.4);
  --btn-hover-shadow: 0 16px 32px rgba(118, 55, 245, 0.25);
  --title-glow: rgba(143, 59, 248, 0.4);
  --header-bg: rgba(22, 24, 36, 0.92);
}

* { box-sizing: border-box; }

body.pay-body {
  margin: 0;
  min-height: 100vh;
  font-family: 'Tajawal', sans-serif;
  background: var(--bg-radial), var(--bg);
  color: var(--text);
  transition: background 0.3s ease, color 0.3s ease;
}

.hidden { display: none !important; }

.glass {
  backdrop-filter: blur(8px);
  background: rgba(255, 255, 255, 0.88);
}

.handle-page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
}

.panel {
  width: min(440px, 100%);
  border-radius: 32px;
  background: var(--panel-glass);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--card-border);
  box-shadow: var(--panel-shadow);
  padding: 40px 32px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  transition: all 0.3s ease;
}

.header-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-bottom: 20px;
  width: 100%;
}

.app-logo-wrapper {
  width: 100px;
  height: 100px;
  background: var(--logo-bg);
  border-radius: 28px;
  box-shadow: var(--logo-shadow), 0 0 0 6px rgba(255, 255, 255, 0.05);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 12px;
  position: relative;
  overflow: hidden;
  transition: all 0.3s ease;
}

.app-logo {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.app-title {
  margin: 0;
  font-size: 2.2rem;
  font-weight: 900;
  letter-spacing: -0.5px;
  background: var(--primary-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  text-shadow: 0 4px 12px var(--title-glow);
  transition: text-shadow 0.3s ease;
}

.panel h2 {
  margin: 0;
  font-size: 1.8rem;
  font-weight: 800;
  letter-spacing: -0.2px;
  background: linear-gradient(to right, #bf953f, #fcf6ba, #b38728, #fcf6ba, #bf953f);
  background-size: 200% auto;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  animation: gold-shine 4s linear infinite;
  transition: all 0.3s ease;
}

@keyframes gold-shine {
  to {
    background-position: 200% center;
  }
}

.subtext {
  margin: 12px 0 32px;
  color: var(--text-secondary);
  font-size: 1rem;
  line-height: 1.5;
  padding: 0 10px;
}

.handle-form {
  display: flex;
  flex-direction: column;
  gap: 24px;
  width: 100%;
}

.input-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
  text-align: right;
  width: 100%;
}

.input-group label {
  font-weight: 800;
  font-size: 0.95rem;
  color: var(--text);
  padding-right: 4px;
}

.input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
  width: 100%;
}

.input-icon {
  position: absolute;
  right: 18px;
  font-weight: 800;
  color: var(--text-secondary);
  font-size: 1.2rem;
  pointer-events: none;
  transition: color 0.3s;
}

.handle-form input {
  height: 60px;
  width: 100%;
  border-radius: 20px;
  border: 2px solid var(--input-border);
  background: var(--input-bg);
  font-size: 1.1rem;
  font-weight: 700;
  padding: 0 45px 0 18px; /* Extra padding right for the @ icon */
  outline: none;
  color: var(--text);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  font-family: monospace; /* makes handle look technical */
}

.handle-form input::placeholder {
  color: var(--text-secondary); /* Changed to use var */
  font-weight: 500;
  font-family: 'Tajawal', sans-serif;
}

.handle-form input:focus {
  box-shadow: 0 0 0 4px rgba(107, 67, 237, 0.1);
}

.handle-form input:focus ~ .input-icon {
  color: #6b43ed;
}

.hint {
  color: #8c90a6;
  font-size: 0.82rem;
  padding-right: 4px;
}

.primary-btn {
  height: 60px;
  border: 0;
  border-radius: 20px;
  font-weight: 900;
  font-size: 1.15rem;
  color: #fff;
  background: var(--primary-gradient);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  box-shadow: var(--btn-shadow);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.primary-btn:hover {
  transform: translateY(-2px);
  box-shadow: var(--btn-hover-shadow);
}

.primary-btn:active {
  transform: translateY(1px);
}

.primary-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.btn-icon {
  width: 20px;
  height: 20px;
  transition: transform 0.3s;
}

.primary-btn:hover:not(:disabled) .btn-icon {
  transform: translateX(-4px); /* Moves left in RTL */
}

.user-preview {
  margin-top: 24px;
  border: 2px solid var(--input-border);
  background: var(--card-bg);
  border-radius: 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 18px;
  width: 100%;
  box-shadow: 0 8px 16px rgba(0,0,0,0.03);
  animation: slideUpFade 0.4s cubic-bezier(0.2, 0.8, 0.2, 1) forwards;
  transition: all 0.3s ease;
}

.user-preview .user-info {
  display: flex;
  align-items: center;
  gap: 14px;
}

.user-preview img {
  width: 48px;
  height: 48px;
  border-radius: 14px;
  object-fit: cover;
  border: 2px solid #fff;
  box-shadow: 0 4px 8px rgba(0,0,0,0.1);
}

.user-preview .user-details {
  text-align: right;
}

.user-preview strong {
  display: block;
  font-size: 1.05rem;
  font-weight: 800;
  color: #1a1a2e;
}

.user-preview span {
  color: var(--text-secondary);
  font-size: 0.85rem;
  font-weight: 600;
}

.error-box {
  margin-top: 16px;
  background: #fff0f0;
  border: 2px solid #ffe1e1;
  color: #d32f2f;
  border-radius: 16px;
  padding: 14px;
  font-size: 0.95rem;
  font-weight: 700;
  width: 100%;
  animation: shake 0.4s cubic-bezier(0.36, 0.07, 0.19, 0.97) both;
}

body.dark-mode .error-box {
  background: #2a1616;
  border-color: #3e2020;
  color: #ff8a8a;
}

/* Theme Toggle Button */
.theme-toggle-container {
  position: fixed;
  top: 24px;
  right: 24px;
  z-index: 1000;
}

.theme-toggle {
  width: 50px;
  height: 50px;
  border-radius: 50%;
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.1);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  padding: 0;
  outline: none;
}

.theme-toggle:hover {
  transform: rotate(15deg) scale(1.1);
  box-shadow: 0 12px 32px rgba(90, 34, 229, 0.2);
}

.theme-toggle svg {
  width: 24px;
  height: 24px;
  fill: currentColor;
}

.theme-toggle .sun-icon { display: block; }
.theme-toggle .moon-icon { display: none; }

body.dark-mode .theme-toggle .sun-icon { display: none; }
body.dark-mode .theme-toggle .moon-icon { display: block; }

@keyframes slideUpFade {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes shake {
  10%, 90% { transform: translate3d(-1px, 0, 0); }
  20%, 80% { transform: translate3d(2px, 0, 0); }
  30%, 50%, 70% { transform: translate3d(-4px, 0, 0); }
  40%, 60% { transform: translate3d(4px, 0, 0); }
}

.recharge-page-container {
  min-height: 100vh;
  direction: rtl;
}

.recharge-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--header-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--card-border);
  transition: background 0.3s ease, border-color 0.3s ease;
}

.recharge-header h2 {
  font-size: 1.15rem;
  font-weight: 800;
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  margin: 0;
  color: var(--text);
}

.back-btn {
  width: 40px;
  height: 40px;
  border: none;
  border-radius: 12px;
  background: var(--card-bg);
  color: var(--text);
  font-size: 1.8rem;
  line-height: 1;
  font-family: Arial, sans-serif;
  cursor: pointer;
  box-shadow: var(--logo-shadow);
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--card-border);
  transition: all 0.3s ease;
}

.back-btn svg {
  width: 20px;
  height: 20px;
  display: block;
}

.balance-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--card-bg);
  padding: 5px 10px;
  border-radius: 20px;
  border: 1px solid var(--accent-gold);
  box-shadow: var(--logo-shadow);
  min-width: 95px;
  justify-content: center;
  transition: background 0.3s ease, box-shadow 0.3s ease;
}

.balance-badge img {
  width: 18px;
  height: 18px;
  border-radius: 999px;
  object-fit: cover;
}

.balance-badge span {
  font-weight: 800;
  color: var(--accent-gold);
  font-size: .9rem;
}

.recharge-content {
  padding: 1rem 0 3rem;
  max-width: 600px;
  margin: 0 auto;
}

.banner-carousel-container {
  position: relative;
  margin: 0.5rem 1rem 1.5rem;
  height: 120px;
  border-radius: 20px;
  overflow: hidden;
  box-shadow: 0 8px 24px rgba(0,0,0,0.12);
  background: var(--card-bg);
  direction: ltr;
}

.banner-track {
  display: flex;
  height: 100%;
  transition: transform .4s ease-out;
}

.banner-slide {
  min-width: 100%;
  height: 100%;
  cursor: pointer;
}

.banner-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.pagination-dots {
  position: absolute;
  bottom: 12px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 6px;
  z-index: 5;
}

.dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: rgba(255,255,255,.45);
  cursor: pointer;
  transition: all .2s;
}

.dot.active {
  background: #fff;
  width: 12px;
  border-radius: 4px;
}

.packages-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: .75rem;
  padding: 0 .75rem;
}

.package-card {
  background: var(--card-bg);
  border-radius: 20px;
  padding: 1.4rem .75rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 1.1rem;
  aspect-ratio: 1 / 1.5;
  border: 1px solid rgba(0,0,0,.05);
  box-shadow: var(--shadow);
  position: relative;
}

.package-card.featured {
  border: 1.5px solid var(--accent-gold);
}

.popularity-tag {
  position: absolute;
  top: -9px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--accent-gold);
  color: #fff;
  font-size: .65rem;
  font-weight: 800;
  padding: 3px 10px;
  border-radius: 10px;
  white-space: nowrap;
}

.discount-badge {
  position: absolute;
  top: 8px;
  right: 10px;
  font-size: .82rem;
  font-weight: 900;
  color: #D4AF37;
}

.pkg-header {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .5rem;
  width: 100%;
}

.pkg-icon-bg {
  width: 52px;
  height: 52px;
  background: rgba(124, 58, 237, 0.1);
  border-radius: 14px;
  display: grid;
  place-items: center;
}

.pkg-icon-bg img {
  width: 42px;
  height: 42px;
  object-fit: contain;
}

.pkg-coins {
  font-size: 1.1rem;
  font-weight: 900;
  margin: 0;
}

.coin-text {
  font-size: .75rem;
  color: var(--text-secondary);
  font-weight: 600;
}

.pkg-vip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: rgba(255, 167, 38, .1);
  padding: 2px 7px;
  border-radius: 7px;
  border: 1px solid rgba(255, 167, 38, .2);
}

.vip-badge { font-size: .55rem; font-weight: 900; color: #FFA726; }
.vip-value { font-size: .7rem; font-weight: 800; color: #F44336; }

.pay-btn {
  background: var(--primary-gradient);
  color: #fff;
  border: none;
  width: 100%;
  padding: 9px 8px;
  border-radius: 12px;
  font-weight: 800;
  cursor: pointer;
}

.security-info {
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: 2.5rem;
  color: var(--text-secondary);
  font-size: .82rem;
  text-align: center;
  padding: 0 1.2rem;
}

.empty-state {
  grid-column: 1 / -1;
  text-align: center;
  border-radius: 14px;
  background: #fff;
  border: 1px dashed #d4d7e5;
  padding: 1.2rem;
}

.modal {
  position: fixed;
  inset: 0;
  background: rgba(13, 10, 24, .48);
  display: grid;
  place-items: center;
  padding: 16px;
  z-index: 999;
}

.modal-card {
  width: min(500px, 100%);
  background: var(--card-bg);
  border-radius: 18px;
  border: 1px solid var(--card-border);
  box-shadow: 0 30px 65px rgba(0,0,0,.4);
  padding: 14px;
  transition: all 0.3s ease;
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.modal-head h3 {
  margin: 0;
  font-size: 1.05rem;
}

.close-btn {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  border: 1px solid var(--card-border);
  background: var(--input-bg);
  color: var(--text);
  font-size: 1.4rem;
  cursor: pointer;
  transition: all 0.3s ease;
}

.pay-summary {
  background: var(--input-bg);
  border: 1px solid var(--input-border);
  border-radius: 12px;
  padding: 10px;
  margin-bottom: 10px;
  color: var(--text);
  transition: all 0.3s ease;
}

.pay-summary p {
  margin: 4px 0;
}

.success-box {
  background: #ecfdf3;
  border: 1px solid #b9f4d1;
  color: #047045;
  border-radius: 12px;
  text-align: center;
  padding: 14px;
  font-weight: 700;
}

@media (max-width: 540px) {
  .packages-grid {
    gap: .7rem;
    padding: 0 .7rem;
  }

  .package-card {
    min-height: 220px;
    aspect-ratio: auto;
  }
}

@media (max-width: 480px) {
  .theme-toggle-container {
    top: 16px;
    right: 16px;
  }
  .theme-toggle {
    width: 44px;
    height: 44px;
  }
  .handle-page {
    padding: 16px 12px;
    justify-content: flex-start;
    padding-top: 5vh;
  }
  .header-section {
    margin-bottom: 16px;
  }
  .app-logo-wrapper {
    width: 85px;
    height: 85px;
    border-radius: 22px;
    margin-bottom: 8px;
  }
  .app-title {
    font-size: 1.8rem;
  }
  .panel {
    padding: 28px 20px;
    border-radius: 28px;
  }
  .panel h2 {
    font-size: 1.5rem;
  }
  .subtext {
    margin-bottom: 24px;
    font-size: 0.9rem;
  }
}
