/*
 * WhatsApp inbox. Self-contained: this page does not load the site's stylesheet,
 * because it is a tool and not part of the public site.
 *
 * Sides are set with logical properties, so in this right-to-left page your own
 * replies sit at the end of the line and the customer's at the start, the way
 * WhatsApp itself mirrors when the language is Arabic.
 */

:root {
  --wa-bg: #0b141a;
  --wa-panel: #111b21;
  --wa-panel-2: #202c33;
  --wa-line: #2a3942;
  --wa-text: #e9edef;
  --wa-muted: #8696a0;
  --wa-green: #005c4b;
  --wa-green-bright: #00a884;
  --wa-in: #202c33;
  --wa-warn: #f0b232;
  --wa-danger: #f15c6d;
  --wa-radius: 10px;
}

* { box-sizing: border-box; }

/*
 * The panels below are laid out with grid and flex, and a class rule outranks the
 * browser's own [hidden] rule. Without this, hiding one from JavaScript does
 * nothing at all.
 */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
}

.reeg-wa-body {
  background: var(--wa-bg);
  color: var(--wa-text);
  font-family: "Segoe UI", Tahoma, Arial, "Helvetica Neue", sans-serif;
  font-size: 15px;
  line-height: 1.5;
}

/* ------------------------------------------------------------------- gate ---- */

