/* ═══════════════════════════════════════════════════════
   LUMAN — AI ASSISTANT  |  style.css
   Refined dark editorial aesthetic
   ═══════════════════════════════════════════════════════ */

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

:root {
  /* Color system */
  --bg-base:        #0f0f11;
  --bg-surface:     #17171a;
  --bg-elevated:    #1f1f24;
  --bg-input:       #1a1a1e;
  --border-subtle:  rgba(255,255,255,0.07);
  --border-mid:     rgba(255,255,255,0.12);

  --text-primary:   #f0ede8;
  --text-secondary: #9d9a96;
  --text-muted:     #5a5856;

  --accent:         #e8a84c;      /* warm amber */
  --accent-dim:     rgba(232,168,76,0.15);
  --accent-glow:    rgba(232,168,76,0.08);

  --user-bubble:    #1e2030;
  --user-border:    rgba(100,120,200,0.25);

  --danger:         #e05c5c;
  --success:        #5cc98a;

  /* Typography */
  --font-display:   'DM Serif Display', Georgia, serif;
  --font-body:      'DM Sans', system-ui, sans-serif;

  /* Spacing */
  --header-h:       56px;
  --footer-h:       42px;
  --input-area-h:   auto;

  /* Radii */
  --r-sm:  6px;
  --r-md:  12px;
  --r-lg:  18px;
  --r-xl:  24px;

  /* Transitions */
  --t-fast:   120ms ease;
  --t-mid:    220ms ease;
  --t-slow:   380ms cubic-bezier(.4,0,.2,1);
}

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

body {
  background: var(--bg-base);
  color: var(--text-primary);
  font-family: var(--font-body);
  font-weight: 400;
  line-height: 1.6;
  height: 100dvh;
  overflow: hidden;
}

/* ── App Layout ─────────────────────────────────────── */
.app-layout {
  display: flex;
  height: 100%;
  width: 100%;
}

/* ── Sidebar ─────────────────────────────────────────── */
.sidebar {
  width: 260px;
  background: var(--bg-surface);
  border-right: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  transition: transform var(--t-mid);
}

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

.new-chat-btn {
  width: 100%;
  background: var(--bg-elevated);
  border: 1px solid var(--border-mid);
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 0.85rem;
  font-weight: 500;
  padding: 10px 14px;
  border-radius: var(--r-md);
  cursor: pointer;
  transition: background var(--t-fast), border-color var(--t-fast), transform var(--t-fast);
  display: flex;
  align-items: center;
  gap: 8px;
}

.new-chat-btn:hover {
  background: var(--bg-input);
  border-color: var(--border-mid);
  transform: translateY(-1px);
}

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

.sidebar-content {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
}

.sidebar-section-title {
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 8px;
  padding: 0 4px;
}

.conversation-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.conversation-item {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-family: var(--font-body);
  font-size: 0.85rem;
  font-weight: 400;
  padding: 10px 12px;
  border-radius: var(--r-sm);
  cursor: pointer;
  transition: background var(--t-fast), color var(--t-fast);
  text-align: left;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.conversation-item:hover {
  background: var(--bg-elevated);
  color: var(--text-primary);
}

.conversation-item:hover .delete-conversation-btn {
  opacity: 1;
}

.conversation-item.active {
  background: var(--bg-elevated);
  color: var(--text-primary);
  font-weight: 500;
}

.delete-conversation-btn {
  opacity: 0;
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 2px;
  border-radius: 4px;
  transition: opacity var(--t-fast), color var(--t-fast), background var(--t-fast);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.delete-conversation-btn:hover {
  color: var(--danger);
  background: rgba(224, 92, 92, 0.1);
}

.conversation-item-title {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-footer {
  padding: 12px 16px;
  border-top: 1px solid var(--border-subtle);
}

.clear-all-btn {
  width: 100%;
  background: transparent;
  border: 1px solid var(--border-subtle);
  color: var(--text-muted);
  font-family: var(--font-body);
  font-size: 0.75rem;
  font-weight: 500;
  padding: 8px 12px;
  border-radius: var(--r-sm);
  cursor: pointer;
  transition: border-color var(--t-fast), color var(--t-fast), background var(--t-fast);
  display: flex;
  align-items: center;
  gap: 6px;
}

.clear-all-btn:hover {
  border-color: var(--danger);
  color: var(--danger);
  background: rgba(224, 92, 92, 0.05);
}

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

/* ── Scrollbar ────────────────────────────────────────── */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-mid); border-radius: 99px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.2); }

