/* ============================================
   FONT FACES
   ============================================ */

@font-face {
  font-family: 'Satoshi';
  src: url('Satoshi_Complete/Fonts/WEB/fonts/Satoshi-Variable.woff2') format('woff2'),
       url('Satoshi_Complete/Fonts/WEB/fonts/Satoshi-Variable.woff') format('woff');
  font-weight: 300 900;
  font-display: swap;
  font-style: normal;
}

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

/* ============================================
   CUSTOM PROPERTIES — DARK (DEFAULT)
   ============================================ */

:root {
  --bg: #0a0a0a;
  --bg-secondary: #111111;
  --surface: #1a1a1a;
  --surface-hover: #222222;
  --text: #f5f5f5;
  --text-secondary: #a0a0a0;
  --text-tertiary: #666666;
  --accent: #f5f0e8;
  --accent-dim: rgba(245, 240, 232, 0.08);
  --accent-warm: #f86a5c;
  --border: #222222;
  --border-light: #2a2a2a;
  --radius: 12px;
  --radius-sm: 8px;
  --radius-pill: 999px;
  --font-heading: 'Poppins', system-ui, -apple-system, sans-serif;
  --font-body: 'Satoshi', system-ui, -apple-system, sans-serif;
  --transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ============================================
   LIGHT THEME
   ============================================ */

[data-theme="light"] {
  --bg: #fafafa;
  --bg-secondary: #f0f0f0;
  --surface: #ffffff;
  --surface-hover: #f5f5f5;
  --text: #111111;
  --text-secondary: #555555;
  --text-tertiary: #999999;
  --accent: #1a1a1a;
  --accent-dim: rgba(26, 26, 26, 0.06);
  --accent-warm: #e85d50;
  --border: #e0e0e0;
  --border-light: #eeeeee;
}

/* ============================================
   RESET & BASE
   ============================================ */

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

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

body {
  font-family: var(--font-body);
  font-weight: 400;
  background: var(--bg);
  color: var(--text);
  min-height: 100dvh;
  overflow-x: hidden;
  transition: background var(--transition), color var(--transition);
}

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

a:hover {
  text-decoration: underline;
}

button {
  font-family: inherit;
  cursor: pointer;
}

input, textarea {
  font-family: var(--font-body);
}

/* ============================================
   DOT GRID BACKGROUND
   ============================================ */

body::before {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background: radial-gradient(circle, var(--border) 1px, transparent 1px);
  background-size: 24px 24px;
  opacity: 0.4;
}

/* ============================================
   APP CONTAINER
   ============================================ */

.app {
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
  max-width: 720px;
  margin: 0 auto;
  padding: 0 20px;
  position: relative;
  z-index: 1;
}

/* ============================================
   LANDING STATE
   ============================================ */

.landing {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex: 1;
  gap: 8px;
  text-align: center;
  transition: opacity var(--transition), transform var(--transition);
  padding-bottom: 120px;
}

.landing__logo {
  width: 64px;
  height: auto;
  margin-bottom: 8px;
}

.landing__name {
  font-family: var(--font-heading);
  font-size: 1.75rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--text);
}

.landing__subtitle {
  font-family: var(--font-heading);
  font-size: 0.875rem;
  font-weight: 300;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

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

/* ============================================
   CHAT ACTIVE STATE
   ============================================ */

body.chat-active .landing {
  opacity: 0;
  pointer-events: none;
  position: absolute;
  transform: translateY(-20px);
}

body.chat-active .header {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

body.chat-active .chat {
  opacity: 1;
}

/* ============================================
   HEADER (CHAT STATE)
   ============================================ */

.header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 0;
  opacity: 0;
  pointer-events: none;
  transform: translateY(-8px);
  transition: opacity var(--transition), transform var(--transition);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.header__logo {
  width: 32px;
  height: auto;
  cursor: pointer;
  transition: opacity 0.2s;
}

.header__logo:hover {
  opacity: 0.7;
}

.header__name {
  font-family: var(--font-heading);
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: -0.01em;
}

/* ============================================
   CHIPS
   ============================================ */

.chip {
  display: inline-flex;
  align-items: center;
  padding: 8px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  background: transparent;
  color: var(--text-secondary);
  font-family: var(--font-body);
  font-size: 0.8125rem;
  font-weight: 500;
  letter-spacing: 0.01em;
  transition: border-color 0.2s, color 0.2s, background 0.2s;
  white-space: nowrap;
}

.chip:hover {
  border-color: var(--accent);
  color: var(--text);
  background: var(--accent-dim);
}

/* ============================================
   CHAT AREA
   ============================================ */

.chat {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 16px;
  overflow-y: auto;
  padding: 16px 0;
  opacity: 0;
  transition: opacity var(--transition);
}

/* ============================================
   MESSAGE BUBBLES
   ============================================ */

.message {
  max-width: 85%;
  padding: 12px 16px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  font-size: 0.9375rem;
  line-height: 1.6;
  animation: fadeSlideUp 0.3s ease-out;
}

.message--user {
  align-self: flex-end;
  background: var(--accent-dim);
}

.message--bot {
  align-self: flex-start;
  background: var(--surface);
}

.message--bot strong {
  font-weight: 600;
}

.message--bot code {
  background: var(--bg-secondary);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.85em;
  font-family: 'SF Mono', 'Fira Code', monospace;
}

.message--bot a {
  color: var(--accent-warm);
}

.message--bot a:hover {
  text-decoration: underline;
}

.message--bot ul,
.message--bot ol {
  padding-left: 20px;
  margin-top: 8px;
}

.message--bot li {
  margin-bottom: 4px;
}

/* ============================================
   TYPING INDICATOR
   ============================================ */

.typing-indicator {
  align-self: flex-start;
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 14px 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  animation: fadeSlideUp 0.3s ease-out;
}

.typing-indicator span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--text-tertiary);
  animation: bounce 1.2s infinite;
}

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

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

