/* =========================================================================
   صفحة "اطبع من الموقع" — print-order page.
   Uses the same tokens as styles.css (ink outlines, hard offset shadows,
   green + pencil-yellow). Logical properties only, so RTL stays correct.
   ========================================================================= */

.po-layout { display: grid; gap: 2rem; align-items: start; }
@media (min-width: 960px) {
  .po-layout { grid-template-columns: minmax(0, 1fr) 390px; gap: 2.5rem; }
}

.po-form { display: grid; gap: 1.5rem; min-width: 0; }
.po-steps { display: grid; gap: 1.5rem; }
.po-steps[hidden] { display: none; }

/* ---------- Step cards ---------- */
.po-step {
  background: var(--white);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.25rem;
}
@media (min-width: 768px) { .po-step { padding: 1.75rem; } }

.po-step__head { display: flex; align-items: center; gap: .75rem; margin-block-end: .6rem; }
.po-step__num {
  display: grid; place-items: center;
  flex: none; width: 40px; height: 40px;
  border: 2px solid var(--border);
  border-radius: 12px;
  background: var(--pencil);
  font-family: var(--font-heading);
  font-weight: 800;
  font-size: 18px;
  line-height: 1;
}
.po-step__title { font-family: var(--font-heading); font-weight: 800; font-size: clamp(20px, 2.4vw, 25px); line-height: 1.3; }
.po-hint { color: var(--muted-foreground); font-size: 15px; margin: 0 0 1rem; }

.po-grid { display: grid; gap: .75rem; }
.po-grid--3 { grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }
.po-grid--2 { grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); }

/* ---------- Radio cards ---------- */
.po-opt { display: block; cursor: pointer; position: relative; }
.po-opt__box {
  position: relative;
  display: flex; flex-direction: column; gap: .2rem;
  height: 100%;
  padding: 1rem;
  background: var(--white);
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  transition: transform .12s ease, box-shadow .12s ease, background-color .12s ease;
}
.po-opt:hover .po-opt__box { transform: translate(2px, -2px); box-shadow: var(--shadow); }
.po-opt input:focus-visible + .po-opt__box { outline: 3px solid var(--pencil); outline-offset: 3px; }
.po-opt input:checked + .po-opt__box {
  background: var(--primary-soft);
  border-color: var(--primary);
  box-shadow: var(--shadow);
}
.po-opt input:checked + .po-opt__box::after {
  content: "";
  position: absolute;
  inset-block-start: .65rem; inset-inline-end: .65rem;
  width: 22px; height: 22px;
  border-radius: 50%;
  background: var(--primary) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 12.5l4.5 4.5L19 7.5'/%3E%3C/svg%3E") center / 14px no-repeat;
}
.po-opt__icon { color: var(--primary); margin-block-end: .2rem; }
.po-opt__name { font-family: var(--font-heading); font-weight: 800; font-size: 19px; line-height: 1.3; }
.po-opt__desc { font-size: 14px; color: var(--muted-foreground); line-height: 1.6; }
.po-price {
  align-self: flex-start;
  margin-block-start: .5rem;
  padding: .1rem .7rem;
  background: var(--pencil);
  border: 2px solid var(--border);
  border-radius: 999px;
  font-size: 14px; font-weight: 700;
  line-height: 1.7;
}

/* ---------- Fields ---------- */
.po-field { display: grid; gap: .35rem; }
.po-field > label, .po-label { font-weight: 700; font-size: 16px; }
.po-input {
  width: 100%;
  min-height: var(--tap);
  padding: .6rem .9rem;
  font: inherit; font-size: 17px;
  color: var(--foreground);
  background: var(--white);
  border: 2px solid var(--border);
  border-radius: 12px;
}
textarea.po-input { min-height: 120px; line-height: 1.8; resize: vertical; }
.po-input:focus-visible { outline: 3px solid var(--pencil); outline-offset: 2px; }
.po-input[readonly] { background: var(--primary-soft); }
.po-input[aria-invalid="true"] { border-color: var(--red); }
.po-error { color: var(--red); font-size: 14px; font-weight: 700; margin: 0; }
.po-error:empty { display: none; }
.po-row { display: grid; gap: 1rem; }
@media (min-width: 640px) { .po-row--2 { grid-template-columns: 1fr 1fr; } }
.po-small { font-size: 14px; color: var(--muted-foreground); margin: 0; }

