/* ============================================================
   Agent Project - Dark Glass Theme
   طراحی شیشه‌ای دارک و ذغالی - منحصر به فرد
   ============================================================ */

/* --- فونت Vazirmatn (فارسی) --- */
@import url('https://cdn.jsdelivr.net/gh/rastikerdar/vazirmatn@v33.003/Vazirmatn-font-face.css');

/* --- متغیرهای رنگ --- */
:root {
  /* پس‌زمینه: ذغالی عمیق با ته‌رنگ آبی */
  --bg-base: #07080d;
  --bg-deep: #0a0c14;
  --bg-mid: #11141f;

  /* شیشه */
  --glass-bg: rgba(22, 26, 38, 0.55);
  --glass-bg-strong: rgba(22, 26, 38, 0.75);
  --glass-border: rgba(255, 255, 255, 0.08);
  --glass-border-hover: rgba(255, 255, 255, 0.14);
  --glass-shine: rgba(255, 255, 255, 0.04);

  /* متن */
  --text-primary: #ecedf2;
  --text-secondary: #a4a8b8;
  --text-muted: #6b7080;

  /* رنگ‌های تاکیدی (گرادیان منحصر به فرد: سبز نعنایی → آبی الکتریک) */
  --accent-1: #00d4aa;
  --accent-2: #5b73ff;
  --accent-gradient: linear-gradient(135deg, #00d4aa 0%, #5b73ff 100%);
  --accent-gradient-hover: linear-gradient(135deg, #00e8bb 0%, #6d83ff 100%);
  --accent-glow: rgba(91, 115, 255, 0.35);

  /* خطر / خطا */
  --danger: #ff5570;
  --danger-bg: rgba(255, 85, 112, 0.12);

  /* موفقیت */
  --success: #00d4aa;

  /* اندازه‌ها */
  --radius-sm: 10px;
  --radius-md: 16px;
  --radius-lg: 24px;
  --radius-xl: 32px;
  --transition: 0.32s cubic-bezier(0.4, 0, 0.2, 1);
}

/* --- ریست پایه --- */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  height: 100%;
  width: 100%;
  /* برای موبایل: استفاده از 100% معادل ارتفاع viewport داینامیک */
}

@supports (height: 100dvh) {
  html, body {
    height: 100dvh;
  }
}

body {
  font-family: 'Vazirmatn', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg-base);
  color: var(--text-primary);
  min-height: 100vh;
  overflow-x: hidden;
  direction: rtl;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  position: relative;
}

/* ============================================================
   پس‌زمینه متحرک - ایجاد حس عمق و بُعد
   ============================================================ */
.bg-aurora {
  position: fixed;
  inset: 0;
  z-index: -2;
  background:
    radial-gradient(circle at 15% 20%, rgba(0, 212, 170, 0.10) 0%, transparent 40%),
    radial-gradient(circle at 85% 80%, rgba(91, 115, 255, 0.10) 0%, transparent 45%),
    radial-gradient(circle at 50% 50%, rgba(180, 90, 255, 0.04) 0%, transparent 60%),
    linear-gradient(180deg, var(--bg-deep) 0%, var(--bg-base) 100%);
  overflow: hidden;
}

.bg-aurora::before,
.bg-aurora::after {
  content: "";
  position: absolute;
  width: 60vmax;
  height: 60vmax;
  border-radius: 50%;
  filter: blur(120px);
  opacity: 0.35;
  animation: float-slow 22s ease-in-out infinite;
}

.bg-aurora::before {
  background: radial-gradient(circle, var(--accent-1) 0%, transparent 70%);
  top: -20%;
  right: -10%;
}

.bg-aurora::after {
  background: radial-gradient(circle, var(--accent-2) 0%, transparent 70%);
  bottom: -20%;
  left: -10%;
  animation-delay: -11s;
}

@keyframes float-slow {
  0%, 100% { transform: translate(0, 0) scale(1); }
  50% { transform: translate(8%, -5%) scale(1.08); }
}

/* شبکه‌ی نقطه‌چین ظریف */
.bg-grid {
  position: fixed;
  inset: 0;
  z-index: -1;
  background-image:
    radial-gradient(circle, rgba(255, 255, 255, 0.025) 1px, transparent 1px);
  background-size: 36px 36px;
  pointer-events: none;
  mask-image: radial-gradient(ellipse at center, black 30%, transparent 75%);
  -webkit-mask-image: radial-gradient(ellipse at center, black 30%, transparent 75%);
}

/* ============================================================
   قاب شیشه‌ای اصلی (Auth Pages)
   ============================================================ */
.auth-wrapper {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  position: relative;
}

