:root {
  --bg-primary: #ffffff;
  --bg-secondary: #f7f7f7;
  --bg-tertiary: #ececf1;
  --text-primary: #0d0d0d;
  --text-secondary: #565869;
  --text-tertiary: #9ca3af;
  --border-color: #d1d5db;
  --accent: #10a37f;
  --accent-light: #d1fae5;
  --message-user-bg: #10a37f;
  --message-assistant-bg: #f7f7f7;
  --hover-color: #f5f5f5;
}

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

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

.hidden {
  display: none !important;
}

.login-screen {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(15, 23, 42, 0.65);
  z-index: 1000;
}

.login-card {
  width: min(460px, 90%);
  background: #ffffff;
  border-radius: 16px;
  padding: 28px 30px;
  box-shadow: 0 20px 60px rgba(15, 23, 42, 0.18);
}

.login-card h2 {
  margin-bottom: 20px;
  font-size: 1.4rem;
  color: #111827;
}

.login-field {
  display: flex;
  flex-direction: column;
  margin-bottom: 14px;
}

.login-field label {
  margin-bottom: 6px;
  font-size: 0.9rem;
  color: #4b5563;
}

.login-field input {
  padding: 12px 14px;
  border: 1px solid #d1d5db;
  border-radius: 10px;
  font-size: 1rem;
  color: #111827;
}

.login-btn {
  width: 100%;
  border: none;
  border-radius: 10px;
  padding: 12px 16px;
  background: #10a37f;
  color: white;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  margin-top: 8px;
}

.login-error {
  min-height: 20px;
  color: #b91c1c;
  margin-bottom: 10px;
  font-size: 0.9rem;
}

.logout-btn {
  margin-left: auto;
  padding: 10px 16px;
  border: 1px solid transparent;
  border-radius: 10px;
  background: #ef4444;
  color: white;
  cursor: pointer;
  font-weight: 600;
}

.logout-btn:hover {
  background: #dc2626;
}

@media (max-width: 768px) {
  .logout-btn {
    margin-top: 12px;
    width: 100%;
  }
}

html,
body {
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", "Roboto", sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.5;
  height: 100%;
  overflow: hidden;
}

body {
  display: flex;
}

.chat-container {
  display: flex;
  width: 100%;
  height: 100vh;
}

/* Sidebar */
.sidebar {
  width: 260px;
  background: var(--bg-primary);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  padding: 12px;
}

.sidebar-header {
  margin-bottom: 20px;
}

.new-chat-btn {
  width: 100%;
  padding: 10px 16px;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  background: transparent;
  cursor: pointer;
  font-size: 0.95em;
  font-weight: 500;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: all 0.2s ease;
}

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

.new-chat-btn .icon {
  font-size: 1.2em;
}

.sidebar-content {
  flex: 1;
  overflow-y: auto;
}

.history-section {
  padding: 8px 0 14px;
  border-bottom: 1px solid var(--border-color);
  margin-bottom: 10px;
}

.history-section h3 {
  font-size: 0.9em;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 10px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.history-list {
  display: grid;
  gap: 8px;
}

.history-item {
  width: 100%;
  text-align: left;
  border: 1px solid var(--border-color);
  background: var(--bg-secondary);
  border-radius: 6px;
  padding: 8px 10px;
  cursor: pointer;
}

.history-item:hover {
  border-color: var(--accent);
}

.history-item.active {
  border-color: var(--accent);
  background: var(--accent-light);
}

.history-title {
  font-size: 0.86em;
  color: var(--text-primary);
  font-weight: 600;
  margin-bottom: 2px;
}

.history-meta {
  font-size: 0.78em;
  color: var(--text-tertiary);
}

.filter-section {
  padding: 12px 0;
}

.filter-section h3 {
  font-size: 0.9em;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 12px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.filter-group {
  margin-bottom: 12px;
}

.filter-group label {
  font-size: 0.85em;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 4px;
  display: block;
}

.filter-group select {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--border-color);
  border-radius: 4px;
  font-size: 0.9em;
  background: var(--bg-primary);
  color: var(--text-primary);
  cursor: pointer;
}

.filter-group select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-light);
}

.btn-apply-filter {
  width: 100%;
  padding: 8px 12px;
  background: var(--accent);
  color: white;
  border: none;
  border-radius: 4px;
  font-size: 0.9em;
  font-weight: 600;
  cursor: pointer;
  margin-top: 12px;
  transition: all 0.2s ease;
}

.btn-apply-filter:hover {
  background: #0d9373;
}

