/* ═══════════════════════════════════════
   NYROXIS AI — CHAT STYLES
═══════════════════════════════════════ */

#app {
  display: none;
  height: 100vh;
  flex-direction: column;
}

/* ─── TOPBAR ─── */
.topbar {
  height: 54px;
  background: var(--bg2);
  border-bottom: 1px solid var(--border2);
  display: flex;
  align-items: center;
  padding: 0 16px;
  gap: 10px;
  flex-shrink: 0;
  position: relative;
  z-index: 50;
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: 'Syne', sans-serif;
  font-size: 17px;
  font-weight: 800;
  color: var(--text);
  letter-spacing: -0.3px;
  text-decoration: none;
}

.brand img { width: 28px; height: 28px; object-fit: contain; }
.brand span { color: var(--orange); }
.topbar-spacer { flex: 1; }

.token-pill {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--bg3);
  border: 1px solid var(--border2);
  border-radius: 20px;
  padding: 5px 12px;
  font-size: 12px;
  font-family: 'JetBrains Mono', monospace;
  font-weight: 500;
  color: var(--text2);
  cursor: pointer;
  transition: all 0.2s;
  user-select: none;
}

.token-pill:hover { border-color: var(--border); color: var(--text); }

.token-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--green);
  flex-shrink: 0;
  animation: pulse 2s infinite;
}

.token-dot.low { background: var(--red); }

