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

:root {
  --primary: #6366f1;
  --primary-dark: #4f46e5;
  --secondary: #0ea5e9;
  --bg-dark: #0f0f0f;
  --bg-sidebar: #171717;
  --bg-chat: #212121;
  --bg-input: #2f2f2f;
  --bg-hover: #2a2a2a;
  --text-primary: #ececec;
  --text-secondary: #8e8e8e;
  --text-muted: #6b6b6b;
  --border-color: #2f2f2f;
  --user-msg-bg: #2f2f2f;
  --bot-msg-bg: transparent;
}

html,
body {
  height: 100%;
}

body {
  font-family: "Inter", -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg-dark);
  color: var(--text-primary);
  line-height: 1.6;
  overflow: hidden;
}

.app-container {
  display: flex;
  height: 100vh;
}

/* ==================== SIDEBAR ==================== */
.sidebar {
  width: 260px;
  background: var(--bg-sidebar);
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--border-color);
  transition: transform 0.3s ease;
}

.sidebar-header {
  padding: 16px;
  border-bottom: 1px solid var(--border-color);
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text-primary);
  text-decoration: none;
  font-weight: 600;
  font-size: 1.1rem;
  margin-bottom: 16px;
}

.logo-icon {
  display: flex;
  align-items: center;
  justify-content: center;
}

.logo-icon svg {
  stroke: var(--primary);
}

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

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

.sidebar-content {
  flex: 1;
  overflow-y: auto;
  padding: 12px 8px;
}

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

.sidebar-content::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: 2px;
}

.chat-history {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.history-section {
  margin-bottom: 8px;
}

.history-label {
  display: block;
  padding: 8px 12px;
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.history-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 8px;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.2s;
  font-size: 0.9rem;
}

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

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

.history-item span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sidebar-footer {
  padding: 16px;
  border-top: 1px solid var(--border-color);
}

.user-info {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px;
  border-radius: 8px;
  margin-bottom: 12px;
  background: var(--bg-hover);
}

.user-avatar {
  width: 32px;
  height: 32px;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 0.85rem;
}

.user-info span {
  font-size: 0.9rem;
}

.sidebar-links {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.sidebar-links a {
  display: block;
  padding: 8px 10px;
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 0.85rem;
  border-radius: 6px;
  transition: all 0.2s;
}

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

/* Sidebar Toggle (Mobile) */
.sidebar-toggle {
  display: none;
  position: fixed;
  top: 16px;
  left: 16px;
  z-index: 100;
  background: var(--bg-sidebar);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 8px;
  color: var(--text-primary);
  cursor: pointer;
}

/* ==================== MAIN CHAT ==================== */
.chat-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: var(--bg-chat);
  position: relative;
}

.chat-container {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

.chat-container::-webkit-scrollbar {
  width: 8px;
}

.chat-container::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: 4px;
}

/* Empty State */
.chat-empty {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 20px;
  text-align: center;
}

.empty-logo {
  margin-bottom: 24px;
  animation: float 3s ease-in-out infinite;
}

@keyframes float {
  0%,
  100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-10px);
  }
}

.chat-empty h1 {
  font-size: 2rem;
  font-weight: 600;
  margin-bottom: 16px;
}

.dev-notice {
  color: var(--text-secondary);
  margin-bottom: 40px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.notice-badge {
  display: inline-block;
  padding: 4px 12px;
  background: rgba(251, 191, 36, 0.15);
  color: #fbbf24;
  border-radius: 20px;
  font-size: 0.8rem;
  font-weight: 500;
}

.suggestion-cards {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  max-width: 600px;
  width: 100%;
}

.suggestion-card {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 16px;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  cursor: pointer;
  text-align: left;
  transition: all 0.2s;
}

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

.card-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  background: rgba(99, 102, 241, 0.15);
  border-radius: 10px;
  flex-shrink: 0;
}

.card-icon svg {
  stroke: var(--primary);
}

.card-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.card-text strong {
  font-weight: 500;
  color: var(--text-primary);
}

.card-text span {
  color: var(--text-secondary);
  font-size: 0.9rem;
}

