/* ============================================================
   NeuralChat — Style System
   Aesthetic: dark editorial / utilitarian-luxury
   Fonts: Syne (display) + DM Mono (body/code)
   ============================================================ */

:root {
  --bg-base:        #0c0c0e;
  --bg-surface:     #141416;
  --bg-elevated:    #1c1c1f;
  --bg-hover:       #242428;
  --border:         rgba(255,255,255,0.07);
  --border-bright:  rgba(255,255,255,0.14);

  --accent:         #f97316;
  --accent-dim:     rgba(249,115,22,0.18);
  --accent-glow:    rgba(249,115,22,0.08);

  --text-primary:   #f0ede8;
  --text-secondary: #888891;
  --text-muted:     #52525a;

  --user-bubble:    #1e1e23;
  --ai-bubble:      #111113;

  --danger:         #ef4444;
  --success:        #22c55e;

  --radius-sm:  6px;
  --radius-md:  12px;
  --radius-lg:  18px;

  --sidebar-w: 280px;
  --header-h:  58px;
}

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

html, body { height: 100%; overflow: hidden; }

body {
  font-family: 'DM Mono', monospace;
  background: var(--bg-base);
  color: var(--text-primary);
  -webkit-font-smoothing: antialiased;
}

/* ── Scrollbar ─────────────────────────────────────────────── */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-bright); border-radius: 99px; }

/* ── Login Screen ──────────────────────────────────────────── */
.login-screen {
  height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(ellipse 80% 60% at 50% -10%, rgba(249,115,22,0.12) 0%, transparent 70%),
    var(--bg-base);
}

.login-card {
  width: 380px;
  padding: 3rem 2.5rem;
  background: var(--bg-surface);
  border: 1px solid var(--border-bright);
  border-radius: var(--radius-lg);
  text-align: center;
  animation: fadeUp .5s ease both;
}

.login-logo {
  font-family: 'Syne', sans-serif;
  font-size: 2rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  color: var(--text-primary);
  margin-bottom: .25rem;
}
.login-logo span { color: var(--accent); }

.login-sub {
  font-size: .78rem;
  color: var(--text-muted);
  letter-spacing: .08em;
  text-transform: uppercase;
  margin-bottom: 2.5rem;
}

.btn-google {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: .75rem;
  width: 100%;
  padding: .85rem 1.25rem;
  background: var(--bg-elevated);
  border: 1px solid var(--border-bright);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-family: 'Syne', sans-serif;
  font-size: .95rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: background .18s, border-color .18s, transform .15s;
}
.btn-google:hover {
  background: var(--bg-hover);
  border-color: rgba(255,255,255,0.22);
  transform: translateY(-1px);
}
.btn-google svg { flex-shrink: 0; }

/* ── App Shell ─────────────────────────────────────────────── */
#root { height: 100vh; }
.app { display: flex; height: 100vh; overflow: hidden; }

