/* ============================================================
   نظام التصميم — "المدرج" (Runway) لإدارة المهام
   فكرة التصميم: لوحة تحكم تنفيذية هادئة ودقيقة. لا فوضى، لا إشعارات
   مزعجة بصريًا — فقط ما يهم رجل الأعمال: ما هي المهام التالية، ومتى بالضبط.
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Fraunces:opsz,wght@9..144,400;9..144,500;9..144,600&family=Inter:wght@400;500;600;700&family=IBM+Plex+Mono:wght@500;600&display=swap');

:root {
  --ink: #10131a;
  --ink-2: #0b0d12;
  --surface: #1a1f2b;
  --surface-2: #232936;
  --surface-3: #2b3242;
  --hairline: #2e3646;
  --hairline-soft: #232936;

  --brass: #c9a24b;
  --brass-soft: #e4c878;
  --brass-dim: rgba(201, 162, 75, 0.16);

  --ivory: #ede7dc;
  --ivory-dim: #b9b3a6;
  --muted: #8a93a6;
  --muted-2: #5c6478;

  --emerald: #3fae7a;
  --emerald-dim: rgba(63, 174, 122, 0.16);
  --amber: #d98e32;
  --amber-dim: rgba(217, 142, 50, 0.16);
  --crimson: #c1443c;
  --crimson-dim: rgba(193, 68, 60, 0.16);
  --slateblue: #5b7ba6;
  --slateblue-dim: rgba(91, 123, 166, 0.16);

  --radius: 14px;
  --radius-sm: 9px;
  --shadow-lift: 0 20px 50px -20px rgba(0, 0, 0, 0.6);

  --font-display: 'Fraunces', 'Georgia', serif;
  --font-body: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono: 'IBM Plex Mono', ui-monospace, monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--ink);
  color: var(--ivory);
  font-family: var(--font-body);
  min-height: 100vh;
}

body {
  background-image:
    radial-gradient(1200px 600px at 85% -10%, rgba(201, 162, 75, 0.06), transparent 60%),
    radial-gradient(900px 500px at -10% 110%, rgba(91, 123, 166, 0.05), transparent 60%);
  background-attachment: fixed;
}

::selection { background: var(--brass-dim); color: var(--brass-soft); }

*:focus-visible {
  outline: 2px solid var(--brass);
  outline-offset: 2px;
}

a { color: inherit; }

button {
  font-family: inherit;
  cursor: pointer;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    transition-duration: 0.001ms !important;
  }
}

/* ---------- الهيكل العام ---------- */
.app-shell {
  max-width: 1080px;
  margin: 0 auto;
  padding: 28px 20px 100px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 28px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-mark {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: linear-gradient(145deg, var(--brass-soft), var(--brass));
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--ink-2);
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 19px;
  flex-shrink: 0;
}

.brand-text h1 {
  font-family: var(--font-display);
  font-size: 21px;
  font-weight: 500;
  margin: 0;
  letter-spacing: 0.2px;
}

.brand-text p {
  margin: 0;
  font-size: 12.5px;
  color: var(--muted);
  font-family: var(--font-mono);
  letter-spacing: 0.3px;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.icon-btn {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  border: 1px solid var(--hairline);
  background: var(--surface);
  color: var(--ivory-dim);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
}
.icon-btn:hover { background: var(--surface-2); color: var(--ivory); border-color: var(--muted-2); }
.icon-btn svg { width: 18px; height: 18px; }

/* ---------- بطاقة "المهمة القادمة" (Hero) ---------- */
.hero {
  background: linear-gradient(155deg, var(--surface) 0%, var(--surface-2) 100%);
  border: 1px solid var(--hairline);
  border-radius: 20px;
  padding: 28px;
  box-shadow: var(--shadow-lift);
  position: relative;
  overflow: hidden;
  margin-bottom: 22px;
}

.hero::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(120deg, transparent 40%, rgba(201, 162, 75, 0.05) 50%, transparent 60%);
  pointer-events: none;
}

.hero-eyebrow {
  font-family: var(--font-mono);
  font-size: 11.5px;
  letter-spacing: 1.6px;
  color: var(--brass-soft);
  text-transform: uppercase;
  margin: 0 0 14px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.hero-eyebrow .dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--emerald);
  box-shadow: 0 0 0 3px var(--emerald-dim);
}

.hero-empty {
  padding: 20px 0 6px;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 13.5px;
}

.hero-body {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  flex-wrap: wrap;
}

.hero-info h2 {
  font-family: var(--font-display);
  font-size: 30px;
  font-weight: 500;
  margin: 0 0 8px;
  line-height: 1.25;
}

.hero-meta {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  color: var(--muted);
  font-size: 13.5px;
}
.hero-meta span { display: flex; align-items: center; gap: 6px; }

.hero-countdown {
  text-align: center;
  min-width: 180px;
}

