/* =============================================================================
   Credits Popup
   ============================================================================= */

.credits-popup {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
}

.credits-popup[x-cloak] {
  display: none !important;
}

.credits-popup .popup-overlay {
  position: absolute;
  inset: 0;
  background: rgba(252, 255, 255, 0.5);
}

.credits-popup .popup-content {
  position: relative;
  background: rgba(255, 255, 255, 0.98);
  border: 1px solid rgba(13, 19, 41, 0.12);
  border-radius: 10px;
  min-width: 280px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.18);
}

.credits-popup .popup-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 14px;
  border-bottom: 1px solid rgba(13, 19, 41, 0.08);
}

.credits-popup .popup-header h3 {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
  color: rgba(13, 19, 41, 0.9);
}

.credits-popup .popup-close {
  border: none;
  background: transparent;
  font-size: 20px;
  line-height: 1;
  color: rgba(13, 19, 41, 0.4);
  cursor: pointer;
  padding: 0;
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.credits-popup .popup-close:hover {
  color: rgba(13, 19, 41, 0.7);
}

.credits-popup .popup-content {
  width: 90vw;
  max-width: 520px;
}

.credits-popup .popup-body {
  padding: 20px 24px;
}

/* Sections */
.credits-section {
  padding-bottom: 20px;
  margin-bottom: 20px;
  border-bottom: 1px solid rgba(13, 19, 41, 0.06);
}

.credits-section:last-child {
  padding-bottom: 0;
  margin-bottom: 0;
  border-bottom: none;
}

.credits-section.disabled-section {
  opacity: 0.5;
  pointer-events: none;
}

/* Redeem code */
.redeem-row {
  display: flex;
  gap: 10px;
  align-items: center;
  justify-content: space-between;
}

/* CD-Key style input container */
.cdkey-input {
  display: flex;
  align-items: center;
  gap: 0;
}

.cdkey-segment {
  width: 50px;
  border: none;
  border-radius: 0;
  font-size: 14px;
  font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-align: left;
  padding-left: 7px;
  text-transform: uppercase;
  color: rgba(13, 19, 41, 0.9);
  background: rgba(13, 19, 41, 0.04);
}

.cdkey-segment:focus {
  outline: none;
  background: rgba(13, 19, 41, 0.06);
}

.cdkey-segment::placeholder {
  color: rgba(13, 19, 41, 0.25);
  font-weight: 400;
  letter-spacing: 0.15em;
}

.cdkey-segment:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.cdkey-dash {
  padding: 0 8px;
  font-size: 18px;
  font-weight: 300;
  color: rgba(13, 19, 41, 0.3);
  -webkit-user-select: none;
  user-select: none;
}

.redeem-btn {
  padding: 10px 16px;
  border: 1px solid rgba(13, 19, 41, 0.12);
  border-radius: 5px;
  background: white;
  font-size: 14px;
  font-weight: 500;
  color: rgba(13, 19, 41, 0.8);
  cursor: pointer;
  transition: background-color 120ms ease;
}

.redeem-btn:hover:not(:disabled) {
  background: rgba(13, 19, 41, 0.04);
}

.redeem-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.redeem-error {
  margin-top: 8px;
  font-size: 12px;
  color: #c44;
  text-align: right;
}

.redeem-success {
  margin-top: 8px;
  font-size: 12px;
  color: #3a8;
}

/* Section header */
.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.section-label {
  font-size: 12px;
  color: rgba(13, 19, 41, 0.5);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.balance-inline {
  font-size: 12px;
  color: rgba(13, 19, 41, 0.5);
}

/* Auto top-up */
.topup-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}

.topup-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
}

.topup-toggle input[type="checkbox"] {
  width: 16px;
  height: 16px;
  cursor: pointer;
}

.toggle-label {
  font-size: 14px;
  color: rgba(13, 19, 41, 0.75);
}

.threshold-input {
  width: 80px;
  padding: 6px 8px;
  border: 1px solid rgba(13, 19, 41, 0.12);
  border-radius: 4px;
  font-size: 13px;
  font-family: inherit;
  text-align: right;
}

