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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
}

.container {
  width: 90%;
  max-width: 1000px;
  height: 90vh;
  background: white;
  border-radius: 20px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
}

.header {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  padding: 15px 25px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
  z-index: 10;
}

.header-left h1 {
  font-size: 22px;
  font-weight: 600;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.model-selector {
  display: flex;
  align-items: center;
  gap: 8px;
}

.model-selector label {
  font-size: 13px;
  font-weight: 500;
}

.model-selector select {
  padding: 6px 12px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.2);
  color: white;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.3s ease;
}

.model-selector select option {
  background: #667eea;
  color: white;
}

.model-selector select:hover {
  background: rgba(255, 255, 255, 0.3);
}

.model-selector select:focus {
  outline: none;
  background: rgba(255, 255, 255, 0.4);
}

.settings-toggle {
  background: rgba(255, 255, 255, 0.2);
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-radius: 8px;
  color: white;
  padding: 6px 8px;
  cursor: pointer;
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.settings-toggle:hover,
.settings-toggle.active {
  background: rgba(255, 255, 255, 0.35);
  transform: rotate(30deg);
}

.settings-panel {
  position: absolute;
  top: 60px;
  right: 0;
  width: 340px;
  max-height: calc(100% - 130px);
  background: white;
  border-left: 1px solid #e0e0e0;
  box-shadow: -4px 0 20px rgba(0, 0, 0, 0.1);
  z-index: 20;
  transform: translateX(100%);
  transition: transform 0.3s ease;
  overflow-y: auto;
  border-radius: 0 0 0 12px;
}

.settings-panel.open {
  transform: translateX(0);
}

.settings-content {
  padding: 20px;
}

.settings-content h3 {
  font-size: 16px;
  margin-bottom: 16px;
  color: #333;
}

.setting-group {
  margin-bottom: 16px;
}

.setting-group label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: #444;
  margin-bottom: 6px;
}

.setting-group small {
  display: block;
  font-size: 11px;
  color: #888;
  margin-top: 4px;
}

.setting-group textarea,
.setting-group input[type="text"],
.setting-group input[type="number"] {
  width: 100%;
  padding: 8px 10px;
  border: 2px solid #e0e0e0;
  border-radius: 8px;
  font-size: 13px;
  font-family: inherit;
  transition: border-color 0.3s;
}

.setting-group textarea:focus,
.setting-group input:focus {
  outline: none;
  border-color: #667eea;
}

.setting-group input[type="range"] {
  width: 100%;
  margin-top: 4px;
  accent-color: #667eea;
}

.checkbox-label {
  display: flex !important;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-weight: 600 !important;
}

.checkbox-label input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: #667eea;
}

.chat-container {
  flex: 1;
  overflow-y: auto;
  padding: 20px 30px;
  background: #f8f9fa;
}

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

.chat-container::-webkit-scrollbar-track {
  background: #f1f1f1;
}

.chat-container::-webkit-scrollbar-thumb {
  background: #888;
  border-radius: 4px;
}

.chat-container::-webkit-scrollbar-thumb:hover {
  background: #555;
}

.welcome-message {
  text-align: center;
  margin-top: 60px;
  color: #6c757d;
}

.welcome-message h2 {
  font-size: 26px;
  margin-bottom: 10px;
  color: #667eea;
}

.welcome-message p {
  font-size: 15px;
  margin-bottom: 24px;
}

.features-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  max-width: 500px;
  margin: 0 auto;
}

.feature-card {
  background: white;
  border: 1px solid #e0e0e0;
  border-radius: 12px;
  padding: 16px 12px;
  font-size: 13px;
  font-weight: 500;
  color: #555;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  transition: all 0.2s;
}

.feature-card span {
  font-size: 24px;
}

.feature-card:hover {
  border-color: #667eea;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.15);
}

.message {
  margin-bottom: 20px;
  display: flex;
  align-items: flex-start;
  animation: fadeIn 0.3s ease;
}

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

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

.message-content {
  max-width: 75%;
  padding: 15px 20px;
  border-radius: 15px;
  line-height: 1.6;
  word-wrap: break-word;
}

.message.user .message-content {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  border-bottom-right-radius: 5px;
}

.message.assistant .message-content {
  background: white;
  color: #333;
  border: 1px solid #e0e0e0;
  border-bottom-left-radius: 5px;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
}

.message-image {
  max-width: 200px;
  max-height: 200px;
  border-radius: 8px;
  margin: 8px 0;
  object-fit: cover;
}

.pdf-badge {
  background: rgba(255, 255, 255, 0.2);
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 13px;
  margin: 4px 0;
}

.error-content {
  background: #ffebee !important;
  color: #c62828 !important;
  border-color: #ef9a9a !important;
}

.thinking-block {
  margin-bottom: 12px;
  border: 1px solid #e8e0f0;
  border-radius: 10px;
  overflow: hidden;
  background: #faf8ff;
}