.profile-btn {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--orange-dim);
  border: 1.5px solid var(--border);
  color: var(--orange);
  font-family: 'Syne', sans-serif;
  font-size: 13px;
  font-weight: 800;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.profile-btn:hover { background: var(--orange); color: #fff; }

/* ─── PROFILE DROPDOWN ─── */
.profile-dropdown {
  position: absolute;
  top: 58px;
  right: 12px;
  background: var(--bg2);
  border: 1px solid var(--border2);
  border-radius: 14px;
  box-shadow: var(--shadow);
  min-width: 252px;
  z-index: 200;
  overflow: hidden;
  display: none;
}

.profile-dropdown.open {
  display: block;
  animation: fadeUp 0.2s ease;
}

.pd-header { padding: 16px; border-bottom: 1px solid var(--border2); }

.pd-email {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 6px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pd-plan { display: flex; align-items: center; gap: 7px; font-size: 12px; color: var(--text2); }

.pd-tokens { padding: 14px 16px; border-bottom: 1px solid var(--border2); }

.pd-token-row {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: var(--text2);
  margin-bottom: 8px;
  font-family: 'Syne', sans-serif;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.pd-track { background: var(--bg3); border-radius: 4px; height: 5px; overflow: hidden; }

.pd-fill {
  height: 100%;
  border-radius: 4px;
  background: var(--orange);
  transition: width 0.5s ease;
}

.dd-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 16px;
  font-size: 13px;
  color: var(--text2);
  cursor: pointer;
  transition: all 0.15s;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  font-family: 'DM Sans', sans-serif;
}

.dd-item:hover { background: var(--bg3); color: var(--text); }
.dd-item.danger { color: #F87171; }
.dd-item.danger:hover { background: rgba(240,82,79,0.08); color: var(--red); }
.dd-icon { width: 18px; text-align: center; font-size: 14px; }

/* ─── LAYOUT ─── */
.main-layout { display: flex; flex: 1; overflow: hidden; }

/* ─── SIDEBAR ─── */
.sidebar {
  width: 248px;
  background: var(--bg2);
  border-right: 1px solid var(--border2);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  transition: width 0.25s ease;
}

.sidebar-top { padding: 12px; border-bottom: 1px solid var(--border2); }

.new-chat-btn {
  width: 100%;
  padding: 9px 14px;
  background: var(--orange-dim);
  border: 1px solid var(--border);
  border-radius: 9px;
  color: var(--orange);
  font-family: 'Syne', sans-serif;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  letter-spacing: 0.02em;
}

.new-chat-btn:hover { background: var(--orange); color: #fff; }

.sidebar-body { flex: 1; overflow-y: auto; padding: 8px; }

.sb-section { font-size: 10px; font-weight: 700; color: var(--text3); text-transform: uppercase; letter-spacing: 0.1em; padding: 8px 8px 4px; font-family: 'Syne', sans-serif; }

.conv-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.15s;
  font-size: 13px;
  color: var(--text2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 1px;
  border: 1px solid transparent;
}

.conv-item:hover { background: var(--bg3); color: var(--text); }
.conv-item.active { background: var(--orange-dim2); border-color: var(--border); color: var(--orange); }
.conv-icon { font-size: 12px; flex-shrink: 0; }

.sb-empty { padding: 28px 8px; text-align: center; font-size: 12px; color: var(--text3); line-height: 1.8; }

/* Upgrade banner */
.upgrade-banner {
  flex-shrink: 0;
  margin: 8px;
  padding: 12px 14px;
  background: var(--orange-dim);
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 12px;
  color: var(--text2);
  line-height: 1.6;
}

.upgrade-banner strong { color: var(--orange); display: block; margin-bottom: 4px; font-family: 'Syne', sans-serif; font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em; }

.upgrade-btn {
  display: block;
  width: 100%;
  margin-top: 10px;
  padding: 8px;
  background: var(--orange);
  color: #fff;
  border: none;
  border-radius: 7px;
  font-family: 'Syne', sans-serif;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
  text-align: center;
  text-decoration: none;
}

.upgrade-btn:hover { background: var(--orange-h); }

/* ─── CHAT AREA ─── */
.chat-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--bg);
}

/* Quick action bar */
.quick-bar {
  padding: 10px 20px;
  display: flex;
  gap: 7px;
  overflow-x: auto;
  border-bottom: 1px solid var(--border2);
  background: var(--bg2);
  flex-shrink: 0;
}

.quick-bar::-webkit-scrollbar { height: 0; }

.q-btn {
  padding: 6px 13px;
  background: var(--bg3);
  border: 1px solid var(--border2);
  border-radius: 20px;
  color: var(--text2);
  font-size: 12px;
  font-family: 'DM Sans', sans-serif;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
  flex-shrink: 0;
}

.q-btn:hover { background: var(--orange-dim); border-color: var(--border); color: var(--orange); }

/* Messages */
.messages {
  flex: 1;
  overflow-y: auto;
  padding: 28px 24px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* Welcome screen */
.welcome {
  background: transparent;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 48px 24px;
  text-align: center;
  flex: 1;
  min-height: 300px;
}

.welcome-logo {
  width: 64px;
  height: 64px;
  object-fit: contain;
  filter: drop-shadow(0 0 20px rgba(251,118,30,0.35));
  animation: float 4s ease-in-out infinite;
}

.welcome h2 {
  font-family: 'Syne', sans-serif;
  font-size: 28px;
  font-weight: 800;
  letter-spacing: -0.5px;
  line-height: 1.2;
  color: var(--text);
}

.welcome h2 span { color: var(--orange); }

.welcome p {
  font-size: 14px;
  color: var(--text2);
  max-width: 420px;
  line-height: 1.75;
}

.welcome-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  margin-top: 8px;
  max-width: 560px;
}

.welcome-chip {
  padding: 8px 16px;
  background: var(--bg2);
  border: 1px solid var(--border2);
  border-radius: 8px;
  font-size: 13px;
  color: var(--text2);
  cursor: pointer;
  transition: all 0.2s;
  font-family: 'DM Sans', sans-serif;
}

.welcome-chip:hover {
  background: var(--orange-dim);
  border-color: var(--border);
  color: var(--orange);
  transform: translateY(-2px);
}

/* Message bubbles */
.message {
  display: flex;
  gap: 12px;
  max-width: 820px;
  margin: 0 auto;
  width: 100%;
  animation: msgSlide 0.2s ease;
}

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

.msg-avatar {
  width: 32px;
  height: 32px;
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 800;
  flex-shrink: 0;
  margin-top: 2px;
  font-family: 'Syne', sans-serif;
}

.msg-avatar.ai {
  background: var(--orange-dim);
  border: 1px solid var(--border);
}

.msg-avatar.ai img { width: 18px; height: 18px; object-fit: contain; }
.msg-avatar.user { background: var(--bg3); border: 1px solid var(--border2); color: var(--text2); }

.msg-content { flex: 1; min-width: 0; }

.msg-bubble {
  padding: 13px 16px;
  border-radius: 13px;
  font-size: 14px;
  line-height: 1.75;
}

.message.user .msg-bubble {
  background: var(--user-bg);
  border: 1px solid var(--border);
  border-radius: 13px 4px 13px 13px;
}

.message.ai .msg-bubble {
  background: var(--ai-bg);
  border: 1px solid var(--border2);
  border-radius: 4px 13px 13px 13px;
}

/* Message content formatting */
.msg-bubble h2, .msg-bubble h3 {
  font-family: 'Syne', sans-serif;
  font-size: 14px;
  font-weight: 700;
  color: var(--orange);
  margin: 14px 0 6px;
}

.msg-bubble h2:first-child, .msg-bubble h3:first-child { margin-top: 0; }
.msg-bubble p { margin-bottom: 10px; }
.msg-bubble p:last-child { margin-bottom: 0; }
.msg-bubble ul, .msg-bubble ol { padding-left: 18px; margin-bottom: 10px; }
.msg-bubble li { margin-bottom: 5px; }
.msg-bubble strong { font-weight: 700; }
.msg-bubble em { font-style: italic; color: var(--text2); }

.msg-bubble code {
  background: var(--bg3);
  border: 1px solid var(--border2);
  padding: 2px 6px;
  border-radius: 4px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  color: var(--orange);
}

.msg-bubble pre {
  background: var(--bg3);
  border: 1px solid var(--border2);
  border-radius: 9px;
  padding: 14px 16px;
  overflow-x: auto;
  margin: 10px 0;
}

.msg-bubble pre code {
  background: none;
  border: none;
  padding: 0;
  color: var(--text);
  font-size: 12px;
  line-height: 1.6;
}

.msg-meta {
  font-size: 11px;
  color: var(--text3);
  margin-top: 5px;
  font-family: 'JetBrains Mono', monospace;
  padding: 0 3px;
}

.message.user .msg-meta { text-align: right; }

/* Image in message */
.msg-image {
  max-width: 280px;
  border-radius: 9px;
  border: 1px solid var(--border2);
  margin-bottom: 8px;
  display: block;
}

/* Typing indicator */
.typing-dots {
  display: flex;
  gap: 4px;
  align-items: center;
  padding: 14px 16px;
}

.dot {
  width: 7px;
  height: 7px;
  background: var(--orange);
  border-radius: 50%;
  animation: bounce 1.3s infinite;
  opacity: 0.5;
}

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

/* Streaming cursor */
.stream-cursor {
  display: inline-block;
  width: 2px;
  height: 14px;
  background: var(--orange);
  margin-left: 2px;
  vertical-align: middle;
  animation: pulse 1s infinite;
}

/* No tokens warning */
.no-tokens-warn {
  display: none;
  background: rgba(240,82,79,0.08);
  border: 1px solid rgba(240,82,79,0.2);
  border-radius: 9px;
  padding: 10px 16px;
  font-size: 13px;
  color: #FCA5A5;
  text-align: center;
  margin: 0 20px 10px;
}

/* ─── INPUT ZONE ─── */
.input-zone {
  padding: 12px 20px 16px;
  background: var(--bg2);
  border-top: 1px solid var(--border2);
  flex-shrink: 0;
}

/* Image preview */
.image-preview-wrap {
  display: none;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
  max-width: 820px;
  margin-left: auto;
  margin-right: auto;
}

.image-preview-wrap.show { display: flex; }

.image-preview {
  width: 56px;
  height: 56px;
  border-radius: 8px;
  object-fit: cover;
  border: 1px solid var(--border);
}

.image-preview-name {
  font-size: 12px;
  color: var(--text2);
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.image-preview-cost {
  font-size: 11px;
  color: var(--orange);
  font-family: 'JetBrains Mono', monospace;
  white-space: nowrap;
}

.image-remove {
  width: 24px;
  height: 24px;
  border-radius: 6px;
  background: rgba(240,82,79,0.1);
  border: none;
  cursor: pointer;
  color: var(--red);
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.image-remove:hover { background: rgba(240,82,79,0.2); }

/* Input box */
.input-box {
  display: flex;
  gap: 8px;
  align-items: flex-end;
  background: var(--input-bg);
  border: 1.5px solid var(--border2);
  border-radius: 14px;
  padding: 10px 12px;
  max-width: 820px;
  margin: 0 auto;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.input-box:focus-within {
  border-color: var(--orange);
  box-shadow: 0 0 0 3px var(--orange-dim);
}

#chat-input {
  flex: 1;
  background: none;
  border: none;
  color: var(--text);
  font-family: 'DM Sans', sans-serif;
  font-size: 14px;
  resize: none;
  outline: none;
  max-height: 130px;
  line-height: 1.55;
  min-height: 22px;
}

#chat-input::placeholder { color: var(--text3); }

.input-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.attach-btn {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: var(--bg3);
  border: 1px solid var(--border2);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  color: var(--text2);
  font-size: 15px;
  flex-shrink: 0;
}

.attach-btn:hover { background: var(--orange-dim); color: var(--orange); border-color: var(--border); }
.attach-btn.pro-only { position: relative; }

.send-btn {
  width: 34px;
  height: 34px;
  background: var(--orange);
  border: none;
  border-radius: 9px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  flex-shrink: 0;
  color: #fff;
  box-shadow: 0 2px 10px rgba(251,118,30,0.3);
}

.send-btn:hover { background: var(--orange-h); transform: scale(1.06); }
.send-btn:disabled { opacity: 0.4; cursor: not-allowed; transform: none; box-shadow: none; }
.send-btn svg { width: 14px; height: 14px; }

.input-hint {
  text-align: center;
  font-size: 11px;
  color: var(--text3);
  margin-top: 8px;
  max-width: 820px;
  margin-left: auto;
  margin-right: auto;
  font-family: 'JetBrains Mono', monospace;
}

/* RTL support for Persian and Hebrew */
[dir="rtl"] .message.user {
  flex-direction: row;
}

[dir="rtl"] .message.user .msg-bubble {
  border-radius: 4px 13px 13px 13px;
  text-align: right;
}

[dir="rtl"] .message.ai .msg-bubble {
  border-radius: 13px 4px 13px 13px;
  text-align: right;
}

[dir="rtl"] .message.user .msg-meta {
  text-align: left;
}

[dir="rtl"] .sidebar {
  border-right: none;
  border-left: 1px solid var(--border2);
}

[dir="rtl"] .msg-bubble ul,
[dir="rtl"] .msg-bubble ol {
  padding-right: 18px;
  padding-left: 0;
}

/* RTL — topbar and sidebar always LTR */
[dir="rtl"] .topbar {
  direction: ltr;
  flex-direction: row;
}

[dir="rtl"] .sidebar {
  direction: ltr;
  right: auto;
  left: 0;
}

[dir="rtl"] .main-layout {
  flex-direction: row;
}

[dir="rtl"] .quick-bar {
  direction: ltr;
}

[dir="rtl"] .input-zone {
  direction: rtl;
}
[dir="rtl"] .input-box {
  direction: rtl;
  flex-direction: row-reverse;
}

[dir="rtl"] #chat-input {
  direction: rtl;
  text-align: right;
}

/* ─── LANGUAGE FLAGS ─── */
.lang-flag {
  cursor: pointer;
  font-size: 20px;
  padding: 3px 5px;
  border-radius: 6px;
  transition: all 0.2s;
  opacity: 0.5;
}
.lang-flag:hover { opacity: 1; transform: scale(1.1); }
.lang-flag.active { opacity: 1; background: var(--orange-dim); outline: 2px solid var(--orange); }

/* ─── HIDE ELEMENTS GLOBALLY ─── 
.brand-badge { display: none; }*/
.token-pill  { display: none; }
.hamburger-btn { display: none; }

/* ─── MOBILE SIDEBAR OVERLAY ─── */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 299;
}
.sidebar-overlay.show { display: block; }

/* Delete button on conversation items */
.conv-title {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.conv-delete {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  font-size: 13px;
  padding: 2px 4px;
  border-radius: 4px;
  opacity: 0.6;
  flex-shrink: 0;
  transition: all 0.2s;
}

.conv-delete:hover { opacity: 1; background: rgba(240,82,79,0.15); }
.conv-item:hover .conv-delete { display: block; }

/*----Support----*/
@supports (padding: env(safe-area-inset-bottom)) {
  .topbar {
    padding-top: var(--safe-top);
  }
  .input-zone {
    padding-bottom: calc(12px + var(--safe-bottom));
  }
  .sidebar {
    padding-bottom: var(--safe-bottom);
  }
}

/* ── Trial Banner ── */
#trial-banner {
  padding: 10px 16px;
  background: linear-gradient(135deg, rgba(251,118,30,.12), rgba(251,118,30,.06));
  border-bottom: 1px solid rgba(251,118,30,.25);
}
.trial-banner-inner {
  display: flex;
  align-items: center;
  gap: 12px;
  max-width: 800px;
  margin: 0 auto;
}
.trial-badge {
  background: var(--orange);
  color: #fff;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}
#trial-days {
  font-size: 12px;
  color: var(--text2);
  white-space: nowrap;
}
.trial-bar-wrap {
  flex: 1;
  height: 4px;
  background: var(--border);
  border-radius: 4px;
  overflow: hidden;
}
.trial-bar-fill {
  height: 100%;
  background: var(--orange);
  border-radius: 4px;
  transition: width .5s ease;
}
.trial-upgrade-btn {
  background: var(--orange);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 6px 14px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  transition: background .2s;
}
.trial-upgrade-btn:hover { background: var(--orange-h); }
/* RTL fix for trial banner and mode toggle */
[dir="rtl"] .trial-banner-inner {
  direction: ltr;
}
[dir="rtl"] #mode-toggle {
  direction: ltr;
}
/* ─── MOBILE ─── */
@media (max-width: 768px) {

  /* Topbar */
  .topbar { padding: 0 12px; gap: 8px; height: 50px; }
  .brand { font-size: 14px; }
  .brand img { width: 22px; height: 22px; }
  .icon-btn { width: 30px; height: 30px; font-size: 13px; }
  .profile-btn { width: 30px; height: 30px; font-size: 11px; }
  .topbar-spacer { min-width: 0; }
  .hamburger-btn { display: flex; }
  .brand-badge { display: none !important; }

  /* Chat layout */
  .chat-area { width: 100%; }
  .quick-bar { padding: 8px 10px; gap: 6px; }
  .q-btn { font-size: 11px; padding: 5px 10px; }
  .messages { padding: 12px 10px 80px; }
  .message { max-width: 100%; }
 
  /* RTL mobile fix */
  [dir="rtl"] .trial-banner-inner {
    direction: ltr;
  }
  [dir="rtl"] #mode-toggle {
    direction: ltr;
    text-align: left;
  }
  [dir="rtl"] .input-zone {
    direction: ltr;
  }

/* Flexbox layout instead of fixed positioning */
  .chat-area {
    display: flex;
    flex-direction: column;
    height: calc(100dvh - 50px - 42px);
  }

  .messages {
    flex: 1;
    overflow-y: auto;
    padding: 12px 10px;
    padding-bottom: 16px;
  }

  .input-zone {
    flex-shrink: 0;
    position: relative;
    padding: 8px 12px 12px;
    background: var(--bg2);
    border-top: 1px solid var(--border2);
  }  

  .input-hint {
    font-size: 10px;
    line-height: 1.4;
    margin-top: 2px;
  }

  /* Sidebar as overlay */
  .sidebar {
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    height: 100svh;
    z-index: 300;
    will-change: transform;
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    box-shadow: var(--shadow);
    pointer-events: none;
  }
  .sidebar.open {
    transform: translateX(0);
    pointer-events: auto;
  }
  
  [dir="rtl"] .sidebar-top,
  [dir="rtl"] .sidebar-body,
  [dir="rtl"] .upgrade-banner {
    direction: ltr;
  }
   
  .sidebar-body {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
  }
  .upgrade-banner {
    flex-shrink: 0;
    font-size: 11px;
  }

  .upgrade-banner strong {
    font-size: 10px;
  }

  .upgrade-btn {
    padding: 6px;
    font-size: 11px;
  }

  /* Welcome screen */
  .welcome { padding: 20px 16px; gap: 12px; }
  .welcome h2 { font-size: 20px; }
  .welcome p { font-size: 13px; }
  .welcome-chips { gap: 6px; }
  .welcome-chip { font-size: 12px; padding: 6px 12px; }
  
  .msg-bubble li { margin-bottom: 2px; }
  .msg-bubble p { margin-bottom: 6px; }
  .msg-bubble ul, .msg-bubble ol { margin-bottom: 6px; }

  /* Misc */
  .no-tokens-warn { margin: 0 10px 8px; font-size: 12px; }
}
