/* ==========================================================================
   IlmCore AI — dashboard.css
   ========================================================================== */

.app-shell {
  position: relative;
  z-index: 2;
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* ---------------------------- Sidebar ---------------------------- */
.sidebar {
  width: 280px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  padding: 18px 14px;
  gap: 14px;
  border-right: 1px solid var(--glass-border);
  background: rgba(8, 10, 20, 0.55);
  backdrop-filter: blur(24px);
  transition: width 380ms var(--ease), padding 380ms var(--ease), opacity 260ms var(--ease);
  position: relative;
  z-index: 5;
}

.app-shell.collapsed .sidebar {
  width: 76px;
  padding: 18px 10px;
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 6px 6px;
}
.sidebar-brand { display: flex; align-items: center; gap: 10px; overflow: hidden; }
.sidebar-brand img { width: 32px; height: 32px; flex-shrink: 0; filter: drop-shadow(0 0 10px rgba(99,102,241,0.6)); }
.sidebar-brand span {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 16.5px;
  white-space: nowrap;
  transition: opacity 220ms var(--ease), width 220ms var(--ease);
}
.app-shell.collapsed .sidebar-brand span,
.app-shell.collapsed .label-fade,
.app-shell.collapsed .sidebar-search,
.app-shell.collapsed .history-group-label {
  opacity: 0;
  width: 0;
  pointer-events: none;
}

.sidebar-toggle {
  width: 32px; height: 32px;
  border-radius: 9px;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-mid);
  background: var(--glass);
  border: 1px solid var(--glass-border);
  transition: all 200ms var(--ease);
  flex-shrink: 0;
}
.sidebar-toggle:hover { color: var(--text-hi); background: var(--glass-strong); }
.sidebar-toggle svg { transition: transform 380ms var(--ease); }
.app-shell.collapsed .sidebar-toggle svg { transform: rotate(180deg); }

.new-chat-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, rgba(59,130,246,0.18), rgba(139,92,246,0.18));
  border: 1px solid rgba(139,92,246,0.3);
  font-weight: 600;
  font-size: 14px;
  color: var(--text-hi);
  transition: all 220ms var(--ease);
  white-space: nowrap;
  overflow: hidden;
}
.new-chat-btn:hover { border-color: rgba(139,92,246,0.55); box-shadow: 0 6px 24px rgba(99,102,241,0.25); transform: translateY(-1px); }
.new-chat-btn svg { flex-shrink: 0; }

.sidebar-search {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 12px;
  border-radius: var(--radius-md);
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--glass-border);
  transition: opacity 200ms var(--ease), width 200ms var(--ease);
}
.sidebar-search input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  font-size: 13.5px;
  color: var(--text-hi);
}
.sidebar-search input::placeholder { color: var(--text-low); }
.sidebar-search svg { color: var(--text-low); flex-shrink: 0; }

.sidebar-history {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 3px;
  margin-top: 2px;
}
.history-group-label {
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-low);
  padding: 12px 10px 4px;
  white-space: nowrap;
}
.sidebar-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 10px;
  border-radius: 10px;
  font-size: 13.5px;
  color: var(--text-mid);
  transition: all 180ms var(--ease);
  white-space: nowrap;
  position: relative;
  overflow: hidden;
}
.sidebar-item:hover { background: rgba(255,255,255,0.055); color: var(--text-hi); }
.sidebar-item.active { background: var(--glass-strong); color: var(--text-hi); border: 1px solid rgba(139,92,246,0.25); }
.sidebar-item svg { flex-shrink: 0; opacity: 0.85; }
.sidebar-item .chat-title { flex: 1; overflow: hidden; text-overflow: ellipsis; }
.sidebar-item .chat-delete {
  opacity: 0;
  color: var(--text-low);
  padding: 2px;
  border-radius: 6px;
  transition: opacity 160ms var(--ease), color 160ms var(--ease);
}
.sidebar-item:hover .chat-delete { opacity: 1; }
.sidebar-item .chat-delete:hover { color: var(--danger); }
.sidebar-empty { padding: 14px 10px; font-size: 13px; color: var(--text-low); text-align: center; }

