/* ================= واجهة الطالب ================= */

/* ---------- شاشة الدخول ---------- */

.login-wrap {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: clip;
  background:
    radial-gradient(900px 500px at 85% 8%, rgba(25, 155, 180, 0.07), transparent 60%),
    radial-gradient(700px 480px at 8% 95%, rgba(226, 138, 37, 0.06), transparent 60%),
    var(--cream);
}
.login-awning { width: 100%; height: 46px; flex: none; }

.login-stage {
  flex: 1;
  display: grid;
  place-items: center;
  padding: 46px 16px 70px;
  position: relative;
  overflow: hidden;
}
.login-stage::before {
  /* وردة باهتة في الخلفية */
  content: "";
  position: absolute;
  inset-inline-start: -130px;
  bottom: -130px;
  width: 460px; height: 460px;
  background: url('/logo.png') center / contain no-repeat;
  opacity: 0.05;
  pointer-events: none;
}

.login-card {
  display: grid;
  grid-template-columns: 315px 1fr;
  width: 100%;
  max-width: 780px;
  background: #fff;
  border: 1px solid #e3ebf1;
  border-radius: 22px;
  overflow: hidden;
  box-shadow: 0 30px 70px rgba(14, 44, 79, 0.16), 0 4px 14px rgba(14, 44, 79, 0.07);
  position: relative;
}

