/* صفحة محاكاة واتساب — /demo/whatsapp
   تصميم يطابق واجهة واتساب الفعلية (ألوان، فقاعات، شريط الحالة، شريط الكتابة)
   بدلاً من استعادة توكنز الداشبورد — الهدف مطابقة بصرية حقيقية لنافذة واتساب. */

:root {
  --wa-header: #008069;
  --wa-header-dark: #202c33;
  --wa-wallpaper: #e5ddd5;
  --wa-wallpaper-dark: #0b141a;
  --wa-bubble-out: #d9fdd3;
  --wa-bubble-out-dark: #005c4b;
  --wa-bubble-in: #ffffff;
  --wa-bubble-in-dark: #202c33;
  --wa-text: #111b21;
  --wa-text-dark: #e9edef;
  --wa-text-meta: #667781;
  --wa-text-meta-dark: #8696a0;
  --wa-check: #53bdeb;
  --wa-composer: #f0f2f5;
  --wa-composer-dark: #2a3942;
  --wa-divider: #fff5c4;
  --wa-divider-dark: #182229;
  --wa-divider-text: #54656f;
  --wa-divider-text-dark: #aebac1;
  --wa-shadow: 0 10px 40px rgba(0,0,0,0.22);
}

.wa-page {
  max-width: 1040px;
  margin: 0 auto;
  padding: var(--spacing-lg) var(--spacing-md) 48px;
}

.wa-intro {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--spacing-md) var(--spacing-lg);
  margin-bottom: var(--spacing-lg);
}

.wa-intro h1 {
  font-size: var(--ashh-type-headline, 28px);
  font-weight: var(--ashh-font-weight-heading, 600);
  margin: 0 0 6px;
}

.wa-intro p {
  font-size: var(--ashh-type-body, 16px);
  color: var(--color-text-secondary);
  margin: 0;
}

.wa-back {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: var(--ashh-type-body-sm, 14px);
  color: var(--color-text-secondary);
  text-decoration: none;
  margin-bottom: var(--spacing-md);
}
.wa-back:hover { color: var(--color-text-primary); }

.wa-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: var(--spacing-lg);
}

.wa-tab {
  flex: 1;
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  color: var(--color-text-secondary);
  border-radius: var(--radius-md);
  padding: 10px 10px;
  font-size: var(--ashh-type-body-sm, 14px);
  font-weight: var(--ashh-font-weight-heading, 600);
  cursor: pointer;
  text-align: center;
}

.wa-tab.is-active {
  background: var(--color-brand);
  color: #fff;
  border-color: var(--color-brand);
}

.wa-layout {
  display: flex;
  justify-content: center;
}

/* ===== جهاز الهاتف ===== */

.wa-phone {
  width: 100%;
  max-width: 380px;
  background: var(--wa-wallpaper);
  border-radius: 42px;
  box-shadow: var(--wa-shadow);
  overflow: hidden;
  border: 6px solid #0d0d0d;
  position: relative;
}

/* نتوء الكاميرا (notch) أعلى الشاشة — أول إشارة بصرية "هاتف حديث" بدل جهاز
   عام/قديم. مرسوم كجزء من الإطار نفسه، يتراكب فوق شريط الحالة. */
.wa-notch {
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 92px;
  height: 20px;
  background: #0d0d0d;
  border-radius: 0 0 14px 14px;
  z-index: 5;
}

/* خط الهوم السفلي — بديل زر الهوم الفعلي، نفس إشارة "آيفون حديث". */
.wa-home-indicator {
  height: 4px;
  width: 120px;
  margin: 6px auto 8px;
  border-radius: 3px;
  background: rgba(0,0,0,0.5);
}
:root[data-theme="dark"] .wa-home-indicator,
:root:not([data-theme="light"]) .wa-home-indicator {
  background: rgba(255,255,255,0.55);
}
:root[data-theme="dark"] .wa-phone,
:root:not([data-theme="light"]) .wa-phone {
  background: var(--wa-wallpaper-dark);
}
@media (prefers-color-scheme: light) {
  :root:not([data-theme]) .wa-phone { background: var(--wa-wallpaper); }
}

