/* ==========================================================================
   SGP Wallet Module — Frontend Styles
   Extends panel-core.css design tokens. RTL-first.
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. Balance Card
   -------------------------------------------------------------------------- */

.sgp-wallet-top {
  margin-bottom: 24px;
}

.sgp-wallet-balance-card {
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 28px 32px;
  background: linear-gradient(
    135deg,
    var(--sgp-primary) 0%,
    var(--sgp-primary-dark) 100%
  );
  border: none;
  color: #fff;
}

.sgp-wallet-balance-icon {
  width: 64px;
  height: 64px;
  background: rgba(255, 255, 255, 0.15);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.sgp-wallet-balance-icon .fas {
  font-size: 32px;
  width: 32px;
  height: 32px;
  color: #fff;
}

.sgp-wallet-balance-info {
  flex: 1;
  min-width: 0;
}

.sgp-wallet-balance-label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  opacity: 0.8;
  margin-bottom: 4px;
}

.sgp-wallet-balance-amount {
  display: block;
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.5px;
}

.sgp-wallet-charge-trigger {
  background: #fff !important;
  color: var(--sgp-primary) !important;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15) !important;
  flex-shrink: 0;
  gap: 6px;
}

.sgp-wallet-charge-trigger:hover:not(:disabled) {
  background: var(--sgp-surface-2) !important;
  transform: translateY(-1px);
}

.sgp-wallet-charge-trigger .fas {
  font-size: 18px;
  width: 18px;
  height: 18px;
}

/* --------------------------------------------------------------------------
   2. Modal
   -------------------------------------------------------------------------- */

.sgp-modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
}

.sgp-modal[hidden] {
  display: none;
}

#sgp-wallet-charge-modal .sgp-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
  animation: sgp-fade-in 0.2s ease;
}

.sgp-modal-box {
  position: relative;
  background: var(--sgp-surface);
  border-radius: var(--sgp-radius-lg);
  box-shadow: var(--sgp-shadow-lg);
  width: 100%;
  max-width: 520px;
  margin: 16px;
  animation: sgp-modal-in 0.3s cubic-bezier(0.34, 1.56, 0.64, 1) both;
  max-height: 90vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

@keyframes sgp-modal-in {
  from {
    opacity: 0;
    transform: scale(0.92) translateY(16px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

.sgp-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 22px 28px;
  border-bottom: 1px solid var(--sgp-border);
  flex-shrink: 0;
}

.sgp-modal-title {
  font-size: 17px;
  font-weight: 700;
  margin: 0;
}

.sgp-modal-close {
  width: 36px;
  height: 36px;
  border: none;
  background: var(--sgp-surface-2);
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--sgp-text-secondary);
  transition:
    background var(--sgp-transition),
    color var(--sgp-transition);
}

.sgp-modal-close:hover {
  background: var(--sgp-danger-light);
  color: var(--sgp-danger);
}

.sgp-modal-close .fas {
  font-size: 18px;
  width: 18px;
  height: 18px;
}

.sgp-modal-body {
  padding: 28px;
  flex: 1;
}

.sgp-modal-footer {
  padding: 18px 28px;
  border-top: 1px solid var(--sgp-border);
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 12px;
  flex-direction: row-reverse;
  flex-shrink: 0;
}

/* --------------------------------------------------------------------------
   3. Charge Presets
   -------------------------------------------------------------------------- */
#sgp-wallet-charge-modal .sgp-label {
  margin-top: 0;
}
.sgp-charge-presets .sgp-label {
  display: block;
  margin-bottom: 12px;
}

.sgp-charge-preset-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 1.5rem;
}

.sgp-charge-preset-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 12px 8px;
  border: 2px solid var(--sgp-border);
  border-radius: var(--sgp-radius-sm);
  background: var(--sgp-surface);
  cursor: pointer;
  font-family: "Vazirmatn", sans-serif;
  font-size: 14px;
  font-weight: 600;
  color: var(--sgp-text);
  transition: all var(--sgp-transition);
  line-height: 1.3;
}

.sgp-charge-preset-btn small {
  font-size: 11px;
  font-weight: 400;
  color: var(--sgp-text-secondary);
}

.sgp-charge-preset-btn:hover {
  border-color: var(--sgp-primary);
  background: var(--sgp-primary-light);
  color: var(--sgp-primary);
}

