/* ═══════════════════════════════════════════════
   TRACK.CSS  —  Story Book Tracking Page
   ═══════════════════════════════════════════════ */

:root {
  --primary:      #FF6B00;
  --primary-lt:   #FF8C38;
  --primary-pale: #FFF3EA;
  --bg:           #F0EDE8;        /* warm parchment background */
  --page-bg:      #FFFDF7;        /* page paper color */
  --page-shadow:  #D4C9B0;
  --spine:        #C8A96E;
  --border:       #E0D5C0;
  --text:         #1A1208;
  --text-2:       #5C4A2A;
  --text-3:       #9C8C6C;
  --success:      #10B981;
  --warning:      #F59E0B;
  --danger:       #EF4444;
  --info:         #3B82F6;
  --ad-bg:        #1A1A2E;
  --ad-text:      #E8E8F0;
}

* { margin:0; padding:0; box-sizing:border-box; }

body {
  font-family: 'Cairo', sans-serif;
  background: var(--bg);
  min-height: 100vh;
  overflow-x: hidden;
}

/* ── HEADER ──────────────────────────────────── */
.header {
  background: #fff;
  border-bottom: 2px solid var(--border);
  padding: 14px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  box-shadow: 0 2px 10px rgba(0,0,0,.08);
  position: sticky;
  top: 0;
  z-index: 100;
}
.logo { display:flex; align-items:center; gap:10px; text-decoration:none; }
.logo-icon {
  width: 36px; height: 36px;
  background: linear-gradient(135deg, var(--primary), var(--primary-lt));
  border-radius: 10px;
  display: flex; align-items:center; justify-content:center;
  color: #fff; font-size: 16px;
}
.logo-text { font-size:22px; font-weight:900; color:var(--text); }
.logo-text span { color: var(--primary); }
.header-sub { font-size:13px; color:var(--text-3); margin-right:auto; }