.sidebar-footer {
  border-top: 1px solid var(--glass-border);
  padding-top: 12px;
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.sidebar-profile {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 8px;
  border-radius: 12px;
  transition: background 180ms var(--ease);
}
.sidebar-profile:hover { background: rgba(255,255,255,0.05); }
.sidebar-profile img { width: 34px; height: 34px; border-radius: 50%; flex-shrink: 0; border: 1.5px solid var(--glass-border); }
.sidebar-profile .who { overflow: hidden; white-space: nowrap; }
.sidebar-profile .who .name { font-size: 13.5px; font-weight: 600; color: var(--text-hi); overflow: hidden; text-overflow: ellipsis; }
.sidebar-profile .who .email { font-size: 12px; color: var(--text-low); overflow: hidden; text-overflow: ellipsis; }

/* ---------------------------- Chat area ---------------------------- */
.chat-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  position: relative;
}

.chat-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 26px;
  border-bottom: 1px solid var(--glass-border);
  background: rgba(6,8,15,0.35);
  backdrop-filter: blur(14px);
}
.chat-topbar .title { font-family: var(--font-display); font-weight: 600; font-size: 15.5px; display: flex; align-items: center; gap: 10px; }
.status-pill {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px; color: var(--text-mid);
  padding: 5px 11px; border-radius: 999px;
  background: var(--glass); border: 1px solid var(--glass-border);
}
.status-pill .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--success); box-shadow: 0 0 6px var(--success); }
.status-pill.offline .dot { background: var(--danger); box-shadow: 0 0 6px var(--danger); }

.chat-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 30px clamp(16px, 6vw, 0px);
  display: flex;
  flex-direction: column;
  align-items: center;
}
.chat-inner { width: 100%; max-width: 820px; display: flex; flex-direction: column; gap: 4px; }

/* Welcome screen */
.welcome-screen {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 40px 20px;
  max-width: 720px;
  margin: 0 auto;
}
.welcome-orb {
  width: 84px; height: 84px;
  margin-bottom: 22px;
  filter: drop-shadow(0 0 30px rgba(99,102,241,0.6));
  animation: orbFloat 5s ease-in-out infinite;
}
.welcome-screen h1 {
  font-family: var(--font-display);
  font-size: clamp(26px, 4vw, 34px);
  font-weight: 700;
  margin-bottom: 10px;
}
.welcome-screen p { color: var(--text-mid); font-size: 15px; margin-bottom: 30px; }

.suggested-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  width: 100%;
}
.suggested-prompt {
  text-align: left;
  padding: 15px 16px;
  border-radius: var(--radius-md);
  background: var(--glass);
  border: 1px solid var(--glass-border);
  font-size: 13.5px;
  color: var(--text-mid);
  transition: all 220ms var(--ease);
  position: relative;
  overflow: hidden;
}
.suggested-prompt strong { display: block; color: var(--text-hi); font-size: 14px; margin-bottom: 3px; font-weight: 600; }
.suggested-prompt:hover { transform: translateY(-3px); border-color: rgba(139,92,246,0.4); box-shadow: 0 10px 30px rgba(99,102,241,0.18); }

/* Messages */
.msg-row {
  display: flex;
  gap: 14px;
  padding: 16px 4px;
  animation: msgIn 380ms var(--ease);
}
@keyframes msgIn {
  from { opacity: 0; transform: translateY(10px); }
  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;
  border: 1.5px solid var(--glass-border);
}
.msg-body { max-width: 78%; display: flex; flex-direction: column; gap: 6px; }
.msg-row.user .msg-body { align-items: flex-end; }