.sgp-charge-preset-btn.is-selected {
  border-color: var(--sgp-primary);
  background: var(--sgp-primary);
  color: #fff;
}

.sgp-charge-preset-btn.is-selected small {
  color: rgba(255, 255, 255, 0.8);
}

/* Charge summary */
.sgp-charge-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 20px;
  padding: 14px 18px;
  background: var(--sgp-primary-light);
  border-radius: var(--sgp-radius-sm);
  border: 1px solid var(--sgp-primary);
}

.sgp-charge-summary-label {
  font-size: 14px;
  color: var(--sgp-text-secondary);
  font-weight: 500;
}

.sgp-charge-summary-amount {
  font-size: 18px;
  font-weight: 700;
  color: var(--sgp-primary);
}

/* --------------------------------------------------------------------------
   4. Transactions Table
   -------------------------------------------------------------------------- */

.sgp-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}

.sgp-table th {
  text-align: right;
  padding: 12px 14px;
  font-size: 12px;
  font-weight: 600;
  color: var(--sgp-text-secondary);
  border-bottom: 2px solid var(--sgp-border);
  white-space: nowrap;
  background: var(--sgp-surface-2);
}

.sgp-table td {
  padding: 13px 14px;
  border-bottom: 1px solid var(--sgp-border);
  vertical-align: middle;
  color: var(--sgp-text);
}

.sgp-table tr:last-child td {
  border-bottom: none;
}

.sgp-table tr:hover td {
  background: var(--sgp-surface-2);
}

/* Amount styling */
.sgp-tx-amount {
  font-weight: 700;
  font-size: 14px;
  white-space: nowrap;
}

.sgp-tx-amount small {
  font-size: 11px;
  font-weight: 400;
  opacity: 0.7;
  margin-right: 2px;
}

.sgp-amount-credit {
  color: var(--sgp-success);
}

.sgp-amount-debit {
  color: var(--sgp-danger);
}

.sgp-amount-sign {
  font-size: 16px;
  margin-left: 2px;
}

.sgp-tx-balance {
  font-size: 13px;
  color: var(--sgp-text-secondary);
  white-space: nowrap;
}

.sgp-tx-date {
  font-size: 12px;
  color: var(--sgp-text-secondary);
  white-space: nowrap;
}

.sgp-tx-desc {
  font-size: 13px;
  color: var(--sgp-text);
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Type badges */
.sgp-tx-type-badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: var(--sgp-radius-full);
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}

.sgp-tx-type-charge {
  background: var(--sgp-info-light);
  color: #1e40af;
}
.sgp-tx-type-purchase {
  background: var(--sgp-danger-light);
  color: #991b1b;
}
.sgp-tx-type-gift {
  background: var(--sgp-success-light);
  color: #065f46;
}
.sgp-tx-type-refund {
  background: var(--sgp-warning-light);
  color: #92400e;
}
.sgp-tx-type-admin_adjust {
  background: var(--sgp-surface-2);
  color: var(--sgp-text-secondary);
}

/* --------------------------------------------------------------------------
   5. Pagination
   -------------------------------------------------------------------------- */

.sgp-wallet-pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 20px 0 4px;
  flex-wrap: wrap;
}

.sgp-page-btn {
  width: 36px;
  height: 36px;
  border-radius: var(--sgp-radius-sm);
  border: 1.5px solid var(--sgp-border);
  background: var(--sgp-surface);
  color: var(--sgp-text);
  font-family: "Vazirmatn", sans-serif;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--sgp-transition);
  display: flex;
  align-items: center;
  justify-content: center;
}

.sgp-page-btn:hover:not(:disabled) {
  border-color: var(--sgp-primary);
  color: var(--sgp-primary);
  background: var(--sgp-primary-light);
}

.sgp-page-btn.active,
.sgp-page-btn:disabled {
  background: var(--sgp-primary);
  border-color: var(--sgp-primary);
  color: #fff;
  cursor: default;
}

/* --------------------------------------------------------------------------
   6. Empty State
   -------------------------------------------------------------------------- */

.sgp-wallet-empty-state {
  text-align: center;
  padding: 56px 20px;
  color: var(--sgp-text-secondary);
}

.sgp-wallet-empty-icon {
  font-size: 48px !important;
  width: 48px !important;
  height: 48px !important;
  opacity: 0.25;
  display: block;
  margin: 0 auto 16px;
}

