/* =====================================================================
 * HUBAKU COMMERCE INTERNAL AI CHATBOT — Core Styles
 * Aesthetic: warm utilitarian. Cream background, deep charcoal text,
 * muted earth accents, distinctive but not flashy. Built for daily use.
 * ===================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Geist:wght@300;400;500;600;700&family=Geist+Mono:wght@400;500;600&display=swap');

:root {
  /* Colors */
  --bg: #FAF7F2;
  --bg-subtle: #F3EFE8;
  --surface: #FFFFFF;
  --border: #E8E2D9;
  --border-strong: #D5CCBE;

  --text: #1A1614;
  --text-muted: #6B6258;
  --text-dim: #9B9082;

  --accent: #E04E1F;
  --accent-hover: #C7421A;
  --accent-soft: #FCE9DF;

  --success: #4A6B3A;
  --warning: #B8830C;
  --error: #8B2C1F;

  /* Typography */
  --font-sans: 'Geist', -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
  --font-mono: 'Geist Mono', 'SFMono-Regular', Consolas, monospace;

  /* Spacing */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --space-6: 32px;
  --space-7: 48px;
  --space-8: 64px;

  /* Radius */
  --radius-sm: 4px;
  --radius-md: 6px;
  --radius-lg: 10px;

  /* Shadows — minimal */
  --shadow-sm: 0 1px 2px rgba(26, 22, 20, 0.04);
  --shadow-md: 0 2px 8px rgba(26, 22, 20, 0.06);
  --shadow-lg: 0 8px 32px rgba(26, 22, 20, 0.08);
}

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

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.55;
  font-feature-settings: 'ss01', 'cv11';
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Subtle background texture */
body {
  background-image:
    radial-gradient(circle at 1px 1px, rgba(26, 22, 20, 0.025) 1px, transparent 0);
  background-size: 24px 24px;
}

button {
  font: inherit;
  cursor: pointer;
  border: none;
  background: none;
  color: inherit;
}

input, textarea {
  font: inherit;
  color: inherit;
}

a {
  color: var(--accent);
  text-decoration: none;
}
a:hover { color: var(--accent-hover); }

/* =====================================================================
 * LOGIN PAGE
 * ===================================================================== */

.login-shell {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-4);
}

.login-card {
  width: 100%;
  max-width: 420px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-7) var(--space-6);
  box-shadow: var(--shadow-lg);
  position: relative;
}

.login-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--accent);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}

.login-brand {
  margin-bottom: var(--space-6);
}

.login-brand-mark {
  font-family: var(--font-mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--text-muted);
  margin-bottom: var(--space-2);
}

.login-brand-name {
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.login-subtitle {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: var(--space-1);
}

.form-group {
  margin-bottom: var(--space-4);
}

.form-label {
  display: block;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
  margin-bottom: var(--space-2);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.form-input {
  width: 100%;
  padding: 10px var(--space-3);
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  font-size: 14px;
  transition: border-color 0.15s, background 0.15s;
}

.form-input:focus {
  outline: none;
  border-color: var(--accent);
  background: var(--surface);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px var(--space-4);
  border-radius: var(--radius-md);
  font-size: 14px;
  font-weight: 500;
  transition: background 0.15s, transform 0.05s;
  white-space: nowrap;
}

.btn-primary {
  background: var(--text);
  color: var(--bg);
  width: 100%;
  padding: 12px var(--space-4);
}

.btn-primary:hover { background: #2D2724; }
.btn-primary:active { transform: translateY(1px); }
.btn-primary:disabled {
  background: var(--text-dim);
  cursor: not-allowed;
}

.btn-ghost {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-ghost:hover { background: var(--bg-subtle); }

.error-message {
  background: #FBE9E5;
  color: var(--error);
  padding: var(--space-3);
  border-radius: var(--radius-md);
  font-size: 13px;
  margin-bottom: var(--space-4);
  border: 1px solid #F0D0C9;
  display: none;
}

.error-message.visible { display: block; }

.login-footer {
  margin-top: var(--space-6);
  padding-top: var(--space-4);
  border-top: 1px solid var(--border);
  font-size: 11px;
  color: var(--text-dim);
  font-family: var(--font-mono);
  text-align: center;
}

/* =====================================================================
 * APP SHELL (post-login)
 * ===================================================================== */

.app-shell {
  display: grid;
  grid-template-columns: 280px 1fr;
  height: 100vh;
  overflow: hidden;
}

.sidebar {
  background: var(--bg-subtle);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.sidebar-header {
  padding: var(--space-4) var(--space-5);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.sidebar-brand {
  display: flex;
  flex-direction: column;
}

.sidebar-brand-mark {
  font-family: var(--font-mono);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--text-muted);
}

.sidebar-brand-name {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.user-badge {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  font-size: 12px;
}

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

.sidebar-section {
  padding: var(--space-4) var(--space-5);
  border-bottom: 1px solid var(--border);
}

.sidebar-section-title {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  margin-bottom: var(--space-3);
}

.sidebar-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.sidebar-item {
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-sm);
  font-size: 13px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  transition: background 0.1s;
}

.sidebar-item:hover { background: var(--surface); }
.sidebar-item.active {
  background: var(--surface);
  font-weight: 500;
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 1px 6px;
  border-radius: 10px;
  font-size: 10px;
  font-family: var(--font-mono);
  font-weight: 500;
}

.badge-accent { background: var(--accent-soft); color: var(--accent); }
.badge-muted { background: var(--border); color: var(--text-muted); }

.sidebar-footer {
  margin-top: auto;
  padding: var(--space-4) var(--space-5);
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.sidebar-action {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  font-size: 12px;
  color: var(--text-muted);
  border-radius: var(--radius-sm);
  cursor: pointer;
}
.sidebar-action:hover {
  background: var(--surface);
  color: var(--text);
}

/* Main chat area */
.main {
  display: flex;
  flex-direction: column;
  background: var(--bg);
  overflow: hidden;
}

.main-header {
  padding: var(--space-4) var(--space-6);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg);
  z-index: 2;
}

.main-header-title {
  font-size: 14px;
  font-weight: 500;
}

.main-header-meta {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-muted);
}

.chat-stream {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-6);
  display: flex;
  flex-direction: column;
  gap: var(--space-5);
}

.chat-empty {
  margin: auto;
  text-align: center;
  max-width: 480px;
  padding: var(--space-7);
}

.chat-empty-title {
  font-size: 18px;
  font-weight: 500;
  margin-bottom: var(--space-2);
}

.chat-empty-subtitle {
  color: var(--text-muted);
  margin-bottom: var(--space-5);
}

.chat-empty-prompts {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--space-2);
  text-align: left;
}

.chat-empty-prompt {
  padding: var(--space-3);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  font-size: 13px;
  cursor: pointer;
  transition: border-color 0.15s;
}
.chat-empty-prompt:hover {
  border-color: var(--accent);
}

.message {
  display: flex;
  gap: var(--space-3);
  max-width: 820px;
  width: 100%;
  margin: 0 auto;
}

.message-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 600;
  font-family: var(--font-mono);
}

.message-user .message-avatar {
  background: var(--text);
  color: var(--bg);
}

.message-assistant .message-avatar {
  background: var(--accent);
  color: white;
}

.message-body {
  flex: 1;
  min-width: 0;
}

.message-meta {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-dim);
  margin-bottom: var(--space-2);
  display: flex;
  gap: var(--space-3);
}