.reeg-wa-gate {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.reeg-wa-gate__card {
  width: 100%;
  max-width: 360px;
  background: var(--wa-panel);
  border: 1px solid var(--wa-line);
  border-radius: 14px;
  padding: 28px;
  display: grid;
  gap: 10px;
}

.reeg-wa-gate__card h1 {
  margin: 0 0 8px;
  font-size: 20px;
}

.reeg-wa-gate__card label {
  font-size: 13px;
  color: var(--wa-muted);
}

.reeg-wa-gate__card input {
  width: 100%;
  padding: 11px 12px;
  border-radius: 8px;
  border: 1px solid var(--wa-line);
  background: var(--wa-panel-2);
  color: var(--wa-text);
  font: inherit;
}

.reeg-wa-gate__card input:focus-visible {
  outline: 2px solid var(--wa-green-bright);
  outline-offset: 1px;
}

.reeg-wa-gate__card button {
  margin-top: 10px;
  padding: 11px 14px;
  border: 0;
  border-radius: 8px;
  background: var(--wa-green-bright);
  color: #04231c;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

.reeg-wa-gate__error {
  margin: 0;
  padding: 9px 11px;
  border-radius: 8px;
  background: rgba(241, 92, 109, 0.14);
  color: var(--wa-danger);
  font-size: 13px;
}

.reeg-wa-gate__card code {
  background: var(--wa-panel-2);
  padding: 1px 5px;
  border-radius: 4px;
}

/* -------------------------------------------------------------------- app ---- */

.reeg-wa {
  display: grid;
  grid-template-columns: minmax(280px, 30%) 1fr;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
}

.reeg-wa__list {
  background: var(--wa-panel);
  border-inline-end: 1px solid var(--wa-line);
  display: grid;
  grid-template-rows: auto auto 1fr;
  min-height: 0;
}

.reeg-wa__listhead {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  background: var(--wa-panel-2);
}

.reeg-wa__me {
  display: block;
  font-size: 12px;
  color: var(--wa-muted);
  direction: ltr;
}

.reeg-wa__logout {
  border: 1px solid var(--wa-line);
  background: transparent;
  color: var(--wa-muted);
  border-radius: 6px;
  padding: 6px 10px;
  font: inherit;
  font-size: 13px;
  cursor: pointer;
}

.reeg-wa__logout:hover { color: var(--wa-text); }

.reeg-wa__cost {
  padding: 10px 16px;
  font-size: 12.5px;
  line-height: 1.45;
  background: rgba(240, 178, 50, 0.12);
  color: var(--wa-warn);
  border-block-end: 1px solid var(--wa-line);
}

.reeg-wa__cost strong { color: #ffd479; }

.reeg-wa__threads {
  overflow-y: auto;
  min-height: 0;
}

.reeg-wa__thread {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 4px 10px;
  width: 100%;
  padding: 12px 16px;
  border: 0;
  border-block-end: 1px solid var(--wa-line);
  background: transparent;
  color: inherit;
  font: inherit;
  text-align: start;
  cursor: pointer;
}

.reeg-wa__thread:hover { background: var(--wa-panel-2); }
.reeg-wa__thread[aria-current="true"] { background: var(--wa-panel-2); }

.reeg-wa__thread-name {
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.reeg-wa__thread-number {
  grid-column: 1;
  font-size: 12px;
  color: var(--wa-muted);
  direction: ltr;
  text-align: start;
}

.reeg-wa__thread-time {
  grid-row: 1;
  grid-column: 2;
  font-size: 11.5px;
  color: var(--wa-muted);
  white-space: nowrap;
}

.reeg-wa__badge {
  grid-row: 2;
  grid-column: 2;
  justify-self: end;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 10px;
  background: var(--wa-green-bright);
  color: #04231c;
  font-size: 12px;
  font-weight: 700;
  display: grid;
  place-items: center;
}

.reeg-wa__empty,
.reeg-wa__placeholder {
  color: var(--wa-muted);
  padding: 24px 16px;
  text-align: center;
}

/* ------------------------------------------------------------------- chat ---- */

.reeg-wa__chat {
  min-width: 0;
  min-height: 0;
  display: grid;
}

.reeg-wa__placeholder {
  place-self: center;
}

.reeg-wa__open {
  display: grid;
  grid-template-rows: auto 1fr auto;
  min-height: 0;
}

.reeg-wa__chathead {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 18px;
  background: var(--wa-panel-2);
  border-block-end: 1px solid var(--wa-line);
}

.reeg-wa__chathead span {
  display: block;
  font-size: 12px;
  color: var(--wa-muted);
  direction: ltr;
  text-align: start;
}

.reeg-wa__window {
  font-size: 12.5px;
  color: var(--wa-muted);
  white-space: nowrap;
  direction: rtl;
}

.reeg-wa__window--open { color: var(--wa-green-bright); }
.reeg-wa__window--closing { color: var(--wa-warn); }
.reeg-wa__window--closed { color: var(--wa-danger); }

.reeg-wa__messages {
  overflow-y: auto;
  min-height: 0;
  padding: 20px 18px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  background:
    radial-gradient(circle at 20% 10%, rgba(0, 168, 132, 0.06), transparent 45%),
    var(--wa-bg);
}

.reeg-wa__msg {
  max-width: min(72%, 620px);
  padding: 8px 11px 6px;
  border-radius: var(--wa-radius);
  background: var(--wa-in);
  align-self: flex-start;
  border-start-start-radius: 2px;
  word-wrap: break-word;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.reeg-wa__msg--out {
  align-self: flex-end;
  background: var(--wa-green);
  border-start-start-radius: var(--wa-radius);
  border-start-end-radius: 2px;
}

.reeg-wa__meta {
  display: block;
  margin-top: 3px;
  font-size: 11px;
  color: var(--wa-muted);
  text-align: end;
  direction: ltr;
}

.reeg-wa__msg--out .reeg-wa__meta { color: rgba(233, 237, 239, 0.6); }

.reeg-wa__meta--charged { color: var(--wa-warn); }
.reeg-wa__meta--failed { color: var(--wa-danger); }

.reeg-wa__day {
  align-self: center;
  padding: 4px 12px;
  border-radius: 12px;
  background: var(--wa-panel-2);
  color: var(--wa-muted);
  font-size: 12px;
}

/* --------------------------------------------------------------- composer ---- */

.reeg-wa__composer {
  background: var(--wa-panel-2);
  border-block-start: 1px solid var(--wa-line);
  padding: 12px 18px;
}

.reeg-wa__form {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: end;
}

.reeg-wa__form textarea {
  width: 100%;
  max-height: 160px;
  padding: 11px 13px;
  border-radius: 10px;
  border: 1px solid var(--wa-line);
  background: var(--wa-panel);
  color: var(--wa-text);
  font: inherit;
  resize: none;
}

.reeg-wa__form textarea:focus-visible {
  outline: 2px solid var(--wa-green-bright);
  outline-offset: 1px;
}

.reeg-wa__form textarea:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.reeg-wa__form button {
  padding: 11px 20px;
  border: 0;
  border-radius: 10px;
  background: var(--wa-green-bright);
  color: #04231c;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

.reeg-wa__form button:disabled {
  background: var(--wa-line);
  color: var(--wa-muted);
  cursor: not-allowed;
}

.reeg-wa__blocked {
  margin-bottom: 10px;
  padding: 11px 13px;
  border-radius: 10px;
  background: rgba(240, 178, 50, 0.12);
  border: 1px solid rgba(240, 178, 50, 0.3);
  display: grid;
  gap: 9px;
  justify-items: start;
}

.reeg-wa__blocked p {
  margin: 0;
  font-size: 13.5px;
  color: var(--wa-warn);
}

.reeg-wa__blocked button {
  border: 1px solid var(--wa-warn);
  background: transparent;
  color: var(--wa-warn);
  border-radius: 8px;
  padding: 7px 12px;
  font: inherit;
  font-size: 13px;
  cursor: pointer;
}

.reeg-wa__blocked button:hover {
  background: rgba(240, 178, 50, 0.16);
}

.reeg-wa__note {
  margin: 8px 0 0;
  min-height: 18px;
  font-size: 12.5px;
  color: var(--wa-muted);
}

.reeg-wa__note--error { color: var(--wa-danger); }
.reeg-wa__note--ok { color: var(--wa-green-bright); }

/* ------------------------------------------------------------------ small ---- */

@media (max-width: 760px) {
  .reeg-wa {
    grid-template-columns: 1fr;
  }

  .reeg-wa__list {
    border-inline-end: 0;
  }

  /* One pane at a time on a phone, the way WhatsApp does it. */
  .reeg-wa[data-view="chat"] .reeg-wa__list { display: none; }
  .reeg-wa:not([data-view="chat"]) .reeg-wa__chat { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
