/* ── RESET ───────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* ── LIGHT THEME ─────────────────────────────────────────── */
:root {
  --red:        #C8102E;
  --red-dark:   #a00d24;
  --red-light:  #fdf0f2;
  --red-mid:    #f5c0c9;
  --font:       'DM Sans', sans-serif;
  --radius:     10px;
  --radius-lg:  16px;

  --bg-body:             #f9f9f8;
  --bg-surface:          #ffffff;
  --bg-sidebar:          #ffffff;
  --bg-input:            #f9f9f8;
  --bg-input-focus:      #ffffff;
  --bg-topbar:           #ffffff;
  --bg-auth-right:       #ffffff;
  --bg-bubble-user:      #C8102E;
  --bg-bubble-bot:       #ffffff;
  --bg-typing:           #ffffff;
  --bg-modal:            #ffffff;
  --bg-overlay:          rgba(0,0,0,0.45);
  --bg-chip:             #f0efed;
  --bg-chat-item-hover:  #f9f9f8;
  --bg-chat-item-active: #fdf0f2;
  --bg-msg-actions:      #f9f9f8;

  --text-primary:      #2a2a28;
  --text-secondary:    #5a5955;
  --text-muted:        #9b9a96;
  --text-bubble-user:  #ffffff;
  --text-bubble-bot:   #2a2a28;
  --text-chat-active:  #C8102E;

  --border-main:   #e3e2df;
  --shadow-modal:  0 20px 60px rgba(0,0,0,0.12);
}

/* ── DARK THEME ──────────────────────────────────────────── */
[data-theme="dark"] {
  --bg-body:             #1a1a1a;
  --bg-surface:          #242424;
  --bg-sidebar:          #1e1e1e;
  --bg-input:            #2a2a2a;
  --bg-input-focus:      #2f2f2f;
  --bg-topbar:           #1e1e1e;
  --bg-auth-right:       #1e1e1e;
  --bg-bubble-user:      #C8102E;
  --bg-bubble-bot:       #2a2a2a;
  --bg-typing:           #2a2a2a;
  --bg-modal:            #242424;
  --bg-overlay:          rgba(0,0,0,0.65);
  --bg-chip:             #2a2a2a;
  --bg-chat-item-hover:  #2a2a2a;
  --bg-chat-item-active: #3a1a1e;
  --bg-msg-actions:      #2a2a2a;

  --text-primary:     #e8e8e6;
  --text-secondary:   #9b9a96;
  --text-muted:       #6b6a66;
  --text-bubble-user: #ffffff;
  --text-bubble-bot:  #e8e8e6;
  --text-chat-active: #e87a8a;

  --border-main:  #333330;
  --shadow-modal: 0 20px 60px rgba(0,0,0,0.5);
}

/* ── BASE ────────────────────────────────────────────────── */
body {
  font-family: var(--font);
  background: var(--bg-body);
  color: var(--text-primary);
  height: 100vh;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.25s, color 0.25s;
}

/* ── AUTH ────────────────────────────────────────────────── */
#auth-screen { width: 100%; height: 100vh; display: flex; }

.auth-left {
  width: 45%;
  background: var(--red);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 48px;
  position: relative;
  overflow: hidden;
}

.auth-left::before {
  content: '';
  position: absolute;
  width: 500px; height: 500px;
  border-radius: 50%;
  border: 80px solid rgba(255,255,255,0.07);
  bottom: -150px; right: -100px;
}

.auth-left::after {
  content: '';
  position: absolute;
  width: 300px; height: 300px;
  border-radius: 50%;
  border: 50px solid rgba(255,255,255,0.05);
  top: -80px; left: -80px;
}

.auth-logo { display: flex; align-items: center; gap: 12px; z-index: 1; }

.auth-logo-box {
  width: 40px; height: 40px;
  background: rgba(255,255,255,0.15);
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-weight: 600; font-size: 14px; color: #fff; letter-spacing: 0.5px;
}