/* ── Sidebar ───────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  background: var(--bg-surface);
  border-right: 1px solid var(--border);
  overflow: hidden;
}

.sidebar-header {
  padding: 1.1rem 1.25rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: .6rem;
}

.sidebar-logo {
  font-family: 'Syne', sans-serif;
  font-size: 1.1rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  flex: 1;
}
.sidebar-logo span { color: var(--accent); }

.btn-new {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 30px; height: 30px;
  border-radius: var(--radius-sm);
  background: var(--accent-dim);
  border: none;
  color: var(--accent);
  cursor: pointer;
  font-size: 1.2rem;
  transition: background .15s;
  flex-shrink: 0;
}
.btn-new:hover { background: rgba(249,115,22,.28); }

.sidebar-search {
  padding: .75rem 1rem;
  border-bottom: 1px solid var(--border);
}
.sidebar-search input {
  width: 100%;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: 'DM Mono', monospace;
  font-size: .78rem;
  padding: .5rem .75rem;
  outline: none;
  transition: border-color .15s;
}
.sidebar-search input::placeholder { color: var(--text-muted); }
.sidebar-search input:focus { border-color: var(--border-bright); }

.conv-list {
  flex: 1;
  overflow-y: auto;
  padding: .5rem 0;
}

.conv-item {
  display: flex;
  align-items: center;
  gap: .5rem;
  padding: .55rem 1rem;
  cursor: pointer;
  border-radius: var(--radius-sm);
  margin: 0 .5rem;
  transition: background .12s;
  min-width: 0;
}
.conv-item:hover { background: var(--bg-hover); }
.conv-item.active { background: var(--accent-dim); }
.conv-item.active .conv-title { color: var(--accent); }

.conv-icon { font-size: .85rem; flex-shrink: 0; opacity: .6; }
.conv-info { flex: 1; min-width: 0; }
.conv-title {
  font-size: .78rem;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--text-primary);
}
.conv-date {
  font-size: .68rem;
  color: var(--text-muted);
  margin-top: 1px;
}
.conv-delete {
  display: none;
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: .8rem;
  padding: 3px 5px;
  border-radius: 4px;
  flex-shrink: 0;
}
.conv-delete:hover { color: var(--danger); background: rgba(239,68,68,.12); }
.conv-item:hover .conv-delete { display: flex; }

.conv-section-label {
  font-size: .65rem;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--text-muted);
  padding: .75rem 1.5rem .3rem;
}

.sidebar-footer {
  padding: .9rem 1rem;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: .75rem;
}
.avatar {
  width: 30px; height: 30px;
  border-radius: 50%;
  object-fit: cover;
  border: 1.5px solid var(--border-bright);
}
.avatar-placeholder {
  width: 30px; height: 30px;
  border-radius: 50%;
  background: var(--accent-dim);
  color: var(--accent);
  display: flex; align-items: center; justify-content: center;
  font-size: .8rem; font-weight: 700;
  flex-shrink: 0;
}
.user-info { flex: 1; min-width: 0; }
.user-name {
  font-size: .78rem;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.user-email {
  font-size: .65rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.btn-logout {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: .8rem;
  padding: 5px;
  border-radius: 4px;
  transition: color .15s;
  flex-shrink: 0;
}
.btn-logout:hover { color: var(--danger); }

/* ── Main Chat Area ─────────────────────────────────────────── */
.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--bg-base);
}