.po-chips { display: flex; flex-wrap: wrap; gap: .5rem; margin-block-start: .6rem; }
.po-chip {
  padding: .25rem .8rem;
  background: var(--pencil-soft);
  border: 2px solid var(--border);
  border-radius: 999px;
  font-size: 14px; font-weight: 700;
  cursor: pointer;
}
.po-chip:hover { background: var(--pencil); }

/* ---------- Upload ---------- */
.po-drop {
  display: flex; flex-direction: column; align-items: center; gap: .35rem;
  padding: 1.6rem 1rem;
  text-align: center;
  background: var(--primary-soft);
  border: 2px dashed var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background-color .12s ease;
}
.po-drop:hover, .po-drop.is-drag { background: hsl(140, 60%, 87%); }
.po-drop:focus-within { outline: 3px solid var(--pencil); outline-offset: 3px; }
.po-drop__title { font-family: var(--font-heading); font-weight: 800; font-size: 19px; }
.po-drop svg { color: var(--primary); }

.po-files { display: grid; gap: .5rem; margin-block-start: .75rem; }
.po-files li {
  display: flex; align-items: center; gap: .6rem;
  padding: .45rem .7rem;
  background: var(--white);
  border: 2px solid var(--border);
  border-radius: 12px;
  font-size: 15px;
}
.po-files__name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 700; }
.po-files__size { color: var(--muted-foreground); font-size: 13px; flex: none; }
.po-files button {
  flex: none; width: 32px; height: 32px;
  display: grid; place-items: center;
  background: var(--white);
  border: 2px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
}
.po-files button:hover { background: var(--red); color: var(--white); }
.po-thumb { width: 44px; height: 44px; object-fit: cover; border: 2px solid var(--border); border-radius: 8px; flex: none; }

/* ---------- Payment ---------- */
.po-total {
  display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: .5rem 1rem;
  padding: 1rem 1.1rem;
  margin-block-end: 1rem;
  background: var(--primary);
  color: var(--primary-foreground);
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
}
.po-total__calc { font-size: 15px; opacity: .92; }
.po-total__sum { font-family: var(--font-heading); font-weight: 800; font-size: clamp(26px, 5vw, 34px); line-height: 1.2; }

.po-paybox {
  display: grid; gap: .9rem;
  margin-block-start: 1rem;
  padding: 1.1rem;
  background: var(--pencil-soft);
  border: 2px dashed var(--border);
  border-radius: var(--radius-sm);
}
.po-paybox[hidden] { display: none; }
.po-number { display: flex; flex-wrap: wrap; align-items: center; gap: .6rem .9rem; }
.po-number__val {
  direction: ltr; unicode-bidi: isolate;
  font-family: var(--font-heading); font-weight: 800;
  font-size: clamp(24px, 5vw, 32px); line-height: 1.3;
  padding: .1rem .8rem;
  background: var(--white);
  border: 2px solid var(--border);
  border-radius: 12px;
}
.po-amount { font-weight: 700; font-size: 17px; margin: 0; }
.po-amount strong { color: var(--primary); font-size: 1.2em; }
.po-shot { display: flex; align-items: center; gap: .75rem; flex-wrap: wrap; }
.po-shot img { width: 64px; height: 64px; object-fit: cover; border: 2px solid var(--border); border-radius: 10px; }
.po-shot img[hidden] { display: none; }

/* ---------- Submit + states ---------- */
.po-submit { display: grid; gap: .75rem; }
.po-submit .btn { width: 100%; font-size: 18px; min-height: 56px; }
.po-submit .btn[disabled] { opacity: .6; cursor: progress; transform: none; box-shadow: var(--shadow); }
.po-progress { height: 14px; border: 2px solid var(--border); border-radius: 999px; background: var(--white); overflow: hidden; }
.po-progress[hidden] { display: none; }
.po-progress__bar { height: 100%; width: 0; background: var(--primary-bright); transition: width .2s ease; }
.po-alert {
  padding: .9rem 1.1rem;
  background: hsl(356, 90%, 95%);
  border: 2px solid var(--red);
  border-radius: var(--radius-sm);
  font-weight: 700;
}
.po-alert[hidden] { display: none; }
.po-alert a { color: var(--primary); }