.auth-logo-name { color: #fff; font-size: 16px; font-weight: 500; letter-spacing: 0.3px; }

.auth-tagline { z-index: 1; }

.auth-tagline h1 {
  color: #fff; font-size: 36px; font-weight: 300;
  line-height: 1.2; margin-bottom: 16px; letter-spacing: -0.5px;
}

.auth-tagline h1 strong { font-weight: 600; }

.auth-tagline p {
  color: rgba(255,255,255,0.65);
  font-size: 15px; line-height: 1.6; max-width: 280px;
}

.auth-right {
  flex: 1;
  display: flex; align-items: center; justify-content: center;
  padding: 48px;
  background: var(--bg-auth-right);
  transition: background 0.25s;
  position: relative;
}

.auth-theme-btn { position: absolute; top: 20px; right: 20px; }

.auth-box { width: 100%; max-width: 380px; }

.auth-tabs {
  display: flex;
  border-bottom: 1px solid var(--border-main);
  margin-bottom: 32px;
}

.auth-tab {
  padding: 10px 0; margin-right: 24px;
  font-size: 14px; font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: all 0.2s;
}

.auth-tab.active { color: var(--red); border-bottom-color: var(--red); }

/* ── FORMS ───────────────────────────────────────────────── */
.form-group { margin-bottom: 16px; }

.form-group label {
  display: block; font-size: 12px; font-weight: 500;
  color: var(--text-secondary); margin-bottom: 6px;
  letter-spacing: 0.3px; text-transform: uppercase;
}

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%; padding: 10px 14px;
  border: 1px solid var(--border-main);
  border-radius: var(--radius);
  font-size: 14px; font-family: var(--font);
  color: var(--text-primary);
  background: var(--bg-input);
  transition: border-color 0.2s, background 0.2s;
  outline: none;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  border-color: var(--red);
  background: var(--bg-input-focus);
}

.form-group select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%239b9a96' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 32px;
  cursor: pointer;
}

.form-group textarea { resize: none; line-height: 1.5; }

.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.btn-primary {
  width: 100%; padding: 12px;
  background: var(--red); color: #fff;
  border: none; border-radius: var(--radius);
  font-size: 14px; font-weight: 500; font-family: var(--font);
  cursor: pointer; transition: background 0.2s; margin-top: 8px;
}

.btn-primary:hover    { background: var(--red-dark); }
.btn-primary:disabled { opacity: 0.6; cursor: not-allowed; }

.auth-msg {
  margin-top: 12px; font-size: 13px;
  padding: 10px 14px; border-radius: var(--radius); display: none;
}

