/* Gift Registry — App Proxy page styles */

#gr-app {
  --gr-accent: rgb(38, 144, 27);
  --gr-accent-hover: rgb(30, 115, 22);
  --gr-accent-light: rgba(38, 144, 27, 0.08);
  --gr-accent-ring: rgba(38, 144, 27, 0.15);
  --gr-bg: #ffffff;
  --gr-surface: #f8fafc;
  --gr-surface-hover: #f1f5f9;
  --gr-border: #e2e8f0;
  --gr-text: #1e293b;
  --gr-text-muted: #64748b;
  --gr-error: #dc2626;
  --gr-radius: 10rem;
  --gr-radius-card: 16px;
  --gr-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);

  max-width: 700px;
  margin: 0 auto;
  padding: 24px 16px 60px;
  font-family: 'Tajawal', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  color: var(--gr-text);
  direction: rtl;
}

/* Loading */
.gr-loading {
  text-align: center;
  padding: 60px 0;
  color: var(--gr-text-muted);
  font-size: 16px;
}

/* Setup intro */
.gr-setup-intro {
  margin-bottom: 28px;
  padding-bottom: 24px;
  border-bottom: 1px solid var(--gr-border);
}
.gr-setup-title {
  margin: 0 0 8px;
  font-size: 26px;
  font-weight: 700;
  color: var(--gr-text);
}
.gr-setup-desc {
  margin: 0 0 20px;
  color: var(--gr-text-muted);
  font-size: 15px;
  line-height: 1.6;
}
.gr-setup-steps {
  margin: 0;
  padding: 0 0 0 1.5em;
  list-style: none;
  counter-reset: gr-step;
}
.gr-setup-steps li {
  position: relative;
  margin-bottom: 12px;
  padding-right: 0;
  font-size: 14px;
  color: var(--gr-text);
  line-height: 1.5;
}
.gr-setup-steps li::before {
  content: none;
}
.gr-step-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  margin-left: 8px;
  background: var(--gr-accent-light);
  color: var(--gr-accent);
  font-weight: 700;
  font-size: 13px;
  border-radius: 50%;
  vertical-align: middle;
}

/* Typography */
#gr-app h2 {
  margin: 0 0 4px;
  font-size: 22px;
  font-weight: 700;
}

.gr-subtitle {
  margin: 0 0 20px;
  color: var(--gr-text-muted);
  font-size: 14px;
}

/* Buttons */
.gr-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 20px;
  border: none;
  border-radius: var(--gr-radius);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
  font-family: inherit;
  white-space: nowrap;
}

.gr-btn:active { transform: scale(0.97); }

.gr-btn-primary {
  background: var(--gr-accent);
  color: #fff;
}
.gr-btn-primary:hover { background: var(--gr-accent-hover); }
.gr-btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }

.gr-btn-secondary {
  background: var(--gr-surface);
  color: var(--gr-text);
  border: 1px solid var(--gr-border);
}
.gr-btn-secondary:hover { background: var(--gr-surface-hover); }

.gr-btn-danger {
  background: #fee2e2;
  color: var(--gr-error);
  border: 1px solid #fecaca;
}
.gr-btn-danger:hover { background: #fecaca; }

.gr-btn-muted {
  background: transparent;
  color: var(--gr-text-muted);
  border: none;
}
.gr-btn-muted:hover { color: var(--gr-text); background: var(--gr-surface); }

.gr-btn-sm { padding: 8px 14px; font-size: 13px; }

.gr-btn-full { width: 100%; }

/* Inputs */
.gr-input-group {
  margin-bottom: 14px;
}
.gr-input-group label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--gr-text-muted);
  margin-bottom: 4px;
}
.gr-input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--gr-border);
  border-radius: var(--gr-radius);
  font-size: max(15px, 16px);
  direction: rtl;
  box-sizing: border-box;
  font-family: inherit;
  background: var(--gr-bg);
  color: var(--gr-text);
}
.gr-input:focus {
  outline: none;
  border-color: var(--gr-accent);
  box-shadow: 0 0 0 3px var(--gr-accent-ring);
}

