/* ============================================================
   Siesta — Design tokens
   Base: MEA dark-navy glass system
   Signature: warm amber "dusk" accent (Siesta = jeda hangat di tengah sistem yg dingin)
   ============================================================ */

:root {
  /* Navy base (MEA family) */
  --bg-0: #0a0e1a;
  --bg-1: #0d1220;
  --bg-2: #111729;
  --surface: rgba(255, 255, 255, 0.03);
  --surface-strong: rgba(255, 255, 255, 0.05);
  --border: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.14);

  /* Text */
  --text-primary: #eef1f8;
  --text-secondary: #9aa3b8;
  --text-tertiary: #5b6478;

  /* Siesta signature accent — warm amber dusk, distinct from MEA's cool blues */
  --accent: #e8a95f;
  --accent-soft: rgba(232, 169, 95, 0.14);
  --accent-strong: #f2bd7e;

  /* Status */
  --success: #6ee7b7;

  /* Radii */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 18px;
  --radius-xl: 24px;

  /* Shadows */
  --shadow-soft: 0 8px 32px rgba(0, 0, 0, 0.35);
  --shadow-glow: 0 0 0 1px rgba(232, 169, 95, 0.08), 0 8px 24px rgba(232, 169, 95, 0.06);

  /* Type */
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono: 'JetBrains Mono', 'SF Mono', Consolas, monospace;
}

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

html, body {
  height: 100%;
}

body {
  font-family: var(--font-sans);
  background: radial-gradient(ellipse at top, #0f1526 0%, var(--bg-0) 55%);
  color: var(--text-primary);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

::selection {
  background: var(--accent-soft);
  color: var(--accent-strong);
}

::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 10px;
}
::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.16);
}

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

textarea {
  font-family: inherit;
}

/* ============================================================
   Layout
   ============================================================ */

.app {
  display: grid;
  grid-template-columns: 280px 1fr;
  height: 100vh;
  transition: grid-template-columns 0.25s ease;
}

.app.sidebar-collapsed {
  grid-template-columns: 0px 1fr;
}

/* ============================================================
   Sidebar
   ============================================================ */

.sidebar {
  background: rgba(13, 18, 32, 0.7);
  backdrop-filter: blur(20px);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 16px 12px;
  overflow: hidden;
  white-space: nowrap;
}

.sidebar-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 8px 20px 8px;
}

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

.brand-mark {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, var(--accent-strong), var(--accent) 60%, #b8763a 100%);
  box-shadow: 0 0 14px rgba(232, 169, 95, 0.35);
  flex-shrink: 0;
}

.brand-name {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--text-primary);
}

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

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

.new-chat-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border-radius: var(--radius-md);
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-primary);
  font-size: 13.5px;
  font-weight: 500;
  transition: background 0.15s, border-color 0.15s;
  margin-bottom: 20px;
}

.new-chat-btn:hover {
  background: var(--surface-strong);
  border-color: var(--border-strong);
}

.history-section {
  flex: 1;
  overflow-y: auto;
  min-height: 0;
}

.history-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-tertiary);
  padding: 0 8px 8px 8px;
}

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

.history-item {
  padding: 9px 10px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  color: var(--text-secondary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.history-item:hover {
  background: var(--surface);
  color: var(--text-primary);
}

.history-item.active {
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.history-empty {
  padding: 12px 10px;
  font-size: 12.5px;
  color: var(--text-tertiary);
  font-style: italic;
}

.sidebar-bottom {
  padding-top: 12px;
  border-top: 1px solid var(--border);
  margin-top: 8px;
}

.model-badge {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px;
  border-radius: var(--radius-md);
}

.model-badge-text {
  display: flex;
  flex-direction: column;
  line-height: 1.3;
}

.model-name {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-primary);
}

.model-sub {
  font-size: 11px;
  color: var(--text-tertiary);
}

.dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
}

.dot-idle {
  background: var(--text-tertiary);
}

.dot-pulse {
  background: var(--accent);
  box-shadow: 0 0 0 0 rgba(232, 169, 95, 0.5);
  animation: pulse 2.2s infinite;
}

.dot-live {
  background: var(--success);
  box-shadow: 0 0 0 0 rgba(110, 231, 183, 0.5);
  animation: pulse-live 2.2s infinite;
}

@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(232, 169, 95, 0.45); }
  70% { box-shadow: 0 0 0 6px rgba(232, 169, 95, 0); }
  100% { box-shadow: 0 0 0 0 rgba(232, 169, 95, 0); }
}

@keyframes pulse-live {
  0% { box-shadow: 0 0 0 0 rgba(110, 231, 183, 0.45); }
  70% { box-shadow: 0 0 0 6px rgba(110, 231, 183, 0); }
  100% { box-shadow: 0 0 0 0 rgba(110, 231, 183, 0); }
}