.thinking-header {
  padding: 10px 14px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  color: #7c3aed;
  display: flex;
  align-items: center;
  gap: 6px;
  user-select: none;
  transition: background 0.2s;
}

.thinking-header:hover {
  background: #f0ebfa;
}

.thinking-header::after {
  content: '\25bc';
  margin-left: auto;
  font-size: 10px;
  transition: transform 0.2s;
}

.thinking-header.collapsed::after {
  transform: rotate(-90deg);
}

.thinking-content {
  padding: 12px 14px;
  font-size: 13px;
  line-height: 1.6;
  color: #666;
  white-space: pre-wrap;
  max-height: 400px;
  overflow-y: auto;
  border-top: 1px solid #e8e0f0;
  transition: max-height 0.3s ease, padding 0.3s ease, opacity 0.3s ease;
}

.thinking-content.collapsed {
  max-height: 0;
  padding: 0 14px;
  opacity: 0;
  border-top: none;
  overflow: hidden;
}

.tool-use-block {
  margin: 8px 0;
  border: 1px solid #d4edda;
  border-radius: 10px;
  overflow: hidden;
  background: #f8fff9;
}

.tool-use-header {
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 600;
  color: #28a745;
  background: #edf7ef;
}

.tool-use-input {
  padding: 10px 14px;
  font-size: 12px;
  line-height: 1.5;
  color: #555;
  background: #f8fff9;
  margin: 0;
  overflow-x: auto;
  white-space: pre-wrap;
  border-top: 1px solid #d4edda;
}

.copy-button {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-top: 8px;
  padding: 5px 12px;
  background: #f0f0f0;
  border: 1px solid #ddd;
  border-radius: 6px;
  font-size: 12px;
  color: #666;
  cursor: pointer;
  transition: all 0.2s ease;
}

.copy-button:hover {
  background: #e0e0e0;
  color: #333;
  border-color: #ccc;
}

.continuation-indicator {
  margin-top: 8px;
  padding: 6px 12px;
  background: #fff3cd;
  border: 1px solid #ffc107;
  border-radius: 6px;
  font-size: 12px;
  color: #856404;
  animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.6; }
}

.usage-info {
  margin-top: 10px;
  padding: 6px 10px;
  background: #f0f0f0;
  border-radius: 6px;
  font-size: 11px;
  color: #888;
  text-align: right;
}

.attachments-preview {
  padding: 8px 30px;
  background: white;
  border-top: 1px solid #eee;
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
}

.attachment-item {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 6px;
  background: #f8f9fa;
  border: 1px solid #e0e0e0;
  border-radius: 8px;
  max-width: 90px;
}

.attachment-item img {
  width: 60px;
  height: 60px;
  object-fit: cover;
  border-radius: 4px;
}

.pdf-icon {
  width: 60px;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #e8f0fe;
  border-radius: 4px;
  font-size: 14px;
  font-weight: 700;
  color: #667eea;
}

.attachment-name {
  font-size: 10px;
  color: #888;
  text-align: center;
  max-width: 80px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.attachment-remove {
  position: absolute;
  top: -4px;
  right: -4px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #ff4444;
  color: white;
  border: none;
  font-size: 12px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.input-container {
  padding: 15px 25px;
  background: white;
  border-top: 1px solid #e0e0e0;
  display: flex;
  gap: 8px;
  align-items: flex-end;
}

.attach-button {
  padding: 10px;
  border: 2px solid #e0e0e0;
  border-radius: 10px;
  background: white;
  color: #6c757d;
  cursor: pointer;
  transition: all 0.3s;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.attach-button:hover {
  border-color: #667eea;
  color: #667eea;
  background: #f8f9ff;
}

#messageInput {
  flex: 1;
  padding: 10px 14px;
  border: 2px solid #e0e0e0;
  border-radius: 12px;
  font-size: 14px;
  font-family: inherit;
  resize: none;
  transition: border-color 0.3s ease;
}

#messageInput:focus {
  outline: none;
  border-color: #667eea;
}

#messageInput.drag-over {
  border-color: #667eea;
  background: #f8f9ff;
}

.send-button,
.clear-button {
  padding: 10px 16px;
  border: none;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
  flex-shrink: 0;
}

.send-button {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
}

.send-button:hover {
  transform: translateY(-2px);
  box-shadow: 0 5px 15px rgba(102, 126, 234, 0.4);
}

.send-button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.clear-button {
  background: #f8f9fa;
  color: #6c757d;
  border: 2px solid #e0e0e0;
}

.clear-button:hover {
  background: #e9ecef;
  border-color: #ced4da;
}

.typing-indicator {
  display: flex;
  gap: 5px;
  padding: 15px 20px;
}

.typing-indicator span {
  width: 8px;
  height: 8px;
  background: #667eea;
  border-radius: 50%;
  animation: typing 1.4s infinite;
}

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

