/* ======================================
   Harmonia & Saúde — ChatGPT-Style Theme
   ====================================== */

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

:root {
  /* Dark Theme Colors */
  --bg-primary: #212121;
  --bg-secondary: #171717;
  --bg-tertiary: #2f2f2f;
  --bg-hover: #3a3a3a;
  --bg-active: #424242;

  --text-primary: #ececec;
  --text-secondary: #b4b4b4;
  --text-tertiary: #8e8e8e;
  --text-placeholder: #666;

  --border-color: #3a3a3a;
  --border-light: #444;

  /* Brand / Accent */
  --accent: #10a37f;
  --accent-hover: #0d8a6b;
  --accent-light: rgba(16, 163, 127, 0.15);

  /* Sizing */
  --sidebar-width: 260px;
  --chat-max-width: 768px;
  --topbar-height: 52px;
  --input-area-height: auto;

  /* Font */
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;

  /* Transitions */
  --transition-fast: 0.15s ease;
  --transition-normal: 0.25s ease;
}

html {
  scroll-behavior: smooth;
  overflow: hidden;
  height: 100%;
}

body {
  font-family: var(--font);
  background: var(--bg-primary);
  color: var(--text-primary);
  height: 100%;
  display: flex;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ======================================
   SIDEBAR
   ====================================== */
.sidebar {
  width: var(--sidebar-width);
  min-width: var(--sidebar-width);
  height: 100%;
  background: var(--bg-secondary);
  display: flex;
  flex-direction: column;
  padding: 8px;
  transition: transform var(--transition-normal);
  z-index: 50;
}

.sidebar-top {
  padding: 4px 0 12px;
}

.new-chat-btn {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  background: transparent;
  border: 1px solid var(--border-color);
  border-radius: 10px;
  color: var(--text-primary);
  font-family: var(--font);
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: background var(--transition-fast);
}

.new-chat-btn:hover {
  background: var(--bg-tertiary);
}

.new-chat-btn svg {
  flex-shrink: 0;
}

/* Sidebar History */
.sidebar-history {
  flex: 1;
  overflow-y: auto;
  padding: 4px 0;
}

.sidebar-history::-webkit-scrollbar {
  width: 4px;
}

.sidebar-history::-webkit-scrollbar-thumb {
  background: var(--bg-hover);
  border-radius: 4px;
}

.history-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-tertiary);
  padding: 12px 14px 8px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

#conversation-list {
  list-style: none;
}

#conversation-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  border-radius: 8px;
  cursor: pointer;
  color: var(--text-secondary);
  font-size: 0.875rem;
  transition: background var(--transition-fast), color var(--transition-fast);
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

#conversation-list li:hover {
  background: var(--bg-tertiary);
  color: var(--text-primary);
}

#conversation-list li.active {
  background: var(--bg-tertiary);
  color: var(--text-primary);
}

#conversation-list li .conv-title {
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
}

#conversation-list li .delete-conv {
  display: none;
  background: none;
  border: none;
  color: var(--text-tertiary);
  cursor: pointer;
  padding: 2px 4px;
  border-radius: 4px;
  font-size: 1rem;
  line-height: 1;
  flex-shrink: 0;
}

#conversation-list li:hover .delete-conv {
  display: block;
}

#conversation-list li .delete-conv:hover {
  color: #ef4444;
  background: rgba(239, 68, 68, 0.1);
}

/* Sidebar Footer */
.sidebar-footer {
  border-top: 1px solid var(--border-color);
  padding-top: 12px;
}

.sidebar-links {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-bottom: 12px;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-radius: 8px;
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 0.875rem;
  transition: background var(--transition-fast), color var(--transition-fast);
}

.sidebar-link:hover {
  background: var(--bg-tertiary);
  color: var(--text-primary);
}

.sidebar-brand {
  padding: 8px 14px 4px;
}

.sidebar-brand p {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-secondary);
}

.sidebar-brand p span {
  color: var(--accent);
}

.sidebar-brand small {
  font-size: 0.65rem;
  color: var(--text-tertiary);
  display: block;
  margin-top: 2px;
}

/* Sidebar Overlay (Mobile) */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  z-index: 40;
  backdrop-filter: blur(2px);
}

.sidebar-overlay.show {
  display: block;
}

/* ======================================
   MAIN CHAT AREA
   ====================================== */
.chat-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  height: 100%;
  min-width: 0;
  position: relative;
}

/* Top Bar */
.chat-topbar {
  height: var(--topbar-height);
  display: flex;
  align-items: center;
  padding: 0 16px;
  gap: 12px;
  background: var(--bg-primary);
  border-bottom: 1px solid transparent;
  flex-shrink: 0;
}

.menu-toggle {
  display: none;
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 6px;
  border-radius: 6px;
  transition: background var(--transition-fast);
}

.menu-toggle:hover {
  background: var(--bg-tertiary);
}

.topbar-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-primary);
}

.topbar-badge {
  font-size: 0.7rem;
  font-weight: 500;
  color: var(--accent);
  background: var(--accent-light);
  padding: 3px 10px;
  border-radius: 12px;
}