/* ── Site Header ──────────────────────────────────────── */
.site-header {
  height: var(--header-h);
  background: var(--bg-base);
  border-bottom: 1px solid var(--border-subtle);
  flex-shrink: 0;
  position: relative;
  z-index: 10;
}

.header-inner {
  height: 100%;
  padding: 0 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

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

.sidebar-toggle {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 4px;
  border-radius: var(--r-sm);
  transition: color var(--t-fast), background var(--t-fast);
  display: none;
  align-items: center;
  justify-content: center;
}

.sidebar-toggle:hover {
  color: var(--text-primary);
  background: var(--bg-elevated);
}

@media (max-width: 768px) {
  .sidebar-toggle {
    display: flex;
  }
}

.brand-mark {
  font-size: 20px;
  color: var(--accent);
  line-height: 1;
  animation: markPulse 4s ease-in-out infinite;
}

@keyframes markPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.55; }
}

.brand-name {
  font-family: var(--font-display);
  font-size: 1.35rem;
  letter-spacing: -0.01em;
  color: var(--text-primary);
}

.header-status {
  display: flex;
  align-items: center;
  gap: 6px;
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--success);
  box-shadow: 0 0 6px var(--success);
  transition: background var(--t-mid), box-shadow var(--t-mid);
}

.status-dot.connecting { background: var(--accent); box-shadow: 0 0 6px var(--accent); animation: blink .8s ease infinite; }
.status-dot.error      { background: var(--danger);  box-shadow: 0 0 6px var(--danger); }

@keyframes blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

.status-label {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-muted);
  letter-spacing: 0.03em;
}

/* ── Chat Shell ───────────────────────────────────────── */
.chat-shell {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ── Conversation ─────────────────────────────────────── */
.conversation {
  flex: 1;
  overflow-y: auto;
  padding: 24px 20px 16px;
  scroll-behavior: smooth;
}

/* ── Welcome State ────────────────────────────────────── */
.welcome-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 60px 20px 20px;
  animation: fadeUp .45s var(--t-slow) both;
}

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

.welcome-state.hidden {
  display: none;
}

.welcome-icon {
  font-size: 3rem;
  color: var(--accent);
  margin-bottom: 20px;
  opacity: 0.8;
  animation: markPulse 3s ease-in-out infinite;
}

.welcome-title {
  font-family: var(--font-display);
  font-size: clamp(1.7rem, 4vw, 2.4rem);
  font-weight: 400;
  color: var(--text-primary);
  letter-spacing: -0.02em;
  margin-bottom: 10px;
}

.welcome-sub {
  font-size: 0.95rem;
  color: var(--text-secondary);
  max-width: 320px;
  margin-bottom: 36px;
  line-height: 1.5;
}

.suggestion-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  width: 100%;
  max-width: 520px;
}

.suggestion-chip {
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  font-family: var(--font-body);
  font-size: 0.82rem;
  font-weight: 400;
  padding: 12px 14px;
  border-radius: var(--r-md);
  text-align: left;
  cursor: pointer;
  transition: background var(--t-fast), border-color var(--t-fast), color var(--t-fast), transform var(--t-fast);
  display: flex;
  align-items: center;
  gap: 8px;
  line-height: 1.4;
}

.suggestion-chip:hover {
  background: var(--bg-input);
  border-color: var(--border-mid);
  color: var(--text-primary);
  transform: translateY(-1px);
}

.suggestion-chip:active { transform: translateY(0); }

.chip-icon {
  font-size: 0.95rem;
  flex-shrink: 0;
  color: var(--accent);
  opacity: 0.75;
}

/* ── Messages ─────────────────────────────────────────── */
.messages {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding-bottom: 8px;
}

.message {
  display: flex;
  flex-direction: column;
  max-width: 84%;
  animation: msgIn .3s cubic-bezier(.4,0,.2,1) both;
}

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

.message.user {
  align-self: flex-end;
  align-items: flex-end;
}

.message.assistant {
  align-self: flex-start;
  align-items: flex-start;
}

.message-role {
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 4px;
  padding: 0 4px;
}

.message.user .message-role {
  color: rgba(100,120,200,0.6);
}

.message-bubble {
  padding: 12px 16px;
  border-radius: var(--r-lg);
  font-size: 0.935rem;
  line-height: 1.65;
  word-break: break-word;
  white-space: pre-wrap;
  position: relative;
}