.auth-card {
  width: 100%;
  max-width: 440px;
  background: var(--glass-bg);
  backdrop-filter: blur(28px) saturate(140%);
  -webkit-backdrop-filter: blur(28px) saturate(140%);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-xl);
  padding: 44px 40px 36px;
  position: relative;
  box-shadow:
    0 24px 80px rgba(0, 0, 0, 0.45),
    0 4px 12px rgba(0, 0, 0, 0.25),
    inset 0 1px 0 var(--glass-shine);
  animation: card-rise 0.7s cubic-bezier(0.16, 1, 0.3, 1) both;
}

@keyframes card-rise {
  from {
    opacity: 0;
    transform: translateY(24px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* درخشش بالایی کارت */
.auth-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 20%;
  right: 20%;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--accent-1), var(--accent-2), transparent);
  opacity: 0.6;
}

/* --- لوگو / برند --- */
.brand {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-bottom: 8px;
}

.brand-logo {
  width: 46px;
  height: 46px;
  border-radius: 14px;
  background: var(--accent-gradient);
  display: grid;
  place-items: center;
  position: relative;
  box-shadow: 0 6px 24px var(--accent-glow);
}

.brand-logo svg {
  width: 26px;
  height: 26px;
  color: #fff;
}

.brand-name {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.3px;
  background: var(--accent-gradient);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

/* --- عنوان فرم --- */
.auth-card h1 {
  font-size: 20px;
  font-weight: 600;
  text-align: center;
  margin-top: 16px;
  margin-bottom: 4px;
  color: var(--text-primary);
}

.auth-card .subtitle {
  text-align: center;
  font-size: 13.5px;
  color: var(--text-secondary);
  margin-bottom: 28px;
}

/* ============================================================
   فیلدهای فرم
   ============================================================ */
.form-field {
  margin-bottom: 18px;
  position: relative;
}

.form-field label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 8px;
  padding-right: 4px;
}

.input-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.input-wrap .input-icon {
  position: absolute;
  right: 14px;
  pointer-events: none;
  color: var(--text-muted);
  transition: color var(--transition);
  display: flex;
}

.input-wrap .input-icon svg {
  width: 18px;
  height: 18px;
}

.form-input {
  width: 100%;
  padding: 13px 44px 13px 16px;
  background: rgba(8, 10, 16, 0.55);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: 14.5px;
  font-family: inherit;
  transition: all var(--transition);
  outline: none;
}

.form-input::placeholder {
  color: var(--text-muted);
}

.form-input:hover {
  border-color: var(--glass-border-hover);
  background: rgba(8, 10, 16, 0.65);
}

.form-input:focus {
  border-color: var(--accent-2);
  background: rgba(8, 10, 16, 0.75);
  box-shadow:
    0 0 0 4px rgba(91, 115, 255, 0.12),
    0 0 24px rgba(91, 115, 255, 0.08);
}

.form-input:focus + .input-icon,
.input-wrap:focus-within .input-icon {
  color: var(--accent-2);
}

/* دکمه نمایش/پنهان رمز */
.toggle-pwd {
  position: absolute;
  left: 10px;
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 6px;
  border-radius: 8px;
  color: var(--text-muted);
  display: flex;
  transition: all var(--transition);
}

.toggle-pwd:hover {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.05);
}

.toggle-pwd svg {
  width: 18px;
  height: 18px;
}

/* --- پیام خطا --- */
.error-msg {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--danger-bg);
  border: 1px solid rgba(255, 85, 112, 0.25);
  color: var(--danger);
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  margin-bottom: 20px;
  animation: shake 0.4s;
}

.error-msg svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-4px); }
  75% { transform: translateX(4px); }
}

/* ============================================================
   دکمه اصلی
   ============================================================ */
.btn-primary {
  width: 100%;
  padding: 14px 20px;
  background: var(--accent-gradient);
  background-size: 150% 150%;
  color: #fff;
  border: none;
  border-radius: var(--radius-md);
  font-size: 15px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: all var(--transition);
  position: relative;
  overflow: hidden;
  box-shadow:
    0 6px 20px rgba(91, 115, 255, 0.25),
    0 2px 8px rgba(0, 212, 170, 0.18);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.btn-primary:hover {
  background-position: 100% 100%;
  transform: translateY(-1px);
  box-shadow:
    0 10px 28px rgba(91, 115, 255, 0.35),
    0 4px 12px rgba(0, 212, 170, 0.25);
}

.btn-primary:active {
  transform: translateY(0);
}

.btn-primary:disabled {
  opacity: 0.7;
  cursor: not-allowed;
  transform: none;
}

/* درخشش متحرک روی دکمه */
.btn-primary::after {
  content: "";
  position: absolute;
  top: 0;
  left: -100%;
  width: 60%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.18), transparent);
  transform: skewX(-20deg);
  transition: left 0.6s;
}