/* ======================================
   MESSAGES
   ====================================== */
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 0;
  scroll-behavior: smooth;
}

.chat-messages::-webkit-scrollbar {
  width: 6px;
}

.chat-messages::-webkit-scrollbar-thumb {
  background: var(--bg-hover);
  border-radius: 6px;
}

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

/* Individual Message Row */
.message-row {
  padding: 24px 0;
  display: flex;
  justify-content: center;
  animation: fadeInUp 0.3s ease;
}

.message-row.user-row {
  background: transparent;
}

.message-row.ai-row {
  background: var(--bg-secondary);
}

@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(8px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.message-content {
  max-width: var(--chat-max-width);
  width: 100%;
  padding: 0 24px;
  display: flex;
  gap: 16px;
  align-items: flex-start;
}

/* Avatars */
.message-avatar {
  width: 32px;
  height: 32px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 14px;
  font-weight: 700;
}

.user-row .message-avatar {
  background: #5436DA;
  color: white;
}

.ai-row .message-avatar {
  background: var(--accent);
  color: white;
}

/* Message Text */
.message-text {
  flex: 1;
  line-height: 1.7;
  font-size: 0.95rem;
  color: var(--text-primary);
  padding-top: 4px;
  overflow-wrap: break-word;
  word-break: break-word;
}

.message-text p {
  margin-bottom: 12px;
}

.message-text p:last-child {
  margin-bottom: 0;
}

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

.message-text ul,
.message-text ol {
  margin: 8px 0;
  padding-left: 24px;
}

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

/* ======================================
   WELCOME SCREEN
   ====================================== */
.welcome-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  padding: 40px 24px;
  text-align: center;
  animation: fadeInUp 0.5s ease;
}

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

.welcome-icon {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: var(--accent-light);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 24px;
  color: var(--accent);
}

.welcome-screen h2 {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 8px;
}

.welcome-subtitle {
  font-size: 1rem;
  color: var(--text-secondary);
  margin-bottom: 36px;
  max-width: 420px;
}

/* Suggestion Chips */
.suggestions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  max-width: 600px;
  width: 100%;
  margin-bottom: 32px;
}

.suggestion-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 18px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: 14px;
  color: var(--text-secondary);
  font-family: var(--font);
  font-size: 0.85rem;
  cursor: pointer;
  text-align: left;
  transition: background var(--transition-fast), border-color var(--transition-fast), color var(--transition-fast);
}

.suggestion-chip:hover {
  background: var(--bg-hover);
  border-color: var(--border-light);
  color: var(--text-primary);
}

.suggestion-chip svg {
  flex-shrink: 0;
  color: var(--accent);
}

.welcome-disclaimer {
  font-size: 0.75rem;
  color: var(--text-tertiary);
  max-width: 400px;
}

/* ======================================
   INPUT AREA
   ====================================== */
.chat-input-area {
  padding: 12px 24px 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  flex-shrink: 0;
}

