:root {
  --bg: #f4faf9;
  --surface: #ffffff;
  --surface-alt: #eef6f5;
  --border: #e0ebe9;
  --ink: #0b0d0e;
  --text: #10161a;
  --text-muted: #5c6b6a;
  --text-faint: #93a3a1;

  --teal: #14b8a6;
  --teal-dark: #0d9488;
  --teal-deep: #0f766e;
  --teal-soft: #d9f5f0;

  --danger: #e5335a;
  --danger-soft: #fde3e9;
  --success: #16a672;

  --shadow: 0 1px 2px rgba(10, 20, 20, 0.05), 0 14px 32px rgba(10, 20, 20, 0.07);
  --radius-lg: 20px;
  --radius-md: 14px;
  --radius-sm: 9px;

  color-scheme: light;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  color: var(--text);
  font-family: "Cairo", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

body {
  background:
    radial-gradient(900px 420px at 50% -12%, rgba(20, 184, 166, 0.14), transparent 62%),
    var(--bg);
}

.page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Logo lockup */
.logo-lockup {
  display: flex;
  align-items: center;
  gap: 8px;
  line-height: 1;
}
.logo-en {
  font-weight: 800;
  color: var(--ink);
}
.logo-ar {
  font-weight: 800;
  color: var(--teal);
}
.logo-lockup--sm .logo-en { font-size: 20px; }
.logo-lockup--sm .logo-ar { font-size: 18px; }

.logo-lockup--lg {
  flex-direction: column;
  gap: 0;
}
.logo-lockup--lg .logo-en { font-size: 46px; letter-spacing: -0.5px; }
.logo-lockup--lg .logo-ar { font-size: 34px; margin-top: -4px; }

.hero-lockup {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 18px;
  margin: 0 auto 22px;
}

.topbar .logo-en { color: #ffffff; }
.topbar .logo-ar { color: var(--teal-deep); }

/* Topbar */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px;
  background: linear-gradient(125deg, var(--ink) 0%, #0e1513 55%, #0d2624 130%);
  border-bottom: 3px solid var(--teal);
  position: sticky;
  top: 0;
  z-index: 10;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 16px;
}

.api-status {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: rgba(255, 255, 255, 0.8);
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.45);
  transition: background 0.2s ease;
}
.dot.ok { background: #43e6c4; }
.dot.down { background: #ff6b6b; }

.lang-toggle {
  display: flex;
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: 999px;
  overflow: hidden;
}
.lang-btn {
  padding: 6px 13px;
  font-family: inherit;
  font-size: 12px;
  font-weight: 700;
  background: transparent;
  color: rgba(255, 255, 255, 0.75);
  border: none;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}
.lang-btn.active {
  background: var(--teal);
  color: #06201c;
}

/* Layout */
.page-inner {
  flex: 1;
  width: 100%;
  max-width: 1100px;
  margin: 0 auto;
  padding: 48px 24px;
}

.page-footer {
  text-align: center;
  padding: 24px;
  color: var(--text-faint);
  font-size: 12px;
}

.instagram-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  flex: 0 0 auto;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.instagram-btn svg { display: block; width: 100%; height: 100%; }
.instagram-btn:hover {
  transform: scale(1.08);
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.15);
}

.instagram-btn--lg {
  width: 68px;
  height: 68px;
}
.instagram-block {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}
.instagram-caption {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-muted);
}

.instagram-btn--lg:hover {
  box-shadow: 0 0 0 4px var(--teal-soft);
}

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: 48px 40px;
  max-width: 600px;
  margin: 24px auto;
  text-align: center;
}

.input-panel h1 { margin: 0 0 10px; font-size: 23px; font-weight: 800; }
.sub { color: var(--text-muted); font-size: 14px; margin: 0 0 28px; line-height: 1.6; }

.url-form {
  display: flex;
  gap: 10px;
}
.delivery-time {
  margin: 12px 0 0;
  font-size: 13px;
  font-weight: 600;
  color: var(--teal-deep);
}

#cartUrlInput {
  flex: 1;
  min-width: 0;
  padding: 14px 16px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--surface-alt);
  color: var(--text);
  font-family: inherit;
  font-size: 14px;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
#cartUrlInput:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px var(--teal-soft);
}