.login-brand {
  background: linear-gradient(160deg, #1d5697 0%, #19477a 55%, #143a66 100%);
  color: #fff;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 48px 28px;
  text-align: center;
  position: relative;
}
.login-brand::before {
  /* نقش الوردة كنسيج خفيف */
  content: "";
  position: absolute;
  inset: 0;
  background: url('/logo.png') -30px -30px / 150px repeat;
  opacity: 0.06;
  pointer-events: none;
}
.login-brand > * { position: relative; }
.login-brand, .login-form { min-width: 0; }
.login-brand-logo {
  width: 116px; height: 116px;
  border-radius: 50%;
  background: #fff;
  display: grid;
  place-items: center;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.28);
  margin-bottom: 6px;
}
.login-brand-logo img { width: 88px; height: 88px; }
.login-brand h1 { color: #fff; font-size: 2.5rem; line-height: 1.15; }
.login-tag { color: #b9d1ea; font-size: 0.95rem; }

.login-form { padding: 44px 40px 36px; }
.login-form h2 { font-size: 1.7rem; margin-bottom: 2px; }
.login-form input {
  padding: 0.72em 1em;
  font-size: 1.05rem;
  border-radius: 11px;
}
.login-btn {
  width: 100%;
  font-size: 1.12rem;
  padding: 0.78em;
  margin-top: 10px;
  border-radius: 12px;
}
.login-hint { font-size: 0.85rem; }

@media (max-width: 700px) {
  .login-card { grid-template-columns: 1fr; max-width: min(420px, 100%); }
  .login-brand { padding: 30px 22px 26px; }
  .login-brand-logo { width: 92px; height: 92px; }
  .login-brand-logo img { width: 70px; height: 70px; }
  .login-brand h1 { font-size: 2.1rem; }
  .login-form { padding: 28px 24px 26px; }
}

/* ---------- ترويسة السوق ---------- */

.shop-header { position: sticky; top: 0; z-index: 50; }
.shop-header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 16px 16px;
  max-width: 1100px;
  margin: 0 auto;
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand-logo { width: 42px; height: 42px; border-radius: 50%; object-fit: contain; background: #fff; padding: 4px; }
.brand h1 { color: var(--cream); font-size: 1.7rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.header-actions { display: flex; align-items: center; gap: 8px; }

.balance-chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  background: rgba(14, 44, 79, 0.55);
  border: 1.5px solid rgba(242, 169, 59, 0.65);
  color: var(--brass-bright);
  font-family: var(--font-num);
  font-weight: 700;
  font-size: 1.05rem;
  border-radius: 999px;
  padding: 0.28em 0.9em;
}

/* المحجوز في السلة داخل شريط الرصيد */
.balance-hold {
  background: var(--coral);
  color: #fff;
  font-size: 0.78rem;
  font-weight: 700;
  border-radius: 999px;
  padding: 0.05em 0.5em;
  margin-inline-start: 2px;
  font-family: var(--font-num);
  animation: rise-in 0.25s ease;
}
.balance-chip.holding {
  border-color: var(--coral);
  box-shadow: 0 0 0 2px rgba(196, 85, 59, 0.25);
}

.hbtn {
  background: rgba(14, 44, 79, 0.5);
  border: 1.5px solid rgba(255, 255, 255, 0.3);
  color: var(--cream);
  border-radius: 999px;
  padding: 0.35em 0.8em;
  font-size: 1rem;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}
.hbtn:hover { background: rgba(14, 44, 79, 0.8); }
.hbtn-label { font-size: 0.9rem; }
@media (max-width: 560px) { .hbtn-label { display: none; } }

/* ---------- جسم السوق ---------- */

.shop-main { max-width: 1100px; margin: 0 auto; padding: 30px 16px 110px; }

.hello-line { display: flex; align-items: baseline; gap: 10px; margin-bottom: 14px; }
#hello-name { font-family: var(--font-display); font-size: 1.6rem; font-weight: 700; color: var(--night); }

.market-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  border-radius: var(--radius);
  padding: 0.9em 1.2em;
  margin-bottom: 18px;
  font-weight: 700;
  font-size: 1.02rem;
  border: 1.5px solid;
}
.market-banner.view {
  background: var(--brass-pale);
  color: #8a4d0e;
  border-color: var(--brass);
}
.market-banner.closed {
  background: var(--coral-soft);
  color: var(--coral);
  border-color: var(--coral);
}

.market-closed-box {
  text-align: center;
  padding: 60px 20px;
}
.market-closed-box .icon { font-size: 4rem; }
.market-closed-box h2 { font-size: 1.8rem; margin: 0.3em 0; }

.filters { display: flex; flex-direction: column; gap: 10px; margin-bottom: 22px; }
.filters-top { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }

/* زر «ما يكفيه رصيدي» */
.afford-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  border: 1.5px solid var(--brass);
  background: #fff;
  color: #8a4d0e;
  border-radius: 999px;
  padding: 0.52em 1.1em;
  font-size: 0.98rem;
  font-weight: 700;
  font-family: inherit;
  white-space: nowrap;
  transition: all 0.15s;
}
.afford-btn:hover { background: var(--brass-pale); }
.afford-btn.on {
  background: linear-gradient(180deg, var(--brass-bright), var(--brass));
  border-color: var(--brass);
  color: #3d2506;
  box-shadow: 0 4px 14px rgba(226, 138, 37, 0.35);
}
.afford-icon { font-size: 1.1em; }
.afford-count {
  background: rgba(138, 77, 14, 0.14);
  border-radius: 999px;
  padding: 0.05em 0.6em;
  font-family: var(--font-num);
  font-size: 0.88em;
}
.afford-btn.on .afford-count { background: rgba(61, 37, 6, 0.18); }

/* سعر يفوق رصيد الطالب */
.pcard-price.over-budget { opacity: 0.72; }
.over-tag {
  display: block;
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--coral);
  margin-top: 1px;
}

@media (max-width: 560px) {
  .filters-top { flex-direction: column; align-items: stretch; }
  .afford-btn { justify-content: center; }
}
.search {
  max-width: 420px;
  border-radius: 999px !important;
  padding-inline: 1.2em !important;
}
.chips-row { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- شبكة المنتجات ---------- */

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 16px;
}
@media (min-width: 700px) {
  .grid { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }
}

.pcard {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.pcard:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); }

.pcard-img {
  position: relative;
  aspect-ratio: 1 / 1;
  background: var(--cream-2);
}
.pcard-img img { width: 100%; height: 100%; object-fit: cover; }

.qadd {
  position: absolute;
  bottom: 10px;
  inset-inline-start: 10px;
  width: 44px; height: 44px;
  border-radius: 50%;
  border: none;
  background: linear-gradient(180deg, var(--brass-bright), var(--brass));
  color: #3d2506;
  font-size: 1.6rem;
  font-weight: 700;
  line-height: 1;
  box-shadow: 0 3px 8px rgba(0,0,0,0.3);
  transition: transform 0.12s;
}
.qadd:hover { transform: scale(1.12); }
.qadd:active { transform: scale(0.95); }

