:root{
  --brand:#07a28f;
  --brand-600:#068a7a;
  --bg:#f6f7fb;
  --card:#ffffff;
  --text:#1f2937;
  --muted:#6b7280;
  --border:#e5e7eb;
  --error:#d93025;
  --success:#0f9d58;
  --radius:16px;
  --shadow:0 8px 24px rgba(0,0,0,.06);
}

*{box-sizing:border-box}
html,body{height:100%}
html{scroll-behavior:smooth}
body{
  margin:0;
  font-family:"Cairo","Tajawal",system-ui,-apple-system,Segoe UI,Roboto,Arial,sans-serif;
  background:var(--bg);
  color:var(--text);
  line-height:1.6;
  -webkit-font-smoothing:antialiased;
  -moz-osx-font-smoothing:grayscale;
  padding:0;
}

/* Header image */
body > img[alt="الرأس"]{
  display:block;
  width:100%;
  height:auto;
  object-fit:cover;
  max-height:220px;
}
h1{
  margin:16px auto 8px;
  font-size:clamp(20px,3.5vw,28px);
  text-align:center;
  font-weight:800;
  letter-spacing:.2px;
}

/* Form surface */
form{
  width:100%;
  max-width:980px;
  margin:12px auto 40px;
  background:var(--card);
  border:1px solid var(--border);
  border-radius:var(--radius);
  box-shadow:var(--shadow);
  padding:16px;
}
@media (min-width:768px){
  form{padding:24px 28px}
}