/* ── Chat Header ────────────────────────────────────────────── */
.chat-header {
  height: var(--header-h);
  padding: 0 1.5rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.chat-title {
  flex: 1;
  font-family: 'Syne', sans-serif;
  font-size: 1rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.model-selector {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-family: 'DM Mono', monospace;
  font-size: .72rem;
  padding: .35rem .65rem;
  outline: none;
  cursor: pointer;
  transition: border-color .15s;
}
.model-selector:focus, .model-selector:hover { border-color: var(--border-bright); }

/* ── Messages ───────────────────────────────────────────────── */
.messages-wrap {
  flex: 1;
  overflow-y: auto;
  padding: 2rem 0;
  scroll-behavior: smooth;
}

.messages-inner {
  max-width: 760px;
  margin: 0 auto;
  padding: 0 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  min-height: 300px;
  color: var(--text-muted);
  text-align: center;
  gap: .75rem;
}
.empty-icon {
  font-size: 2.5rem;
  opacity: .4;
}
.empty-title {
  font-family: 'Syne', sans-serif;
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text-secondary);
}
.empty-sub { font-size: .78rem; }

.message { display: flex; gap: .75rem; animation: fadeUp .25s ease both; }
.message.user { flex-direction: row-reverse; }

.msg-avatar {
  width: 28px; height: 28px;
  border-radius: 50%;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: .72rem;
  font-weight: 700;
  margin-top: 2px;
}
.msg-avatar.user-av { background: var(--accent); color: #fff; }
.msg-avatar.ai-av   { background: var(--bg-elevated); color: var(--accent); border: 1px solid var(--border-bright); }
.msg-avatar img { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; }

.msg-body { max-width: 78%; }

.msg-role {
  font-size: .65rem;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: .35rem;
  padding: 0 .15rem;
}
.message.user .msg-role { text-align: right; }

.msg-bubble {
  padding: .85rem 1.1rem;
  border-radius: var(--radius-md);
  font-size: .875rem;
  line-height: 1.65;
  white-space: pre-wrap;
  word-break: break-word;
}
.message.user .msg-bubble {
  background: var(--user-bubble);
  border: 1px solid var(--border-bright);
  border-bottom-right-radius: var(--radius-sm);
}
.message.assistant .msg-bubble {
  background: var(--ai-bubble);
  border: 1px solid var(--border);
  border-bottom-left-radius: var(--radius-sm);
}

.msg-file-badge {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  background: var(--accent-dim);
  color: var(--accent);
  border-radius: 99px;
  padding: .2rem .65rem;
  font-size: .7rem;
  margin-bottom: .5rem;
}

.typing-dot {
  display: inline-block;
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--accent);
  animation: blink 1.2s infinite;
  margin: 0 1.5px;
}
.typing-dot:nth-child(2) { animation-delay: .2s; }
.typing-dot:nth-child(3) { animation-delay: .4s; }

/* ── Input Area ─────────────────────────────────────────────── */
.input-area {
  padding: 1rem 1.5rem 1.25rem;
  border-top: 1px solid var(--border);
  background: var(--bg-base);
  flex-shrink: 0;
}

.input-files {
  display: flex;
  flex-wrap: wrap;
  gap: .4rem;
  margin-bottom: .6rem;
}
.file-chip {
  display: flex;
  align-items: center;
  gap: .35rem;
  background: var(--bg-elevated);
  border: 1px solid var(--border-bright);
  border-radius: 99px;
  padding: .25rem .65rem;
  font-size: .7rem;
  color: var(--text-secondary);
  animation: fadeUp .2s ease;
}
.file-chip-remove {
  background: none; border: none;
  color: var(--text-muted); cursor: pointer;
  font-size: .8rem; display: flex; align-items: center;
  padding: 0; margin-left: 1px;
}
.file-chip-remove:hover { color: var(--danger); }

.input-row {
  display: flex;
  align-items: flex-end;
  gap: .6rem;
  background: var(--bg-elevated);
  border: 1px solid var(--border-bright);
  border-radius: var(--radius-md);
  padding: .5rem .6rem .5rem .75rem;
  transition: border-color .15s;
}
.input-row:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-glow); }

.input-row textarea {
  flex: 1;
  background: none;
  border: none;
  outline: none;
  resize: none;
  color: var(--text-primary);
  font-family: 'DM Mono', monospace;
  font-size: .875rem;
  line-height: 1.55;
  max-height: 180px;
  overflow-y: auto;
  padding: .2rem 0;
}
.input-row textarea::placeholder { color: var(--text-muted); }

.btn-icon {
  display: flex; align-items: center; justify-content: center;
  width: 34px; height: 34px;
  border-radius: var(--radius-sm);
  border: none;
  cursor: pointer;
  flex-shrink: 0;
  transition: background .15s, color .15s;
}
.btn-attach {
  background: none;
  color: var(--text-muted);
}
.btn-attach:hover { background: var(--bg-hover); color: var(--text-primary); }

.btn-send {
  background: var(--accent);
  color: #fff;
}
.btn-send:hover { background: #ea6a07; }
.btn-send:disabled { background: var(--bg-hover); color: var(--text-muted); cursor: not-allowed; }

.input-hint {
  font-size: .67rem;
  color: var(--text-muted);
  text-align: center;
  margin-top: .55rem;
}

/* ── Upload progress overlay ────────────────────────────────── */
.upload-bar {
  height: 2px;
  background: var(--accent);
  border-radius: 99px;
  margin-bottom: .5rem;
  animation: grow .6s ease;
  transform-origin: left;
}

/* ── No conversation selected ───────────────────────────────── */
.no-conv {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  gap: 1rem;
}
.no-conv-icon { font-size: 3rem; opacity: .25; }
.no-conv h3 {
  font-family: 'Syne', sans-serif;
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--text-secondary);
}
.no-conv p { font-size: .8rem; }

/* ── Utility ────────────────────────────────────────────────── */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes blink {
  0%,80%,100% { opacity: .2; }
  40%         { opacity: 1; }
}
@keyframes grow {
  from { transform: scaleX(0); }
  to   { transform: scaleX(1); }
}