.btn-primary:hover::after {
  left: 130%;
}

/* --- لینک پایین (ثبت‌نام / ورود) --- */
.auth-footer {
  text-align: center;
  margin-top: 26px;
  padding-top: 22px;
  border-top: 1px solid var(--glass-border);
  font-size: 13.5px;
  color: var(--text-secondary);
}

.auth-footer a {
  color: var(--accent-1);
  text-decoration: none;
  font-weight: 600;
  transition: color var(--transition);
  position: relative;
}

.auth-footer a::after {
  content: "";
  position: absolute;
  bottom: -2px;
  right: 0;
  width: 0;
  height: 1px;
  background: var(--accent-1);
  transition: width var(--transition);
}

.auth-footer a:hover {
  color: var(--accent-2);
}

.auth-footer a:hover::after {
  width: 100%;
}

/* ============================================================
   صفحه چت
   ============================================================ */
.chat-app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  position: relative;
}

/* --- هدر --- */
.chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 28px;
  background: var(--glass-bg-strong);
  backdrop-filter: blur(20px) saturate(140%);
  -webkit-backdrop-filter: blur(20px) saturate(140%);
  border-bottom: 1px solid var(--glass-border);
  position: relative;
  z-index: 10;
}

.chat-header::after {
  content: "";
  position: absolute;
  bottom: 0;
  left: 20%;
  right: 20%;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--glass-border-hover), transparent);
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.header-brand .brand-logo {
  width: 38px;
  height: 38px;
  border-radius: 11px;
}

.header-brand .brand-logo svg {
  width: 22px;
  height: 22px;
}

.header-brand .brand-name {
  font-size: 18px;
}

.header-brand .status {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11.5px;
  color: var(--text-secondary);
  margin-top: 2px;
}

.status .dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--success);
  box-shadow: 0 0 8px var(--success);
  animation: pulse-dot 2s infinite;
}

@keyframes pulse-dot {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

.header-user {
  display: flex;
  align-items: center;
  gap: 14px;
}

.user-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 14px 6px 6px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--glass-border);
  border-radius: 999px;
  font-size: 13.5px;
  color: var(--text-primary);
}

.user-avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--accent-gradient);
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 13px;
  color: #fff;
}

.btn-logout {
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(255, 85, 112, 0.08);
  color: var(--danger);
  border: 1px solid rgba(255, 85, 112, 0.18);
  padding: 7px 14px;
  border-radius: 10px;
  font-size: 13px;
  font-family: inherit;
  cursor: pointer;
  transition: all var(--transition);
  text-decoration: none;
}

.btn-logout:hover {
  background: rgba(255, 85, 112, 0.15);
  border-color: rgba(255, 85, 112, 0.35);
}

.btn-logout svg {
  width: 15px;
  height: 15px;
}

/* --- محتوای چت --- */
.chat-main {
  flex: 1;
  overflow-y: auto;
  padding: 32px 24px 24px;
  scroll-behavior: smooth;
}

.chat-main::-webkit-scrollbar {
  width: 8px;
}
.chat-main::-webkit-scrollbar-track {
  background: transparent;
}
.chat-main::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.08);
  border-radius: 4px;
}
.chat-main::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.16);
}

.chat-inner {
  max-width: 820px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* پیام خوش‌آمدگویی */
.welcome-msg {
  text-align: center;
  padding: 48px 24px 24px;
  animation: card-rise 0.8s cubic-bezier(0.16, 1, 0.3, 1) both;
}

.welcome-msg .welcome-icon {
  width: 72px;
  height: 72px;
  margin: 0 auto 18px;
  border-radius: 22px;
  background: var(--accent-gradient);
  display: grid;
  place-items: center;
  box-shadow: 0 12px 40px var(--accent-glow);
  position: relative;
}

.welcome-msg .welcome-icon::before {
  content: "";
  position: absolute;
  inset: -8px;
  border-radius: 28px;
  background: var(--accent-gradient);
  opacity: 0.2;
  filter: blur(16px);
  z-index: -1;
}

.welcome-msg .welcome-icon svg {
  width: 38px;
  height: 38px;
  color: #fff;
}

.welcome-msg h2 {
  font-size: 24px;
  font-weight: 700;
  margin-bottom: 8px;
  background: var(--accent-gradient);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.welcome-msg p {
  font-size: 14.5px;
  color: var(--text-secondary);
  max-width: 480px;
  margin: 0 auto;
  line-height: 1.7;
}

/* --- حباب پیام --- */
.msg-row {
  display: flex;
  gap: 12px;
  animation: msg-in 0.4s cubic-bezier(0.16, 1, 0.3, 1) both;
}

@keyframes msg-in {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

.msg-row.user {
  flex-direction: row-reverse;
}

.msg-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  flex-shrink: 0;
  display: grid;
  place-items: center;
  font-size: 13px;
  font-weight: 700;
}

.msg-row.user .msg-avatar {
  background: var(--accent-gradient);
  color: #fff;
}

.msg-row.assistant .msg-avatar {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--glass-border);
  color: var(--accent-1);
}

.msg-avatar svg {
  width: 18px;
  height: 18px;
}

.msg-bubble {
  max-width: 75%;
  padding: 12px 16px;
  border-radius: 16px;
  font-size: 14.5px;
  line-height: 1.7;
  word-wrap: break-word;
  white-space: pre-wrap;
}

.msg-row.user .msg-bubble {
  background: var(--accent-gradient);
  color: #fff;
  border-bottom-right-radius: 4px;
  box-shadow: 0 4px 16px rgba(91, 115, 255, 0.2);
}

.msg-row.assistant .msg-bubble {
  background: var(--glass-bg-strong);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--glass-border);
  color: var(--text-primary);
  border-bottom-left-radius: 4px;
}

