:root {
  --color-primary: #10b981;
  --color-primary-light: #d1fae5;
  --color-primary-dark: #059669;
  --color-dark: #1f2937;
  --color-gray: #6b7280;
  --color-light: #f3f4f6;
  --color-white: #ffffff;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
  --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.1);

  --radius: 12px;
  --radius-lg: 16px;

  --transition: all 0.25s ease;

  --mobile-bottom-nav-height: 60px;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto;
  background: var(--color-light);
  color: var(--color-dark);
  height: 100dvh;
  overflow: hidden;
}

button {
  border: none;
  background: none;
  cursor: pointer;
}

/* Layout */
.container {
  display: flex;
  height: 100dvh;
}

/* Sidebar */
.sidebar {
  width: 260px;
  background: var(--color-white);
  border-right: 1px solid #e5e7eb;
  display: flex;
  flex-direction: column;
}

.sidebar-header {
  padding: 20px 16px;
  border-bottom: 1px solid #e5e7eb;
}

.sidebar-footer {
  margin-top: auto;
  padding: 16px;
  border-top: 1px solid #e5e7eb;
  font-size: 14px;
  color: var(--color-gray);
  text-align: center;
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 20px;
  font-weight: 700;
  color: var(--color-primary);
}

.sidebar-nav {
  padding: 16px 8px;
}

.nav-btn {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-radius: var(--radius);
  font-size: 14px;
  color: var(--color-gray);
  transition: var(--transition);
}

.nav-btn:hover {
  background: var(--color-light);
  color: var(--color-primary);
}

.nav-btn.active {
  background: var(--color-primary-light);
  color: var(--color-primary);
}

/* Chat Area */
.chat-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: var(--color-white);
}

.chat-header {
  padding: 20px 24px;
  border-bottom: 1px solid #e5e7eb;
}

.header-content h1 {
  font-size: 24px;
  margin-bottom: 4px;
}

.header-content p {
  font-size: 14px;
  color: var(--color-gray);
}

/* Message Area */
.messages-area {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  scroll-behavior: smooth;
}

#chatMessages {
  display: flex;
  flex-direction: column;
  gap: 20px;
  width: 100%;
}

/* Welcome */
.welcome-section {
  text-align: center;
  margin: auto;
}

.welcome-icon {
  width: 80px;
  height: 80px;
  background: var(--color-primary);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 40px;
  margin: auto;
  margin-bottom: 20px;
}

.welcome-section p {
  margin-top: 20px;
}

/* Message */
.message {
  width: 100%;
  display: flex;
  animation: fadeIn 0.2s ease;
}

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

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

.message-bubble {
  max-width: 620px;
  padding: 12px 16px;
  border-radius: var(--radius-lg);
  line-height: 1.6;
  word-break: break-word;
}

/* User Bubble */
.message--user .message-bubble {
  background: #e5e7eb;
  border-radius: 16px 4px 16px 16px;
}

/* Ai Bubble */
.message--assistant .message-bubble {
  background: #f3f4f6;
  border-radius: 4px 16px 16px 16px;
}

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

/* Input */
.input-section {
  padding: 20px 24px;
  border-top: 1px solid #e5e7eb;
}

.input-box {
  background: var(--color-light);
  border: 1px solid #e5e7eb;
  border-radius: var(--radius-lg);
  padding: 12px;
}

.text-input {
  width: 100%;
  border: none;
  background: transparent;
  resize: none;
  outline: none;
  font-size: 15px;
  max-height: 120px;
  font-family: "Segoe UI", Roboto, sans-serif;
}

.input-controls {
  display: flex;
  justify-content: flex-end;
  margin-top: 8px;
}

.input-buttons {
  display: flex;
  gap: 8px;
}

.input-btn,
.send-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.input-btn {
  background: white;
  border: 1px solid #e5e7eb;
  color: var(--color-gray);
}

.input-btn:hover {
  background: var(--color-primary-light);
  color: var(--color-primary);
}

.send-btn {
  background: var(--color-primary);
  color: white;
}

.send-btn:hover {
  background: var(--color-primary-dark);
}

/* Upload Preview */
.upload-preview {
  margin-bottom: 10px;
}

.upload-preview.hidden {
  display: none;
}

.preview-content {
  position: relative;
  display: inline-block;
}

.preview-content img {
  max-width: 120px;
  border-radius: 10px;
  box-shadow: var(--shadow-sm);
  margin-bottom: 6px;
}

.close-preview {
  position: absolute;
  top: -8px;
  right: -8px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--color-primary);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Toast */
.toast {
  position: fixed;
  bottom: 20px;
  right: 20px;
  background: var(--color-dark);
  color: white;
  padding: 12px 18px;
  border-radius: var(--radius);
  opacity: 0;
  transition: 0.3s;
}

.toast.show {
  opacity: 1;
}

/* Scrollbar */
::-webkit-scrollbar {
  width: 6px;
}

::-webkit-scrollbar-thumb {
  background: #d1d5db;
  border-radius: 3px;
}

/* Loading Spinner */
.spinner {
  width: 18px;
  height: 18px;
  border: 2px solid rgba(255, 255, 255, 0.4);
  border-top: 2px solid white;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* Tablet */
@media (max-width: 768px) {
  .sidebar {
    width: 70px;
  }

  .sidebar-header {
    display: none !important;
  }

  .sidebar-footer {
    display: none !important;
  }

  .chat-header {
    display: none !important;
  }

  .logo span {
    display: none !important;
  }

  .nav-btn {
    justify-content: center;
    padding: 12px;
  }

  .nav-btn span {
    display: none !important;
  }

  .messages-area {
    padding: 18px;
  }

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

  .chat-header h1 {
    font-size: 20px;
  }
}

/* Mobile */
@media (max-width: 480px) {
  .container {
    flex-direction: column;
  }

  .sidebar {
    width: 100%;
    height: var(--mobile-bottom-nav-height);
    flex-direction: row;
    align-items: center;
    border-right: none;
    border-top: 1px solid #e5e7eb;
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1000;
    background: var(--color-white);
    padding-bottom: env(safe-area-inset-bottom);
  }

  .chat-header {
    display: none !important;
  }

  .sidebar-nav {
    flex-direction: row;
    width: 100%;
    justify-content: center;
  }

  .chat-header {
    display: none !important;
  }

  .chat-container {
    height: 100dvh;
    padding-bottom: calc(
      var(--mobile-bottom-nav-height) + env(safe-area-inset-bottom)
    );
  }

  .chat-header,
  .messages-area,
  .input-section {
    padding: 16px;
  }

  .message-bubble {
    max-width: 90%;
    font-size: 14px;
  }
}