.gr-error-msg {
  color: var(--gr-error);
  font-size: 13px;
  margin-top: 4px;
  min-height: 18px;
}

/* Cards */
.gr-card {
  background: var(--gr-bg);
  border: 1px solid var(--gr-border);
  border-radius: var(--gr-radius-card);
  padding: 24px;
}

.gr-login-card {
  max-width: 400px;
  margin: 40px auto;
  text-align: center;
}
.gr-login-card h2 { font-size: 24px; }
.gr-login-card .gr-input-group { text-align: right; }
.gr-auth-step { margin-bottom: 16px; }
.gr-auth-step .gr-btn-full { margin-top: 8px; }
.gr-otp-sent-msg {
  margin: 0 0 12px;
  font-size: 14px;
  color: var(--gr-text-muted);
}
.gr-otp-sent-msg span { font-weight: 600; color: var(--gr-text); }

/* Greeting row */
.gr-greeting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 20px;
}
.gr-greeting-row .gr-subtitle {
  margin: 0;
}

/* Header */
.gr-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}
.gr-header-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.gr-back-link {
  display: inline-block;
  font-size: 13px;
  color: var(--gr-accent);
  text-decoration: none;
  margin-bottom: 4px;
}
.gr-back-link:hover { text-decoration: underline; }

/* Create row */
#gr-show-create-btn {
  margin-bottom: 20px;
}
.gr-create-row {
  display: flex;
  gap: 8px;
  margin-bottom: 4px;
}
.gr-create-row .gr-input { flex: 1; }

/* Registry list */
.gr-registry-card {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 12px 4px 4px;
  background: var(--gr-surface);
  border: 1px solid var(--gr-border);
  border-radius: var(--gr-radius-card);
  margin-bottom: 8px;
  transition: border-color 0.15s, background 0.15s;
}
.gr-registry-card:hover {
  border-color: var(--gr-accent);
  background: var(--gr-accent-light);
}
.gr-registry-card-link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex: 1;
  min-width: 0;
  padding: 12px 4px;
  text-decoration: none;
  color: inherit;
}
.gr-registry-card-info h3 {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
}
.gr-registry-card-info p {
  margin: 2px 0 0;
  font-size: 13px;
  color: var(--gr-text-muted);
}
.gr-arrow {
  font-size: 20px;
  color: var(--gr-text-muted);
}

.gr-empty {
  text-align: center;
  padding: 40px 16px;
  color: var(--gr-text-muted);
  font-size: 15px;
}