/* ============================================================
   Chat main
   ============================================================ */

.chat-main {
  display: flex;
  flex-direction: column;
  min-width: 0;
  height: 100vh;
}

.chat-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 24px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.mobile-only {
  display: none;
}

.chat-header-title {
  flex: 1;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.status-chip {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-secondary);
  padding: 5px 10px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--border);
}

.chat-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 0 24px;
}

/* Empty state */

.empty-state {
  max-width: 640px;
  margin: 0 auto;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 40px 20px;
}

.empty-mark {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, var(--accent-strong), var(--accent) 55%, #b8763a 100%);
  box-shadow: var(--shadow-glow), 0 0 40px rgba(232, 169, 95, 0.25);
  margin-bottom: 22px;
}

.empty-state h1 {
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.01em;
  margin-bottom: 8px;
}

.empty-state p {
  font-size: 14px;
  color: var(--text-secondary);
  max-width: 420px;
  line-height: 1.6;
  margin-bottom: 32px;
}

.suggestion-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  width: 100%;
}

.suggestion-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  border-radius: var(--radius-md);
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  font-size: 13px;
  text-align: left;
  transition: background 0.15s, border-color 0.15s, transform 0.15s;
}

.suggestion-card:hover {
  background: var(--surface-strong);
  border-color: var(--border-strong);
  transform: translateY(-1px);
  color: var(--text-primary);
}

.suggestion-icon {
  color: var(--accent);
  font-size: 14px;
  flex-shrink: 0;
}

/* Messages */

.messages {
  max-width: 720px;
  margin: 0 auto;
  padding: 24px 0 12px 0;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.msg {
  display: flex;
  gap: 12px;
  animation: rise 0.25s ease;
}

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

.msg-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 600;
  margin-top: 2px;
}

.msg.user .msg-avatar {
  background: var(--surface-strong);
  color: var(--text-secondary);
}

.msg.assistant .msg-avatar {
  background: radial-gradient(circle at 35% 30%, var(--accent-strong), var(--accent) 60%, #b8763a 100%);
  box-shadow: 0 0 12px rgba(232, 169, 95, 0.3);
}

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

.msg-role {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-tertiary);
  margin-bottom: 4px;
}

.msg.assistant .msg-role {
  color: var(--accent);
}

.msg-content {
  font-size: 14.5px;
  line-height: 1.65;
  color: var(--text-primary);
  white-space: pre-wrap;
  word-wrap: break-word;
}

.msg.user .msg-content {
  color: var(--text-primary);
}

/* Typing indicator */

.typing-indicator {
  display: flex;
  gap: 4px;
  padding: 4px 0;
}

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

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

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

/* Composer */

.composer-wrap {
  padding: 12px 24px 20px 24px;
  flex-shrink: 0;
}

.composer {
  max-width: 720px;
  margin: 0 auto;
  display: flex;
  align-items: flex-end;
  gap: 10px;
  background: var(--surface-strong);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 10px 10px 10px 18px;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.composer:focus-within {
  border-color: rgba(232, 169, 95, 0.35);
  box-shadow: 0 0 0 3px rgba(232, 169, 95, 0.08);
}

.composer-input {
  flex: 1;
  background: none;
  border: none;
  outline: none;
  resize: none;
  color: var(--text-primary);
  font-size: 14.5px;
  line-height: 1.5;
  max-height: 160px;
  padding: 6px 0;
}

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

.send-btn {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
  background: var(--accent);
  color: #1a1206;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.15s, transform 0.1s, opacity 0.15s;
}

.send-btn:hover:not(:disabled) {
  background: var(--accent-strong);
}

.send-btn:active:not(:disabled) {
  transform: scale(0.94);
}

.send-btn:disabled {
  background: var(--surface-strong);
  color: var(--text-tertiary);
  cursor: not-allowed;
}

.composer-hint {
  text-align: center;
  font-size: 11.5px;
  color: var(--text-tertiary);
  margin-top: 10px;
}

/* ============================================================
   Responsive
   ============================================================ */

@media (max-width: 860px) {
  .app {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 280px;
    z-index: 50;
    transform: translateX(0);
    transition: transform 0.25s ease;
    box-shadow: var(--shadow-soft);
  }

  .app.sidebar-collapsed .sidebar {
    transform: translateX(-100%);
  }

  .app.sidebar-collapsed {
    grid-template-columns: 1fr;
  }

  .mobile-only {
    display: flex;
  }

  .suggestion-grid {
    grid-template-columns: 1fr;
  }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.001ms !important;
    transition-duration: 0.001ms !important;
  }
}