.message.user .message-bubble {
  background: var(--user-bubble);
  border: 1px solid var(--user-border);
  border-bottom-right-radius: var(--r-sm);
  color: var(--text-primary);
}

.message.assistant .message-bubble {
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-bottom-left-radius: var(--r-sm);
  color: var(--text-primary);
}

/* Code blocks inside messages */
.message-bubble pre {
  background: var(--bg-base);
  border: 1px solid var(--border-subtle);
  border-radius: var(--r-sm);
  padding: 12px 14px;
  overflow-x: auto;
  font-size: 0.82rem;
  line-height: 1.55;
  margin: 10px 0;
  font-family: 'Cascadia Code', 'Fira Code', 'Consolas', monospace;
  white-space: pre;
}

.message-bubble code {
  font-family: 'Cascadia Code', 'Fira Code', 'Consolas', monospace;
  font-size: 0.85em;
  background: rgba(255,255,255,0.07);
  padding: 2px 5px;
  border-radius: 4px;
}

.message-bubble pre code {
  background: none;
  padding: 0;
  font-size: inherit;
}

/* Lists */
.message-bubble ul, .message-bubble ol {
  padding-left: 20px;
}

.message-bubble li {
  margin: 3px 0;
}

/* Strong / em */
.message-bubble strong { font-weight: 600; color: var(--text-primary); }
.message-bubble em { font-style: italic; color: var(--text-secondary); }

/* Headings */
.message-bubble h1 {
  font-family: var(--font-display);
  font-size: 1.4rem;
  font-weight: 400;
  margin: 16px 0 8px 0;
  color: var(--text-primary);
  line-height: 1.3;
}

.message-bubble h2 {
  font-family: var(--font-display);
  font-size: 1.2rem;
  font-weight: 400;
  margin: 14px 0 6px 0;
  color: var(--text-primary);
  line-height: 1.35;
}

.message-bubble h3 {
  font-family: var(--font-display);
  font-size: 1.05rem;
  font-weight: 400;
  margin: 12px 0 5px 0;
  color: var(--text-primary);
  line-height: 1.4;
}

.message-bubble h4 {
  font-size: 0.95rem;
  font-weight: 600;
  margin: 10px 0 4px 0;
  color: var(--text-primary);
  line-height: 1.45;
}

/* Message timestamp */
.message-time {
  font-size: 0.65rem;
  color: var(--text-muted);
  margin-top: 4px;
  padding: 0 4px;
  opacity: 0;
  transition: opacity var(--t-mid);
}

.message:hover .message-time { opacity: 1; }

/* ── Typing Indicator ─────────────────────────────────── */
.typing-indicator {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 14px 16px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--r-lg);
  border-bottom-left-radius: var(--r-sm);
  width: fit-content;
  align-self: flex-start;
  margin-top: 4px;
}

.typing-dot {
  width: 6px;
  height: 6px;
  background: var(--text-muted);
  border-radius: 50%;
  animation: typingBounce 1.2s ease-in-out infinite;
}

.typing-dot:nth-child(2) { animation-delay: .18s; }
.typing-dot:nth-child(3) { animation-delay: .36s; }

@keyframes typingBounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.5; }
  30% { transform: translateY(-5px); opacity: 1; }
}

/* ── Error Message ────────────────────────────────────── */
.error-bubble {
  align-self: center;
  background: rgba(224, 92, 92, 0.08);
  border: 1px solid rgba(224, 92, 92, 0.25);
  color: #e88a8a;
  font-size: 0.85rem;
  padding: 10px 16px;
  border-radius: var(--r-md);
  max-width: 84%;
  text-align: center;
  animation: msgIn .3s ease both;
}

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

/* Cooldown progress bar */
.cooldown-bar-wrap {
  height: 2px;
  background: var(--border-subtle);
  border-radius: 99px;
  margin-bottom: 10px;
  overflow: hidden;
  opacity: 0;
  transition: opacity var(--t-mid);
}

.cooldown-bar-wrap.active {
  opacity: 1;
}

.cooldown-bar {
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg, var(--accent), rgba(232,168,76,0.4));
  border-radius: 99px;
  transform-origin: left;
  transform: scaleX(1);
  transition: transform linear;
}

/* Input row */
.input-row {
  display: flex;
  gap: 10px;
  align-items: flex-end;
}