/* --------------------------------------------------------------------------
   7. WooCommerce Checkout Box
   -------------------------------------------------------------------------- */

.sgp-wallet-checkout-box {
  background: var(--sgp-surface);
  border: 2px solid var(--sgp-border);
  border-radius: var(--sgp-radius);
  padding: 20px;
  margin-bottom: 20px;
  transition: border-color var(--sgp-transition);
}

.sgp-wallet-checkout-box.wallet-active {
  border-color: var(--sgp-primary);
}

.sgp-wallet-checkout-header {
  display: flex;
  align-items: center;
  gap: 14px;
}

.sgp-wallet-checkout-icon {
  width: 44px;
  height: 44px;
  background: var(--sgp-primary-light);
  border-radius: var(--sgp-radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  color: var(--sgp-primary);
  flex-shrink: 0;
}

.sgp-wallet-checkout-info {
  flex: 1;
}

.sgp-wallet-checkout-info strong {
  display: block;
  font-size: 14px;
  font-weight: 700;
  color: var(--sgp-text);
}

.sgp-wallet-checkout-balance {
  font-size: 13px;
  color: var(--sgp-text-secondary);
  display: block;
  margin-top: 2px;
}

/* Toggle switch */
.sgp-wallet-toggle {
  position: relative;
  display: inline-block;
  width: 48px;
  height: 26px;
  cursor: pointer;
  flex-shrink: 0;
}

.sgp-wallet-toggle input {
  opacity: 0;
  width: 0;
  height: 0;
  position: absolute;
}

.sgp-toggle-slider {
  position: absolute;
  inset: 0;
  background: var(--sgp-border-strong);
  border-radius: 26px;
  transition: background var(--sgp-transition);
}

.sgp-toggle-slider::before {
  content: "";
  position: absolute;
  width: 20px;
  height: 20px;
  left: 3px;
  top: 3px;
  background: #fff;
  border-radius: 50%;
  transition: transform var(--sgp-transition);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

.sgp-wallet-toggle input:checked + .sgp-toggle-slider {
  background: var(--sgp-primary);
}

.sgp-wallet-toggle input:checked + .sgp-toggle-slider::before {
  transform: translateX(22px);
}

/* Deduct info */
.sgp-wallet-checkout-deduct {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 14px;
  padding: 10px 14px;
  background: var(--sgp-success-light);
  border-radius: var(--sgp-radius-sm);
  font-size: 13px;
  color: #065f46;
  font-weight: 500;
  animation: sgp-slide-down 0.25s ease;
}

.sgp-wallet-checkout-deduct .fas {
  color: var(--sgp-success);
  font-size: 18px;
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

/* --------------------------------------------------------------------------
   8. Responsive
   -------------------------------------------------------------------------- */

@media (max-width: 640px) {
  .sgp-wallet-balance-card {
    flex-wrap: wrap;
    padding: 20px;
    gap: 16px;
  }

  .sgp-wallet-balance-amount {
    font-size: 22px;
  }

  .sgp-wallet-charge-trigger {
    width: 100%;
    justify-content: center;
  }

  .sgp-charge-preset-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .sgp-modal-box {
    margin: 8px;
    border-radius: var(--sgp-radius);
  }

  .sgp-modal-header,
  .sgp-modal-body,
  .sgp-modal-footer {
    padding: 16px;
  }

  .sgp-table th:nth-child(3),
  .sgp-table td:nth-child(3) {
    display: none;
  }
}

/* --------------------------------------------------------------------------
   Payment result alerts
   -------------------------------------------------------------------------- */

/* .sgp-alert {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 18px;
  border-radius: var(--sgp-radius-sm);
  margin-bottom: 20px;
  font-size: 14px;
  font-weight: 500;
} */

.sgp-alert .fas {
  font-size: 20px;
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  margin-top: 1px;
}

.sgp-alert--success {
  background: var(--sgp-success-light, #d1fae5);
  border: 1px solid #6ee7b7;
  color: #065f46;
}

.sgp-alert--success .fas {
  color: #059669;
}

.sgp-alert--error {
  background: var(--sgp-danger-light, #fee2e2);
  border: 1px solid #fca5a5;
  color: #991b1b;
}

.sgp-alert--error .fas {
  color: #dc2626;
}