/* ============================================
   FOLLOW-UP CHIPS (INLINE)
   ============================================ */

.chips--inline {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-self: flex-start;
  animation: fadeSlideUp 0.3s ease-out;
}

/* ============================================
   INPUT AREA
   ============================================ */

.input-area {
  position: sticky;
  bottom: 0;
  padding: 12px 0;
  padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px));
  background: var(--bg);
  z-index: 10;
  flex-shrink: 0;
}

.input-area::before {
  content: '';
  position: absolute;
  top: -24px;
  left: -20px;
  right: -20px;
  height: 24px;
  background: linear-gradient(to top, var(--bg), transparent);
  pointer-events: none;
}

.input-form {
  display: flex;
  align-items: center;
  gap: 4px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 4px 4px 4px 16px;
  background: var(--surface);
  transition: border-color 0.2s;
}

.input-form:focus-within {
  border-color: var(--text-tertiary);
}

.input-field {
  flex: 1;
  border: none;
  background: transparent;
  color: var(--text);
  font-size: 0.9375rem;
  font-weight: 400;
  min-height: 40px;
  outline: none;
  line-height: 1.4;
}

.input-field::placeholder {
  color: var(--text-tertiary);
}

/* ============================================
   ACTION BUTTONS
   ============================================ */

.btn-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-tertiary);
  transition: color 0.2s, background 0.2s;
  flex-shrink: 0;
}

.btn-icon:hover {
  color: var(--text);
  background: var(--surface-hover);
}

.btn-icon svg {
  width: 18px;
  height: 18px;
}

.btn-icon--send {
  background: var(--accent);
  color: var(--bg);
}

.btn-icon--send:hover {
  opacity: 0.85;
  background: var(--accent);
  color: var(--bg);
}

.btn-icon--send:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.btn-icon--voice.listening {
  color: var(--accent-warm);
  animation: pulse 1.5s infinite;
}

/* ============================================
   THEME TOGGLE
   ============================================ */

.theme-toggle {
  position: fixed;
  top: 16px;
  right: 16px;
  display: flex;
  gap: 2px;
  padding: 4px;
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  background: var(--surface);
  z-index: 100;
}

.theme-toggle__btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border: none;
  border-radius: var(--radius-pill);
  background: transparent;
  color: var(--text-tertiary);
  transition: color 0.2s, background 0.2s;
}

.theme-toggle__btn:hover {
  color: var(--text-secondary);
}

.theme-toggle__btn.active {
  color: var(--text);
  background: var(--bg);
}

.theme-toggle__btn svg {
  width: 16px;
  height: 16px;
}

/* ============================================
   OFFLINE INDICATOR
   ============================================ */

.offline-indicator {
  text-align: center;
  font-size: 0.75rem;
  color: var(--text-tertiary);
  padding: 8px 0;
}

.offline-indicator[hidden] {
  display: none;
}

/* ============================================
   KEYFRAMES
   ============================================ */

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

@keyframes bounce {
  0%, 80%, 100% {
    transform: translateY(0);
  }
  40% {
    transform: translateY(-4px);
  }
}

@keyframes pulse {
  0%, 100% {
    opacity: 1;
  }
  50% {
    opacity: 0.5;
  }
}

/* ============================================
   SCROLLBAR
   ============================================ */

.chat::-webkit-scrollbar {
  width: 4px;
}

.chat::-webkit-scrollbar-track {
  background: transparent;
}

.chat::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 2px;
}

/* ============================================
   RESPONSIVE
   ============================================ */

@media (max-width: 480px) {
  .landing__logo {
    width: 48px;
  }

  .landing__name {
    font-size: 1.5rem;
  }

  .message {
    max-width: 92%;
  }

  .chip {
    font-size: 0.75rem;
    padding: 6px 12px;
  }

  .theme-toggle {
    top: 12px;
    right: 12px;
  }
}