/* Items */
.gr-item-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  background: var(--gr-surface);
  border: 1px solid var(--gr-border);
  border-radius: var(--gr-radius-card);
  margin-bottom: 8px;
  transition: background 0.15s;
}
.gr-item-img {
  width: 56px;
  height: 56px;
  border-radius: 8px;
  object-fit: contain;
  background: var(--gr-bg);
  flex-shrink: 0;
}
.gr-item-img-ph {
  width: 56px;
  height: 56px;
  border-radius: 8px;
  background: var(--gr-surface-hover);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  flex-shrink: 0;
  color: var(--gr-text-muted);
}
.gr-item-link {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1;
  min-width: 0;
  text-decoration: none;
  color: inherit;
  transition: opacity 0.15s;
}
.gr-item-link:hover {
  opacity: 0.85;
}
.gr-item-body { flex: 1; min-width: 0; }
.gr-item-name {
  font-weight: 700;
  font-size: 14px;
  margin-bottom: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.gr-item-meta {
  display: flex;
  gap: 8px;
  font-size: 12px;
  color: var(--gr-text-muted);
  flex-wrap: wrap;
  align-items: center;
}
.gr-item-price {
  font-weight: 600;
  color: var(--gr-accent);
}
.gr-item-barcode {
  direction: ltr;
  font-family: monospace;
}
.gr-item-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}
.gr-quantity {
  position: relative;
  display: flex;
  width: 12.5rem;
  min-height: 4.8rem;
  border-radius: 10rem;
}
.gr-qty-btn {
  width: 4.5rem;
  flex-shrink: 0;
  position: absolute;
  top: 0;
  bottom: 0;
  border: 0;
  background: transparent;
  color: var(--gr-text);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  font-size: 1.8rem;
  z-index: 1;
}
.gr-qty-btn[data-qty-down],
#gr-preview-qty-down { left: 0; }
.gr-qty-btn[data-qty-up],
#gr-preview-qty-up { right: 0; }
.gr-qty-btn:hover { background: var(--gr-surface-hover); }
.gr-qty-btn svg { width: 1.4rem; pointer-events: none; stroke-width: .2rem; }
.gr-qty-btn svg path { stroke-width: .2rem; }
.gr-qty-btn:disabled { color: var(--gr-border); cursor: default; }
.gr-qty-btn:disabled:hover { background: transparent; }
.gr-qty-display {
  width: 100%;
  flex-grow: 1;
  text-align: center;
  font-weight: 500;
  font-size: 1.6rem;
  background: transparent;
  border: 0;
  box-shadow: 0 0 0 1px var(--gr-border);
  border-radius: 10rem;
  padding-inline: 4.5rem;
  line-height: 4.8rem;
  box-sizing: border-box;
}
.gr-remove-btn {
  border: none;
  border-radius: var(--gr-radius);
  background: #fee2e2;
  color: var(--gr-error);
  font-size: 12px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 6px 12px;
  margin-inline-end: 4px;
  transition: background 0.15s;
  white-space: nowrap;
}
.gr-remove-btn:hover { background: #fecaca; }

/* Source tags */
.gr-source-tag {
  display: inline-block;
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
}
.gr-source-store {
  background: #fef3c7;
  color: #92400e;
}
.gr-source-manual {
  background: #e0e7ff;
  color: #3730a3;
}
.gr-source-shopify {
  background: #d1fae5;
  color: #065f46;
}

/* Modals */
.gr-modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 99999;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.gr-modal {
  background: var(--gr-bg);
  border-radius: var(--gr-radius-card);
  width: 100%;
  max-width: 440px;
  max-height: 85vh;
  overflow-y: auto;
  padding: 24px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2);
  direction: rtl;
}
.gr-modal-lg { max-width: 560px; overflow: visible; }
.gr-modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}
.gr-modal-header h3 {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
}
.gr-close-btn {
  width: 32px;
  height: 32px;
  border: none;
  background: var(--gr-surface);
  border-radius: 50%;
  font-size: 20px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--gr-text-muted);
  transition: background 0.15s;
}
.gr-close-btn:hover { background: var(--gr-surface-hover); }

.gr-actions {
  display: flex;
  gap: 8px;
  margin-top: 16px;
}
.gr-actions .gr-btn { flex: 1; }

/* Scanner */
.gr-scanner-viewport {
  position: relative;
  width: 100%;
  min-height: 180px;
  border-radius: 8px;
  overflow: hidden;
  background: var(--gr-surface);
  -webkit-transform: translateZ(0);
}
.gr-scanner-video {
  width: 100%;
  height: auto;
  min-height: 180px;
  object-fit: cover;
  display: block;
  -webkit-transform: translateZ(0);
}
.gr-scan-region {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}
.gr-scan-line {
  width: 80%;
  max-width: 280px;
  height: 2px;
  background: var(--gr-accent);
  border-radius: 2px;
  animation: gr-scan-pulse 1.5s ease-in-out infinite;
}
@keyframes gr-scan-pulse {
  0%, 100% { opacity: 0.6; }
  50% { opacity: 1; }
}
.gr-camera-help {
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 200px;
  text-align: center;
  padding: 20px;
  gap: 12px;
}
.gr-camera-help-title {
  margin: 0;
  font-weight: 700;
  font-size: 16px;
}
.gr-camera-help-text {
  margin: 0;
  font-size: 14px;
  color: var(--gr-text-muted);
}
.gr-camera-help-steps {
  text-align: right;
  margin: 12px 0;
}
.gr-camera-help-step {
  margin: 6px 0;
  font-size: 13px;
  color: var(--gr-text-muted);
}
#gr-scanner-body {
  overflow: visible;
}
.gr-scanner-hint {
  text-align: center;
  color: var(--gr-text-muted);
  font-size: 14px;
  margin-top: 8px;
}
.gr-scanner-manual {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--gr-border);
  text-align: center;
}
.gr-scanner-manual p {
  color: var(--gr-text-muted);
  font-size: 14px;
  margin: 0 0 8px;
}
.gr-scanner-manual-row {
  display: flex;
  gap: 8px;
}
.gr-scanner-manual-row .gr-input {
  flex: 1;
}

