/* ============================================
   STUDY BUDDY - STYLE.CSS
   Tema: lucu, minimalis, cute, biru muda
   ============================================ */

:root {
  --color-primary: #BFDBFE;       /* biru muda utama */
  --color-primary-dark: #3B82F6;  /* biru aksen lebih gelap */
  --color-primary-darker: #2563EB;
  --color-bg: #F0F7FF;            /* background halaman */
  --color-white: #FFFFFF;
  --color-bot-bubble: #F3F6FB;    /* abu sangat terang */
  --color-text: #33415C;
  --color-text-light: #7A8BA6;
  --color-error-bg: #FFE4E6;
  --color-error-text: #B91C1C;
  --radius-lg: 22px;
  --radius-md: 16px;
  --font-heading: 'Poppins', sans-serif;
  --font-body: 'Nunito', sans-serif;
  --shadow-soft: 0 4px 16px rgba(59, 130, 246, 0.12);
}

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

html, body {
  height: 100%;
}

body {
  font-family: var(--font-body);
  background: linear-gradient(180deg, var(--color-bg) 0%, #E4EFFF 100%);
  color: var(--color-text);
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
}

/* ============ APP CONTAINER ============ */
.app {
  width: 100%;
  max-width: 720px;
  height: 100vh;
  background: var(--color-white);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: var(--shadow-soft);
}

@media (min-width: 768px) {
  .app {
    height: 90vh;
    max-height: 860px;
    border-radius: 28px;
    margin: 16px;
  }
}

/* ============ HEADER ============ */
.chat-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 20px;
  background: linear-gradient(135deg, var(--color-primary) 0%, #A7CBFB 100%);
  border-bottom: 1px solid rgba(255,255,255,0.4);
  flex-shrink: 0;
}

.header-avatar {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  background: var(--color-white);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
  flex-shrink: 0;
}

.header-info {
  flex: 1;
}

.header-info h1 {
  font-family: var(--font-heading);
  font-size: 1.15rem;
  font-weight: 700;
  color: #1E3A8A;
}

.header-status {
  font-size: 0.78rem;
  color: #2748A0;
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 2px;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #22C55E;
  display: inline-block;
  box-shadow: 0 0 0 3px rgba(34,197,94,0.2);
}

.new-chat-btn {
  background: var(--color-white);
  border: none;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--color-primary-darker);
  cursor: pointer;
  transition: transform 0.15s ease, background 0.15s ease;
  flex-shrink: 0;
}

.new-chat-btn:hover {
  background: #E8F1FF;
  transform: rotate(-25deg);
}

/* ============ CHAT AREA ============ */
.chat-area {
  flex: 1;
  overflow-y: auto;
  padding: 20px 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  scroll-behavior: smooth;
}

.chat-area::-webkit-scrollbar {
  width: 6px;
}
.chat-area::-webkit-scrollbar-thumb {
  background: var(--color-primary);
  border-radius: 10px;
}

/* ============ WELCOME ============ */
.welcome-block {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 24px 12px 8px;
  gap: 10px;
}

.welcome-emoji {
  font-size: 44px;
  animation: bounce-in 0.6s ease;
}

.welcome-block h2 {
  font-family: var(--font-heading);
  font-size: 1.2rem;
  color: #1E3A8A;
}

.welcome-block p {
  font-size: 0.92rem;
  color: var(--color-text-light);
  max-width: 320px;
}

.suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  margin-top: 12px;
}

.suggestion-chip {
  background: var(--color-primary);
  color: #1E3A8A;
  border: none;
  padding: 10px 16px;
  border-radius: 999px;
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 0.85rem;
  cursor: pointer;
  transition: transform 0.15s ease, background 0.15s ease;
}

.suggestion-chip:hover {
  background: var(--color-primary-dark);
  color: var(--color-white);
  transform: translateY(-2px);
}

@keyframes bounce-in {
  0% { transform: scale(0.5); opacity: 0; }
  60% { transform: scale(1.1); opacity: 1; }
  100% { transform: scale(1); }
}

