@font-face {
  font-family: IranYekan;
  src: url("/assets/fonts/Qs_Iranyekan.ttf") format("truetype");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: IranYekan;
  src: url("/assets/fonts/Qs_Iranyekan_medium.ttf") format("truetype");
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: IranYekan;
  src: url("/assets/fonts/Qs_Iranyekan_bold.ttf") format("truetype");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

:root {
  --orange: #ffd632;
  --dm-orange: #ffde00;
  --dm-bg: #0c0e12;
  --glass: rgba(57, 57, 57, 0.28);
  --line: rgba(255, 255, 255, 0.1);
  --text: #fff;
  --muted: rgba(255, 255, 255, 0.7);
}

* { box-sizing: border-box; }
html, body {
  height: 100%;
  margin: 0;
}
body {
  font-family: IranYekan, Tahoma, sans-serif;
  color: var(--text);
  background: #0c0e12;
  overflow: hidden;
}
[hidden] { display: none !important; }

.bg-layer {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  overflow: hidden;
}
.bg-layer .orb-a,
.bg-layer .orb-b {
  position: absolute;
  border-radius: 999px;
  filter: blur(120px);
}
.bg-layer .orb-a {
  top: -20%;
  right: -30%;
  width: 70vw;
  height: 70vw;
  background: radial-gradient(circle, rgba(147, 51, 234, 0.18), transparent 70%);
}
.bg-layer .orb-b {
  bottom: 5%;
  left: -20%;
  width: 70vw;
  height: 70vw;
  background: radial-gradient(circle, rgba(245, 158, 11, 0.12), transparent 70%);
}
.bg-layer .grid {
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(to right, rgba(255, 255, 255, 0.07) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(255, 255, 255, 0.07) 1px, transparent 1px);
  background-size: 28px 28px;
}

.phone-shell {
  position: relative;
  z-index: 1;
  width: min(430px, 100%);
  height: 100%;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  background: rgba(12, 14, 18, 0.55);
  backdrop-filter: blur(18px);
  border-inline: 1px solid var(--line);
  overflow: hidden;
}

.gate {
  height: 100%;
  overflow: auto;
  padding: 24px 16px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.glass-card {
  background: var(--glass);
  backdrop-filter: blur(28px);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 22px 18px 18px;
}

.logo-wrap {
  margin-bottom: 20px;
  text-align: right;
}
.logo-wrap h1 {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.02em;
}
.logo-wrap p {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 12.5px;
  line-height: 1.9;
  font-weight: 400;
}

.field { margin-bottom: 14px; }
.field label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 7px;
  font-size: 12.5px;
  color: rgba(255, 255, 255, 0.78);
}
.req {
  color: var(--dm-orange);
  font-size: 11px;
  font-weight: 700;
}
.opt {
  color: rgba(255, 255, 255, 0.38);
  font-size: 11px;
  font-weight: 500;
}
.field input, .composer textarea {
  width: 100%;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(0, 0, 0, 0.22);
  color: #fff;
  border-radius: 12px;
  padding: 11px 13px;
  outline: none;
  font-family: inherit;
  font-size: 14px;
}
.field input::placeholder {
  color: rgba(255, 255, 255, 0.32);
}
.field input:focus, .composer textarea:focus {
  border-color: rgba(255, 214, 50, 0.45);
  background: rgba(0, 0, 0, 0.28);
}

.btn {
  border: 0;
  border-radius: 12px;
  padding: 12px 16px;
  cursor: pointer;
  font-family: inherit;
  font-weight: 700;
  background: var(--dm-orange);
  color: #111;
}
.btn.full { width: 100%; margin-top: 6px; }
.auth-switch {
  margin: 16px 0 0;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
}
.auth-switch button {
  border: 0;
  background: none;
  color: var(--dm-orange);
  font-family: inherit;
  font-weight: 700;
  cursor: pointer;
  padding: 0;
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn.ghost {
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
}

.error {
  display: none;
  background: rgba(239, 68, 68, 0.12);
  color: #fecaca;
  border: 1px solid rgba(239, 68, 68, 0.25);
  padding: 10px 12px;
  border-radius: 12px;
  margin-bottom: 12px;
  font-size: 13px;
}
.error.show { display: block; }

.chat-app {
  height: 100%;
  display: grid;
  grid-template-rows: auto auto 1fr auto;
  min-height: 0;
}
.status-pin {
  margin: 8px 12px 0;
  padding: 8px 12px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.08);
  font-size: 12px;
  text-align: center;
}
.status-pin.reviewing { background: rgba(255, 214, 50, 0.16); color: #ffe9a3; }
.status-pin.resolved { background: rgba(34, 197, 94, 0.16); color: #86efac; }
.status-pin.closed { background: rgba(239, 68, 68, 0.16); color: #fecaca; }
.event-box {
  align-self: center;
  max-width: 90%;
  padding: 8px 12px;
  border-radius: 12px;
  font-size: 12px;
  text-align: center;
}
.event-box.closed, .event-box.resolved, .event-box.banned { background: rgba(239, 68, 68, 0.18); color: #fecaca; }
.event-box.unbanned { background: rgba(34, 197, 94, 0.18); color: #86efac; }
.event-box.new_ticket { background: rgba(34, 197, 94, 0.18); color: #86efac; }
.event-box.reviewing, .event-box.open, .event-box.reopen { background: rgba(255, 214, 50, 0.14); color: #ffe9a3; }
.badge.reviewing { background: rgba(255, 214, 50, 0.16); color: #ffe9a3; }
.badge.resolved { background: rgba(34, 197, 94, 0.16); color: #86efac; }
.thread {
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.18);
}
.top-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}
.btn.logout {
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  font-size: 12px;
  padding: 8px 12px;
  height: 36px;
}
.topbar strong { font-size: 15px; }
.who { color: var(--muted); font-size: 12px; margin-top: 4px; }
.badge {
  font-size: 11px;
  padding: 5px 10px;
  border-radius: 999px;
  background: rgba(34, 197, 94, 0.18);
  color: #86efac;
  font-weight: 700;
}
.badge.closed {
  background: rgba(239, 68, 68, 0.16);
  color: #fecaca;
}

.notice {
  display: none;
  margin: 10px 12px 0;
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(255, 214, 50, 0.12);
  color: #ffe9a3;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 12px;
}
.notice.show { display: flex; }

.messages {
  overflow: auto;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 0;
  flex: 1;
}

.bubble {
  max-width: 82%;
  padding: 10px 12px;
  border-radius: 16px;
  line-height: 1.7;
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 14px;
}
.bubble.customer {
  align-self: flex-start;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--line);
  border-bottom-right-radius: 6px;
}
.bubble.admin {
  align-self: flex-end;
  background: rgba(255, 214, 50, 0.16);
  border: 1px solid rgba(255, 214, 50, 0.22);
  color: #fff;
  border-bottom-left-radius: 6px;
}
.meta { display: block; margin-top: 6px; color: var(--muted); font-size: 11px; }
.img-open {
  display: block;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: zoom-in;
  font: inherit;
}
.bubble img { display: block; max-width: 210px; border-radius: 12px; margin-bottom: 8px; pointer-events: none; }
.img-lightbox {
  position: absolute;
  inset: 0;
  z-index: 30;
  background: rgba(0, 0, 0, 0.92);
  display: grid;
  place-items: center;
  padding: 48px 12px 12px;
  cursor: zoom-out;
}
.img-lightbox img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  border-radius: 10px;
}
.img-lightbox-close {
  position: absolute;
  top: 10px;
  left: 10px;
  z-index: 1;
  border: 1px solid var(--line);
  background: #16181d;
  color: #fff;
  border-radius: 10px;
  padding: 8px 12px;
  cursor: pointer;
  font-family: inherit;
}
.file-chip {
  display: inline-flex;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.25);
  color: inherit;
  text-decoration: none;
}

.typing {
  display: none;
  color: var(--muted);
  font-size: 12px;
  padding: 0 16px 8px;
}
.typing.show { display: block; }

.composer {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 10px 12px 14px;
  border-top: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.22);
}
.composer textarea {
  flex: 1;
  min-width: 0;
  height: 44px;
  min-height: 44px;
  max-height: 160px;
  resize: none;
  overflow-y: auto;
  line-height: 1.6;
  padding: 10px 12px;
  field-sizing: content;
}
.composer .btn.send {
  flex: 0 0 auto;
  height: 44px;
  min-width: 44px;
  padding: 0 14px;
  align-self: flex-end;
  border-radius: 12px;
  font-size: 13px;
}
.icon-btn {
  flex: 0 0 44px;
  width: 44px;
  height: 44px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.06);
  color: rgba(255, 255, 255, 0.85);
  border-radius: 12px;
  cursor: pointer;
  align-self: flex-end;
  display: grid;
  place-items: center;
  padding: 0;
}
.icon-btn svg {
  display: block;
}

.file-preview {
  position: absolute;
  inset: 0;
  z-index: 20;
  background: rgba(0, 0, 0, 0.62);
  display: grid;
  place-items: center;
  padding: 20px;
}
.file-preview-card {
  width: 100%;
  background: #16181d;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 16px;
  text-align: center;
}
.file-preview-card p {
  margin: 0 0 12px;
  font-size: 14px;
}
.file-preview-card img {
  display: block;
  width: 100%;
  max-height: 280px;
  object-fit: contain;
  border-radius: 12px;
  margin-bottom: 14px;
  background: #000;
}
.file-preview-name {
  margin-bottom: 14px;
  padding: 10px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.06);
  word-break: break-all;
  font-size: 13px;
}
.file-preview-actions {
  display: flex;
  gap: 8px;
}
.file-preview-actions .btn {
  flex: 1;
}

@media (max-width: 768px) {
  .bg-layer { display: none; }
  .phone-shell {
    width: 100%;
    border-inline: 0;
    background: #0c0e12;
    backdrop-filter: none;
  }
}
