/* =========================================================
   استایل پنل مدیریت چت
   ========================================================= */

:root {
  --ap-primary: #6d5bff;
  --ap-primary-dark: #4f3ff0;
  --ap-bg: #0f0d24;
  --ap-panel: rgba(255, 255, 255, 0.05);
  --ap-panel-hover: rgba(255, 255, 255, 0.09);
  --ap-border: rgba(255, 255, 255, 0.1);
  --ap-text: #f4f4f8;
  --ap-text-muted: rgba(244, 244, 248, 0.55);
  --ap-danger: #ff5470;
  --ap-radius: 16px;
  --ap-font: "Vazirmatn", Tahoma, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--ap-font);
  background: radial-gradient(circle at top right, #1e1b4b, var(--ap-bg) 60%);
  color: var(--ap-text);
  direction: rtl;
  min-height: 100vh;
}

input, select, textarea, button {
  font-family: var(--ap-font);
}

/* ================= صفحه ورود ================= */
.login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.login-card {
  width: 100%;
  max-width: 380px;
  background: rgba(255, 255, 255, 0.06);
  backdrop-filter: blur(18px);
  border: 1px solid var(--ap-border);
  border-radius: var(--ap-radius);
  padding: 36px 30px;
  text-align: center;
  box-shadow: 0 25px 70px rgba(0, 0, 0, 0.4);
  animation: ap-fade-up 0.4s ease;
}

@keyframes ap-fade-up {
  from { opacity: 0; transform: translateY(14px); }
  to { opacity: 1; transform: translateY(0); }
}

.login-logo { font-size: 34px; margin-bottom: 6px; }
.login-card h1 { font-size: 19px; margin: 0 0 4px; }
.login-sub { color: var(--ap-text-muted); font-size: 13px; margin: 0 0 22px; }

.field {
  display: block;
  text-align: right;
  margin-bottom: 14px;
}
.field span {
  display: block;
  font-size: 12.5px;
  color: var(--ap-text-muted);
  margin-bottom: 6px;
}
.field input {
  width: 100%;
  padding: 11px 14px;
  border-radius: 10px;
  border: 1px solid var(--ap-border);
  background: rgba(255, 255, 255, 0.05);
  color: var(--ap-text);
  outline: none;
  font-size: 14px;
  transition: border-color 0.2s;
}
.field input:focus { border-color: var(--ap-primary); }

.login-error {
  background: rgba(255, 84, 112, 0.12);
  border: 1px solid rgba(255, 84, 112, 0.4);
  color: #ff8fa3;
  font-size: 12.5px;
  padding: 9px 12px;
  border-radius: 10px;
  margin-bottom: 14px;
}

.btn-primary {
  width: 100%;
  padding: 12px;
  border: none;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--ap-primary), var(--ap-primary-dark));
  color: #fff;
  font-weight: 700;
  font-size: 14px;
  cursor: pointer;
  transition: opacity 0.2s, transform 0.15s;
}
.btn-primary:hover { transform: translateY(-1px); }
.btn-primary:disabled { opacity: 0.6; cursor: not-allowed; transform: none; }

.btn-danger {
  padding: 8px 14px;
  border-radius: 10px;
  border: 1px solid rgba(255, 84, 112, 0.4);
  background: rgba(255, 84, 112, 0.12);
  color: #ff8fa3;
  cursor: pointer;
  font-size: 12.5px;
  transition: background 0.2s;
}
.btn-danger:hover { background: rgba(255, 84, 112, 0.22); }