/* ============ MESSAGE ROWS ============ */
.message-row {
  display: flex;
  gap: 8px;
  align-items: flex-end;
  max-width: 100%;
  animation: fade-up 0.25s ease;
}

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

.user-row {
  justify-content: flex-end;
}

.bot-row {
  justify-content: flex-start;
}

.avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  flex-shrink: 0;
}

.bot-avatar {
  background: var(--color-primary);
}

.user-avatar {
  background: #DCEBFF;
}

.bubble {
  padding: 12px 16px;
  font-size: 0.94rem;
  line-height: 1.5;
  max-width: 75%;
  word-wrap: break-word;
}

.user-bubble {
  background: var(--color-primary);
  color: #1E3A8A;
  border-radius: var(--radius-lg) var(--radius-lg) 4px var(--radius-lg);
}

.bot-bubble {
  background: var(--color-bot-bubble);
  color: var(--color-text);
  border-radius: var(--radius-lg) var(--radius-lg) var(--radius-lg) 4px;
}

/* Markdown formatting inside bubbles */
.bot-bubble strong { color: #1E3A8A; }
.bot-bubble em { color: #4B5B7A; }
.bot-bubble code {
  background: #E4EAF5;
  padding: 2px 6px;
  border-radius: 6px;
  font-size: 0.85em;
  font-family: 'Courier New', monospace;
}
.bot-bubble pre {
  background: #2A3A55;
  color: #E8F0FF;
  padding: 12px;
  border-radius: 12px;
  overflow-x: auto;
  margin: 8px 0;
}
.bot-bubble pre code {
  background: none;
  color: inherit;
  padding: 0;
}
.bot-bubble ul, .bot-bubble ol {
  margin: 6px 0 6px 20px;
}
.bot-bubble p { margin-bottom: 6px; }
.bot-bubble p:last-child { margin-bottom: 0; }

/* ============ TYPING INDICATOR ============ */
.typing-indicator-wrapper {
  padding: 0 16px 6px;
}

.typing-bubble {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 14px 18px;
}

.dot {
  width: 8px;
  height: 8px;
  background: #A9B8D4;
  border-radius: 50%;
  animation: bounce-dot 1.2s infinite ease-in-out;
}

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

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

.hidden {
  display: none !important;
}

/* ============ ERROR BANNER ============ */
.error-banner {
  margin: 0 16px 8px;
  background: var(--color-error-bg);
  color: var(--color-error-text);
  padding: 10px 14px;
  border-radius: var(--radius-md);
  font-size: 0.85rem;
  font-weight: 600;
  text-align: center;
}

/* ============ INPUT AREA ============ */
.input-area {
  flex-shrink: 0;
  padding: 12px 16px;
  background: var(--color-white);
  border-top: 1px solid #EAF1FC;
}

.chat-form {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  background: var(--color-bg);
  border-radius: var(--radius-lg);
  padding: 6px 8px 6px 16px;
  border: 2px solid transparent;
  transition: border-color 0.15s ease;
}

.chat-form:focus-within {
  border-color: var(--color-primary-dark);
}

.chat-input {
  flex: 1;
  border: none;
  background: transparent;
  outline: none;
  font-family: var(--font-body);
  font-size: 0.95rem;
  color: var(--color-text);
  resize: none;
  max-height: 120px;
  padding: 10px 0;
  line-height: 1.4;
}

.chat-input::placeholder {
  color: var(--color-text-light);
}

.send-btn {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: none;
  background: var(--color-primary-dark);
  color: var(--color-white);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.15s ease, transform 0.1s ease;
}

.send-btn:hover {
  background: var(--color-primary-darker);
}

.send-btn:active {
  transform: scale(0.92);
}

.send-btn:disabled {
  background: #C9D6EA;
  cursor: not-allowed;
}

/* ============ RESPONSIVE ============ */
@media (max-width: 480px) {
  .app {
    height: 100vh;
    border-radius: 0;
    margin: 0;
  }
  .bubble {
    max-width: 84%;
  }
  .header-info h1 {
    font-size: 1.05rem;
  }
}