/* Main Content */
.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.chat-header {
  border-bottom: 1px solid var(--border-color);
  padding: 16px 24px;
  background: var(--bg-primary);
}

.header-content h1 {
  font-size: 1.5em;
  font-weight: 700;
  margin-bottom: 4px;
}

.header-content .subtitle {
  font-size: 0.9em;
  color: var(--text-secondary);
}

.messages-container {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
  display: flex;
  flex-direction: column;
  background: var(--bg-primary);
}

.welcome-section {
  text-align: center;
  margin: auto 0;
  max-width: 600px;
  width: 100%;
}

.welcome-section h2 {
  font-size: 2em;
  font-weight: 700;
  margin-bottom: 12px;
}

.welcome-section p {
  color: var(--text-secondary);
  margin-bottom: 24px;
}

.example-prompts {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

@media (max-width: 768px) {
  .example-prompts {
    grid-template-columns: 1fr;
  }
}

.example-btn {
  padding: 12px 16px;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  background: var(--bg-secondary);
  color: var(--text-primary);
  cursor: pointer;
  font-size: 0.9em;
  font-weight: 500;
  transition: all 0.2s ease;
  text-align: left;
  line-height: 1.4;
}

.example-btn:hover {
  border-color: var(--accent);
  background: var(--accent-light);
}

/* Messages */
.message {
  display: flex;
  margin-bottom: 16px;
  animation: slideIn 0.3s ease;
}

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

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

.message.assistant {
  justify-content: flex-start;
}

.message-content {
  max-width: 70%;
  padding: 12px 16px;
  border-radius: 12px;
  word-wrap: break-word;
  line-height: 1.5;
  white-space: pre-wrap;
}

.message.user .message-content {
  background: var(--message-user-bg);
  color: white;
  border-bottom-right-radius: 4px;
}

.message.assistant .message-content {
  background: var(--message-assistant-bg);
  color: var(--text-primary);
  border-bottom-left-radius: 4px;
  border: 1px solid var(--border-color);
}

.message.assistant .message-content p {
  margin-bottom: 8px;
}

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

.trips-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  margin-top: 12px;
}

.trip-card {
  background: white;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 12px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.trip-card:hover {
  border-color: var(--accent);
  box-shadow: 0 2px 8px rgba(16, 163, 127, 0.1);
}

.trip-card-name {
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 4px;
  font-size: 0.95em;
}

.trip-card-meta {
  font-size: 0.85em;
  color: var(--text-tertiary);
  margin-bottom: 2px;
}

.trip-card-meta strong {
  color: var(--text-secondary);
}

/* Chat Footer */
.chat-footer {
  border-top: 1px solid var(--border-color);
  padding: 16px 24px;
  background: var(--bg-primary);
}

.input-form {
  max-width: 900px;
  margin: 0 auto;
}

.input-wrapper {
  display: flex;
  gap: 12px;
  align-items: flex-end;
}

#prompt {
  flex: 1;
  padding: 12px 16px;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  font-size: 0.95em;
  font-family: "Inter", sans-serif;
  color: var(--text-primary);
  resize: none;
  max-height: 200px;
  min-height: 44px;
  line-height: 1.4;
}

#prompt:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-light);
}

.send-btn {
  padding: 10px 12px;
  width: 40px;
  height: 40px;
  background: var(--accent);
  color: white;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2em;
  transition: all 0.2s ease;
  flex-shrink: 0;
}

.send-btn:hover {
  background: #0d9373;
}

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

.input-hints {
  margin-top: 8px;
  font-size: 0.85em;
  color: var(--text-tertiary);
}

.status-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 3px;
  background: #dbeafe;
  color: #0369a1;
  font-weight: 500;
  font-size: 0.85em;
}

.status-badge.ready {
  background: var(--accent-light);
  color: var(--accent);
}

.status-badge.working {
  background: #ffe8b6;
  color: #d97706;
}

/* Loading State */
.message-loading {
  display: flex;
  gap: 4px;
  padding: 12px;
}

.loading-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--text-secondary);
  animation: bounce 1.4s infinite;
}

.loading-dot:nth-child(1) {
  animation-delay: 0s;
}

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

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

@keyframes bounce {
  0%,
  80%,
  100% {
    transform: translateY(0);
    opacity: 0.7;
  }
  40% {
    transform: translateY(-8px);
    opacity: 1;
  }
}

/* Responsive */
@media (max-width: 768px) {
  .sidebar {
    position: absolute;
    left: 0;
    top: 0;
    height: 100%;
    z-index: 100;
    transform: translateX(-100%);
    transition: transform 0.3s ease;
  }

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

  .message-content {
    max-width: 85%;
  }
}