/* --- نشانگر تایپ --- */
.typing-indicator {
  display: flex;
  gap: 4px;
  align-items: center;
  padding: 14px 18px;
}

.typing-indicator span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--text-muted);
  animation: typing-bounce 1.4s infinite ease-in-out;
}

.typing-indicator span:nth-child(2) { animation-delay: 0.2s; }
.typing-indicator span:nth-child(3) { animation-delay: 0.4s; }

@keyframes typing-bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30% { transform: translateY(-6px); opacity: 1; }
}

/* --- نوار ورود (Composer) --- */
.composer-wrap {
  padding: 12px 24px 28px;  /* 28px فاصله از پایین */
  background: linear-gradient(180deg, transparent, rgba(7, 8, 13, 0.6) 30%, rgba(7, 8, 13, 0.95));
  position: relative;
  z-index: 5;
}

.composer {
  max-width: 820px;
  margin: 0 auto;
  background: var(--glass-bg-strong);
  backdrop-filter: blur(24px) saturate(140%);
  -webkit-backdrop-filter: blur(24px) saturate(140%);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  padding: 10px 10px 10px 12px;
  display: flex;
  align-items: flex-end;
  gap: 10px;
  box-shadow:
    0 12px 40px rgba(0, 0, 0, 0.4),
    inset 0 1px 0 var(--glass-shine);
  transition: all var(--transition);
}

.composer:focus-within {
  border-color: var(--accent-2);
  box-shadow:
    0 12px 40px rgba(0, 0, 0, 0.4),
    0 0 0 4px rgba(91, 115, 255, 0.10),
    inset 0 1px 0 var(--glass-shine);
}

.composer textarea {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text-primary);
  font-family: inherit;
  font-size: 14.5px;
  line-height: 1.6;
  resize: none;
  padding: 10px 6px;
  max-height: 180px;
  min-height: 24px;
}

.composer textarea::placeholder {
  color: var(--text-muted);
}

.send-btn {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: var(--accent-gradient);
  border: none;
  cursor: pointer;
  display: grid;
  place-items: center;
  color: #fff;
  transition: all var(--transition);
  flex-shrink: 0;
  box-shadow: 0 4px 14px rgba(91, 115, 255, 0.3);
}

.send-btn:hover:not(:disabled) {
  transform: scale(1.06);
  box-shadow: 0 6px 20px rgba(91, 115, 255, 0.45);
}

.send-btn:active:not(:disabled) {
  transform: scale(0.96);
}

.send-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  box-shadow: none;
}

.send-btn svg {
  width: 20px;
  height: 20px;
  transform: rotate(180deg);  /* برای RTL */
}

/* --- ریسپانسیو --- */
@media (max-width: 640px) {
  .auth-card {
    padding: 36px 24px 28px;
    max-width: 100%;
  }

  .chat-header {
    padding: 12px 16px;
  }

  .header-brand .brand-name {
    font-size: 16px;
  }

  .user-chip span:not(.user-avatar) {
    display: none;
  }

  .btn-logout span {
    display: none;
  }

  .chat-main {
    padding: 20px 14px 14px;
  }

  .composer-wrap {
    padding: 10px 14px 22px;
  }

  .msg-bubble {
    max-width: 82%;
    font-size: 14px;
  }
}

/* --- کاربردی: hide scroll on body when chat --- */
body.chat-body {
  overflow: hidden;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  width: 100%;
  height: 100%;
}

@supports (height: 100dvh) {
  body.chat-body {
    height: 100dvh;
  }
}
