/* Reset and Base Styles */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  /* ShadCN-inspired palette */
  --primary: #111111;
  --primary-hover: #1f1f1f;
  --primary-active: #2a2a2a;

  --background: #ffffff;
  --foreground: #111111;
  --muted: #f5f5f5;
  --muted-foreground: #6b7280; /* gray-500 */
  --border: #e5e7eb; /* gray-200 */
  --input: #e5e7eb;
  --ring: #111111;

  --success: #16a34a;
  --error: #ef4444;
  --warning: #f59e0b;

  --radius: 0.6rem;

  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial,
    sans-serif;
}

body {
  background-color: var(--muted);
  color: var(--foreground);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

.container {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Header */
.header {
  background: var(--background);
  color: var(--foreground);
  padding: 1.25rem 1rem;
  border-bottom: 1px solid var(--border);
}

.header-content {
  max-width: 1200px;
  margin: 0 auto;
}

.header-title {
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  margin-bottom: 0.25rem;
}

.header-subtitle {
  font-size: 1rem;
  opacity: 0.9;
  font-weight: 400;
}

/* Main Content */
.main-content {
  flex: 1;
  max-width: 960px;
  width: 100%;
  margin: 0 auto;
  padding: 1.5rem 1rem;
}

/* Upload Section */
.upload-section {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: calc(100vh - 200px);
}

.upload-card {
  background: var(--background);
  border: 1px solid var(--border);
  border-radius: calc(var(--radius) * 1.5);
  padding: 2rem 1.5rem;
  max-width: 640px;
  width: 100%;
  box-shadow: 0 1px 0 rgba(0,0,0,0.04);
}

.upload-icon {
  font-size: 3rem;
  text-align: center;
  margin-bottom: 1.5rem;
}

.upload-title {
  font-size: 1.5rem;
  font-weight: 700;
  text-align: center;
  margin-bottom: 0.5rem;
}

.upload-description {
  text-align: center;
  color: var(--muted-foreground);
  margin-bottom: 2rem;
}

.upload-description code {
  background: var(--muted);
  padding: 0.2rem 0.4rem;
  border-radius: 0.25rem;
  font-family: monospace;
  font-size: 0.875rem;
}

/* Drop Zone */
.drop-zone {
  border: 1.5px dashed var(--border);
  border-radius: calc(var(--radius) * 1.2);
  padding: 2rem 1.25rem;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s ease;
  background: var(--muted);
}

.drop-zone:hover {
  border-color: var(--primary);
  background: var(--background);
}

.drop-zone.drag-over {
  border-color: var(--primary);
  background: var(--muted);
  border-style: solid;
}

.upload-svg {
  margin: 0 auto 1rem;
  color: var(--muted-foreground);
}

.drop-text {
  margin-bottom: 0.5rem;
  color: var(--foreground);
}

.drop-text-bold {
  font-weight: 600;
  color: var(--primary);
}

.drop-text-small {
  font-size: 0.875rem;
  color: var(--muted-foreground);
}

/* File Info */
.file-info {
  margin-top: 2rem;
  padding: 1.5rem;
  background: var(--muted);
  border-radius: var(--radius);
}

.file-info-content {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1rem;
}

.file-icon {
  font-size: 2rem;
}

.file-details {
  flex: 1;
}

.file-name {
  font-weight: 600;
  margin-bottom: 0.25rem;
}

.file-stats {
  font-size: 0.875rem;
  color: var(--muted-foreground);
}

/* Buttons */
.btn-primary,
.btn-secondary,
.btn-icon,
.btn-send {
  border: none;
  border-radius: var(--radius);
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
}

.btn-primary {
  background: var(--foreground);
  color: white;
  padding: 0.75rem 1rem;
  width: 100%;
  font-size: 0.95rem;
}

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

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

.btn-secondary {
  background: var(--background);
  color: var(--foreground);
  border: 1px solid var(--border);
  padding: 0.5rem 1rem;
  font-size: 0.875rem;
}

.btn-secondary:hover {
  background: var(--muted);
}

.btn-icon {
  background: transparent;
  color: var(--muted-foreground);
  padding: 0.25rem;
}

.btn-icon:hover {
  color: var(--foreground);
}

.btn-send {
  background: var(--primary);
  color: white;
  padding: 0.75rem;
  border-radius: 50%;
}

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

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

/* Chat Section */
.chat-section {
  display: flex;
  flex-direction: column;
  height: calc(100vh - 140px);
  background: var(--background);
  border: 1px solid var(--border);
  border-radius: calc(var(--radius) * 1.5);
  overflow: hidden;
  box-shadow: 0 1px 0 rgba(0,0,0,0.04);
}

.chat-header {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
  background: var(--background);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}

.chat-header-content {
  flex: 1;
}

.chat-title {
  font-size: 1.25rem;
  font-weight: 700;
  margin-bottom: 0.25rem;
}

.chat-subtitle {
  font-size: 0.875rem;
  color: var(--muted-foreground);
}

/* Chat Messages */
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

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

.chat-messages::-webkit-scrollbar-track {
  background: var(--muted);
}

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

.chat-messages::-webkit-scrollbar-thumb:hover {
  background: var(--muted-foreground);
}

/* Welcome Message */
.welcome-message {
  text-align: center;
  padding: 2rem;
}

.welcome-icon {
  font-size: 3rem;
  margin-bottom: 1rem;
}

.welcome-message h3 {
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
}

.welcome-message p {
  color: var(--muted-foreground);
  margin-bottom: 2rem;
}

/* Suggestions */
.suggestions {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  max-width: 600px;
  margin: 0 auto;
}

.suggestions-title {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--muted-foreground);
  text-align: left;
}

.suggestion-chip {
  background: var(--background);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.6rem 0.8rem;
  text-align: left;
  cursor: pointer;
  transition: all 0.15s ease;
  font-size: 0.875rem;
}

.suggestion-chip:hover {
  background: var(--background);
  border-color: var(--primary);
  transform: translateY(-2px);
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

/* Message Bubbles */
.message {
  display: flex;
  gap: 0.75rem;
  max-width: 760px;
  animation: slideIn 0.2s ease;
}

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

.message.user {
  align-self: flex-end;
  flex-direction: row-reverse;
}

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

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

.message.assistant .message-avatar {
  background: var(--muted);
}

.message-content {
  flex: 1;
}

.message.user .message-content {
  background: var(--foreground);
  color: white;
  border-radius: 1rem 1rem 0.5rem 1rem;
}

.message.assistant .message-content {
  background: var(--muted);
  border-radius: 1rem 1rem 1rem 0.5rem;
}

.message-text {
  padding: 0.75rem 1rem;
  line-height: 1.5;
  word-wrap: break-word;
}

.message-text p {
  margin-bottom: 0.5rem;
}

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

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

.message-text ul,
.message-text ol {
  margin-left: 1.5rem;
  margin-bottom: 0.5rem;
}

.message-text code {
  background: rgba(0, 0, 0, 0.1);
  padding: 0.2rem 0.4rem;
  border-radius: 0.25rem;
  font-family: monospace;
  font-size: 0.875rem;
}

.message.user .message-text code {
  background: rgba(255, 255, 255, 0.2);
}

/* Typing Indicator */
.typing-indicator .message-content {
  padding: 0.75rem 1rem;
}

.typing-dots {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.typing-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--muted-foreground);
  animation: typing 1.2s ease-in-out infinite;
  will-change: transform, opacity;
}

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

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

@keyframes typing {
  0%, 60%, 100% {
    transform: translateY(0) scale(0.9);
    opacity: 0.45;
  }
  30% {
    transform: translateY(-4px) scale(1);
    opacity: 1;
  }
}

@media (prefers-reduced-motion: reduce) {
  .typing-dot {
    animation: none;
    opacity: 0.6;
  }
}

/* Chat Input */
.chat-input-container {
  padding: 1rem 1.25rem;
  border-top: 1px solid var(--border);
  background: var(--background);
}

.chat-form {
  max-width: 100%;
}

.chat-input-wrapper {
  display: flex;
  gap: 0.75rem;
  align-items: flex-end;
}

.chat-input {
  flex: 1;
  padding: 0.7rem 0.9rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 1rem;
  font-family: inherit;
  resize: none;
  max-height: 150px;
  line-height: 1.5;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.chat-input:focus {
  outline: none;
  border-color: var(--foreground);
  box-shadow: 0 0 0 3px rgba(17, 17, 17, 0.08);
}

.chat-input::placeholder {
  color: var(--muted-foreground);
}

/* Responsive Design */
@media (max-width: 768px) {
  .header {
    padding: 1.5rem 1rem;
  }

  .header-title {
    font-size: 1.5rem;
  }

  .header-subtitle {
    font-size: 0.875rem;
  }

  .main-content {
    padding: 1rem;
  }

  .upload-card {
    padding: 2rem 1.5rem;
  }

  .drop-zone {
    padding: 2rem 1rem;
  }

  .chat-section {
    height: calc(100vh - 120px);
    border-radius: var(--radius);
  }

  .chat-header {
    padding: 1rem;
  }

  .chat-title {
    font-size: 1.125rem;
  }

  .chat-messages {
    padding: 1rem;
  }

  .message {
    max-width: 90%;
  }

  .chat-input-container {
    padding: 1rem;
  }

  .welcome-message {
    padding: 1rem;
  }

  .welcome-icon {
    font-size: 2rem;
  }

  .welcome-message h3 {
    font-size: 1.25rem;
  }
}

@media (max-width: 480px) {
  .header-title {
    font-size: 1.25rem;
  }

  .upload-title {
    font-size: 1.25rem;
  }

  .message {
    max-width: 95%;
  }

  .message-avatar {
    width: 32px;
    height: 32px;
    font-size: 1rem;
  }
}

/* Loading State */
.loading {
  opacity: 0.6;
  pointer-events: none;
}

/* Error State */
.error-message {
  background: #fee2e2;
  border: 1px solid #fecaca;
  color: #991b1b;
  padding: 1rem;
  border-radius: var(--radius);
  margin-bottom: 1rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.error-message svg {
  flex-shrink: 0;
}
