/* ============================================================
   Moka AI — Premium Chatbot Styles
   ============================================================ */

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

:root {
  /* Color Palette - Coffee Theme */
  --bg-primary: #1e1611;
  --bg-secondary: #2d221b;
  --bg-card: rgba(45, 34, 27, 0.7);
  --bg-glass: rgba(255, 235, 205, 0.04);
  --bg-glass-hover: rgba(255, 235, 205, 0.08);

  --text-primary: #f5eedc;
  --text-secondary: #d4c4b7;
  --text-muted: #8c7a6b;

  --accent-cyan: #d4a373;
  --accent-violet: #8b5e3c;
  --accent-teal: #e9edc9;

  --border-subtle: rgba(212, 163, 115, 0.1);
  --border-medium: rgba(212, 163, 115, 0.2);

  --user-bubble: linear-gradient(135deg, #a67c52, #6b4c3a);
  --bot-bubble: rgba(60, 42, 33, 0.8);

  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.5);
  --shadow-glow: 0 0 20px rgba(212, 163, 115, 0.15);

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 20px;
  --radius-xl: 24px;

  --font-main: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-base: 250ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-slow: 400ms cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
  font-family: var(--font-main);
  background: var(--bg-primary);
  background-image:
    radial-gradient(ellipse at 20% 50%, rgba(212, 163, 115, 0.08) 0%, transparent 60%),
    radial-gradient(ellipse at 80% 20%, rgba(139, 94, 60, 0.08) 0%, transparent 60%),
    radial-gradient(ellipse at 50% 100%, rgba(180, 140, 100, 0.05) 0%, transparent 50%);
  color: var(--text-primary);
  min-height: 100vh;
  overflow: hidden;
}

/* --- Custom Scrollbar --- */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.12);
  border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover { background: rgba(255, 255, 255, 0.2); }

/* --- App Layout --- */
.app-wrapper {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  max-width: 860px;
  margin: 0 auto;
  position: relative;
}

/* --- Header --- */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  background: rgba(17, 24, 39, 0.6);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border-subtle);
  z-index: 10;
  flex-shrink: 0;
}

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

.logo-icon {
  width: 42px;
  height: 42px;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, var(--accent-cyan), var(--accent-violet));
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  box-shadow: 0 0 16px rgba(212, 163, 115, 0.3);
  flex-shrink: 0;
}

.header-title h1 {
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  background: linear-gradient(135deg, var(--accent-cyan), var(--accent-violet));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  line-height: 1.2;
}

.header-subtitle {
  font-size: 0.72rem;
  color: var(--text-muted);
  font-weight: 500;
  letter-spacing: 0.02em;
}

.btn-icon {
  width: 38px;
  height: 38px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
  background: var(--bg-glass);
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-fast);
}

.btn-icon:hover {
  background: var(--bg-glass-hover);
  color: var(--text-primary);
  border-color: var(--border-medium);
}

/* --- Chat Area --- */
.chat-area {
  flex: 1;
  overflow-y: auto;
  padding: 24px 20px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  scroll-behavior: smooth;
}

/* --- Welcome Screen --- */
.welcome-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 40px 20px 20px;
  flex: 1;
  animation: fadeInUp 0.6s var(--transition-slow) both;
}

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

.welcome-icon {
  width: 88px;
  height: 88px;
  border-radius: 50%;
  background: rgba(212, 163, 115, 0.08);
  border: 1px solid rgba(212, 163, 115, 0.15);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 24px;
  animation: pulse-glow 3s ease-in-out infinite;
}

.welcome-screen h2 {
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 10px;
  letter-spacing: -0.02em;
  background: linear-gradient(135deg, var(--text-primary), var(--text-secondary));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.welcome-screen > p {
  color: var(--text-secondary);
  font-size: 0.92rem;
  line-height: 1.6;
  max-width: 480px;
  margin-bottom: 32px;
}

/* --- Suggestion Chips --- */
.suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
  max-width: 560px;
}

.suggestion-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 18px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-medium);
  background: var(--bg-glass);
  color: var(--text-secondary);
  font-family: var(--font-main);
  font-size: 0.82rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition-base);
  white-space: nowrap;
}

.suggestion-chip:hover {
  background: rgba(212, 163, 115, 0.1);
  border-color: rgba(212, 163, 115, 0.3);
  color: var(--accent-cyan);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(212, 163, 115, 0.15);
}

.suggestion-chip svg {
  flex-shrink: 0;
  opacity: 0.6;
}

/* --- Messages --- */
.messages-container {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.message-row {
  display: flex;
  gap: 10px;
  animation: fadeInUp 0.35s ease-out both;
  max-width: 100%;
}

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

.message-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-top: 2px;
}

.message-row.bot .message-avatar {
  background: linear-gradient(135deg, var(--accent-cyan), var(--accent-violet));
  color: white;
  box-shadow: 0 0 10px rgba(212, 163, 115, 0.2);
}

.message-row.user .message-avatar {
  background: rgba(166, 124, 82, 0.2);
  color: var(--accent-violet);
}

.message-bubble {
  padding: 12px 16px;
  border-radius: var(--radius-lg);
  font-size: 0.9rem;
  line-height: 1.65;
  max-width: 78%;
  word-wrap: break-word;
  overflow-wrap: break-word;
}

