/* Bereshta — internal support chat widget (local, no external assets). */
.bereshta-chat {
  position: fixed;
  z-index: 40;
  left: 24px;
  bottom: calc(28px + env(safe-area-inset-bottom));
  font-family: "Mikhak", Tahoma, sans-serif;
  direction: rtl;
  color: #f0e9dc;
}

.bereshta-chat__launcher {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 50px;
  padding: 0 17px;
  border: 1px solid rgba(208, 178, 124, .45);
  border-radius: 999px;
  background: linear-gradient(145deg, #33291c, #1b1916);
  color: #f0e2c4;
  font: 500 12px/1 "Mikhak", Tahoma, sans-serif;
  box-shadow: 0 10px 28px rgba(0, 0, 0, .38);
  cursor: pointer;
  transition: transform .2s ease, border-color .2s ease, background .2s ease;
}
.bereshta-chat__launcher:hover { transform: translateY(-2px); border-color: rgba(232, 202, 148, .8); }
.bereshta-chat__launcher:focus-visible { outline: 2px solid #d8bd80; outline-offset: 3px; }
.bereshta-chat__launcher[hidden] { display: none; }
.bereshta-chat__launcher svg { width: 19px; height: 19px; stroke: #d8bd80; fill: none; stroke-width: 1.6; }

.bereshta-chat__panel {
  position: absolute;
  left: 0;
  bottom: 0;
  width: min(372px, calc(100vw - 32px));
  max-height: min(560px, calc(100vh - 120px));
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid rgba(216, 189, 128, .26);
  border-radius: 20px;
  background: #1b1a17;
  box-shadow: 0 24px 60px rgba(0, 0, 0, .5);
}
.bereshta-chat__panel[hidden] { display: none; }

.bereshta-chat__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 13px 15px;
  border-bottom: 1px solid rgba(216, 189, 128, .16);
  background: linear-gradient(145deg, #2b2519, #1e1c18);
}
.bereshta-chat__title { margin: 0; font-size: 13px; font-weight: 500; color: #f4e9d3; }
.bereshta-chat__subtitle { margin: 3px 0 0; font-size: 10px; color: #a99f8d; }
.bereshta-chat__status {
  display: inline-flex; align-items: center; gap: 5px;
  margin-inline-start: auto; font-size: 10px; color: #b7ac98;
}
.bereshta-chat__status::before {
  content: ""; width: 7px; height: 7px; border-radius: 50%;
  background: #7f7a70;
}
.bereshta-chat__status.is-online::before { background: #77c08a; box-shadow: 0 0 8px rgba(119, 192, 138, .6); }
.bereshta-chat__close {
  width: 32px; height: 32px; display: grid; place-items: center;
  border: 1px solid rgba(216, 189, 128, .24); border-radius: 50%;
  background: transparent; color: #e2d3b4; cursor: pointer;
}
.bereshta-chat__close:focus-visible { outline: 2px solid #d8bd80; outline-offset: 2px; }
.bereshta-chat__close svg { width: 15px; height: 15px; stroke: currentColor; fill: none; stroke-width: 1.7; }

.bereshta-chat__notice {
  margin: 10px 13px 0;
  padding: 8px 10px;
  border: 1px solid rgba(216, 189, 128, .24);
  border-radius: 10px;
  background: rgba(216, 189, 128, .07);
  color: #d9c8a4;
  font-size: 10px;
  line-height: 1.8;
}
.bereshta-chat__notice[hidden] { display: none; }

.bereshta-chat__log {
  flex: 1 1 auto;
  min-height: 120px;
  overflow-y: auto;
  margin: 0;
  padding: 12px 13px;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
  scrollbar-width: thin;
}
.bereshta-chat__msg {
  max-width: 86%;
  padding: 8px 11px;
  border-radius: 13px;
  font-size: 11.5px;
  line-height: 1.9;
  word-break: break-word;
  white-space: pre-wrap;
  background: #262420;
  border: 1px solid rgba(255, 255, 255, .05);
}
.bereshta-chat__msg--customer, .bereshta-chat__msg--guest {
  align-self: flex-end;
  background: linear-gradient(145deg, #3a301f, #2a251c);
  border-color: rgba(216, 189, 128, .3);
}
.bereshta-chat__msg--admin { align-self: flex-start; }
.bereshta-chat__msg--system {
  align-self: center;
  max-width: 94%;
  background: transparent;
  border: 1px dashed rgba(216, 189, 128, .24);
  color: #b8ad98;
  font-size: 10.5px;
  text-align: center;
}
.bereshta-chat__time { display: block; margin-top: 3px; font-size: 9px; color: #8d8475; }

.bereshta-chat__canned { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 13px 8px; }
.bereshta-chat__chip {
  border: 1px solid rgba(216, 189, 128, .28);
  border-radius: 999px;
  padding: 5px 10px;
  background: rgba(216, 189, 128, .05);
  color: #d9c9a9;
  font: 400 10px/1.6 "Mikhak", Tahoma, sans-serif;
  cursor: pointer;
  text-align: right;
}
.bereshta-chat__chip:hover { border-color: rgba(232, 202, 148, .65); }
.bereshta-chat__chip:focus-visible { outline: 2px solid #d8bd80; outline-offset: 2px; }

.bereshta-chat__form { border-top: 1px solid rgba(216, 189, 128, .14); padding: 9px 11px 11px; }
.bereshta-chat__row { display: flex; align-items: flex-end; gap: 7px; }
.bereshta-chat__input {
  flex: 1 1 auto;
  min-height: 42px;
  max-height: 110px;
  resize: none;
  padding: 9px 11px;
  border: 1px solid rgba(235, 226, 211, .12);
  border-radius: 12px;
  background: rgba(0, 0, 0, .2);
  color: #f0e9dc;
  font: 400 11.5px/1.8 "Mikhak", Tahoma, sans-serif;
}
.bereshta-chat__input:focus { outline: none; border-color: rgba(200, 166, 109, .6); }
.bereshta-chat__send {
  flex: 0 0 auto;
  min-height: 42px;
  padding: 0 14px;
  border: 1px solid rgba(200, 166, 109, .45);
  border-radius: 12px;
  background: rgba(200, 166, 109, .14);
  color: #f0e2c2;
  font: 500 11px/1 "Mikhak", Tahoma, sans-serif;
  cursor: pointer;
}
.bereshta-chat__send:disabled { opacity: .45; cursor: wait; }
.bereshta-chat__send:focus-visible { outline: 2px solid #d8bd80; outline-offset: 2px; }

.bereshta-chat__meta { display: flex; justify-content: space-between; gap: 8px; margin-top: 6px; font-size: 9px; color: #938a7a; }
.bereshta-chat__error { margin: 6px 0 0; color: #e2a294; font-size: 10px; }
.bereshta-chat__error[hidden] { display: none; }
.bereshta-chat__contact { margin-top: 6px; }
.bereshta-chat__contact summary { color: #b9ad97; font-size: 10px; cursor: pointer; }
.bereshta-chat__contact-fields { display: grid; gap: 6px; margin-top: 6px; }
.bereshta-chat__contact input {
  min-height: 34px; padding: 6px 9px;
  border: 1px solid rgba(235, 226, 211, .12); border-radius: 9px;
  background: rgba(0, 0, 0, .2); color: #f0e9dc;
  font: 400 11px/1.6 "Mikhak", Tahoma, sans-serif;
}
.bereshta-chat__contact button {
  min-height: 32px; border: 1px solid rgba(200, 166, 109, .35); border-radius: 9px;
  background: rgba(200, 166, 109, .1); color: #e6d6b5;
  font: 500 10px/1 "Mikhak", Tahoma, sans-serif; cursor: pointer;
}
.bereshta-chat__hint { margin: 6px 0 0; font-size: 9px; color: #857c6d; }

@media (max-width: 760px) {
  .bereshta-chat {
    left: 12px;
    right: auto;
    width: auto;
    bottom: calc(84px + env(safe-area-inset-bottom));
  }
  .bereshta-chat__launcher { min-height: 52px; padding: 0 15px; }
  /* Above the fixed bottom navigation and clear of the back-to-top button. */
  .bereshta-chat__panel {
    left: 0;
    right: auto;
    width: min(360px, calc(100vw - 24px));
    max-height: min(70vh, calc(100vh - 200px));
    /* Lifted above the launcher so the panel never covers the back-to-top
       button that floats over the bottom navigation. */
    bottom: 60px;
    border-radius: 18px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .bereshta-chat__launcher { transition: none; }
  .bereshta-chat__launcher:hover { transform: none; }
}

/* Admin inbox (unchanged layout, shared by /admin/support/chat). */
.chat-meta { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; }
.chat-meta > div { display: grid; gap: 3px; font-size: 12px; }
.chat-meta .muted { font-size: 10px; }
.chat-thread { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.chat-msg { padding: 9px 11px; border: 1px solid rgba(255, 255, 255, .07); border-radius: 12px; background: rgba(255, 255, 255, .02); }
.chat-msg--admin { border-color: rgba(200, 166, 109, .32); background: rgba(200, 166, 109, .06); }
.chat-msg--internal { border-style: dashed; opacity: .9; }
.chat-msg__head { display: flex; align-items: center; gap: 8px; font-size: 11px; }
.chat-msg__body { margin: 5px 0 0; font-size: 12px; line-height: 1.9; white-space: pre-wrap; word-break: break-word; }
.chat-admin-actions { display: grid; gap: 10px; margin-top: 14px; padding-top: 12px; border-top: 1px solid rgba(255, 255, 255, .08); }
