/* ─── Layout ────────────────────────────────────────────────────────────────── */
.assistant-body {
  margin: 0;
  background: #F4F9F7;
  font-family: 'Plus Jakarta Sans', sans-serif;
}

.chat-layout {
  display: flex;
  flex-direction: column;
  height: 100vh;
  max-width: 100%;
}

/* ─── Sidebar ────────────────────────────────────────────────────────────────── */
.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  width: 300px;
  height: 100vh;
  background: #fff;
  border-right: 1px solid #E0EBE7;
  z-index: 100;
  display: flex;
  flex-direction: column;
  transform: translateX(-100%);
  transition: transform 0.25s ease;
  box-shadow: 2px 0 16px rgba(0,0,0,0.08);
}

.sidebar.open {
  transform: translateX(0);
}

.sidebar-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 99;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}

.sidebar-overlay.visible {
  opacity: 1;
  pointer-events: auto;
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid #E0EBE7;
}

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

.sidebar-back {
  display: flex;
  align-items: center;
  color: var(--fg-muted, #6B8A82);
  text-decoration: none;
  transition: color 0.15s;
}

.sidebar-back:hover { color: var(--fg, #2C3F35); }

.sidebar-brand-text {
  font-family: 'Playfair Display', serif;
  font-size: 18px;
  font-weight: 600;
  color: var(--fg, #2C3F35);
}

.sidebar-close {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--fg-muted, #6B8A82);
  padding: 4px;
  display: none;
}

@media (max-width: 768px) {
  .sidebar-close { display: flex; }
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 12px 16px;
  border-bottom: 1px solid #E0EBE7;
}
.sidebar-nav-link {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 8px;
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-size: 0.875rem;
  font-weight: 500;
  color: #6B8A82;
  text-decoration: none;
  transition: all 0.15s;
}
.sidebar-nav-link:hover { background: #F4F9F7; color: #2C3F35; }

/* ─── Conversation List ───────────────────────────────────────────────────────── */
.conversations-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px 0;
}

.conv-item {
  display: flex;
  align-items: center;
  padding: 10px 20px;
  cursor: pointer;
  transition: background 0.15s;
  gap: 8px;
}

.conv-item:hover { background: #F4F9F7; }
.conv-item.active { background: #EEF9F5; }

.conv-content { flex: 1; min-width: 0; }

.conv-preview {
  font-size: 14px;
  color: var(--fg, #2C3F35);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin: 0 0 2px;
}

.conv-meta {
  font-size: 12px;
  color: var(--fg-muted, #6B8A82);
}

.conv-delete {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--fg-muted, #6B8A82);
  padding: 4px;
  opacity: 0;
  transition: opacity 0.15s, color 0.15s;
}

.conv-item:hover .conv-delete { opacity: 1; }
.conv-delete:hover { color: #c0392b; }

.conv-empty {
  padding: 40px 20px;
  text-align: center;
}

.conv-empty-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--fg, #2C3F35);
  margin: 0 0 4px;
}

.conv-empty-sub {
  font-size: 13px;
  color: var(--fg-muted, #6B8A82);
  margin: 0;
}

/* ─── New Chat Button ─────────────────────────────────────────────────────────── */
.btn-new-chat {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 12px 16px;
  padding: 10px 16px;
  background: #1A7A6E;
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
  width: calc(100% - 32px);
}

.btn-new-chat:hover { background: #15695F; }

/* ─── Chat Header ────────────────────────────────────────────────────────────── */
.chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
  background: #fff;
  border-bottom: 1px solid #E0EBE7;
  gap: 12px;
  flex-shrink: 0;
  position: sticky;
  top: 0;
  z-index: 10;
}

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

.btn-menu {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--fg, #2C3F35);
  padding: 4px;
}

@media (max-width: 768px) {
  .btn-menu { display: flex; }
  .sidebar {
    width: 85%;
    max-width: 320px;
  }
}

.chat-title {
  font-family: 'Playfair Display', serif;
  font-size: 18px;
  font-weight: 600;
  color: var(--fg, #2C3F35);
  margin: 0;
}

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

.pet-selector-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
}

.pet-selector-label {
  font-size: 13px;
  color: var(--fg-muted, #6B8A82);
  white-space: nowrap;
}

@media (max-width: 480px) {
  .pet-selector-label { display: none; }
}

.pet-selector {
  border: 1px solid #D1E4DF;
  border-radius: 6px;
  padding: 6px 10px;
  font-size: 13px;
  font-family: 'Plus Jakarta Sans', sans-serif;
  color: var(--fg, #2C3F35);
  background: #fff;
  cursor: pointer;
  max-width: 160px;
}

.pet-selector:focus {
  outline: none;
  border-color: #1A7A6E;
}

/* ─── Messages Area ───────────────────────────────────────────────────────────── */
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* ─── Welcome State ────────────────────────────────────────────────────────────── */
.welcome-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  flex: 1;
  padding: 40px 20px;
  gap: 12px;
}

.welcome-icon {
  margin-bottom: 8px;
}

.welcome-title {
  font-family: 'Playfair Display', serif;
  font-size: 22px;
  font-weight: 600;
  color: var(--fg, #2C3F35);
  margin: 0;
}

.welcome-sub {
  font-size: 15px;
  color: var(--fg-muted, #6B8A82);
  margin: 0;
  max-width: 340px;
  line-height: 1.5;
}

/* ─── Message Bubbles ─────────────────────────────────────────────────────────── */
.msg {
  display: flex;
  flex-direction: column;
  animation: msgIn 0.2s ease;
}

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

.msg-user {
  align-items: flex-end;
}

.msg-ai {
  align-items: flex-start;
}

.msg-bubble {
  max-width: min(480px, 85%);
  padding: 12px 16px;
  border-radius: 16px;
  line-height: 1.55;
  font-size: 15px;
}

.msg-user .msg-bubble {
  background: #1A7A6E;
  color: #fff;
  border-bottom-right-radius: 4px;
}

.msg-ai .msg-bubble {
  background: #fff;
  color: var(--fg, #2C3F35);
  border: 1px solid #D1E4DF;
  border-bottom-left-radius: 4px;
}

/* Markdown inside AI bubbles */
.msg-bubble p { margin: 0 0 8px; }
.msg-bubble p:last-child { margin-bottom: 0; }
.msg-bubble ul, .msg-bubble ol {
  margin: 4px 0 8px;
  padding-left: 20px;
}
.msg-bubble li { margin-bottom: 4px; }
.msg-bubble code {
  background: #F4F9F7;
  border: 1px solid #D1E4DF;
  border-radius: 4px;
  padding: 1px 5px;
  font-size: 13px;
  color: #2C3F35;
}
.msg-bubble strong { font-weight: 600; }
.msg-bubble em { font-style: italic; }
.msg-bubble a { color: #1A7A6E; }

/* ─── Urgency Badge ──────────────────────────────────────────────────────────── */
.urgency-badge {
  display: inline-block;
  font-size: 12px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 20px;
  margin-bottom: 6px;
}

.urgency-urgent {
  background: #FEE2E2;
  color: #991B1B;
}

.urgency-soon {
  background: #FEF3C7;
  color: #92400E;
}

.urgency-monitor {
  background: #D1FAE5;
  color: #065F46;
}

/* ─── Disclaimer ──────────────────────────────────────────────────────────────── */
.msg-disclaimer {
  font-size: 11px;
  color: var(--fg-muted, #6B8A82);
  margin: 4px 0 0;
  font-style: italic;
}

/* ─── Timestamp ─────────────────────────────────────────────────────────────── */
.msg-time {
  font-size: 11px;
  color: var(--fg-muted, #6B8A82);
  margin-top: 4px;
  opacity: 0;
  transition: opacity 0.2s;
}

.msg:hover .msg-time,
.msg-ai .msg-time {
  opacity: 1;
}

/* ─── Typing Indicator ────────────────────────────────────────────────────────── */
.typing-bubble {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 14px 18px !important;
}

.dot {
  width: 7px;
  height: 7px;
  background: #6B8A82;
  border-radius: 50%;
  animation: typing 1.2s ease-in-out infinite;
}

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

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

/* ─── Input Area ─────────────────────────────────────────────────────────────── */
.chat-input-area {
  border-top: 1px solid #E0EBE7;
  background: #fff;
  padding: 12px 20px 16px;
  flex-shrink: 0;
}

/* ─── Usage Row ──────────────────────────────────────────────────────────────── */
.usage-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
  min-height: 20px;
}

.usage-text {
  font-size: 12px;
  color: var(--fg-muted, #6B8A82);
}

.usage-text.usage-warning { color: #D97706; }
.usage-text.usage-exhausted { color: #DC2626; }

.usage-upgrade {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  font-weight: 600;
  color: #1A7A6E;
  text-decoration: none;
  transition: color 0.15s;
}

.usage-upgrade:hover { color: #15695F; }

/* ─── Input Row ──────────────────────────────────────────────────────────────── */
.input-row {
  display: flex;
  gap: 10px;
  align-items: flex-end;
}

.input-wrap {
  flex: 1;
  display: flex;
  align-items: flex-end;
  gap: 8px;
  background: #F4F9F7;
  border: 1.5px solid #D1E4DF;
  border-radius: 12px;
  padding: 8px 12px;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.input-wrap:focus-within {
  border-color: #1A7A6E;
  box-shadow: 0 0 0 3px rgba(26, 122, 110, 0.1);
}

.chat-textarea {
  flex: 1;
  border: none;
  background: transparent;
  resize: none;
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-size: 15px;
  line-height: 1.5;
  color: var(--fg, #2C3F35);
  min-height: 22px;
  max-height: 120px;
  overflow-y: auto;
  padding: 0;
  width: 100%;
}

.chat-textarea:focus { outline: none; }
.chat-textarea::placeholder { color: #6B8A82; }
.chat-textarea:disabled { opacity: 0.6; cursor: not-allowed; }

.btn-send {
  background: #1A7A6E;
  color: #fff;
  border: none;
  border-radius: 50%;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
  flex-shrink: 0;
  padding: 0;
}

.btn-send:hover:not(:disabled) { background: #15695F; transform: scale(1.05); }
.btn-send:disabled { background: #B0C9C4; cursor: not-allowed; transform: none; }

/* ─── Mobile Full Screen ──────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  .assistant-body {
    display: flex;
  }

  .sidebar {
    top: 0;
    left: 0;
    height: 100%;
  }

  .chat-messages {
    padding: 16px;
  }

  .msg-bubble {
    max-width: 90%;
  }

  .pet-selector {
    max-width: 130px;
    font-size: 12px;
  }

  .usage-row {
    flex-wrap: wrap;
    gap: 4px;
  }
}

@media (max-width: 480px) {
  .chat-header {
    padding: 10px 14px;
  }

  .chat-title {
    font-size: 16px;
  }

  .chat-input-area {
    padding: 10px 14px 14px;
  }

  .input-wrap {
    padding: 8px 10px;
  }

  .chat-messages {
    padding: 12px;
    gap: 12px;
  }

  .welcome-title {
    font-size: 19px;
  }
}