.message-row.user .message-bubble {
  background: var(--user-bubble);
  color: white;
  border-bottom-right-radius: 6px;
  box-shadow: var(--shadow-md);
}

.message-row.bot .message-bubble {
  background: var(--bot-bubble);
  border: 1px solid var(--border-subtle);
  color: var(--text-primary);
  border-bottom-left-radius: 6px;
  box-shadow: var(--shadow-sm);
}

/* Markdown inside bot messages */
.message-row.bot .message-bubble h1,
.message-row.bot .message-bubble h2,
.message-row.bot .message-bubble h3 {
  font-weight: 600;
  margin: 12px 0 6px;
  line-height: 1.3;
}
.message-row.bot .message-bubble h1 { font-size: 1.1rem; }
.message-row.bot .message-bubble h2 { font-size: 1rem; }
.message-row.bot .message-bubble h3 { font-size: 0.95rem; }

.message-row.bot .message-bubble p {
  margin: 4px 0;
}

.message-row.bot .message-bubble ul,
.message-row.bot .message-bubble ol {
  padding-left: 20px;
  margin: 6px 0;
}

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

.message-row.bot .message-bubble strong {
  color: var(--accent-cyan);
  font-weight: 600;
}

.message-row.bot .message-bubble code {
  font-family: 'Fira Code', 'Consolas', monospace;
  background: rgba(0, 0, 0, 0.3);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.85em;
}

.message-row.bot .message-bubble pre {
  background: rgba(0, 0, 0, 0.3);
  padding: 12px;
  border-radius: var(--radius-sm);
  overflow-x: auto;
  margin: 8px 0;
}

.message-row.bot .message-bubble pre code {
  background: none;
  padding: 0;
}

/* Error message style */
.message-row.bot .message-bubble.error-msg {
  border-color: rgba(239, 68, 68, 0.3);
  background: rgba(239, 68, 68, 0.08);
}

/* --- Typing Indicator --- */
.typing-indicator {
  display: none;
  align-items: center;
  gap: 10px;
  padding: 0 0 8px;
  animation: fadeInUp 0.3s ease-out both;
}

.typing-indicator.visible {
  display: flex;
}

.typing-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent-cyan), var(--accent-violet));
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  flex-shrink: 0;
}

.typing-dots {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 12px 18px;
  background: var(--bot-bubble);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  border-bottom-left-radius: 6px;
}

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

.typing-dots span:nth-child(2) { animation-delay: 0.15s; }
.typing-dots span:nth-child(3) { animation-delay: 0.3s; }

/* --- Input Bar --- */
.input-bar {
  padding: 12px 20px 16px;
  background: rgba(17, 24, 39, 0.6);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-top: 1px solid var(--border-subtle);
  flex-shrink: 0;
}

#chat-form {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.input-wrapper {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  background: var(--bg-glass);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-lg);
  padding: 6px 6px 6px 18px;
  transition: all var(--transition-fast);
}

.input-wrapper:focus-within {
  border-color: rgba(212, 163, 115, 0.4);
  box-shadow: 0 0 0 3px rgba(212, 163, 115, 0.08), var(--shadow-glow);
}

#user-input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text-primary);
  font-family: var(--font-main);
  font-size: 0.92rem;
  resize: none;
  max-height: 120px;
  padding: 8px 0;
  line-height: 1.5;
}

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

#btn-send {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  border: none;
  background: linear-gradient(135deg, var(--accent-cyan), var(--accent-violet));
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-fast);
  flex-shrink: 0;
}

#btn-send:hover {
  transform: scale(1.06);
  box-shadow: 0 0 16px rgba(212, 163, 115, 0.3);
}

#btn-send:active {
  transform: scale(0.95);
}

#btn-send:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

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

.input-hint kbd {
  background: var(--bg-glass);
  border: 1px solid var(--border-subtle);
  padding: 1px 5px;
  border-radius: 4px;
  font-family: var(--font-main);
  font-size: 0.68rem;
}

/* --- Animations --- */
@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

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

@keyframes pulse-glow {
  0%, 100% { box-shadow: 0 0 20px rgba(212, 163, 115, 0.1); }
  50% { box-shadow: 0 0 30px rgba(212, 163, 115, 0.25); }
}

/* --- Responsive --- */
@media (max-width: 640px) {
  .app-header {
    padding: 12px 16px;
  }

  .logo-icon {
    width: 36px;
    height: 36px;
  }

  .logo-icon svg {
    width: 22px;
    height: 22px;
  }

  .header-title h1 {
    font-size: 1rem;
  }

  .chat-area {
    padding: 16px 14px;
  }

  .welcome-screen {
    padding: 24px 10px 10px;
  }

  .welcome-screen h2 {
    font-size: 1.25rem;
  }

  .welcome-icon {
    width: 72px;
    height: 72px;
  }

  .welcome-icon svg {
    width: 42px;
    height: 42px;
  }

  .suggestions {
    gap: 8px;
  }

  .suggestion-chip {
    font-size: 0.78rem;
    padding: 8px 14px;
    white-space: normal;
    text-align: left;
  }

  .message-bubble {
    max-width: 88%;
    font-size: 0.87rem;
  }

  .message-avatar {
    width: 28px;
    height: 28px;
  }

  .input-bar {
    padding: 10px 14px 14px;
  }

  .input-hint {
    display: none;
  }
}