/* Preview */
.gr-preview-img {
  width: 100%;
  max-height: 200px;
  object-fit: contain;
  border-radius: var(--gr-radius-card);
  margin-bottom: 12px;
  background: var(--gr-surface);
}
.gr-preview-img-ph {
  width: 100%;
  height: 120px;
  background: var(--gr-surface);
  border-radius: var(--gr-radius-card);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 48px;
  margin-bottom: 12px;
  color: var(--gr-text-muted);
}
.gr-preview-name {
  font-weight: 700;
  font-size: 16px;
  margin-bottom: 4px;
}
.gr-preview-price {
  font-size: 18px;
  font-weight: 800;
  color: var(--gr-accent);
  margin-bottom: 4px;
}
.gr-preview-source {
  margin-bottom: 12px;
}
.gr-qty-row {
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 12px 0;
}

/* Editable row */
.gr-edit-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: var(--gr-text-muted);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  flex-shrink: 0;
}
.gr-edit-btn:hover {
  background: var(--gr-surface);
  color: var(--gr-accent);
}
.gr-editable-row {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  flex: 1;
}
.gr-inline-edit {
  display: flex;
  align-items: center;
  gap: 6px;
  width: 100%;
}
.gr-inline-edit .gr-input {
  flex: 1;
  padding: 6px 10px;
  font-size: 14px;
  min-width: 0;
}
.gr-inline-edit .gr-btn {
  flex-shrink: 0;
}

/* Toast */
.gr-toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  padding: 12px 24px;
  border-radius: var(--gr-radius);
  font-size: 14px;
  font-weight: 600;
  z-index: 100000;
  transition: transform 0.3s;
  direction: rtl;
  white-space: nowrap;
  pointer-events: none;
}
.gr-toast.gr-visible { transform: translateX(-50%) translateY(0); }
.gr-toast-success { background: var(--gr-accent); color: #fff; }
.gr-toast-error { background: var(--gr-error); color: #fff; }

/* Shared view */
.gr-shared-header {
  text-align: center;
  margin-bottom: 24px;
}
.gr-shared-header h2 {
  font-size: 24px;
}
.gr-shared-action {
  flex-shrink: 0;
}
.gr-shared-buy-btn {
  text-decoration: none;
}
.gr-shared-store-tag {
  padding: 4px 10px;
  font-size: 12px;
}

/* Purchased state */
.gr-item-purchased {
  opacity: 0.55;
}
.gr-purchased-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 6px 14px;
  border-radius: var(--gr-radius);
  background: #d1fae5;
  color: #065f46;
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
}
.gr-qty-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 6px;
  background: var(--gr-accent-light);
  color: var(--gr-accent);
  font-size: 13px;
  font-weight: 700;
}
.gr-purchased-partial {
  color: var(--gr-accent);
  font-weight: 600;
}
.gr-shared-action-col {
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-items: stretch;
}
.gr-purchased-indicator {
  font-size: 12px;
  color: #065f46;
  font-weight: 600;
}

/* Responsive */
@media (max-width: 480px) {
  .gr-header { flex-direction: column; }
  .gr-header-actions { width: 100%; }
  .gr-header-actions .gr-btn { flex: 1; }
  .gr-item-card { flex-wrap: wrap; }
  .gr-item-actions { width: 100%; justify-content: flex-end; margin-top: 8px; }
  .gr-shared-action { width: 100%; margin-top: 8px; }
  .gr-shared-buy-btn { width: 100%; text-align: center; }
}