/* شريط حالة الجهاز (ساعة / شبكة / بطارية) */
.wa-statusbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 18px 2px;
  background: var(--wa-header);
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  direction: ltr;
}
:root[data-theme="dark"] .wa-statusbar,
:root:not([data-theme="light"]) .wa-statusbar {
  background: var(--wa-header-dark);
}
.wa-statusbar__icons { display: flex; align-items: center; gap: 4px; }
.wa-statusbar__icons svg { display: block; }

.wa-phone__header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px 10px;
  background: var(--wa-header);
  color: #fff;
}
:root[data-theme="dark"] .wa-phone__header,
:root:not([data-theme="light"]) .wa-phone__header {
  background: var(--wa-header-dark);
}

.wa-phone__back {
  flex-shrink: 0;
  opacity: 0.95;
  line-height: 0;
}

.wa-phone__avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(255,255,255,0.22);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 14px;
  flex-shrink: 0;
}

.wa-phone__id { flex: 1; min-width: 0; }
.wa-phone__title {
  font-weight: 600;
  font-size: 15px;
  line-height: 1.3;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.wa-phone__status { font-size: 12.5px; opacity: 0.85; }

.wa-phone__icons {
  display: flex;
  align-items: center;
  gap: 16px;
  opacity: 0.95;
  flex-shrink: 0;
}

/* ===== جسم المحادثة ===== */

.wa-phone__body {
  height: 440px;
  overflow-y: auto;
  padding: 10px 10px 6px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  /* ترتيب الفقاعات (يمين/يسار) عالمي في واتساب بغض النظر عن لغة الواجهة —
     نجعل التموضع LTR ونرجع RTL داخل كل فقاعة فقط لمحاذاة النص العربي. */
  direction: ltr;
  background-image:
    radial-gradient(circle at 15% 20%, rgba(0,0,0,0.025) 0, transparent 2px),
    radial-gradient(circle at 70% 60%, rgba(0,0,0,0.025) 0, transparent 2px),
    radial-gradient(circle at 40% 85%, rgba(0,0,0,0.025) 0, transparent 2px);
  background-size: 60px 60px;
}
:root[data-theme="dark"] .wa-phone__body,
:root:not([data-theme="light"]) .wa-phone__body {
  background-image:
    radial-gradient(circle at 15% 20%, rgba(255,255,255,0.03) 0, transparent 2px),
    radial-gradient(circle at 70% 60%, rgba(255,255,255,0.03) 0, transparent 2px),
    radial-gradient(circle at 40% 85%, rgba(255,255,255,0.03) 0, transparent 2px);
  background-size: 60px 60px;
}

.wa-divider {
  align-self: center;
  background: var(--wa-divider);
  color: var(--wa-divider-text);
  font-size: 11.5px;
  padding: 5px 12px;
  border-radius: 7px;
  margin: 8px 0;
  text-align: center;
  max-width: 85%;
  box-shadow: 0 1px 1px rgba(0,0,0,0.08);
  opacity: 0;
  transform: translateY(4px);
  animation: wa-in .25s ease forwards;
}
:root[data-theme="dark"] .wa-divider,
:root:not([data-theme="light"]) .wa-divider {
  background: var(--wa-divider-dark);
  color: var(--wa-divider-text-dark);
  box-shadow: none;
}

.wa-msg-row {
  display: flex;
  margin: 2px 0;
  opacity: 0;
  transform: translateY(6px);
  animation: wa-in .22s ease forwards;
}
/* mine = رسالة الطرف صاحب الهاتف (المستأجر/الفني/المدير) — دائماً يمين، أخضر.
   theirs = رد البوت — دائماً يسار، أبيض. هذا ترتيب واتساب العالمي، لا علاقة له
   باتجاه اللغة. */
.wa-msg-row--mine { justify-content: flex-end; }
.wa-msg-row--theirs { justify-content: flex-start; }
@keyframes wa-in { to { opacity: 1; transform: translateY(0); } }

.wa-msg {
  max-width: 80%;
  padding: 6px 7px 7px 9px;
  border-radius: 7.5px;
  font-size: 14.3px;
  line-height: 1.45;
  color: var(--wa-text);
  position: relative;
  box-shadow: 0 1px 0.5px rgba(0,0,0,0.13);
  white-space: pre-line;
  /* النص العربي داخل الفقاعة RTL دائماً، بغض النظر عن تموضع الفقاعة نفسها. */
  direction: rtl;
  text-align: right;
}
:root[data-theme="dark"] .wa-msg,
:root:not([data-theme="light"]) .wa-msg {
  color: var(--wa-text-dark);
}

.wa-msg--theirs {
  background: var(--wa-bubble-in);
  border-radius: 7.5px 0 7.5px 7.5px;
}
:root[data-theme="dark"] .wa-msg--theirs,
:root:not([data-theme="light"]) .wa-msg--theirs {
  background: var(--wa-bubble-in-dark);
}

.wa-msg--mine {
  background: var(--wa-bubble-out);
  border-radius: 0 7.5px 7.5px 7.5px;
}
:root[data-theme="dark"] .wa-msg--mine,
:root:not([data-theme="light"]) .wa-msg--mine {
  background: var(--wa-bubble-out-dark);
  color: var(--wa-text-dark);
}

.wa-msg__meta {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 3px;
  font-size: 10.5px;
  color: var(--wa-text-meta);
  margin-top: 2px;
  direction: ltr;
}
:root[data-theme="dark"] .wa-msg__meta,
:root:not([data-theme="light"]) .wa-msg__meta {
  color: var(--wa-text-meta-dark);
}
.wa-msg__check { color: var(--wa-text-meta); }
.wa-msg__check--read { color: var(--wa-check); }

.wa-msg__media {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(0,0,0,0.06);
  border-radius: 6px;
  padding: 8px;
  margin-bottom: 4px;
  font-size: 13px;
}
:root[data-theme="dark"] .wa-msg__media,
:root:not([data-theme="light"]) .wa-msg__media {
  background: rgba(255,255,255,0.08);
}
.wa-msg__media-icon {
  width: 34px;
  height: 34px;
  border-radius: 5px;
  background: rgba(0,0,0,0.12);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  flex-shrink: 0;
}
:root[data-theme="dark"] .wa-msg__media-icon,
:root:not([data-theme="light"]) .wa-msg__media-icon {
  background: rgba(255,255,255,0.14);
}

.wa-typing-row { display: flex; justify-content: flex-start; margin: 2px 0; }
.wa-typing {
  display: flex;
  gap: 4px;
  padding: 10px 14px;
  background: var(--wa-bubble-in);
  border-radius: 0 7.5px 7.5px 7.5px;
  box-shadow: 0 1px 0.5px rgba(0,0,0,0.13);
}
:root[data-theme="dark"] .wa-typing,
:root:not([data-theme="light"]) .wa-typing {
  background: var(--wa-bubble-in-dark);
}
.wa-typing span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--wa-text-meta);
  animation: wa-bounce 1s infinite;
}
.wa-typing span:nth-child(2) { animation-delay: .15s; }
.wa-typing span:nth-child(3) { animation-delay: .3s; }
@keyframes wa-bounce { 0%, 60%, 100% { transform: translateY(0); opacity: .4; } 30% { transform: translateY(-4px); opacity: 1; } }

