:root {
  --ink: #17223b;          /* ليل الصحراء */
  --ink-soft: #2a3756;
  --paper: #f3f5f1;
  --surface: #ffffff;
  --acacia: #2f5d50;       /* الأخضر: الإجراء الأساسي */
  --acacia-dark: #234a3f;
  --saffron: #e3a93b;      /* الأصفر: ليالي الإقامة المختارة */
  --saffron-soft: #f6e4b7;
  --text: #1d2433;
  --muted: #5a6477;
  --line: #d6dbd3;
  --danger: #a93a2b;
  --danger-bg: #fbe9e5;
  --ok-bg: #e3f0ea;
  --radius: 14px;
  --font: 'Readex Pro', 'Segoe UI', Tahoma, system-ui, sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.7;
}
[hidden] { display: none !important; }
button, input, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--saffron); outline-offset: 2px; }

.wrap { max-width: 520px; margin: 0 auto; padding: 0 16px; }

/* ===== الرأس ===== */
.masthead {
  background: var(--ink);
  color: #fff;
  padding: 28px 0 22px;
  border-bottom: 4px dashed var(--saffron);
}
.masthead h1 {
  margin: 0;
  font-size: 44px;
  line-height: 1.15;
  font-weight: 600;
  letter-spacing: 0;
}
.masthead p { margin: 6px 0 0; color: #c9d1e3; font-size: 15px; }

.banner {
  margin: 14px 0 0;
  padding: 10px 14px;
  border-radius: 10px;
  font-size: 14px;
  background: var(--saffron-soft);
  color: #4a3600;
}
.banner.warn { background: var(--danger-bg); color: var(--danger); }

/* ===== البطاقات والأقسام ===== */
.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px 16px;
  margin: 16px 0;
}
.panel h2 { margin: 0 0 4px; font-size: 20px; font-weight: 600; }
.panel .sub { margin: 0 0 14px; color: var(--muted); font-size: 14px; }

/* ===== التقويم ===== */
.cal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.cal-head h3 { margin: 0; font-size: 18px; font-weight: 600; }
.nav-btn {
  width: 44px; height: 44px;
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: 50%;
  cursor: pointer;
  font-size: 20px;
  line-height: 1;
}
.nav-btn:disabled { opacity: .35; cursor: not-allowed; }

.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.cal-dow { text-align: center; font-size: 12px; color: var(--muted); padding: 4px 0; }