/* Flash messages (fallback if modal disabled) */
.message{
  max-width:980px;
  margin:10px auto 0;
  padding:10px 14px;
  border-radius:12px;
  border:1px solid var(--border);
  background:#fff;
  box-shadow:var(--shadow);
  font-weight:600;
}
.message.error{background:#ffecec;border-color:#ffd3d3;color:var(--error)}
.message.success{background:#ecfff2;border-color:#cbf4dc;color:var(--success)}

/* Fields */
label{
  display:block;
  font-weight:700;
  margin:14px 0 6px;
  font-size:15px;
}
.error{color:var(--error); margin-top:6px; font-size:13px}
input[type="text"],
input[type="tel"],
input[type="number"],
select,
textarea{
  width:100%;
  padding:12px 14px;
  border:1px solid var(--border);
  border-radius:12px;
  background:#fff;
  outline:none;
  font-size:15px;
  transition:border-color .2s, box-shadow .2s;
  direction:rtl;
}
input:focus, select:focus, textarea:focus{
  border-color:var(--brand);
  box-shadow:0 0 0 4px rgba(7,162,143,.12);
}

/* ================================
   Product card (square, 1 per row)
   ================================ */
.product{
  width:min(560px,96vw) !important;
  aspect-ratio:1/1;
  margin:18px auto !important;
  padding:0 !important;
  position:relative;
  overflow:hidden;
  background:var(--card);
  border:1px solid var(--border);
  border-radius:14px;
  box-shadow:var(--shadow);
  transition:transform .15s ease, box-shadow .15s ease;

  display:block !important;
  float:none !important;
  clear:both !important;
  flex:0 0 100% !important;
  max-width:100%;
  grid-column:1 / -1;
}
.product:hover{transform:translateY(-2px); box-shadow:0 10px 28px rgba(0,0,0,.08)}

/* Make the label fill the square (image zone) */
.product > label{
  display:block !important;
  height:100% !important;
  margin:0 !important;
  cursor:pointer;
}

/* Image wrapper forced to fill */
.product > label > div:first-child{
  height:100% !important;
  margin-bottom:0 !important;
  overflow:hidden !important;
}
.product > label > div:first-child img{
  width:100% !important;
  height:100% !important;
  object-fit:cover !important;
  display:block;
}

/* Checkbox pinned in the corner (visible) */
.product > input[type="checkbox"]{
  position:absolute;
  top:12px;
  inset-inline-end:12px;
  width:24px; height:24px;
  margin:0 !important;
  accent-color:var(--brand);
  z-index:3;
  filter:drop-shadow(0 1px 2px rgba(0,0,0,.25));
}

/* Name chip (2nd div in label) */
.product > label > div:nth-of-type(2){
  position:absolute;
  top:12px;
  inset-inline-start:12px;
  background:rgba(255,255,255,.9);
  padding:6px 10px;
  border-radius:10px;
  font-weight:700;
  max-width:75%;
  z-index:3;
}

/* Price chip (3rd div in label) */
.product > label > div:nth-of-type(3){
  position:absolute;
  bottom:12px;
  inset-inline-start:12px;
  background:rgba(255,255,255,.95);
  padding:8px 12px;
  border-radius:10px;
  font-weight:800;
  z-index:3;
}

/* Quantity overlay (ALWAYS visible inside card) */
.product .qty{
  position:absolute;
  bottom:12px;
  inset-inline-end:12px; /* RTL-aware right */
  display:none;
  align-items:center;
  gap:.5rem;
  background:rgba(255,255,255,.96);
  padding:8px 10px;
  border-radius:10px;
  z-index:4; /* above label/image */
  box-shadow:0 2px 8px rgba(0,0,0,.10);
  font-weight:700;
}
.product .qty input[type="number"]{
  width:70px;
  padding:8px 10px;
  border:1px solid var(--border);
  border-radius:10px;
  background:#fff;
  font-weight:700;
}
.product .qty span{white-space:nowrap}

/* Selected state (modern browsers) */
.product:has(> input[type="checkbox"]:checked){
  outline:3px solid rgba(7,162,143,.25);
  box-shadow:0 0 0 6px rgba(7,162,143,.10), var(--shadow);
}

/* Larger single column on big screens */
@media (min-width:1200px){
  .product{ width:min(640px,90vw) !important; }
}

/* Location sections spacing */
#location_fields, #home_extra, #stop_extra{margin-top:10px}

/* Submit button */
button[type="submit"]{
  width:100%;
  appearance:none;
  border:none;
  background:linear-gradient(135deg,var(--brand),var(--brand-600));
  color:#fff;
  font-weight:800;
  font-size:16px;
  padding:14px 18px;
  border-radius:14px;
  margin-top:18px;
  cursor:pointer;
  box-shadow:0 10px 24px rgba(7,162,143,.28);
  transition:transform .08s ease, filter .2s ease, box-shadow .2s ease;
}
button[type="submit"]:hover{filter:brightness(1.02)}
button[type="submit"]:active{transform:translateY(1px); box-shadow:0 8px 18px rgba(7,162,143,.24)}

/* Utility */
.hidden{display:none !important}
.hint{color:var(--muted); font-size:12.5px; margin-top:4px}

/* Mobile comfort */
@media (max-width:420px){
  input, select, textarea{font-size:16px}
}

/* Optional modal styles (if you move inline styles into CSS) */
.modal{
  display:none;
  position:fixed;
  inset:0;
  background:rgba(0,0,0,0.25);
  z-index:9999;
  justify-content:center;
  align-items:center;
}
.modal .modal-content{
  background:#fff;
  padding:2rem 1.5rem;
  border-radius:12px;
  box-shadow:0 8px 32px rgba(0,0,0,.18);
  text-align:center;
  max-width:350px;
  margin:auto;
  position:relative;
}

/* Dark mode */
@media (prefers-color-scheme: dark){
  :root{
    --bg:#0f1216; --card:#151a21; --text:#e5e7eb; --muted:#9ca3af; --border:#222831;
    --shadow:0 8px 24px rgba(0,0,0,.35);
  }
  .message{background:var(--card)}
  .product{background:var(--card)}
  input, select, textarea{background:#0f1115; border-color:#232935; color:var(--text)}
  button[type="submit"]{box-shadow:0 12px 28px rgba(7,162,143,.35)}

  /* Chips + qty contrast */
  .product > label > div:nth-of-type(2),
  .product > label > div:nth-of-type(3),
  .product .qty{
    background:rgba(21,26,33,.85);
    color:var(--text);
  }
}

/* Hide quantity input by default */
.product .qty {
    display: none;
}

/* Show quantity input ONLY when product is selected */
.product:has(> input[type="checkbox"]:checked) .qty {
    display: flex;
}