.btn {
  border: none;
  border-radius: var(--radius-md);
  padding: 14px 22px;
  font-family: inherit;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  transition: filter 0.15s ease, transform 0.05s ease, opacity 0.15s ease, box-shadow 0.15s ease;
  white-space: nowrap;
}
.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.6; cursor: not-allowed; }

.btn-primary {
  background: linear-gradient(90deg, var(--teal-deep), var(--teal));
  color: #062420;
  box-shadow: 0 8px 20px rgba(20, 184, 166, 0.32);
}
.btn-primary:hover:not(:disabled) { filter: brightness(1.05); }

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

.btn-outline {
  background: transparent;
  color: var(--teal-dark);
  border: 1px solid var(--teal);
  width: 100%;
  margin-top: 18px;
}
.btn-outline:hover:not(:disabled) { background: var(--teal-soft); }

.error-text {
  color: var(--danger);
  font-size: 13px;
  margin-top: 14px;
}

/* Loading */
.loading-panel { padding: 64px 40px; }

.spinner {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 3px solid var(--border);
  border-top-color: var(--teal);
  margin: 0 auto 24px;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.loading-panel h2 { margin: 0 0 8px; font-size: 18px; }

/* Error */
.error-icon {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--danger-soft);
  color: var(--danger);
  font-weight: 800;
  font-size: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 18px;
}
.error-panel h2 { margin: 0 0 8px; font-size: 18px; }
.error-panel .btn { margin-top: 10px; }

/* Results */
.results-view {
  max-width: 1100px;
}

.results-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 24px;
}
.results-header h1 { margin: 0 0 4px; font-size: 24px; font-weight: 800; }
.results-header .sub { margin: 0; }

.results-body {
  display: grid;
  grid-template-columns: 1fr 300px;
  gap: 24px;
  align-items: start;
}
/* Let the columns shrink to the screen instead of to their widest card. */
.results-body > * { min-width: 0; }

@media (max-width: 860px) {
  .results-body { grid-template-columns: 1fr; }
  .url-form { flex-direction: column; }
}

/* Item list */
.items-grid {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.item-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-inline-start: 3px solid transparent;
  border-radius: var(--radius-md);
  overflow: hidden;
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 14px;
  padding: 10px 14px;
  transition: opacity 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}
.item-card:hover {
  border-color: var(--border);
  border-inline-start-color: var(--teal);
  box-shadow: var(--shadow);
}
.item-card.is-updating { opacity: 0.55; pointer-events: none; }
.item-card.is-removed { opacity: 0.65; }

.item-image-wrap {
  position: relative;
  width: 52px;
  height: 52px;
  flex: 0 0 52px;
  border-radius: var(--radius-sm);
  background: var(--surface-alt);
  overflow: hidden;
}
.item-image-wrap img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.discount-badge {
  position: absolute;
  top: 3px;
  inset-inline-start: 3px;
  background: var(--teal-dark);
  color: #fff;
  font-size: 9px;
  font-weight: 800;
  padding: 2px 4px;
  border-radius: 5px;
  line-height: 1;
}

.item-body {
  display: flex;
  flex-direction: row;
  align-items: center;
  flex-wrap: wrap;
  gap: 14px;
  flex: 1;
  min-width: 0;
}