.auth-msg.error   { background: #fff0f2; color: #a00d24; border: 1px solid var(--red-mid); }
.auth-msg.success { background: #f0faf4; color: #1a6b3a; border: 1px solid #b3dfc5; }
.auth-msg.show    { display: block; }

[data-theme="dark"] .auth-msg.error   { background: #3a1218; color: #f48a98; border-color: #7a2030; }
[data-theme="dark"] .auth-msg.success { background: #0f2a1a; color: #5fbd8a; border-color: #1f5a34; }

/* ── THEME TOGGLE ────────────────────────────────────────── */
.theme-btn {
  width: 34px; height: 34px;
  border-radius: 8px;
  background: none;
  border: 1px solid var(--border-main);
  color: var(--text-secondary);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background 0.2s, border-color 0.2s;
  flex-shrink: 0;
}

.theme-btn:hover { background: var(--bg-chip); }
.theme-btn svg   { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }

.icon-sun  { display: none; }
.icon-moon { display: block; }
[data-theme="dark"] .icon-sun  { display: block; }
[data-theme="dark"] .icon-moon { display: none; }

/* ── APP ─────────────────────────────────────────────────── */
#app-screen { display: none; width: 100%; height: 100vh; flex-direction: column; }

.topbar {
  height: 54px;
  background: var(--bg-topbar);
  border-bottom: 1px solid var(--border-main);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 24px; flex-shrink: 0;
  transition: background 0.25s, border-color 0.25s;
}

.topbar-left { display: flex; align-items: center; gap: 12px; }

.topbar-logo {
  width: 32px; height: 32px;
  background: var(--red); border-radius: 7px;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 600; color: #fff; letter-spacing: 0.3px;
}

.topbar-title      { font-size: 14px; font-weight: 500; color: var(--text-primary); }
.topbar-title span { color: var(--text-muted); font-weight: 400; margin-left: 6px; font-size: 13px; }

.topbar-right { display: flex; align-items: center; gap: 12px; }

.user-info        { font-size: 13px; color: var(--text-secondary); }
.user-info strong { color: var(--text-primary); font-weight: 500; }

.avatar {
  width: 30px; height: 30px;
  background: var(--red-light); border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 600; color: var(--red);
}

[data-theme="dark"] .avatar { background: #3a1218; color: #f48a98; }

.btn-logout {
  padding: 6px 12px; background: none;
  border: 1px solid var(--border-main); border-radius: 6px;
  font-size: 12px; color: var(--text-secondary);
  cursor: pointer; font-family: var(--font); transition: all 0.2s;
}

.btn-logout:hover { border-color: var(--red); color: var(--red); }

.app-body { display: flex; flex: 1; overflow: hidden; }

/* ── SIDEBAR ─────────────────────────────────────────────── */
.sidebar {
  width: 240px;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border-main);
  display: flex; flex-direction: column; flex-shrink: 0;
  transition: background 0.25s, border-color 0.25s;
}

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

.btn-new-chat {
  width: 100%; padding: 9px 14px;
  background: var(--red); color: #fff; border: none;
  border-radius: var(--radius);
  font-size: 13px; font-weight: 500; font-family: var(--font);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center; gap: 6px;
  transition: background 0.2s;
}

.btn-new-chat:hover { background: var(--red-dark); }

.sidebar-section {
  padding: 12px 16px 4px;
  font-size: 10px; font-weight: 600;
  color: var(--text-muted); letter-spacing: 0.8px; text-transform: uppercase;
}

.chat-list { flex: 1; overflow-y: auto; padding: 4px 8px; }

.chat-item {
  padding: 8px 10px; border-radius: 8px;
  cursor: pointer; transition: background 0.15s; margin-bottom: 2px;
  position: relative;
}

.chat-item:hover  { background: var(--bg-chat-item-hover); }
.chat-item.active { background: var(--bg-chat-item-active); }

.chat-item-title {
  font-size: 13px; color: var(--text-primary);
  font-weight: 400; white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis;
}

.chat-item.active .chat-item-title { color: var(--text-chat-active); font-weight: 500; }

.chat-item-time { font-size: 11px; color: var(--text-muted); margin-top: 2px; }

.chat-item-del {
  position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
  display: none;
  background: none; border: none;
  color: var(--text-muted); cursor: pointer;
  font-size: 16px; line-height: 1;
  padding: 2px 5px; border-radius: 4px;
  transition: color 0.15s, background 0.15s;
}

.chat-item:hover .chat-item-del  { display: block; }
.chat-item-del:hover { color: var(--red); background: var(--bg-chat-item-active); }

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

.messages {
  flex: 1; overflow-y: auto;
  padding: 32px 24px;
  display: flex; flex-direction: column;
  align-items: center;
  gap: 4px;
}

.msg-row {
  width: 100%; max-width: 720px;
  display: flex; flex-direction: column;
  margin-bottom: 20px;
}

.welcome {
  text-align: center; padding: 60px 20px;
  color: var(--text-muted);
  width: 100%; max-width: 720px;
}

.welcome-icon {
  width: 56px; height: 56px;
  background: var(--red); border-radius: 14px;
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto 16px;
  font-size: 20px; font-weight: 700; color: #fff;
}

.welcome h2 { font-size: 18px; font-weight: 500; color: var(--text-primary); margin-bottom: 8px; }
.welcome p  { font-size: 14px; color: var(--text-muted); line-height: 1.6; max-width: 320px; margin: 0 auto; }

/* ── MESSAGES ────────────────────────────────────────────── */
.msg { display: flex; gap: 12px; animation: fadeUp 0.2s ease; }

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

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

.msg-avatar {
  width: 30px; height: 30px; border-radius: 50%; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 600; margin-top: 2px;
}

.msg.bot  .msg-avatar { background: var(--red); color: #fff; }
.msg.user .msg-avatar { background: var(--bg-chip); color: var(--text-secondary); }

.bubble {
  padding: 12px 16px; border-radius: 14px;
  font-size: 14px; line-height: 1.65;
  max-width: calc(100% - 42px);
}

.msg.bot .bubble {
  background: var(--bg-bubble-bot);
  color: var(--text-bubble-bot);
  border: 1px solid var(--border-main);
  border-radius: 4px 14px 14px 14px;
}

.msg.user .bubble {
  background: var(--bg-bubble-user);
  color: var(--text-bubble-user);
  border-radius: 14px 4px 14px 14px;
  margin-left: auto;
}

.bubble strong { font-weight: 600; }
.bubble em     { font-style: italic; }

/* ── MESSAGE ACTIONS ─────────────────────────────────────── */
.msg-actions {
  display: flex; align-items: center; gap: 2px;
  margin-top: 5px; margin-left: 42px;
  opacity: 0; height: 28px;
  transition: opacity 0.15s;
}

.msg-row:hover .msg-actions { opacity: 1; }

.action-btn {
  width: 28px; height: 28px; border-radius: 6px;
  border: 1px solid transparent;
  background: none; color: var(--text-muted);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
  font-family: var(--font);
}

.action-btn:hover {
  background: var(--bg-msg-actions);
  border-color: var(--border-main);
  color: var(--text-secondary);
}

.action-btn svg {
  width: 14px; height: 14px;
  fill: none; stroke: currentColor;
  stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round;
}

.action-btn.copied          { color: #1a8a4a; }
.action-btn.thumb-up-active { color: #1a8a4a; border-color: #b3dfc5; background: #f0faf4; }
.action-btn.thumb-dn-active { color: var(--red); border-color: var(--red-mid); background: var(--red-light); }

[data-theme="dark"] .action-btn.thumb-up-active { background: #0f2a1a; border-color: #1f5a34; }
[data-theme="dark"] .action-btn.thumb-dn-active { background: #3a1218; border-color: #7a2030; }

/* ── TYPING ──────────────────────────────────────────────── */
.typing {
  display: flex; gap: 4px;
  padding: 14px 16px;
  background: var(--bg-typing);
  border: 1px solid var(--border-main);
  border-radius: 4px 14px 14px 14px;
  width: fit-content;
  transition: background 0.25s;
}

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

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

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

/* ── INPUT ───────────────────────────────────────────────── */
.input-zone {
  background: var(--bg-body);
  padding: 0 24px 16px;
  display: flex; flex-direction: column; align-items: center;
  transition: background 0.25s;
}

.input-inner { width: 100%; max-width: 720px; }

.input-wrap {
  background: var(--bg-surface);
  border: 1px solid var(--border-main);
  border-radius: 14px;
  display: flex; gap: 10px; align-items: flex-end;
  padding: 4px 4px 4px 14px;
  transition: border-color 0.2s, background 0.25s;
}

.input-wrap:focus-within { border-color: var(--red); }

#user-input {
  flex: 1; border: none; background: none;
  padding: 9px 0;
  font-size: 14px; font-family: var(--font);
  color: var(--text-primary);
  resize: none; min-height: 40px; max-height: 120px;
  outline: none; line-height: 1.5;
}

#user-input::placeholder { color: var(--text-muted); }

.btn-send {
  width: 36px; height: 36px;
  background: var(--red); border: none; border-radius: 9px;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  transition: background 0.2s, transform 0.1s;
  margin-bottom: 2px;
}

.btn-send:hover    { background: var(--red-dark); }
.btn-send:active   { transform: scale(0.95); }
.btn-send:disabled { opacity: 0.4; cursor: not-allowed; }
.btn-send svg      { width: 15px; height: 15px; fill: #fff; }

.input-hint {
  font-size: 11px; color: var(--text-muted);
  padding: 8px 0 0; text-align: center;
}

/* ── FEEDBACK MODAL ──────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0;
  background: var(--bg-overlay);
  display: flex; align-items: center; justify-content: center;
  z-index: 1000;
  opacity: 0; pointer-events: none;
  transition: opacity 0.2s;
}

.modal-overlay.open { opacity: 1; pointer-events: all; }

.modal {
  background: var(--bg-modal);
  border-radius: 16px;
  width: 100%; max-width: 500px;
  margin: 24px;
  box-shadow: var(--shadow-modal);
  border: 1px solid var(--border-main);
  transform: translateY(10px);
  transition: transform 0.2s, background 0.25s;
}

.modal-overlay.open .modal { transform: translateY(0); }

.modal-header {
  padding: 20px 20px 0;
  display: flex; justify-content: space-between; align-items: flex-start;
}

.modal-header h3 { font-size: 16px; font-weight: 600; color: var(--text-primary); }
.modal-header p  { font-size: 13px; color: var(--text-muted); margin-top: 3px; }

.modal-close {
  width: 28px; height: 28px; border-radius: 6px;
  border: none; background: var(--bg-chip);
  color: var(--text-secondary); cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; transition: background 0.15s;
}

.modal-close:hover { background: var(--border-main); }
.modal-close svg   { width: 14px; height: 14px; stroke: currentColor; stroke-width: 2; fill: none; stroke-linecap: round; }

.modal-body                { padding: 20px; }
.modal-body .form-group    { margin-bottom: 14px; }

.feedback-types { display: flex; gap: 8px; flex-wrap: wrap; }

.fb-chip {
  padding: 6px 14px; border-radius: 20px;
  border: 1px solid var(--border-main);
  font-size: 13px; font-family: var(--font);
  color: var(--text-secondary); background: var(--bg-chip);
  cursor: pointer; transition: all 0.15s;
}

.fb-chip:hover  { border-color: var(--red); color: var(--red); }
.fb-chip.active { border-color: var(--red); color: var(--red); background: var(--red-light); font-weight: 500; }

[data-theme="dark"] .fb-chip.active { background: #3a1218; color: #f48a98; border-color: #7a2030; }

.modal-footer {
  padding: 0 20px 20px;
  display: flex; gap: 10px; justify-content: flex-end;
}

.btn-cancel {
  padding: 10px 20px; background: none;
  border: 1px solid var(--border-main); border-radius: var(--radius);
  font-size: 13px; font-family: var(--font);
  color: var(--text-secondary); cursor: pointer; transition: all 0.2s;
}

.btn-cancel:hover { border-color: var(--text-muted); color: var(--text-primary); }

.btn-submit {
  padding: 10px 22px;
  background: var(--red); color: #fff; border: none;
  border-radius: var(--radius);
  font-size: 13px; font-weight: 500; font-family: var(--font);
  cursor: pointer;
  display: flex; align-items: center; gap: 6px;
  transition: background 0.2s;
}

.btn-submit:hover    { background: var(--red-dark); }
.btn-submit:disabled { opacity: 0.6; cursor: not-allowed; }
.btn-submit svg      { width: 13px; height: 13px; fill: #fff; }

.req { color: var(--red); margin-left: 2px; }
.opt { color: var(--text-muted); font-weight: 400; font-size: 11px; margin-left: 4px; text-transform: none; letter-spacing: 0; }

/* ── SCROLLBARS ──────────────────────────────────────────── */
.messages::-webkit-scrollbar,
.chat-list::-webkit-scrollbar        { width: 4px; }
.messages::-webkit-scrollbar-thumb,
.chat-list::-webkit-scrollbar-thumb  { background: var(--border-main); border-radius: 2px; }
.messages::-webkit-scrollbar-track,
.chat-list::-webkit-scrollbar-track  { background: transparent; }