.threshold-input:focus {
  outline: none;
  border-color: rgba(13, 19, 41, 0.25);
}

.threshold-input:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* Packages row */
.packages-row {
  display: flex;
  gap: 10px;
  margin-bottom: 20px;
}

.package-btn {
  flex: 1;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 16px 8px;
  border: 1px solid rgba(13, 19, 41, 0.1);
  border-radius: 6px;
  background: white;
  cursor: pointer;
  transition: border-color 120ms ease, background-color 120ms ease;
}

.package-btn:hover {
  border-color: rgba(13, 19, 41, 0.2);
  background: rgba(13, 19, 41, 0.02);
}

.package-btn.selected {
  border-color: rgba(13, 19, 41, 0.4);
  background: rgba(13, 19, 41, 0.04);
}

.package-btn:active:not(:disabled) {
  transform: translateY(1px);
}

.package-btn:disabled {
  cursor: not-allowed;
}

.package-credits {
  font-size: 14px;
  font-weight: 600;
  color: rgba(13, 19, 41, 0.85);
}

.package-bonus {
  font-size: 8px;
  color: rgba(13, 19, 41, 0.4);
  vertical-align: super;
  margin-left: 2px;
}

/* Purchase button */
.purchase-btn {
  width: 100%;
  padding: 12px 16px;
  border: none;
  border-radius: 6px;
  background: rgba(13, 19, 41, 0.85);
  font-size: 14px;
  font-weight: 500;
  color: white;
  cursor: pointer;
  transition: background-color 120ms ease;
}

.purchase-btn:hover:not(:disabled) {
  background: rgba(13, 19, 41, 0.95);
}

.purchase-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.purchase-btn:active:not(:disabled) {
  transform: translateY(1px);
}

/* =============================================================================
   Account Popup
   ============================================================================= */

.account-popup {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
}

.account-popup[x-cloak] {
  display: none !important;
}

.account-popup .popup-overlay {
  position: absolute;
  inset: 0;
  background: rgba(252, 255, 255, 0.5);
}

.account-popup .popup-content {
  position: relative;
  background: rgba(255, 255, 255, 0.98);
  border: 1px solid rgba(13, 19, 41, 0.12);
  border-radius: 10px;
  min-width: 300px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.18);
}

.account-popup .popup-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 14px;
  border-bottom: 1px solid rgba(13, 19, 41, 0.08);
}

.account-popup .popup-header h3 {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
  color: rgba(13, 19, 41, 0.9);
}

.account-popup .popup-close {
  border: none;
  background: transparent;
  font-size: 20px;
  line-height: 1;
  color: rgba(13, 19, 41, 0.4);
  cursor: pointer;
  padding: 0;
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.account-popup .popup-close:hover {
  color: rgba(13, 19, 41, 0.7);
}

.account-popup .popup-body {
  padding: 14px;
}

.account-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field-label {
  font-size: 12px;
  color: rgba(13, 19, 41, 0.6);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.field-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 10px;
  background: rgba(13, 19, 41, 0.03);
  border-radius: 6px;
}

.field-value {
  font-size: 14px;
  color: rgba(13, 19, 41, 0.85);
  word-break: break-all;
}

.field-action {
  flex-shrink: 0;
  padding: 4px 10px;
  border: 1px solid rgba(13, 19, 41, 0.15);
  border-radius: 4px;
  background: transparent;
  font-size: 12px;
  color: rgba(13, 19, 41, 0.7);
  cursor: pointer;
  transition: background-color 120ms ease;
}

.field-action:hover:not(:disabled) {
  background: rgba(13, 19, 41, 0.06);
}

.field-action:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.account-popup .popup-footer {
  padding: 12px 14px;
  border-top: 1px solid rgba(13, 19, 41, 0.06);
  background: rgba(13, 19, 41, 0.02);
  text-align: center;
}

.account-popup .privacy-note {
  margin: 0 0 6px 0;
  font-size: 11px;
  line-height: 1.45;
  color: rgba(13, 19, 41, 0.5);
}

.account-popup .legal-links {
  margin: 0;
  font-size: 11px;
  color: rgba(13, 19, 41, 0.5);
}

.account-popup .legal-links a {
  color: rgba(13, 19, 41, 0.55);
  text-decoration: none;
}

.account-popup .legal-links a:hover {
  color: rgba(13, 19, 41, 0.75);
  text-decoration: underline;
}

/* =============================================================================
   AI Literacy Popup
   ============================================================================= */

.ai-literacy-popup {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
}

.ai-literacy-popup[x-cloak] {
  display: none !important;
}

.ai-literacy-popup .popup-overlay {
  position: absolute;
  inset: 0;
  background: rgba(252, 255, 255, 0.6);
  -webkit-backdrop-filter: blur(2px);
  backdrop-filter: blur(2px);
}

.ai-literacy-popup .popup-panel {
  position: relative;
  display: flex;
  flex-direction: column;
  width: min(880px, 92vw);
  height: min(calc(100vh - 60px), 800px);
  background: rgba(255, 255, 255, 0.99);
  border: 1px solid rgba(13, 19, 41, 0.12);
  border-radius: 12px;
  box-shadow: 0 12px 48px rgba(0, 0, 0, 0.2);
  overflow: hidden;
}

.ai-literacy-popup .popup-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 18px;
  border-bottom: 1px solid rgba(13, 19, 41, 0.08);
  background: rgba(248, 249, 250, 0.8);
  flex-shrink: 0;
}