.day {
  position: relative;
  min-height: 52px;
  padding: 4px 0 2px;
  border: 1px solid transparent;
  border-radius: 10px;
  background: #f7f9f6;
  cursor: pointer;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  line-height: 1.2;
}
.day .num { font-size: 16px; font-weight: 500; }
.day .price { font-size: 10px; color: var(--muted); margin-top: 2px; }
.day.weekend .price { color: var(--acacia-dark); font-weight: 600; }
.day .price.special { color: #8a5a00; font-weight: 600; }
.day:hover:not(:disabled) { border-color: var(--acacia); }

/* ليلة محجوزة أو ماضية: خطوط كغرزة خيمة */
.day:disabled {
  cursor: not-allowed;
  color: #9aa2b3;
  background: repeating-linear-gradient(135deg, #eceee9 0 5px, #e1e4dd 5px 6px);
}
.day.past { background: transparent; }
.day.blank { visibility: hidden; }

.day.checkout-ok { border: 1.5px dashed var(--acacia); }
.day.in-range { background: var(--saffron-soft); color: var(--text); }
.day.edge { background: var(--saffron); border-color: var(--saffron); color: #2b1f00; }
.day.edge .price { color: #2b1f00; }
.day.today .num::after { content: ''; display: block; height: 2px; margin-top: 1px; background: currentColor; border-radius: 1px; }

.legend { display: flex; flex-wrap: wrap; gap: 8px 16px; margin-top: 12px; font-size: 13px; color: var(--muted); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.sw { width: 16px; height: 16px; border-radius: 4px; display: inline-block; }
.sw.free { background: #f7f9f6; border: 1px solid var(--line); }
.sw.booked { background: repeating-linear-gradient(135deg, #eceee9 0 3px, #d8dcd4 3px 4px); }
.sw.chosen { background: var(--saffron); }

.hint { min-height: 24px; margin: 10px 0 0; font-size: 14px; color: var(--muted); }
.hint.err { color: var(--danger); }

/* ===== النموذج ===== */
label { display: block; font-weight: 500; margin: 14px 0 4px; }
.field-note { font-weight: 400; color: var(--muted); font-size: 13px; }
input[type=text], input[type=tel], textarea {
  width: 100%;
  padding: 12px 14px;
  border: 1.5px solid var(--line);
  border-radius: 10px;
  background: #fff;
  font-size: 16px; /* يمنع تكبير الصفحة تلقائياً في الآيفون */
}
input:focus, textarea:focus { border-color: var(--acacia); outline: none; box-shadow: 0 0 0 3px rgba(47,93,80,.18); }
input[aria-invalid=true] { border-color: var(--danger); }
.field-err { color: var(--danger); font-size: 13px; margin: 4px 0 0; min-height: 1px; }

.stepper { display: inline-flex; align-items: center; border: 1.5px solid var(--line); border-radius: 10px; overflow: hidden; }
.stepper button { width: 48px; height: 48px; border: 0; background: #f7f9f6; font-size: 22px; cursor: pointer; }
.stepper button:disabled { opacity: .35; cursor: not-allowed; }
.stepper output { min-width: 56px; text-align: center; font-weight: 600; font-size: 18px; }

/* ===== الأزرار ===== */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 52px;
  padding: 0 22px;
  border-radius: 12px;
  border: 0;
  background: var(--acacia);
  color: #fff;
  font-weight: 600;
  font-size: 17px;
  cursor: pointer;
  text-decoration: none;
}
.btn:hover:not(:disabled) { background: var(--acacia-dark); }
.btn:disabled { background: #a9b3ad; cursor: not-allowed; }
.btn.block { width: 100%; }
.btn.ghost { background: transparent; color: var(--acacia-dark); border: 1.5px solid var(--acacia); }
.btn.ghost:hover:not(:disabled) { background: var(--ok-bg); }
.btn.small { min-height: 40px; padding: 0 14px; font-size: 15px; }
.btn.danger { background: var(--danger); }
.linkish { background: none; border: 0; padding: 8px 0; color: var(--acacia-dark); text-decoration: underline; cursor: pointer; font-size: 15px; }

/* ===== شريط الملخص السفلي ===== */
.spacer { height: 110px; }
.bar {
  position: fixed; inset: auto 0 0 0;
  background: var(--surface);
  border-top: 1px solid var(--line);
  box-shadow: 0 -6px 18px rgba(23,34,59,.08);
  padding: 10px 0 calc(10px + env(safe-area-inset-bottom));
}
.bar .wrap { display: flex; align-items: center; gap: 12px; }
.bar .info { flex: 1; min-width: 0; }
.bar .info strong { display: block; font-size: 17px; }
.bar .info span { display: block; font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar .btn { flex: none; }

/* ===== ملخص الحجز ===== */
.summary { margin: 0; padding: 0; list-style: none; }
.summary li { display: flex; justify-content: space-between; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.summary li:last-child { border-bottom: 0; }
.summary .k { color: var(--muted); }
.summary .total { font-weight: 700; font-size: 18px; }
details.breakdown { margin-top: 8px; font-size: 14px; }
details.breakdown summary { cursor: pointer; color: var(--acacia-dark); padding: 6px 0; }
details.breakdown ul { margin: 4px 0 0; padding: 0; list-style: none; }
details.breakdown li { display: flex; justify-content: space-between; padding: 3px 0; color: var(--muted); }

.timer {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 14px; margin-bottom: 14px;
  background: var(--saffron-soft); border-radius: 10px; font-size: 14px; color: #4a3600;
}
.timer strong { font-size: 20px; font-variant-numeric: tabular-nums; }
.timer.low { background: var(--danger-bg); color: var(--danger); }

.msg { padding: 14px 16px; border-radius: 12px; margin: 14px 0; }
.msg.ok { background: var(--ok-bg); }
.msg.bad { background: var(--danger-bg); color: var(--danger); }
.msg h2 { margin: 0 0 4px; font-size: 20px; }
.msg p { margin: 0; }

.test-box { margin-top: 14px; padding: 12px 14px; background: #f1f3ef; border-radius: 10px; font-size: 13px; color: var(--muted); }
.test-box code { direction: ltr; unicode-bidi: embed; background: #fff; padding: 1px 6px; border-radius: 4px; border: 1px solid var(--line); color: var(--text); }

.foot { text-align: center; color: var(--muted); font-size: 13px; padding: 8px 0 24px; }
.foot a { color: var(--acacia-dark); }

/* ===== لوحة المالك ===== */
.table-list { display: grid; gap: 10px; }
.card-row { border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; background: #fff; }
.card-row .top { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; }
.badge { font-size: 12px; padding: 2px 10px; border-radius: 999px; background: #eceee9; white-space: nowrap; }
.badge.confirmed { background: var(--ok-bg); color: var(--acacia-dark); }
.badge.pending { background: var(--saffron-soft); color: #4a3600; }
.badge.refund_needed, .badge.cancelled { background: var(--danger-bg); color: var(--danger); }
.badge.blocked { background: #dfe4f1; color: var(--ink); }
.card-row .meta { font-size: 14px; color: var(--muted); margin-top: 4px; }
.card-row .actions { margin-top: 10px; display: flex; gap: 8px; flex-wrap: wrap; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

@media (min-width: 560px) {
  .masthead h1 { font-size: 52px; }
}
@media (prefers-reduced-motion: reduce) {
  * { scroll-behavior: auto !important; transition: none !important; animation: none !important; }
}