.item-main {
  flex: 1 1 200px;
  min-width: 150px;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.item-name {
  font-size: 13px;
  line-height: 1.35;
  font-weight: 600;
  margin: 0;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.item-variant {
  font-size: 11.5px;
  color: var(--text-muted);
}

.item-actions {
  display: flex;
  align-items: center;
  gap: 18px;
  flex: 0 0 auto;
}

.item-price-row {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  width: 92px;
}
.item-price {
  font-size: 14px;
  font-weight: 700;
  direction: ltr;
  unicode-bidi: isolate;
}
.item-original-price {
  font-size: 11px;
  color: var(--text-faint);
  text-decoration: line-through;
  direction: ltr;
  unicode-bidi: isolate;
}

.item-controls {
  display: flex;
  align-items: center;
  gap: 10px;
}

.qty-control {
  display: flex;
  align-items: center;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
}
.qty-control button {
  width: 26px;
  height: 26px;
  border: none;
  background: var(--surface-alt);
  color: var(--text);
  font-size: 14px;
  cursor: pointer;
  line-height: 1;
}
.qty-control button:hover { background: var(--teal-soft); color: var(--teal-deep); }
.qty-control span {
  min-width: 26px;
  text-align: center;
  font-size: 13px;
  font-weight: 600;
}

.remove-link {
  background: none;
  border: none;
  color: var(--danger);
  font-family: inherit;
  font-size: 12px;
  cursor: pointer;
  padding: 4px;
  font-weight: 700;
}
.remove-link:hover { text-decoration: underline; }

.restore-link {
  background: none;
  border: none;
  color: var(--success);
  font-family: inherit;
  font-size: 12px;
  cursor: pointer;
  padding: 4px;
  font-weight: 700;
}
.restore-link:hover { text-decoration: underline; }

.line-total {
  font-size: 11.5px;
  color: var(--text-muted);
  width: 105px;
  text-align: end;
}

.removed-section {
  margin-top: 28px;
}
.removed-section h3 {
  font-size: 14px;
  color: var(--text-muted);
  margin: 0 0 12px;
}

/* Summary */
.summary-col { position: sticky; top: 84px; }
/* Phones: summary first, scrolling away with the items (not pinned). */
@media (max-width: 860px) {
  .summary-col { order: -1; position: static; }
}

.summary-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: 22px;
}
.summary-card h3 {
  margin: 0 0 16px;
  font-size: 15px;
  font-weight: 800;
}
.summary-row {
  display: flex;
  justify-content: space-between;
  font-size: 13.5px;
  color: var(--text-muted);
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
}
.summary-row span:last-child { direction: ltr; unicode-bidi: isolate; }
.summary-row:last-of-type { border-bottom: none; }
.summary-total {
  font-size: 16px;
  font-weight: 800;
  color: var(--text);
  padding: 12px;
  margin-top: 6px;
  border-top: none;
  background: var(--teal-soft);
  border-radius: var(--radius-sm);
}
.summary-total span:first-child { color: var(--teal-deep); }
.summary-note {
  margin: 10px 0 0;
  font-size: 12.5px;
  color: var(--text-muted);
  text-align: center;
}

@media (max-width: 640px) {
  .item-card { flex-wrap: wrap; }
  .item-actions { flex-wrap: wrap; gap: 10px; }
  .line-total { width: auto; }
}

@media (max-width: 480px) {
  .panel { padding: 32px 22px; }
  .page-inner { padding: 24px 16px; }
  .logo-lockup--lg .logo-en { font-size: 38px; }
  .logo-lockup--lg .logo-ar { font-size: 28px; }
}

/* Calculate Shein Price additions */
.qty-control input {
  width: 34px;
  height: 26px;
  border: none;
  padding: 0;
  text-align: center;
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  background: var(--surface);
  color: var(--text);
  -moz-appearance: textfield;
}
.qty-control input::-webkit-outer-spin-button,
.qty-control input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.qty-control input:focus { outline: none; box-shadow: inset 0 0 0 2px var(--teal-soft); }

.status-tag {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  color: var(--danger);
  background: var(--danger-soft);
  border-radius: 5px;
  padding: 1px 6px;
  width: fit-content;
}

.summary-actions { display: flex; gap: 8px; }
.summary-actions .btn-outline { flex: 1; white-space: normal; }

.summary-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 16px;
}
.summary-head h3 { margin: 0; }
.promo-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  flex: 0 0 auto;
  background: #22c55e;
}
.promo-dot[data-level="medium"] { background: #eab308; }
.promo-dot[data-level="high"] { background: #ef4444; }

.screenshot-note {
  margin: 14px 0 0;
  font-size: 13px;
  font-weight: 700;
  text-align: center;
  color: var(--text);
}

.btn-instagram {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  margin-top: 10px;
  white-space: normal;
  text-align: center;
  text-decoration: none;
  color: #fff;
  background: linear-gradient(90deg, #d6249f, #fd5949 70%, #fdb349);
  box-shadow: 0 8px 20px rgba(214, 36, 159, 0.25);
}
.btn-instagram:hover { filter: brightness(1.05); }
.btn-instagram svg { width: 22px; height: 22px; flex: 0 0 auto; }
.line-total { width: 140px; }
@media (max-width: 640px) {
  .line-total { width: auto; }
  .item-actions { flex: 1 1 100%; min-width: 0; }
}