/* ================= داشبورد ================= */
.dashboard {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

.sidebar {
  width: 320px;
  flex-shrink: 0;
  background: rgba(255, 255, 255, 0.03);
  border-inline-start: 1px solid var(--ap-border);
  display: flex;
  flex-direction: column;
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 16px;
  border-bottom: 1px solid var(--ap-border);
}
.sidebar-logo { font-weight: 800; font-size: 15px; display: flex; align-items: center; gap: 8px; }

.icon-btn {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  border: 1px solid var(--ap-border);
  background: transparent;
  color: var(--ap-text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s, color 0.2s;
}
.icon-btn:hover { background: var(--ap-panel-hover); color: var(--ap-text); }
.icon-btn svg { width: 16px; height: 16px; fill: currentColor; }

.sidebar-search { padding: 12px 16px 0; }
.sidebar-search input {
  width: 100%;
  padding: 10px 14px;
  border-radius: 10px;
  border: 1px solid var(--ap-border);
  background: rgba(255, 255, 255, 0.04);
  color: var(--ap-text);
  outline: none;
  font-size: 13px;
}
.sidebar-search input:focus { border-color: var(--ap-primary); }

.sidebar-sort { padding: 10px 16px; }
.sidebar-sort select {
  width: 100%;
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid var(--ap-border);
  background: rgba(255, 255, 255, 0.04);
  color: var(--ap-text-muted);
  font-size: 12.5px;
  outline: none;
}

.conversation-list {
  flex: 1;
  overflow-y: auto;
  padding: 6px 10px 16px;
}

.conv-item {
  padding: 12px 12px;
  border-radius: 12px;
  cursor: pointer;
  margin-bottom: 4px;
  transition: background 0.15s;
  border: 1px solid transparent;
}
.conv-item:hover { background: var(--ap-panel-hover); }
.conv-item.active {
  background: rgba(109, 91, 255, 0.16);
  border-color: rgba(109, 91, 255, 0.4);
}

.conv-item-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 4px;
}
.conv-item-name { font-weight: 700; font-size: 13.5px; }
.conv-item-time { font-size: 10.5px; color: var(--ap-text-muted); }
.conv-item-preview {
  font-size: 12px;
  color: var(--ap-text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.empty-state {
  text-align: center;
  color: var(--ap-text-muted);
  font-size: 13px;
  padding: 40px 20px;
}

/* ================= پنل چت ================= */
.chat-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  position: relative;
}

.chat-empty {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--ap-text-muted);
}
.chat-empty-icon { font-size: 42px; margin-bottom: 10px; opacity: 0.5; }

.chat-active { flex: 1; display: flex; flex-direction: column; overflow: hidden; }

.chat-active-header {
  padding: 16px 22px;
  border-bottom: 1px solid var(--ap-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.chat-active-name { font-weight: 700; font-size: 15px; }
.chat-active-id { font-size: 11.5px; color: var(--ap-text-muted); margin-top: 2px; direction: ltr; text-align: right;}

.active-messages {
  flex: 1;
  overflow-y: auto;
  padding: 22px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.a-msg {
  max-width: 65%;
  padding: 11px 15px;
  border-radius: 16px;
  font-size: 13.5px;
  line-height: 1.8;
  white-space: pre-wrap;
  word-wrap: break-word;
}
.a-msg.user {
  align-self: flex-start;
  background: var(--ap-panel);
  border: 1px solid var(--ap-border);
}
.a-msg.admin {
  align-self: flex-end;
  background: linear-gradient(135deg, var(--ap-primary), var(--ap-primary-dark));
}
.a-msg-time { font-size: 10px; color: var(--ap-text-muted); margin-top: 5px; }
.a-msg.admin .a-msg-time { color: rgba(255,255,255,0.75); }

.reply-form {
  padding: 14px 18px;
  border-top: 1px solid var(--ap-border);
  display: flex;
  gap: 10px;
  align-items: flex-end;
}
.reply-form textarea {
  flex: 1;
  resize: none;
  min-height: 42px;
  max-height: 110px;
  border-radius: 12px;
  border: 1px solid var(--ap-border);
  background: rgba(255, 255, 255, 0.04);
  color: var(--ap-text);
  padding: 10px 14px;
  font-size: 13.5px;
  outline: none;
}
.reply-form textarea:focus { border-color: var(--ap-primary); }
.reply-form .btn-primary { width: auto; padding: 10px 22px; }

/* ================= Toast ================= */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: #1e1b4b;
  border: 1px solid var(--ap-border);
  color: var(--ap-text);
  padding: 11px 20px;
  border-radius: 12px;
  font-size: 13px;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.4);
  z-index: 9999;
  animation: ap-fade-up 0.25s ease;
}

/* ================= Responsive ================= */
@media (max-width: 900px) {
  .dashboard { flex-direction: column; }
  .sidebar { width: 100%; height: 40vh; border-inline-start: none; border-bottom: 1px solid var(--ap-border); }
  .chat-panel { height: 60vh; }
  .a-msg { max-width: 85%; }
}