.stock-tag {
  position: absolute;
  top: 10px;
  inset-inline-end: 10px;
  background: rgba(14, 44, 79, 0.78);
  color: var(--cream);
  font-size: 0.75rem;
  font-weight: 700;
  border-radius: 999px;
  padding: 0.15em 0.7em;
}
.stock-tag.out { background: var(--coral); }

.pcard-body { padding: 10px 12px 12px; display: flex; flex-direction: column; gap: 4px; flex: 1; }
.pcard-name { font-weight: 700; font-size: 0.98rem; line-height: 1.35; }
.pcard-meta { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.pcard-price { margin-top: auto; font-size: 1.1rem; color: var(--night); }

.pcard.sold-out .pcard-img img { filter: grayscale(0.9) opacity(0.6); }

/* حد الشراء من نفس المنتج */
.badge-limit { background: var(--teal-soft); color: var(--night); }
.limit-tag {
  position: absolute;
  bottom: 10px;
  inset-inline-start: 10px;
  background: var(--mint);
  color: #fff;
  font-size: 0.78rem;
  font-weight: 700;
  border-radius: 999px;
  padding: 0.28em 0.85em;
  box-shadow: 0 3px 8px rgba(0,0,0,0.25);
}

/* ---------- شريط السلة ---------- */

.cart-bar {
  position: fixed;
  bottom: 14px;
  inset-inline: 0;
  display: flex;
  justify-content: center;
  z-index: 60;
  pointer-events: none;
  padding: 0 16px;
}
.cart-bar-btn {
  pointer-events: auto;
  font-size: 1.1rem;
  padding: 0.75em 2em;
  border-radius: 999px;
  box-shadow: 0 6px 20px rgba(156, 90, 18, 0.4);
  animation: rise-in 0.25s ease;
}

/* ---------- السلة (داخل المودال) ---------- */

.cart-item {
  display: grid;
  grid-template-columns: 56px 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid var(--cream-2);
}
.cart-item img { width: 56px; height: 56px; border-radius: 10px; object-fit: cover; background: var(--cream-2); }
.cart-item-name { font-weight: 700; font-size: 0.95rem; }
.cart-item-note { font-size: 0.82rem; color: var(--ink-soft); overflow-wrap: anywhere; }
.qty-ctrl { display: inline-flex; align-items: center; gap: 8px; }
.qty-ctrl button {
  width: 28px; height: 28px;
  border-radius: 50%;
  border: 1.5px solid var(--line);
  background: #fff;
  font-size: 1rem;
  font-weight: 700;
}
.qty-ctrl button:hover { border-color: var(--brass); background: var(--brass-pale); }
.qty-num { font-family: var(--font-num); font-weight: 700; min-width: 20px; text-align: center; }

.cart-summary {
  margin-top: 14px;
  background: var(--cream-2);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.cart-summary .line { display: flex; justify-content: space-between; align-items: center; }
.cart-summary .line.total { font-size: 1.15rem; font-weight: 700; }
.after-balance.neg { color: var(--coral); font-weight: 700; }

/* ---------- طلباتي ---------- */

.orders-wrap { max-width: 760px; margin: 0 auto; padding: 26px 16px 90px; }
.orders-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; }
.orders-head h2 { font-size: 1.9rem; }

.order-card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 16px;
  overflow: hidden;
}
.order-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  background: var(--cream-2);
  padding: 8px 14px;
  font-size: 0.88rem;
}
.cancel-window {
  color: #8a4d0e;
  font-weight: 700;
  font-family: var(--font-num);
}

.order-item {
  display: grid;
  grid-template-columns: 52px 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 10px 14px;
  border-bottom: 1px solid var(--cream-2);
}
.order-item:last-child { border-bottom: none; }
.order-item img { width: 52px; height: 52px; border-radius: 10px; object-fit: cover; background: var(--cream-2); }
.order-item-info { min-width: 0; }
.order-item-name { font-weight: 700; font-size: 0.95rem; }
.order-item-sub { font-size: 0.82rem; color: var(--ink-soft); overflow-wrap: anywhere; }
.order-item-side { display: flex; flex-direction: column; align-items: flex-end; gap: 5px; }


/* لافتة «فُتح السوق لك خاصةً» */
.market-banner.grant {
  background: linear-gradient(135deg, #e9f7ec, #d9f0e2);
  color: #17703a;
  border: 1px solid #bfe6ca;
}
