@font-face {
  font-family: 'Vazirmatn';
  src: url('/static/Vazirmatn-Regular.woff2') format('woff2');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'Vazirmatn';
  src: url('/static/Vazirmatn-Bold.woff2') format('woff2');
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

:root {
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --primary-light: #eff6ff;
  --bg-main: #f1f5f9;
  --bg-card: #ffffff;
  --text-main: #0f172a;
  --text-muted: #64748b;
  --border: #e2e8f0;
  --online: #10b981;
  --danger: #ef4444;
  --font-family: 'Vazirmatn', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Tahoma, sans-serif;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: var(--font-family);
  direction: rtl;
}

body {
  background-color: var(--bg-main);
  color: var(--text-main);
  height: 100vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* Login Modal */
#login-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.7);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
  padding: 16px;
}
.login-card {
  background: #ffffff;
  width: 100%;
  max-width: 400px;
  border-radius: 20px;
  padding: 36px 32px;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.2);
  text-align: center;
}
.login-card h2 {
  font-size: 22px;
  color: var(--text-main);
  margin-bottom: 8px;
}
.login-card p {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 28px;
}
.form-group {
  margin-bottom: 18px;
  text-align: right;
}
.form-group label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--text-main);
}
.form-control {
  width: 100%;
  padding: 12px 14px;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  font-size: 14px;
  outline: none;
  transition: all 0.2s;
}
.form-control:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}
.btn-primary {
  width: 100%;
  padding: 13px;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: 10px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
  margin-top: 10px;
}
.btn-primary:hover {
  background: var(--primary-hover);
}
.login-error {
  color: var(--danger);
  font-size: 13px;
  margin-top: 14px;
  display: none;
}

/* App Header */
#app-header {
  height: 60px;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  z-index: 10;
}
.brand-title {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 17px;
  color: var(--primary);
}
.header-actions {
  display: flex;
  align-items: center;
  gap: 14px;
}
.btn-icon {
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 7px 12px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-main);
  transition: all 0.2s;
}
.btn-icon:hover {
  background: var(--bg-main);
}
.status-pill {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 500;
  padding: 4px 10px;
  border-radius: 12px;
  background: #ecfdf5;
  color: #065f46;
}
.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--online);
}

/* App Main Layout */
#app-main {
  flex: 1;
  display: flex;
  height: calc(100vh - 60px);
  overflow: hidden;
}

/* Sidebar: Conversations */
#sidebar-conversations {
  width: 340px;
  background: var(--bg-card);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
}
.conv-tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
}
.conv-tab {
  flex: 1;
  padding: 14px 0;
  text-align: center;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: all 0.2s;
}
.conv-tab.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
  background: var(--primary-light);
}
.conv-list {
  flex: 1;
  overflow-y: auto;
  list-style: none;
}
.conv-item {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 12px;
  transition: background 0.15s;
  position: relative;
}
.conv-item:hover {
  background: #f8fafc;
}
.conv-item.active {
  background: var(--primary-light);
  border-right: 4px solid var(--primary);
}
.conv-avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: #e2e8f0;
  color: var(--primary);
  font-weight: 700;
  font-size: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.conv-details {
  flex: 1;
  min-width: 0;
}
.conv-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 4px;
}
.conv-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.conv-time {
  font-size: 11px;
  color: var(--text-muted);
}
.conv-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.conv-preview {
  font-size: 12.5px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 180px;
}
.conv-unread {
  background: var(--danger);
  color: white;
  font-size: 11px;
  font-weight: 700;
  padding: 1px 7px;
  border-radius: 10px;
  min-width: 18px;
  text-align: center;
}

/* Chat Area */
#chat-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: var(--bg-card);
}
#chat-placeholder {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  gap: 12px;
}
#chat-placeholder svg {
  width: 64px;
  height: 64px;
  stroke: #cbd5e1;
}

/* Active Chat Box */
#chat-active-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  height: 100%;
}
.chat-header {
  padding: 14px 24px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.chat-user-meta h3 {
  font-size: 16px;
  font-weight: 700;
}
.chat-user-meta span {
  font-size: 12px;
  color: var(--text-muted);
}
.btn-close-chat {
  background: #fef2f2;
  color: var(--danger);
  border: 1px solid #fee2e2;
  border-radius: 8px;
  padding: 6px 14px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}
.btn-close-chat:hover {
  background: var(--danger);
  color: white;
}

/* Messages List */
.messages-container {
  flex: 1;
  padding: 24px;
  overflow-y: auto;
  background: #f8fafc;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.msg-bubble-wrap {
  display: flex;
  flex-direction: column;
  max-width: 65%;
}
.msg-bubble-wrap.operator {
  align-self: flex-start;
  align-items: flex-start;
}
.msg-bubble-wrap.visitor {
  align-self: flex-end;
  align-items: flex-end;
}
.msg-bubble {
  padding: 12px 16px;
  border-radius: 16px;
  font-size: 14px;
  line-height: 1.5;
  word-break: break-word;
}
.msg-bubble-wrap.operator .msg-bubble {
  background: var(--primary);
  color: white;
  border-bottom-right-radius: 4px;
}
.msg-bubble-wrap.visitor .msg-bubble {
  background: #ffffff;
  color: var(--text-main);
  border: 1px solid var(--border);
  border-bottom-left-radius: 4px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}
.msg-meta {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 4px;
  padding: 0 4px;
}
.typing-box {
  display: none;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text-muted);
  padding: 6px 12px;
  background: #ffffff;
  border-radius: 12px;
  width: fit-content;
  border: 1px solid var(--border);
}

/* Chat Input Bar */
.chat-input-bar {
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: #ffffff;
}
.canned-chips {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 4px;
}
.chip {
  background: var(--bg-main);
  border: 1px solid var(--border);
  padding: 4px 12px;
  border-radius: 14px;
  font-size: 12px;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.2s;
}
.chip:hover {
  background: var(--primary-light);
  border-color: var(--primary);
  color: var(--primary);
}
.input-row {
  display: flex;
  align-items: center;
  gap: 12px;
}
.input-row textarea {
  flex: 1;
  border: 1.5px solid var(--border);
  border-radius: 12px;
  padding: 10px 16px;
  font-size: 14px;
  outline: none;
  resize: none;
  height: 48px;
  line-height: 1.4;
  transition: border-color 0.2s;
}
.input-row textarea:focus {
  border-color: var(--primary);
}
.btn-send {
  background: var(--primary);
  color: white;
  border: none;
  padding: 12px 24px;
  border-radius: 12px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: background 0.2s;
}
.btn-send:hover {
  background: var(--primary-hover);
}

/* Drawer / Info Sidebar */
#sidebar-info {
  width: 280px;
  background: var(--bg-card);
  border-right: 1px solid var(--border);
  padding: 24px 20px;
  overflow-y: auto;
}
.info-section {
  margin-bottom: 24px;
}
.info-section h4 {
  font-size: 13px;
  color: var(--text-muted);
  text-transform: uppercase;
  margin-bottom: 12px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 6px;
}
.info-item {
  margin-bottom: 12px;
}
.info-item label {
  display: block;
  font-size: 11px;
  color: var(--text-muted);
  margin-bottom: 2px;
}
.info-item span {
  font-size: 13.5px;
  font-weight: 500;
  word-break: break-word;
}