.ai-literacy-popup .popup-header h3 {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
  color: rgba(13, 19, 41, 0.9);
}

.ai-literacy-popup .popup-header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.ai-literacy-popup .copy-link-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  background: transparent;
  border: none;
  color: rgba(13, 19, 41, 0.35);
  cursor: pointer;
  transition: color 0.15s;
}

.ai-literacy-popup .copy-link-icon:hover {
  color: rgba(13, 19, 41, 0.6);
}

.ai-literacy-popup .copy-link-icon.copied {
  color: #228b22;
}

.ai-literacy-popup .popup-close {
  border: none;
  background: transparent;
  font-size: 22px;
  line-height: 1;
  color: rgba(13, 19, 41, 0.4);
  cursor: pointer;
  padding: 0;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  transition: background-color 120ms ease, color 120ms ease;
}

.ai-literacy-popup .popup-close:hover {
  color: rgba(13, 19, 41, 0.7);
  background: rgba(13, 19, 41, 0.06);
}

.ai-literacy-popup .popup-layout {
  display: flex;
  flex: 1;
  min-height: 0;
}

/* Sidebar */
.ai-literacy-popup .popup-sidebar {
  width: 180px;
  flex-shrink: 0;
  padding: 12px 8px;
  border-right: 1px solid rgba(13, 19, 41, 0.06);
  background: rgba(248, 249, 250, 0.5);
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.ai-literacy-popup .sidebar-item {
  padding: 10px 12px;
  border: none;
  background: transparent;
  text-align: left;
  font-size: 13px;
  font-weight: 500;
  color: rgba(13, 19, 41, 0.65);
  border-radius: 6px;
  cursor: pointer;
  transition: background-color 120ms ease, color 120ms ease;
}

.ai-literacy-popup .sidebar-item:hover {
  background: rgba(13, 19, 41, 0.05);
  color: rgba(13, 19, 41, 0.85);
}

.ai-literacy-popup .sidebar-item.active {
  background: rgba(13, 19, 41, 0.08);
  color: rgba(13, 19, 41, 0.95);
  font-weight: 600;
}

/* Content area */
.ai-literacy-popup .popup-content-area {
  flex: 1;
  padding: 24px 32px;
  overflow-y: auto;
  min-height: 0;
}

/* Literacy content styling */
.literacy-content {
  max-width: 640px;
  line-height: 1.7;
  color: rgba(13, 19, 41, 0.85);
}

.literacy-content h2 {
  margin: 0 0 20px 0;
  font-size: 22px;
  font-weight: 600;
  color: rgba(13, 19, 41, 0.95);
}

.literacy-content h3 {
  margin: 28px 0 12px 0;
  font-size: 15px;
  font-weight: 600;
  color: rgba(13, 19, 41, 0.9);
}

.literacy-content h3:first-of-type {
  margin-top: 20px;
}

.literacy-content p {
  margin: 0 0 16px 0;
  font-size: 14px;
}

.literacy-content ul {
  margin: 0 0 16px 0;
  padding-left: 24px;
}

.literacy-content li {
  margin-bottom: 8px;
  font-size: 14px;
}

.literacy-content li:last-child {
  margin-bottom: 0;
}

/* =============================================================================
   Mobile Responsive - Credits Popup
   ============================================================================= */

@media (max-width: 640px) {
  .credits-popup .popup-content {
    width: 94vw;
    max-width: none;
  }

  .credits-popup .popup-body {
    padding: 16px;
  }

  .credits-section {
    padding-bottom: 16px;
    margin-bottom: 16px;
  }

  /* Redeem section - stack vertically */
  .redeem-row {
    flex-direction: column;
    gap: 12px;
    align-items: stretch;
  }

  .cdkey-input {
    justify-content: center;
  }

  .cdkey-segment {
    width: 44px;
    font-size: 13px;
    padding: 8px 4px;
  }

  .cdkey-dash {
    padding: 0 5px;
    font-size: 16px;
  }

  .redeem-btn {
    width: 100%;
    padding: 12px 16px;
    font-size: 13px;
  }

  /* Section header */
  .section-header {
    margin-bottom: 12px;
  }

  .section-label {
    font-size: 11px;
  }

  .balance-inline {
    font-size: 11px;
  }

  /* Auto top-up row */
  .topup-row {
    gap: 8px;
    margin-bottom: 12px;
  }

  .toggle-label {
    font-size: 13px;
  }

  .threshold-input {
    width: 65px;
    padding: 5px 6px;
    font-size: 12px;
  }

  /* Packages - wrap to 2 rows on very small screens */
  .packages-row {
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 16px;
  }

  .package-btn {
    flex: 1 1 calc(33.33% - 6px);
    min-width: 70px;
    padding: 12px 4px;
  }

  .package-credits {
    font-size: 12px;
  }

  .package-bonus {
    font-size: 7px;
  }

  /* Purchase button */
  .purchase-btn {
    padding: 10px 14px;
    font-size: 13px;
  }
}

/* =============================================================================
   Mobile Responsive - Account Popup
   ============================================================================= */

@media (max-width: 640px) {
  .account-popup .popup-content {
    width: 90vw;
    min-width: auto;
  }

  .account-popup .popup-header {
    padding: 10px 12px;
  }

  .account-popup .popup-header h3 {
    font-size: 13px;
  }

  .account-popup .popup-body {
    padding: 12px;
  }

  .field-label {
    font-size: 11px;
  }

  .field-row {
    padding: 6px 8px;
    gap: 8px;
  }

  .field-value {
    font-size: 13px;
  }

  .field-action {
    padding: 3px 8px;
    font-size: 11px;
  }

  .account-popup .popup-footer {
    padding: 10px 12px;
  }

  .account-popup .privacy-note {
    font-size: 10px;
    margin-bottom: 4px;
  }

  .account-popup .legal-links {
    font-size: 10px;
  }
}

/* =============================================================================
   Mobile Responsive - AI Literacy Popup
   ============================================================================= */

@media (max-width: 640px) {
  .ai-literacy-popup .popup-panel {
    width: 100vw;
    height: 100vh;
    border-radius: 0;
  }

  .ai-literacy-popup .popup-layout {
    flex-direction: column;
  }

  .ai-literacy-popup .popup-sidebar {
    width: 100%;
    flex-direction: row;
    overflow-x: auto;
    padding: 8px;
    gap: 4px;
    border-right: none;
    border-bottom: 1px solid rgba(13, 19, 41, 0.06);
  }

  .ai-literacy-popup .sidebar-item {
    white-space: nowrap;
    padding: 8px 12px;
    font-size: 12px;
  }

  .ai-literacy-popup .popup-content-area {
    padding: 20px 16px;
  }

  .literacy-content h2 {
    font-size: 18px;
  }

  .literacy-content h3 {
    font-size: 14px;
  }

  .literacy-content p,
  .literacy-content li {
    font-size: 13px;
  }
}