/* ── SEARCH ──────────────────────────────────── */
.search-wrap { padding: 24px 20px 0; max-width: 480px; margin: 0 auto; }
.search-box {
  background: #fff;
  border: 1.5px solid var(--border);
  border-radius: 16px;
  padding: 20px;
  box-shadow: 0 4px 20px rgba(0,0,0,.06);
}
.search-box h2 { font-size: 17px; font-weight: 800; margin-bottom: 4px; }
.search-box p  { font-size: 12px; color: var(--text-3); margin-bottom: 14px; }
.search-row    { display: flex; gap: 8px; }
.search-input {
  flex: 1;
  padding: 11px 14px;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  font-family: 'Cairo', sans-serif;
  font-size: 14px; font-weight: 700;
  background: var(--bg);
  outline: none;
  transition: border-color .2s;
}
.search-input:focus { border-color: var(--primary); background:#FFF8F4; }
.btn-search {
  padding: 11px 20px;
  background: linear-gradient(135deg, var(--primary), var(--primary-lt));
  color: #fff; border: none; border-radius: 10px;
  font-family:'Cairo',sans-serif; font-size:14px; font-weight:700;
  cursor: pointer; transition: all .2s;
  display: flex; align-items:center; gap:6px; white-space:nowrap;
}
.btn-search:hover  { transform:translateY(-1px); box-shadow:0 4px 16px rgba(255,107,0,.4); }
.btn-search:disabled { opacity:.6; cursor:not-allowed; transform:none; }
.spinner {
  display:inline-block; width:18px; height:18px;
  border:2.5px solid rgba(255,255,255,.4);
  border-top-color:#fff; border-radius:50%;
  animation: spin .6s linear infinite;
}
@keyframes spin { to { transform:rotate(360deg); } }

/* ── STORY AREA ──────────────────────────────── */
.story-area {
  max-width: 480px;
  margin: 20px auto 40px;
  padding: 0 16px;
}
.story-area.hidden { display: none; }
.error-area { max-width:480px; margin:24px auto; padding:0 16px; }
.error-area.hidden { display:none; }

/* ── AD BARS ─────────────────────────────────── */
.ad-bar {
  background: var(--ad-bg);
  border-radius: 10px;
  padding: 10px 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  overflow: hidden;
  position: relative;
}
.ad-above { margin-bottom: 14px; }
.ad-below { margin-top: 14px; }
.ad-label {
  font-size: 9px; font-weight: 900;
  color: rgba(255,255,255,.35);
  text-transform: uppercase;
  letter-spacing: .5px;
  border: 1px solid rgba(255,255,255,.15);
  border-radius: 4px;
  padding: 2px 5px;
  flex-shrink: 0;
}
.ad-content-banner {
  flex: 1;
  display: flex; align-items:center; justify-content:center; gap:10px;
  color: var(--ad-text);
  font-size: 13px; font-weight: 600;
}

/* ── THE BOOK SCENE ──────────────────────────── */
.book-scene {
  position: relative;
  perspective: 1200px;
}

/* Corner ribbon ad */
.corner-ribbon {
  position: absolute;
  top: 0; left: 0;
  width: 80px; height: 80px;
  overflow: hidden;
  z-index: 20;
  pointer-events: none;
}
.corner-ribbon span {
  display: block;
  background: linear-gradient(135deg, var(--primary), var(--primary-lt));
  color: #fff;
  font-size: 10px; font-weight: 900;
  text-align: center;
  width: 100px;
  padding: 5px 0;
  transform: rotate(-45deg) translate(-28px, 6px);
  box-shadow: 0 2px 8px rgba(255,107,0,.4);
  letter-spacing: .5px;
}

/* ── BOOK SHELL ──────────────────────────────── */
.book-shell {
  display: flex;
  border-radius: 4px 12px 12px 4px;
  box-shadow:
    -6px 6px 30px rgba(0,0,0,.22),
    -2px 2px 8px rgba(0,0,0,.15),
    inset -1px 0 0 rgba(255,255,255,.3);
  min-height: 520px;
  overflow: hidden;
}

/* Spine (left edge) */
.book-spine {
  width: 18px;
  background: linear-gradient(180deg,
    #8B6914 0%, #C8A040 20%,
    #A07020 50%, #C8A040 80%, #8B6914 100%);
  flex-shrink: 0;
  position: relative;
  border-radius: 4px 0 0 4px;
  box-shadow: inset -2px 0 4px rgba(0,0,0,.3);
}
.book-spine::after {
  content: 'سريع';
  position: absolute;
  bottom: 30px; left: 50%;
  transform: translateX(-50%) rotate(90deg);
  color: rgba(255,255,255,.6);
  font-size: 9px; font-weight: 900;
  letter-spacing: 2px;
  white-space: nowrap;
}

/* Book body (pages area) */
.book-body {
  flex: 1;
  background: var(--page-bg);
  display: flex; flex-direction: column;
  position: relative;
  overflow: hidden;
  border-radius: 0 12px 12px 0;
}

/* ── PAGES STACK ─────────────────────────────── */
.pages-stack {
  flex: 1;
  position: relative;
  overflow: hidden;
}

.book-page {
  position: absolute;
  inset: 0;
  display: flex; flex-direction: column;
  background: var(--page-bg);
  opacity: 0;
  pointer-events: none;
  transform-origin: right center;
  backface-visibility: hidden;
}

/* ── PAGE TRANSITIONS ────────────────────────── */
.book-page.active {
  opacity: 1;
  pointer-events: auto;
  z-index: 5;
  animation: pageReveal .5s ease forwards;
}
.book-page.flip-out {
  z-index: 6;
  animation: flipOut .45s ease-in forwards;
}
.book-page.flip-in {
  opacity: 0;
  z-index: 4;
  animation: flipIn .45s ease-out forwards;
  animation-delay: .22s;
}
.book-page.flip-back-out {
  z-index: 6;
  animation: flipBackOut .45s ease-in forwards;
}
.book-page.flip-back-in {
  opacity: 0;
  z-index: 4;
  animation: flipBackIn .45s ease-out forwards;
  animation-delay: .22s;
}

@keyframes pageReveal {
  from { opacity:0; transform:scaleX(.96); }
  to   { opacity:1; transform:scaleX(1); }
}
@keyframes flipOut {
  0%   { transform:perspective(900px) rotateY(0deg);   opacity:1; }
  100% { transform:perspective(900px) rotateY(-88deg); opacity:0; }
}
@keyframes flipIn {
  0%   { transform:perspective(900px) rotateY(88deg);  opacity:0; }
  100% { transform:perspective(900px) rotateY(0deg);   opacity:1; }
}
@keyframes flipBackOut {
  0%   { transform:perspective(900px) rotateY(0deg);  opacity:1; }
  100% { transform:perspective(900px) rotateY(88deg); opacity:0; }
}
@keyframes flipBackIn {
  0%   { transform:perspective(900px) rotateY(-88deg); opacity:0; }
  100% { transform:perspective(900px) rotateY(0deg);   opacity:1; }
}

/* Page curl shadow (bottom-left corner) */
.book-page::after {
  content: '';
  position: absolute;
  bottom: 0; left: 0;
  width: 40px; height: 40px;
  background: linear-gradient(135deg, transparent 50%, rgba(0,0,0,.08) 50%);
  pointer-events: none;
}

/* ═══════════  PAGE 1 — INTRO  ══════════════════ */
.p1-ad-header {
  background: var(--ad-bg);
  padding: 8px 12px;
  display: flex; align-items:center; justify-content:center; gap:8px;
  color: var(--ad-text);
  font-size: 12px; font-weight: 600;
  flex-shrink: 0;
}
.p1-ad-header .ad-label { font-size:8px; }

.p1-logos {
  display: flex;
  align-items: center;
  justify-content: space-around;
  padding: 20px 16px 14px;
  border-bottom: 1.5px dashed var(--border);
  flex-shrink: 0;
  gap: 12px;
}
.p1-logo-box {
  display: flex; flex-direction:column; align-items:center; gap:6px;
}
.p1-logo-img {
  width: 60px; height: 60px;
  border-radius: 14px;
  object-fit: contain;
  background: var(--primary-pale);
  display: flex; align-items:center; justify-content:center;
  font-size: 26px;
  border: 1.5px solid var(--border);
  box-shadow: 0 2px 8px rgba(0,0,0,.08);
}
.p1-logo-name {
  font-size: 11px; font-weight: 700;
  color: var(--text-2);
  text-align: center;
  max-width: 80px;
}
.p1-logo-divider {
  font-size: 20px; color: var(--text-3);
}

.p1-section-title {
  font-size: 11px; font-weight: 900;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: 1px;
  padding: 12px 16px 8px;
  flex-shrink: 0;
}

/* Products grid */
.p1-products {
  flex: 1;
  overflow-y: auto;
  padding: 0 12px 8px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  align-content: start;
}
.p1-product {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px;
  display: flex; flex-direction:column; align-items:center; gap:6px;
  box-shadow: 0 1px 4px rgba(0,0,0,.05);
}
.p1-product-icon {
  width: 44px; height: 44px;
  background: var(--primary-pale);
  border-radius: 10px;
  display: flex; align-items:center; justify-content:center;
  font-size: 22px;
}
.p1-product-name {
  font-size: 11px; font-weight: 700;
  color: var(--text);
  text-align: center;
  line-height: 1.3;
}
.p1-product-price {
  font-size: 12px; font-weight: 900;
  color: var(--primary);
}

.p1-ad-footer {
  background: var(--ad-bg);
  padding: 8px 12px;
  display: flex; align-items:center; justify-content:center; gap:8px;
  color: var(--ad-text);
  font-size: 12px; font-weight: 600;
  flex-shrink: 0;
}
.p1-ad-footer .ad-label { font-size:8px; }

/* ═══════════  PAGE 2 — STATUS  ══════════════════ */
.p2-illustration {
  flex-shrink: 0;
  display: flex; flex-direction:column; align-items:center;
  padding: 28px 20px 16px;
  gap: 10px;
}
.p2-scene {
  width: 130px; height: 130px;
  border-radius: 50%;
  display: flex; align-items:center; justify-content:center;
  font-size: 62px;
  position: relative;
  box-shadow: 0 8px 30px rgba(0,0,0,.12);
}
.p2-scene-label {
  font-size: 11px; font-weight: 700;
  color: var(--text-3);
  letter-spacing: .5px;
}

/* Order detail rows */
.p2-details {
  flex: 1;
  overflow-y: auto;
  padding: 0 16px 12px;
  display: flex; flex-direction:column; gap:8px;
}
.p2-row {
  display: flex; align-items:center; gap:10px;
  padding: 10px 12px;
  background: #f9f6f0;
  border-radius: 10px;
  border: 1px solid var(--border);
}
.p2-row-icon {
  width: 32px; height: 32px;
  border-radius: 8px;
  display: flex; align-items:center; justify-content:center;
  font-size: 14px; flex-shrink: 0;
}
.p2-row-label { font-size:10px; color:var(--text-3); font-weight:700; }
.p2-row-value { font-size:13px; font-weight:700; color:var(--text); line-height:1.3; }

/* Progress bar at bottom of page 2 */
.p2-progress-bar-wrap {
  padding: 10px 16px 14px;
  flex-shrink: 0;
}
.p2-progress-label {
  font-size: 10px; font-weight:700; color:var(--text-3);
  margin-bottom: 6px;
  display: flex; justify-content:space-between; align-items:center;
}
.p2-progress-track {
  height: 8px;
  background: var(--border);
  border-radius: 99px;
  overflow: hidden;
}
.p2-progress-fill {
  height: 100%;
  border-radius: 99px;
  background: linear-gradient(90deg, var(--primary), var(--primary-lt));
  transition: width 1s ease;
}

/* ═══════════  PAGE 3 — ENDING  ══════════════════ */
.p3-wrap {
  flex: 1;
  display: flex; flex-direction:column;
  align-items:center; justify-content:center;
  padding: 24px 20px;
  gap: 16px;
  text-align: center;
}
.p3-big-icon {
  font-size: 72px;
  line-height: 1;
  filter: drop-shadow(0 4px 12px rgba(0,0,0,.15));
  animation: iconPulse 2s ease-in-out infinite;
}
@keyframes iconPulse {
  0%,100% { transform:scale(1);   }
  50%      { transform:scale(1.08); }
}
.p3-title {
  font-size: 24px; font-weight: 900;
  color: var(--text);
  line-height: 1.2;
}
.p3-subtitle {
  font-size: 13px; color:var(--text-2);
  line-height: 1.6;
  max-width: 260px;
}
.p3-badge {
  padding: 8px 20px;
  border-radius: 50px;
  font-size: 13px; font-weight: 800;
  display: flex; align-items:center; gap:8px;
}
.p3-badge.end   { background:rgba(16,185,129,.12); color:var(--success); border:1.5px solid rgba(16,185,129,.3); }
.p3-badge.cont  { background:rgba(255,107,0,.1);   color:var(--primary); border:1.5px solid rgba(255,107,0,.3); }
.p3-badge.ret   { background:rgba(239,68,68,.1);   color:var(--danger);  border:1.5px solid rgba(239,68,68,.3); }

/* Stars decoration for End Story */
.p3-stars { display:flex; gap:4px; }
.p3-stars span { font-size:18px; animation: starPop .3s ease both; }
.p3-stars span:nth-child(2) { animation-delay:.1s; }
.p3-stars span:nth-child(3) { animation-delay:.2s; }
@keyframes starPop {
  from { transform:scale(0); opacity:0; }
  to   { transform:scale(1); opacity:1; }
}

/* Dotted lines decoration (notebook style) */
.p3-divider {
  width: 60%;
  border: none;
  border-top: 2px dashed var(--border);
}

/* ── BOOK FOOTER NAV ──────────────────────────── */
.book-footer-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  border-top: 1.5px solid var(--border);
  background: linear-gradient(0deg, #F5F0E8, var(--page-bg));
  flex-shrink: 0;
}
.flip-btn {
  width: 34px; height: 34px;
  border-radius: 50%;
  border: 1.5px solid var(--border);
  background: #fff;
  color: var(--text-2);
  cursor: pointer;
  display: flex; align-items:center; justify-content:center;
  font-size: 13px;
  transition: all .2s;
  box-shadow: 0 1px 4px rgba(0,0,0,.08);
}
.flip-btn:hover:not(:disabled) {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
  transform: scale(1.05);
}
.flip-btn:disabled { opacity:.3; cursor:not-allowed; }

.page-dots {
  display: flex; gap: 6px; align-items:center;
}
.page-dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--border);
  transition: all .3s;
  cursor: pointer;
}
.page-dot.active {
  background: var(--primary);
  transform: scale(1.4);
}

/* ── ERROR BOX ────────────────────────────────── */
.msg-box {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 40px 24px;
  text-align: center;
  box-shadow: 0 4px 20px rgba(0,0,0,.06);
}
.msg-icon  { font-size:48px; display:block; margin-bottom:14px; }
.msg-title { font-size:18px; font-weight:800; margin-bottom:6px; }
.msg-sub   { font-size:13px; color:var(--text-2); }

/* ── RESPONSIVE ───────────────────────────────── */
@media (max-width:360px) {
  .book-spine { width:14px; }
  .p1-products { grid-template-columns:1fr 1fr; }
}