.msg-bubble {
  padding: 13px 17px;
  border-radius: 18px;
  font-size: 14.5px;
  line-height: 1.65;
  word-wrap: break-word;
}
.msg-row.assistant .msg-bubble {
  background: var(--glass);
  border: 1px solid var(--glass-border);
  border-top-left-radius: 6px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.25);
}
.msg-row.user .msg-bubble {
  background: linear-gradient(135deg, rgba(59,130,246,0.85), rgba(139,92,246,0.85));
  color: #fff;
  border-top-right-radius: 6px;
  box-shadow: 0 6px 22px rgba(99,102,241,0.35);
}

.msg-bubble p { margin: 0 0 10px; }
.msg-bubble p:last-child { margin-bottom: 0; }
.msg-bubble ul, .msg-bubble ol { margin: 8px 0 10px 20px; }
.msg-bubble li { margin-bottom: 4px; }
.msg-bubble a { color: var(--blue-soft); text-decoration: underline; }
.msg-bubble blockquote { border-left: 3px solid rgba(139,92,246,0.5); padding-left: 12px; color: var(--text-mid); margin: 8px 0; }
.msg-bubble code.inline-code {
  background: rgba(255,255,255,0.08);
  padding: 2px 6px;
  border-radius: 6px;
  font-family: var(--font-mono);
  font-size: 0.88em;
}
.msg-row.user .msg-bubble code.inline-code { background: rgba(255,255,255,0.2); }

.code-block {
  margin: 10px 0;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid var(--glass-border);
  background: #0a0d18;
}
.code-block-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 14px;
  background: rgba(255,255,255,0.04);
  font-size: 12px;
  color: var(--text-low);
  font-family: var(--font-mono);
}
.code-copy-btn {
  display: flex; align-items: center; gap: 5px;
  color: var(--text-mid);
  font-size: 12px;
  padding: 3px 8px;
  border-radius: 6px;
  transition: all 160ms var(--ease);
}
.code-copy-btn:hover { background: rgba(255,255,255,0.08); color: var(--text-hi); }
.code-block pre {
  margin: 0;
  padding: 14px 16px;
  overflow-x: auto;
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.6;
}
.tok-kw { color: #c792ea; }
.tok-str { color: #a5e0a5; }
.tok-com { color: #6b7390; font-style: italic; }
.tok-num { color: #f0b34e; }
.tok-fn { color: #82aaff; }

.msg-meta {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 11.5px;
  color: var(--text-low);
  padding: 0 4px;
}
.msg-actions { display: flex; gap: 4px; opacity: 0; transition: opacity 180ms var(--ease); }
.msg-row:hover .msg-actions { opacity: 1; }
.msg-action-btn {
  width: 26px; height: 26px;
  border-radius: 7px;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-low);
  transition: all 160ms var(--ease);
}
.msg-action-btn:hover { color: var(--text-hi); background: rgba(255,255,255,0.08); }
.msg-action-btn.liked { color: var(--success); }
.msg-action-btn.disliked { color: var(--danger); }

/* Typing indicator */
.typing-dots {
  display: inline-flex;
  gap: 4px;
  padding: 6px 4px;
}
.typing-dots span {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--blue-soft);
  animation: typingBounce 1.1s infinite ease-in-out;
}
.typing-dots span:nth-child(2) { animation-delay: 0.15s; background: var(--indigo); }
.typing-dots span:nth-child(3) { animation-delay: 0.3s; background: var(--purple-soft); }
@keyframes typingBounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.5; }
  30% { transform: translateY(-6px); opacity: 1; }
}

.streaming-cursor {
  display: inline-block;
  width: 2px; height: 1em;
  background: var(--blue-soft);
  vertical-align: text-bottom;
  margin-left: 2px;
  animation: cursorBlink 0.9s steps(1) infinite;
}
@keyframes cursorBlink { 50% { opacity: 0; } }

/* ---------------------------- Input area ---------------------------- */
.input-area {
  padding: 16px 20px 22px;
  display: flex;
  justify-content: center;
}
.input-shell {
  width: 100%;
  max-width: 820px;
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 10px 10px 10px 16px;
  border-radius: 24px;
  background: var(--glass-strong);
  border: 1px solid var(--glass-border);
  box-shadow: 0 12px 40px rgba(0,0,0,0.35);
  transition: border-color 220ms var(--ease), box-shadow 220ms var(--ease);
}
.input-shell:focus-within {
  border-color: rgba(139,92,246,0.5);
  box-shadow: 0 12px 40px rgba(99,102,241,0.25), 0 0 0 4px rgba(139,92,246,0.1);
}
#chat-input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  resize: none;
  color: var(--text-hi);
  font-size: 15px;
  line-height: 1.5;
  max-height: 200px;
  padding: 8px 0;
  font-family: var(--font-body);
}
#chat-input::placeholder { color: var(--text-low); }
.input-icon-btn {
  width: 38px; height: 38px;
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-mid);
  flex-shrink: 0;
  transition: all 180ms var(--ease);
}
.input-icon-btn:hover { color: var(--text-hi); background: rgba(255,255,255,0.08); }
.input-icon-btn.recording { color: var(--danger); animation: recordPulse 1.2s infinite; }
@keyframes recordPulse { 0%,100%{opacity:1;} 50%{opacity:0.4;} }