.message-content {
  font-size: 14px;
  line-height: 1.65;
  color: var(--text);
}

.message-content p { margin-bottom: var(--space-3); }
.message-content p:last-child { margin-bottom: 0; }
.message-content ul, .message-content ol { margin: var(--space-3) 0; padding-left: var(--space-5); }
.message-content li { margin-bottom: var(--space-1); }
.message-content code {
  font-family: var(--font-mono);
  font-size: 12px;
  background: var(--bg-subtle);
  padding: 2px 5px;
  border-radius: 3px;
}
.message-content pre {
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  padding: var(--space-3);
  border-radius: var(--radius-md);
  overflow-x: auto;
  margin: var(--space-3) 0;
}
.message-content pre code {
  background: none;
  padding: 0;
}
.message-content strong { font-weight: 600; }

.thinking-indicator {
  display: flex;
  gap: 4px;
  padding: var(--space-2) 0;
}

.thinking-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--text-dim);
  animation: thinking 1.4s infinite ease-in-out;
}
.thinking-dot:nth-child(2) { animation-delay: 0.16s; }
.thinking-dot:nth-child(3) { animation-delay: 0.32s; }

@keyframes thinking {
  0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
  40% { transform: scale(1); opacity: 1; }
}

/* Composer */
.composer {
  padding: var(--space-4) var(--space-6) var(--space-5);
  border-top: 1px solid var(--border);
  background: var(--bg);
}

.composer-inner {
  max-width: 820px;
  margin: 0 auto;
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  transition: border-color 0.15s;
  box-shadow: var(--shadow-sm);
}

.composer-inner:focus-within {
  border-color: var(--accent);
}

.composer-input {
  width: 100%;
  border: none;
  background: transparent;
  padding: var(--space-4);
  padding-right: 56px;
  font-size: 14px;
  font-family: var(--font-sans);
  resize: none;
  min-height: 56px;
  max-height: 200px;
  outline: none;
}

.composer-send {
  position: absolute;
  right: var(--space-2);
  bottom: var(--space-2);
  width: 36px;
  height: 36px;
  background: var(--text);
  color: var(--bg);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
}

.composer-send:hover { background: var(--accent); }
.composer-send:disabled {
  background: var(--border-strong);
  cursor: not-allowed;
}

.composer-meta {
  max-width: 820px;
  margin: var(--space-2) auto 0;
  font-size: 10px;
  font-family: var(--font-mono);
  color: var(--text-dim);
  display: flex;
  justify-content: space-between;
}

/* =====================================================================
 * MOBILE
 * ===================================================================== */
@media (max-width: 768px) {
  .app-shell {
    grid-template-columns: 1fr;
  }
  .sidebar {
    position: fixed;
    inset: 0 30% 0 0;
    z-index: 10;
    transform: translateX(-100%);
    transition: transform 0.2s;
    box-shadow: var(--shadow-lg);
  }
  .sidebar.open {
    transform: translateX(0);
  }
  .sidebar-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(26, 22, 20, 0.4);
    z-index: 9;
    display: none;
  }
  .sidebar-backdrop.visible { display: block; }
  .mobile-only { display: block !important; }
  .desktop-only { display: none !important; }
  .chat-stream { padding: var(--space-4); }
  .composer { padding: var(--space-3) var(--space-4); }
  .chat-empty-prompts { grid-template-columns: 1fr; }
}

@media (min-width: 769px) {
  .mobile-only { display: none !important; }
}

/* =====================================================================
 * UTILITY
 * ===================================================================== */
.text-muted { color: var(--text-muted); }
.text-mono { font-family: var(--font-mono); }
.text-xs { font-size: 11px; }
.text-sm { font-size: 13px; }
.mt-2 { margin-top: var(--space-2); }
.mt-4 { margin-top: var(--space-4); }
.hidden { display: none !important; }