@keyframes typing {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.7; }
  30% { transform: translateY(-10px); opacity: 1; }
}

@media (max-width: 768px) {
  .container {
    width: 100%;
    height: 100vh;
    border-radius: 0;
  }

  .header {
    flex-direction: column;
    gap: 10px;
    align-items: flex-start;
    padding: 12px 16px;
  }

  .header-right {
    width: 100%;
    justify-content: space-between;
  }

  .settings-panel {
    width: 100%;
    border-radius: 0;
    top: 100px;
  }

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

  .chat-container {
    padding: 15px;
  }

  .input-container {
    flex-wrap: wrap;
    padding: 10px 15px;
  }

  .clear-button {
    width: 100%;
    order: 3;
  }

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

.message-content h1,
.message-content h2,
.message-content h3,
.message-content h4,
.message-content h5,
.message-content h6 {
  margin: 16px 0 12px 0;
  font-weight: 600;
  line-height: 1.3;
  color: #2c3e50;
}

.message-content h1 { font-size: 28px; border-bottom: 2px solid #667eea; padding-bottom: 8px; }
.message-content h2 { font-size: 24px; border-bottom: 1px solid #e0e0e0; padding-bottom: 6px; }
.message-content h3 { font-size: 20px; }
.message-content h4 { font-size: 18px; }

.message-content p {
  margin: 12px 0;
  line-height: 1.7;
}

.message-content ul,
.message-content ol {
  margin: 12px 0;
  padding-left: 24px;
  line-height: 1.8;
}

.message-content ul { list-style-type: disc; }
.message-content ol { list-style-type: decimal; }

.message-content li {
  margin: 6px 0;
  padding-left: 4px;
}

.message-content li::marker {
  color: #667eea;
}

.message-content blockquote {
  margin: 12px 0;
  padding: 12px 16px;
  border-left: 4px solid #667eea;
  background: #f8f9fa;
  font-style: italic;
  color: #555;
}

.message-content pre {
  background: #2d2d2d;
  color: #f8f8f2;
  padding: 16px;
  border-radius: 8px;
  overflow-x: auto;
  margin: 12px 0;
  font-size: 14px;
}

.message-content pre code {
  background: transparent;
  padding: 0;
  color: inherit;
}

.message-content code {
  background: #f4f4f4;
  padding: 3px 6px;
  border-radius: 4px;
  font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
  font-size: 14px;
  color: #e83e8c;
}

.message-content strong {
  font-weight: 700;
  color: #2c3e50;
}

.message-content em {
  font-style: italic;
}

.message-content a {
  color: #667eea;
  text-decoration: none;
  border-bottom: 1px solid #667eea;
  transition: all 0.2s ease;
}

.message-content a:hover {
  color: #764ba2;
  border-bottom-color: #764ba2;
}

.message-content table {
  border-collapse: collapse;
  width: 100%;
  margin: 12px 0;
}

.message-content th,
.message-content td {
  border: 1px solid #e0e0e0;
  padding: 8px 12px;
  text-align: left;
}

.message-content th {
  background: #f8f9fa;
  font-weight: 600;
}

.message-content hr {
  border: none;
  border-top: 2px solid #e0e0e0;
  margin: 20px 0;
}

.message-content img {
  max-width: 100%;
  height: auto;
  border-radius: 8px;
  margin: 12px 0;
}

/* ===== LOGIN PAGE ===== */
.login-container {
  width: 100%;
  height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 20px;
}

.login-card {
  background: white;
  border-radius: 20px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  padding: 40px;
  width: 100%;
  max-width: 420px;
}

.login-header {
  text-align: center;
  margin-bottom: 30px;
}

.login-header h1 {
  font-size: 28px;
  color: #333;
  margin-bottom: 8px;
}

.login-header p {
  color: #888;
  font-size: 14px;
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.login-field label {
  display: block;
  font-weight: 600;
  font-size: 13px;
  color: #555;
  margin-bottom: 6px;
}

.login-field input {
  width: 100%;
  padding: 12px 16px;
  border: 2px solid #e0e0e0;
  border-radius: 12px;
  font-size: 15px;
  transition: border-color 0.2s;
  outline: none;
}

.login-field input:focus {
  border-color: #667eea;
}

.login-error {
  background: #fff0f0;
  border: 1px solid #ffcdd2;
  color: #d32f2f;
  padding: 10px 14px;
  border-radius: 10px;
  font-size: 13px;
  text-align: center;
}

.login-button {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  border: none;
  padding: 14px;
  border-radius: 12px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.2s, transform 0.1s;
}

.login-button:hover {
  opacity: 0.9;
}

.login-button:active {
  transform: scale(0.98);
}

.login-button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* ===== LOGOUT BUTTON ===== */
.logout-button {
  background: rgba(255,255,255,0.15);
  border: none;
  color: white;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
}

.logout-button:hover {
  background: rgba(255,60,60,0.4);
}