.textarea-wrap {
  flex: 1;
  position: relative;
}

.user-input {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border-mid);
  border-radius: var(--r-lg);
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 0.935rem;
  font-weight: 400;
  line-height: 1.55;
  padding: 12px 44px 12px 16px;
  resize: none;
  outline: none;
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
  max-height: 180px;
  overflow-y: auto;
}

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

.user-input:focus {
  border-color: rgba(232,168,76,0.45);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.user-input:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.char-counter {
  position: absolute;
  right: 14px;
  bottom: 12px;
  font-size: 0.65rem;
  color: var(--text-muted);
  pointer-events: none;
  opacity: 0;
  transition: opacity var(--t-fast);
}

.char-counter.visible { opacity: 1; }
.char-counter.warn    { color: var(--danger); opacity: 1; }

/* Send button */
.send-btn {
  background: var(--accent);
  color: #1a120a;
  border: none;
  border-radius: var(--r-md);
  padding: 0 18px;
  height: 46px;
  font-family: var(--font-body);
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  transition: background var(--t-fast), opacity var(--t-fast), transform var(--t-fast), box-shadow var(--t-fast);
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
  white-space: nowrap;
}

.send-btn:hover:not(:disabled) {
  background: #f0b85a;
  box-shadow: 0 4px 16px rgba(232,168,76,0.3);
  transform: translateY(-1px);
}

.send-btn:active:not(:disabled) {
  transform: translateY(0);
  box-shadow: none;
}

.send-btn:disabled {
  opacity: 0.38;
  cursor: not-allowed;
  transform: none;
}

.send-icon {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

/* Input meta row */
.input-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 7px;
  padding: 0 2px;
  min-height: 18px;
}

.cooldown-text {
  font-size: 0.74rem;
  color: var(--accent);
  font-weight: 500;
  letter-spacing: 0.02em;
  min-width: 120px;
}

.input-hint {
  font-size: 0.7rem;
  color: var(--text-muted);
}

.model-selector {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--r-sm);
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 0.76rem;
  font-weight: 500;
  padding: 6px 10px;
  cursor: pointer;
  transition: all var(--t-fast);
  max-width: 220px;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%239d9a96' d='M6 8L2 4h8z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
  padding-right: 28px;
}

.model-selector:hover {
  border-color: var(--border-mid);
  background-color: var(--bg-elevated);
}

.model-selector:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.model-selector option {
  background: var(--bg-surface);
  color: var(--text-primary);
  padding: 8px;
}

/* ── Site Footer ──────────────────────────────────────── */
.site-footer {
  height: var(--footer-h);
  background: var(--bg-base);
  border-top: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  flex-shrink: 0;
}

.site-footer span {
  font-size: 0.72rem;
  color: var(--text-muted);
  max-width: 70%;
}

.clear-btn {
  background: transparent;
  border: 1px solid var(--border-subtle);
  color: var(--text-muted);
  font-family: var(--font-body);
  font-size: 0.72rem;
  padding: 5px 12px;
  border-radius: var(--r-sm);
  cursor: pointer;
  transition: border-color var(--t-fast), color var(--t-fast);
  white-space: nowrap;
}

.clear-btn:hover {
  border-color: var(--danger);
  color: var(--danger);
}

/* ── Responsive ───────────────────────────────────────── */
@media (max-width: 768px) {
  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    height: 100%;
    z-index: 100;
    transform: translateX(-100%);
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 99;
  }

  .sidebar-overlay.open {
    display: block;
  }

  .header-inner {
    padding: 0 16px;
  }

  .conversation {
    padding: 16px 14px 10px;
  }

  .input-area {
    padding: 8px 14px 10px;
  }
}

@media (max-width: 600px) {
  .suggestion-grid {
    grid-template-columns: 1fr;
    max-width: 340px;
  }

  .message { max-width: 92%; }

  .send-label { display: none; }

  .send-btn {
    padding: 0 14px;
    border-radius: var(--r-md);
  }

  .input-hint { display: none; }

  .site-footer span { display: none; }
}

@media (max-width: 380px) {
  .brand-name { font-size: 1.15rem; }
  .welcome-title { font-size: 1.45rem; }
}

/* ── Print / Reduce Motion ────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    transition-duration: .01ms !important;
  }
}

/* ── Utility ──────────────────────────────────────────── */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  white-space: nowrap;
  border: 0;
}