.send-btn {
  width: 40px; height: 40px;
  border-radius: 14px;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, var(--blue-soft), var(--purple));
  color: #fff;
  flex-shrink: 0;
  transition: all 200ms var(--ease);
  box-shadow: 0 6px 20px rgba(99,102,241,0.4);
}
.send-btn:hover:not(:disabled) { transform: translateY(-2px) scale(1.04); }
.send-btn:disabled { opacity: 0.4; cursor: not-allowed; box-shadow: none; }

.input-hint {
  text-align: center;
  font-size: 11.5px;
  color: var(--text-low);
  margin-top: 10px;
}

/* Loading spinner (page-level) */
.page-spinner {
  width: 46px; height: 46px;
  border-radius: 50%;
  border: 3px solid rgba(255,255,255,0.1);
  border-top-color: var(--purple-soft);
  animation: spin 800ms linear infinite;
}
.center-loader {
  position: fixed; inset: 0;
  display: flex; align-items: center; justify-content: center;
  z-index: 50;
  background: var(--bg-0);
  transition: opacity 400ms var(--ease);
}

/* ---------------------------- Mobile sidebar backdrop ---------------------------- */
.sidebar-backdrop {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 4;
}

/* ---------------------------- Responsive ---------------------------- */
@media (max-width: 900px) {
  .sidebar {
    position: fixed;
    left: 0; top: 0; bottom: 0;
    transform: translateX(0);
    z-index: 20;
  }
  .app-shell.collapsed .sidebar { transform: translateX(-100%); width: 280px; padding: 18px 14px; }
  .app-shell.collapsed .sidebar-brand span,
  .app-shell.collapsed .label-fade,
  .app-shell.collapsed .sidebar-search,
  .app-shell.collapsed .history-group-label { opacity: 1; width: auto; pointer-events: auto; }
  .app-shell:not(.collapsed) .sidebar-backdrop { display: block; }
  .suggested-grid { grid-template-columns: 1fr; }
  .msg-body { max-width: 88%; }
}
@media (max-width: 560px) {
  .chat-topbar { padding: 12px 16px; }
  .input-area { padding: 12px 10px 16px; }
}

/* ---------- Image Preview ---------- */

#image-preview-container{
    display:flex;
    justify-content:center;
    margin-bottom:12px;
}

.image-preview-wrapper{
    position:relative;
    display:inline-block;
}

.image-preview{
    width:180px;
    max-height:180px;
    object-fit:cover;
    border-radius:14px;
    border:2px solid rgba(255,255,255,.15);
    box-shadow:0 10px 30px rgba(0,0,0,.4);
}

.remove-image{
    position:absolute;
    top:-8px;
    right:-8px;
    width:28px;
    height:28px;
    border:none;
    border-radius:50%;
    cursor:pointer;
    background:#ff4b4b;
    color:white;
    font-size:16px;
    font-weight:bold;
}