.countdown-number {
  font-family: var(--font-mono);
  font-size: 44px;
  font-weight: 600;
  color: var(--brass-soft);
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.countdown-label {
  font-size: 11.5px;
  color: var(--muted);
  margin-top: 6px;
  letter-spacing: 0.5px;
}

.hero-actions {
  display: flex;
  gap: 8px;
  margin-top: 18px;
  flex-wrap: wrap;
}

/* ---------- شريط مهام اليوم ---------- */
.runway {
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  padding: 18px 20px 20px;
  margin-bottom: 22px;
}

.runway-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 14px;
}

.runway-header h3 {
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 500;
  margin: 0;
}

.runway-header span {
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--muted);
}

.runway-track {
  position: relative;
  height: 54px;
  background: var(--surface-2);
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--hairline-soft);
}

.runway-hour-tick {
  position: absolute;
  top: 0; bottom: 0;
  width: 1px;
  background: var(--hairline-soft);
}
.runway-hour-label {
  position: absolute;
  bottom: 3px;
  font-family: var(--font-mono);
  font-size: 9.5px;
  color: var(--muted-2);
  transform: translateX(-50%);
}

.runway-block {
  position: absolute;
  top: 8px;
  height: 38px;
  border-radius: 6px;
  min-width: 6px;
  cursor: pointer;
  transition: filter 0.15s ease, transform 0.15s ease;
  border: 1px solid rgba(255,255,255,0.08);
}
.runway-block:hover { filter: brightness(1.15); transform: translateY(-1px); }

.runway-now {
  position: absolute;
  top: 0; bottom: 0;
  width: 2px;
  background: var(--brass-soft);
  box-shadow: 0 0 8px rgba(228, 200, 120, 0.7);
  z-index: 3;
}
.runway-now::before {
  content: '';
  position: absolute;
  top: -4px; right: -3px;
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--brass-soft);
}

/* ---------- حالات المهام (الحلة الجديدة) ---------- */
.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 100px;
  font-size: 11.5px;
  font-weight: 600;
  font-family: var(--font-body);
  white-space: nowrap;
}

.status-pending   { background: var(--amber-dim); color: var(--amber); }
.status-completed { background: var(--emerald-dim); color: var(--emerald); }
.status-postponed { background: var(--slateblue-dim); color: var(--slateblue); }
.status-on_hold   { background: rgba(138, 147, 166, 0.16); color: var(--muted); border: 1px solid var(--hairline); }
.status-cancelled { background: var(--surface-2); color: var(--muted-2); text-decoration: line-through; }
/* المهمة الفائتة تظهر بلون أحمر لجذب الانتباه */
.status-missed    { background: var(--crimson-dim); color: var(--crimson); border: 1px solid rgba(193, 68, 60, 0.3); }

/* ألوان المربعات في شريط اليوم */
.bg-pending   { background: var(--amber); }
.bg-completed { background: var(--emerald); }
.bg-postponed { background: var(--slateblue); }
.bg-on_hold   { background: var(--muted); opacity: 0.7; }
.bg-cancelled { background: var(--surface-3); opacity: 0.5; }
.bg-missed    { background: var(--crimson); box-shadow: 0 0 8px rgba(193, 68, 60, 0.6); }

.importance-critical { box-shadow: inset 0 0 0 1.5px var(--crimson); }
.importance-high { box-shadow: inset 0 0 0 1.5px var(--brass); }