.input-wrapper {
  max-width: var(--chat-max-width);
  width: 100%;
  display: flex;
  align-items: flex-end;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: 24px;
  padding: 8px 12px 8px 20px;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.input-wrapper:focus-within {
  border-color: var(--border-light);
  box-shadow: 0 0 0 2px rgba(16, 163, 127, 0.08);
}

.input-wrapper textarea {
  flex: 1;
  background: none;
  border: none;
  outline: none;
  color: var(--text-primary);
  font-family: var(--font);
  font-size: 0.95rem;
  line-height: 1.5;
  resize: none;
  max-height: 150px;
  padding: 6px 0;
}

.input-wrapper textarea::placeholder {
  color: var(--text-placeholder);
}

.input-wrapper button {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  border: none;
  background: var(--accent);
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background var(--transition-fast), opacity var(--transition-fast);
  margin-left: 8px;
}

.input-wrapper button:disabled {
  background: var(--bg-hover);
  color: var(--text-tertiary);
  cursor: not-allowed;
  opacity: 0.5;
}

.input-wrapper button:not(:disabled):hover {
  background: var(--accent-hover);
}

/* Character Counter */
.char-counter {
  font-size: 0.7rem;
  color: var(--text-tertiary);
  margin-right: 8px;
  white-space: nowrap;
  align-self: center;
  transition: color var(--transition-fast);
}

.char-counter.warn {
  color: #f59e0b;
}

.input-disclaimer {
  font-size: 0.7rem;
  color: var(--text-tertiary);
  margin-top: 10px;
  text-align: center;
}

/* ======================================
   FEEDBACK FORM
   ====================================== */
.feedback-field {
  margin-bottom: 16px;
}

.feedback-field label {
  display: block;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.feedback-field label .required {
  color: #ef4444;
  margin-left: 2px;
}

.feedback-field label .optional {
  color: var(--text-tertiary);
  font-weight: 400;
  font-size: 0.78rem;
}

.feedback-field input[type="text"],
.feedback-field textarea {
  width: 100%;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  color: var(--text-primary);
  font-family: var(--font);
  font-size: 0.9rem;
  padding: 10px 14px;
  outline: none;
  transition: border-color var(--transition-fast);
  resize: none;
}

.feedback-field input[type="text"]:focus,
.feedback-field textarea:focus {
  border-color: var(--accent);
}

.feedback-field input[type="text"]::placeholder,
.feedback-field textarea::placeholder {
  color: var(--text-placeholder);
}

/* Photo upload area */
.fb-photo-area {
  position: relative;
}

.fb-photo-area input[type="file"] {
  position: absolute;
  width: 0;
  height: 0;
  opacity: 0;
}

.fb-photo-label {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  background: var(--bg-tertiary);
  border: 1px dashed var(--border-light);
  border-radius: 10px;
  color: var(--text-secondary);
  font-size: 0.85rem;
  cursor: pointer;
  transition: border-color var(--transition-fast), background var(--transition-fast);
}

.fb-photo-label:hover {
  border-color: var(--accent);
  background: var(--bg-hover);
}

.fb-photo-label svg {
  color: var(--accent);
  flex-shrink: 0;
}

.fb-preview {
  width: 100%;
  max-height: 150px;
  object-fit: cover;
  border-radius: 10px;
  margin-top: 10px;
  border: 1px solid var(--border-color);
}

/* Submit button */
.feedback-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 4px;
}

.fb-submit-btn {
  background: var(--accent);
  color: white;
  border: none;
  border-radius: 10px;
  padding: 10px 24px;
  font-family: var(--font);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: background var(--transition-fast);
}

.fb-submit-btn:hover {
  background: var(--accent-hover);
}

.fb-status {
  font-size: 0.85rem;
  margin-top: 10px;
  min-height: 20px;
  text-align: center;
}

/* ======================================
   TYPING INDICATOR
   ====================================== */
.typing-dots {
  display: flex;
  gap: 5px;
  padding: 8px 0;
}

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

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

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

@keyframes typingBounce {

  0%,
  80%,
  100% {
    transform: scale(0.6);
    opacity: 0.4;
  }

  40% {
    transform: scale(1);
    opacity: 1;
  }
}

/* Streaming cursor */
.message-text.streaming p:last-child::after {
  content: '▍';
  color: var(--accent);
  animation: blink-cursor 0.8s infinite;
  font-weight: 300;
}

@keyframes blink-cursor {

  0%,
  100% {
    opacity: 1;
  }

  50% {
    opacity: 0;
  }
}

/* ======================================
   MODALS
   ====================================== */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  z-index: 200;
  justify-content: center;
  align-items: center;
  backdrop-filter: blur(4px);
}

.modal-overlay.show {
  display: flex;
}

.modal {
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  max-width: 520px;
  width: calc(100% - 32px);
  max-height: 80vh;
  overflow-y: auto;
  animation: modalIn 0.2s ease;
}

@keyframes modalIn {
  from {
    opacity: 0;
    transform: scale(0.95);
  }

  to {
    opacity: 1;
    transform: scale(1);
  }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border-color);
}

.modal-header h3 {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text-primary);
}

.modal-close {
  background: none;
  border: none;
  color: var(--text-tertiary);
  font-size: 1.5rem;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 6px;
  line-height: 1;
  transition: background var(--transition-fast), color var(--transition-fast);
}

.modal-close:hover {
  background: var(--bg-tertiary);
  color: var(--text-primary);
}

.modal-body {
  padding: 24px;
  color: var(--text-secondary);
  font-size: 0.9rem;
  line-height: 1.7;
}

.modal-body h4 {
  color: var(--text-primary);
  font-size: 1rem;
  margin-bottom: 8px;
}

.modal-body ul {
  list-style: none;
  padding: 0;
}

.modal-body ul li {
  padding: 8px 0;
  border-bottom: 1px solid var(--border-color);
}

.modal-body ul li:last-child {
  border-bottom: none;
}

/* Contact items in modal */
.contact-items {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin-top: 8px;
}

.contact-item {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--text-secondary);
  font-size: 0.9rem;
}

.contact-item svg {
  color: var(--accent);
  flex-shrink: 0;
}

/* ======================================
   RESPONSIVE — Mobile
   ====================================== */
@media (max-width: 768px) {
  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    height: 100%;
    transform: translateX(-100%);
    z-index: 50;
  }

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

  .menu-toggle {
    display: flex;
  }

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

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

  .message-content {
    padding: 0 16px;
  }

  .chat-input-area {
    padding: 8px 12px 16px;
  }

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

@media (max-width: 480px) {
  .topbar-badge {
    display: none;
  }

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

  .message-content {
    gap: 10px;
  }

  .input-wrapper {
    padding: 6px 8px 6px 16px;
  }
}

/* ======================================
   SCROLLBAR GLOBAL
   ====================================== */
::-webkit-scrollbar {
  width: 6px;
}

::-webkit-scrollbar-thumb {
  background: var(--bg-hover);
  border-radius: 6px;
}

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

/* Selection Color */
::selection {
  background: rgba(16, 163, 127, 0.3);
  color: var(--text-primary);
}