/* ── Responsive (narrow) ────────────────────────────────────── */
@media (max-width: 640px) {
  .sidebar { width: 220px; }
  :root { --sidebar-w: 220px; }
}

/* ── Tamil font support ─────────────────────────────────────── */
.login-logo,
.sidebar-logo,
.no-conv h3,
.input-hint,
.empty-title,
.empty-sub,
.conv-title,
.msg-role {
  font-family: 'Noto Sans Tamil', 'Syne', sans-serif;
}

/* ── Model selector wrap ────────────────────────────────────── */
.model-selector-wrap {
  position: relative;
  flex-shrink: 0;
}

/* ── Modal overlay ──────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.65);
  backdrop-filter: blur(4px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fadeIn .18s ease;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.modal-card {
  width: min(540px, 94vw);
  background: var(--bg-elevated);
  border: 1px solid var(--border-bright);
  border-radius: var(--radius-lg);
  padding: 1.75rem;
  animation: fadeUp .22s ease;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-title {
  font-family: 'Syne', sans-serif;
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-primary);
}

.modal-close {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 1rem;
  padding: 4px 7px;
  border-radius: var(--radius-sm);
  transition: background .12s, color .12s;
}
.modal-close:hover { background: var(--bg-hover); color: var(--text-primary); }

.modal-hint {
  font-size: .78rem;
  color: var(--text-secondary);
  line-height: 1.55;
}
.modal-hint a { color: var(--accent); text-decoration: none; }
.modal-hint a:hover { text-decoration: underline; }

.modal-add-row {
  display: flex;
  gap: .5rem;
  flex-wrap: wrap;
}

.modal-input {
  flex: 1;
  min-width: 160px;
  background: var(--bg-surface);
  border: 1px solid var(--border-bright);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: 'DM Mono', monospace;
  font-size: .78rem;
  padding: .55rem .75rem;
  outline: none;
  transition: border-color .15s;
}
.modal-input::placeholder { color: var(--text-muted); }
.modal-input:focus { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-glow); }

.modal-btn-add {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  padding: .55rem 1.1rem;
  font-family: 'Syne', sans-serif;
  font-size: .85rem;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s;
  white-space: nowrap;
}
.modal-btn-add:hover { background: #ea6a07; }

.modal-err {
  font-size: .75rem;
  color: var(--danger);
  padding: .3rem .5rem;
  background: rgba(239,68,68,.1);
  border-radius: var(--radius-sm);
}

.modal-list {
  display: flex;
  flex-direction: column;
  gap: .4rem;
  max-height: 240px;
  overflow-y: auto;
  padding-right: 2px;
}

.modal-item {
  display: flex;
  align-items: center;
  gap: .5rem;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: .55rem .85rem;
  animation: fadeUp .15s ease;
}

.modal-item-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.modal-item-label {
  font-size: .82rem;
  color: var(--text-primary);
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.modal-item-value {
  font-size: .7rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.modal-item-del {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: .78rem;
  padding: 4px 6px;
  border-radius: 4px;
  flex-shrink: 0;
  transition: color .12s, background .12s;
}
.modal-item-del:hover { color: var(--danger); background: rgba(239,68,68,.12); }

.modal-empty {
  text-align: center;
  font-size: .78rem;
  color: var(--text-muted);
  padding: 1.25rem 0;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: .6rem;
  padding-top: .25rem;
  border-top: 1px solid var(--border);
}

.modal-btn-cancel {
  background: none;
  border: 1px solid var(--border-bright);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-family: 'Syne', sans-serif;
  font-size: .85rem;
  padding: .5rem 1.1rem;
  cursor: pointer;
  transition: background .12s;
}
.modal-btn-cancel:hover { background: var(--bg-hover); }

.modal-btn-save {
  background: var(--accent);
  border: none;
  border-radius: var(--radius-sm);
  color: #fff;
  font-family: 'Syne', sans-serif;
  font-size: .85rem;
  font-weight: 600;
  padding: .5rem 1.4rem;
  cursor: pointer;
  transition: background .15s;
}
.modal-btn-save:hover { background: #ea6a07; }