/* ===== شريط الكتابة (تجميلي فقط — غير فعّال) ===== */

.wa-composer {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  background: var(--wa-wallpaper);
}
:root[data-theme="dark"] .wa-composer,
:root:not([data-theme="light"]) .wa-composer {
  background: var(--wa-wallpaper-dark);
}
.wa-composer__pill {
  flex: 1;
  background: var(--wa-composer);
  border-radius: 24px;
  padding: 9px 14px;
  font-size: 13.5px;
  color: var(--wa-text-meta);
  display: flex;
  align-items: center;
  gap: 8px;
}
:root[data-theme="dark"] .wa-composer__pill,
:root:not([data-theme="light"]) .wa-composer__pill {
  background: var(--wa-composer-dark);
  color: var(--wa-text-meta-dark);
}

.wa-composer__mic {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--wa-header);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
:root[data-theme="dark"] .wa-composer__mic,
:root:not([data-theme="light"]) .wa-composer__mic {
  background: #00a884;
}

/* ===== عناصر التحكم بالمحاكاة (خارج جسم الهاتف) ===== */

.wa-controls {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin-top: 14px;
}

.wa-note {
  max-width: 380px;
  margin: 10px auto 0;
  font-size: var(--ashh-type-caption, 12px);
  color: var(--color-text-secondary);
  text-align: center;
}

@media (max-width: 480px) {
  .wa-phone__body { height: 54vh; }
}