/* Messages */
.messages-container {
  display: none;
  flex-direction: column;
  max-width: 800px;
  width: 100%;
  margin: 0 auto;
  padding: 20px;
}

.messages-container.active {
  display: flex;
}

.message-row {
  display: flex;
  gap: 16px;
  padding: 24px 0;
  border-bottom: 1px solid var(--border-color);
  animation: fadeIn 0.3s ease;
}

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

.message-row:last-child {
  border-bottom: none;
}

.message-avatar {
  width: 36px;
  height: 36px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 1rem;
}

.message-row.user .message-avatar {
  background: var(--primary);
}

.message-row.bot .message-avatar {
  background: linear-gradient(135deg, #10b981, #059669);
}

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

.message-sender {
  font-weight: 600;
  margin-bottom: 8px;
  font-size: 0.95rem;
}

.message-text {
  color: var(--text-primary);
  line-height: 1.7;
  white-space: pre-wrap;
  word-wrap: break-word;
}

.message-text a {
  color: #6C63FF;
  text-decoration: underline;
  font-weight: 600;
  transition: color 0.2s ease;
}

.message-text a:hover {
  color: #8b83ff;
  text-decoration: underline;
}

.message-text pre {
  background: var(--bg-sidebar);
  padding: 16px;
  border-radius: 8px;
  margin: 12px 0;
  overflow-x: auto;
  overflow-wrap: break-word;
  word-wrap: break-word;
  white-space: pre-wrap;
  max-width: 100%;
  font-family: "Fira Code", "Monaco", monospace;
  font-size: 0.9rem;
}

.message-text code {
  background: var(--bg-sidebar);
  padding: 2px 6px;
  border-radius: 4px;
  font-family: "Fira Code", "Monaco", monospace;
  font-size: 0.9rem;
}

/* Typing Indicator */
.typing-row {
  display: flex;
  gap: 16px;
  padding: 24px 0;
}

.typing-dots {
  display: flex;
  gap: 6px;
  padding: 12px 0;
}

.typing-dots span {
  width: 10px;
  height: 10px;
  background: var(--text-muted);
  border-radius: 50%;
  animation: bounce 1.4s infinite;
}

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

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

/* ==================== INPUT AREA ==================== */
.input-area {
  padding: 20px;
  background: var(--bg-chat);
}

.input-wrapper {
  max-width: 800px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  transition: border-color 0.2s;
}

.input-wrapper:focus-within {
  border-color: var(--primary);
}

.input-wrapper textarea {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text-primary);
  font-size: 1rem;
  font-family: inherit;
  resize: none;
  max-height: 200px;
  line-height: 1.5;
}

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