/* ---------- القسم / القائمة ---------- */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 30px 0 14px;
}
.section-header h3 {
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 500;
  margin: 0;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 16px;
  border-radius: 10px;
  border: 1px solid var(--hairline);
  background: var(--surface-2);
  color: var(--ivory);
  font-size: 13.5px;
  font-weight: 600;
  transition: all 0.15s ease;
}
.btn:hover { background: var(--surface-3); border-color: var(--muted-2); }
.btn-primary {
  background: linear-gradient(145deg, var(--brass-soft), var(--brass));
  color: var(--ink-2);
  border: none;
}
.btn-primary:hover { filter: brightness(1.08); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn-ghost:hover { color: var(--ivory); background: var(--surface-2); }
.btn-danger { color: var(--crimson); }
.btn-sm { padding: 6px 11px; font-size: 12.5px; border-radius: 8px; }

.day-group { margin-bottom: 18px; }
.day-group-label {
  font-family: var(--font-mono);
  font-size: 11.5px;
  letter-spacing: 1px;
  color: var(--muted);
  text-transform: uppercase;
  margin-bottom: 8px;
  padding-inline-start: 4px;
}

.appt-card {
  display: flex;
  align-items: center;
  gap: 16px;
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  margin-bottom: 8px;
  transition: border-color 0.15s ease;
}
.appt-card:hover { border-color: var(--muted-2); }

.appt-time {
  font-family: var(--font-mono);
  font-size: 15px;
  font-weight: 600;
  color: var(--brass-soft);
  min-width: 58px;
  text-align: center;
}

.appt-main { flex: 1; min-width: 0; }
.appt-main h4 {
  margin: 0 0 4px;
  font-size: 15px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.appt-sub {
  font-size: 12.5px;
  color: var(--muted);
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.appt-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.empty-state {
  text-align: center;
  padding: 50px 20px;
  color: var(--muted);
}
.empty-state h4 {
  font-family: var(--font-display);
  color: var(--ivory-dim);
  font-size: 18px;
  font-weight: 500;
  margin: 12px 0 6px;
}
.empty-state p { font-size: 13.5px; margin: 0; }

/* ---------- نافذة منبثقة (Modal) ---------- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(8, 9, 13, 0.72);
  backdrop-filter: blur(3px);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 40px 16px;
  z-index: 50;
  overflow-y: auto;
}

.modal {
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: 18px;
  width: 100%;
  max-width: 520px;
  padding: 24px;
  box-shadow: var(--shadow-lift);
}

.modal h3 {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 19px;
  margin: 0 0 18px;
}

.field { margin-bottom: 14px; }
.field label {
  display: block;
  font-size: 12.5px;
  color: var(--muted);
  margin-bottom: 6px;
}
.field-row { display: flex; gap: 12px; }
.field-row .field { flex: 1; }

input[type="text"], input[type="datetime-local"], input[type="password"],
textarea, select {
  width: 100%;
  background: var(--surface-2);
  border: 1px solid var(--hairline);
  border-radius: 9px;
  padding: 10px 12px;
  color: var(--ivory);
  font-family: var(--font-body);
  font-size: 14px;
}
input:focus, textarea:focus, select:focus { border-color: var(--brass); }
textarea { resize: vertical; min-height: 64px; }

.chip-group { display: flex; gap: 8px; flex-wrap: wrap; }
.chip {
  padding: 7px 13px;
  border-radius: 100px;
  border: 1px solid var(--hairline);
  background: var(--surface-2);
  font-size: 12.5px;
  color: var(--muted);
}
.chip.active { background: var(--brass-dim); border-color: var(--brass); color: var(--brass-soft); }

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 18px;
}

/* ---------- شريط تنبيه/بانر ---------- */
.banner {
  border: 1px solid var(--hairline);
  background: var(--surface);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 18px;
  font-size: 13px;
  color: var(--ivory-dim);
}
.banner.warn { border-color: rgba(217, 142, 50, 0.4); background: var(--amber-dim); color: var(--brass-soft); }
.banner strong { color: var(--ivory); }

/* ---------- صفحة الإعدادات ---------- */
.settings-grid { display: grid; gap: 16px; }
.card {
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  padding: 18px 20px;
}
.card h4 {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 16px;
  margin: 0 0 10px;
}
.device-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid var(--hairline-soft);
  font-size: 13px;
}
.device-row:last-child { border-bottom: none; }
.device-row .ua { color: var(--muted); font-size: 12px; max-width: 320px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- تسجيل الدخول ---------- */
.auth-shell {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.auth-card {
  width: 100%;
  max-width: 400px;
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: 20px;
  padding: 34px 30px;
  box-shadow: var(--shadow-lift);
}
.auth-mark {
  width: 52px; height: 52px;
  border-radius: 14px;
  background: linear-gradient(145deg, var(--brass-soft), var(--brass));
  display: flex; align-items: center; justify-content: center;
  color: var(--ink-2); font-family: var(--font-display); font-weight: 600; font-size: 24px;
  margin: 0 auto 18px;
}
.auth-card h2 {
  font-family: var(--font-display);
  text-align: center;
  font-size: 22px;
  font-weight: 500;
  margin: 0 0 6px;
}
.auth-card > p.sub {
  text-align: center;
  color: var(--muted);
  font-size: 13px;
  margin: 0 0 26px;
}
.auth-error {
  background: var(--crimson-dim);
  color: var(--crimson);
  border: 1px solid rgba(193, 68, 60, 0.4);
  border-radius: 9px;
  padding: 10px 12px;
  font-size: 13px;
  margin-bottom: 14px;
  display: none;
}
.auth-card .btn-primary { width: 100%; justify-content: center; padding: 11px; margin-top: 6px; }
.auth-switch { text-align: center; margin-top: 18px; font-size: 12.5px; color: var(--muted); }
.auth-switch a { color: var(--brass-soft); text-decoration: none; cursor: pointer; }

/* ---------- توست ---------- */
.toast-wrap {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 100;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
}
.toast {
  background: var(--surface-3);
  border: 1px solid var(--hairline);
  color: var(--ivory);
  padding: 11px 18px;
  border-radius: 10px;
  font-size: 13px;
  box-shadow: var(--shadow-lift);
  animation: toast-in 0.2s ease;
}
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

/* ---------- شبكة التنقل السفلي (موبايل) ---------- */
.fab {
  position: fixed;
  bottom: 24px;
  inset-inline-end: 24px;
  width: 56px; height: 56px;
  border-radius: 50%;
  background: linear-gradient(145deg, var(--brass-soft), var(--brass));
  color: var(--ink-2);
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 12px 30px -8px rgba(201, 162, 75, 0.5);
  border: none;
  z-index: 40;
}
.fab svg { width: 24px; height: 24px; }

@media (max-width: 640px) {
  .hero-body { flex-direction: column; align-items: stretch; }
  .hero-countdown { text-align: start; }
  .appt-card { flex-wrap: wrap; }
  .appt-actions { width: 100%; justify-content: flex-end; margin-top: 8px; }
}