.po-done {
  display: grid; gap: .75rem;
  padding: 1.6rem;
  background: var(--primary);
  color: var(--primary-foreground);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.po-done[hidden] { display: none; }
.po-done__badge {
  display: grid; place-items: center;
  width: 56px; height: 56px;
  background: var(--pencil); color: var(--border);
  border: 2px solid var(--border);
  border-radius: 16px;
}
.po-done h2 { font-size: clamp(26px, 4vw, 38px); }
.po-done p { margin: 0; color: rgba(255, 255, 255, .95); font-size: 17px; }
.po-done__actions { display: flex; flex-wrap: wrap; gap: .75rem; margin-block-start: .5rem; }

.po-hp { position: absolute; inset-inline-start: -9999px; width: 1px; height: 1px; overflow: hidden; }

/* ---------- Invoice / receipt ---------- */
.po-aside { min-width: 0; }
@media (min-width: 960px) { .po-aside { position: sticky; inset-block-start: 96px; } }

.po-receipt-wrap { filter: drop-shadow(-4px 4px 0 var(--border)); padding-block-end: 12px; }
.receipt {
  position: relative;
  padding: 1.9rem 1.4rem 1.6rem;
  background: var(--foreground);
  background-image: radial-gradient(120% 80% at 100% 0%, hsl(145, 55%, 22%) 0%, transparent 62%);
  color: var(--white);
  border-radius: 18px 18px 0 0;
}
.receipt::before {
  content: "";
  position: absolute;
  inset-block-start: -8px; inset-inline: 1.5rem;
  height: 12px;
  background: var(--pencil);
  border: 2px solid var(--border);
  border-block-end: 0;
  border-radius: 10px 10px 0 0;
}
.receipt::after {
  content: "";
  position: absolute;
  inset-inline: 0; inset-block-start: 100%;
  height: 12px;
  background: var(--foreground);
  -webkit-mask: conic-gradient(from -45deg at bottom, #0000, #000 1deg 89deg, #0000 90deg) 50% / 24px 100%;
  mask: conic-gradient(from -45deg at bottom, #0000, #000 1deg 89deg, #0000 90deg) 50% / 24px 100%;
}
.receipt__head { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; margin-block-end: 1.1rem; }
.receipt__title { font-family: var(--font-heading); font-weight: 800; font-size: 25px; line-height: 1.3; }
.receipt__id { font-size: 12px; letter-spacing: .06em; color: var(--pencil); direction: ltr; unicode-bidi: isolate; }
.receipt__shop { font-size: 13px; color: rgba(255, 255, 255, .65); margin-block-end: 1rem; }

.receipt__rows { display: grid; gap: .55rem; margin: 0; padding: 0; }
.receipt__row { display: flex; align-items: baseline; gap: .6rem; font-size: 15px; line-height: 1.6; }
.receipt__row dt { flex: none; margin: 0; color: rgba(255, 255, 255, .78); }
.receipt__row::after { content: none; }
.receipt__dots { flex: 1; min-width: 12px; border-block-end: 1px dotted rgba(255, 255, 255, .35); transform: translateY(-4px); }
.receipt__row dd { margin: 0; font-weight: 700; text-align: end; max-width: 55%; overflow-wrap: anywhere; }

.receipt__sep { margin-block: 1rem; border: 0; border-block-start: 1px dashed rgba(255, 255, 255, .4); }
.receipt__total { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; }
.receipt__total > span:first-child { font-size: 16px; color: rgba(255, 255, 255, .85); }
.receipt__sum { font-family: var(--font-heading); font-weight: 800; font-size: 38px; line-height: 1.2; color: var(--pencil); }
.receipt__sum small { font-size: 16px; font-weight: 700; margin-inline-start: .3rem; color: var(--white); }

.receipt__status { display: flex; align-items: center; gap: .55rem; font-size: 14px; color: rgba(255, 255, 255, .85); }
.receipt__status::before { content: ""; flex: none; width: 8px; height: 18px; background: var(--pencil); }
.receipt.is-done .receipt__status { color: var(--white); font-weight: 700; }
.receipt.is-done .receipt__status::before { background: var(--primary-bright); }

@media (prefers-reduced-motion: reduce) {
  .po-opt__box, .po-progress__bar { transition: none; }
}