.send-btn {
  width: 40px;
  height: 40px;
  background: var(--text-muted);
  border: none;
  border-radius: 8px;
  color: var(--bg-dark);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

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

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

.send-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.input-disclaimer {
  max-width: 800px;
  margin: 12px auto 0;
  text-align: center;
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* ==================== RESPONSIVE ==================== */

/* Tablets and medium screens */
@media (max-width: 1024px) {
  .sidebar {
    width: 220px;
  }

  .suggestion-cards {
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
  }

  .chat-empty h1 {
    font-size: 1.8rem;
  }

  .chat-empty p {
    font-size: 0.95rem;
  }
}

/* Small tablets and large phones */
@media (max-width: 768px) {
  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    width: 260px;
    z-index: 200;
    transform: translateX(-100%);
  }

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

  .sidebar-toggle {
    display: block;
  }

  .chat-main {
    width: 100%;
  }

  .suggestion-cards {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .suggestion-card {
    padding: 16px;
  }

  .card-icon {
    width: 40px;
    height: 40px;
  }

  .card-icon svg {
    width: 20px;
    height: 20px;
  }

  .chat-empty h1 {
    font-size: 1.5rem;
  }

  .chat-empty p {
    font-size: 0.9rem;
  }

  .message-row {
    padding: 16px 12px;
  }

  .message-avatar {
    width: 32px;
    height: 32px;
    min-width: 32px;
  }

  .message-sender {
    font-size: 0.9rem;
  }

  .message-text {
    font-size: 0.95rem;
  }

  .input-area {
    padding: 12px;
  }

  .input-wrapper textarea {
    font-size: 0.95rem;
    padding: 12px 50px 12px 16px;
  }

  .send-btn {
    width: 40px;
    height: 40px;
    right: 8px;
  }

  .send-btn svg {
    width: 18px;
    height: 18px;
  }
}

/* Mobile devices */
@media (max-width: 640px) {
  .sidebar {
    width: 280px;
  }

  .sidebar-header {
    padding: 12px;
  }

  .sidebar-logo {
    font-size: 1rem;
    margin-bottom: 12px;
  }

  .new-chat-btn {
    padding: 10px 14px;
    font-size: 0.85rem;
  }

  .history-label {
    font-size: 0.7rem;
  }

  .history-item {
    padding: 10px 12px;
    font-size: 0.85rem;
  }

  .user-info {
    padding: 10px 12px;
    font-size: 0.85rem;
  }

  .user-avatar {
    width: 32px;
    height: 32px;
    font-size: 0.9rem;
  }

  .sidebar-links {
    padding: 10px 12px;
  }

  .sidebar-links a {
    font-size: 0.8rem;
  }

  .chat-empty {
    padding: 20px;
  }

  .empty-logo svg {
    width: 48px;
    height: 48px;
  }

  .chat-empty h1 {
    font-size: 1.3rem;
    margin-bottom: 10px;
  }

  .dev-notice {
    font-size: 0.85rem;
    padding: 8px 12px;
  }

  .notice-badge {
    font-size: 0.7rem;
    padding: 2px 8px;
  }

  .suggestion-cards {
    gap: 8px;
  }

  .suggestion-card {
    padding: 14px;
  }

  .card-text strong {
    font-size: 0.9rem;
  }

  .card-text span {
    font-size: 0.8rem;
  }

  .messages-container {
    padding: 12px;
  }

  .message-row {
    padding: 12px 0;
  }

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

  .message-text {
    font-size: 0.9rem;
    line-height: 1.6;
  }

  .message-text pre {
    padding: 12px;
    font-size: 0.8rem;
    margin: 8px 0;
    overflow-x: auto;
    overflow-wrap: break-word;
    word-wrap: break-word;
    white-space: pre-wrap;
    max-width: 100%;
  }

  .message-text code {
    font-size: 0.8rem;
    padding: 2px 5px;
  }

  .typing-dots {
    padding: 12px 16px;
  }

  .typing-dots span {
    width: 8px;
    height: 8px;
  }

  .input-area {
    padding: 10px;
  }

  .input-wrapper {
    max-width: 100%;
  }

  .input-wrapper textarea {
    font-size: 0.9rem;
    padding: 10px 45px 10px 14px;
    min-height: 44px;
  }

  .input-wrapper textarea::placeholder {
    font-size: 0.9rem;
  }

  .send-btn {
    width: 38px;
    height: 38px;
    right: 6px;
    bottom: 6px;
  }

  .input-disclaimer {
    font-size: 0.7rem;
    padding: 8px 0;
  }
}

/* Very small mobile devices */
@media (max-width: 380px) {
  .sidebar {
    width: 100%;
  }

  .chat-empty h1 {
    font-size: 1.1rem;
  }

  .chat-empty p {
    font-size: 0.85rem;
  }

  .suggestion-card {
    padding: 12px;
  }

  .card-icon {
    width: 36px;
    height: 36px;
  }

  .card-text strong {
    font-size: 0.85rem;
  }

  .card-text span {
    font-size: 0.75rem;
  }

  .message-text {
    font-size: 0.85rem;
  }

  .input-wrapper textarea {
    font-size: 0.85rem;
  }
}

/* Landscape orientation on mobile */
@media (max-width: 768px) and (orientation: landscape) {
  .chat-container {
    height: calc(100vh - 60px);
  }

  .chat-empty {
    padding: 15px;
  }

  .chat-empty h1 {
    font-size: 1.2rem;
    margin-bottom: 8px;
  }

  .suggestion-cards {
    grid-template-columns: repeat(2, 1fr);
  }

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

/* Overlay for mobile sidebar */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 150;
  backdrop-filter: blur(2px);
}

.sidebar-overlay.active {
  display: block;
  animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}
