/* ===== Custom Scrollbar ===== */
.custom-scrollbar::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
.custom-scrollbar::-webkit-scrollbar-track {
  background: transparent;
}
.custom-scrollbar::-webkit-scrollbar-thumb {
  background: #32324a;
  border-radius: 3px;
}
.custom-scrollbar::-webkit-scrollbar-thumb:hover {
  background: #44446a;
}

/* ===== Chat Input Auto-Resize ===== */
#chatInput {
  min-height: 24px;
  max-height: 128px;
  line-height: 1.5;
}

/* ===== Message Animations ===== */
@keyframes messageSlideIn {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.message-enter {
  animation: messageSlideIn 0.3s ease-out;
}

/* ===== Typing Indicator ===== */
@keyframes typingDot {
  0%, 60%, 100% { opacity: 0.3; transform: translateY(0); }
  30% { opacity: 1; transform: translateY(-4px); }
}

.typing-dot {
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #818cf8;
  margin: 0 2px;
}

.typing-dot:nth-child(1) { animation: typingDot 1.4s ease-in-out infinite 0s; }
.typing-dot:nth-child(2) { animation: typingDot 1.4s ease-in-out infinite 0.2s; }
.typing-dot:nth-child(3) { animation: typingDot 1.4s ease-in-out infinite 0.4s; }

/* ===== Streaming Cursor ===== */
@keyframes blink {
  0%, 50% { opacity: 1; }
  51%, 100% { opacity: 0; }
}

.streaming-cursor::after {
  content: '▊';
  color: #818cf8;
  animation: blink 1s step-end infinite;
  margin-left: 1px;
}

/* ===== Code Blocks in Chat ===== */
.ai-message .code-block-wrapper {
  position: relative;
  margin: 12px 0;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid #27273a;
}

.ai-message .code-block-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 16px;
  background: #1e1e28;
  border-bottom: 1px solid #27273a;
}

.ai-message .code-block-lang {
  font-size: 12px;
  color: #818cf8;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.ai-message .code-block-copy {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  font-size: 12px;
  color: #a1a1aa;
  background: #27273a;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s;
}

.ai-message .code-block-copy:hover {
  background: #32324a;
  color: #e2e8f0;
}

.ai-message pre {
  margin: 0 !important;
  padding: 16px !important;
  background: #0f0f14 !important;
  overflow-x: auto;
}

.ai-message pre code {
  font-size: 13px !important;
  line-height: 1.6 !important;
  font-family: 'JetBrains Mono', 'Fira Code', 'Cascadia Code', monospace !important;
}

/* ===== Markdown Styles in AI Messages ===== */
.ai-message p {
  margin-bottom: 8px;
  line-height: 1.7;
}

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

.ai-message ul, .ai-message ol {
  margin: 8px 0;
  padding-left: 24px;
}

.ai-message li {
  margin-bottom: 4px;
  line-height: 1.6;
}

.ai-message strong {
  color: #e2e8f0;
  font-weight: 600;
}

.ai-message em {
  color: #c4b5fd;
}

.ai-message h1, .ai-message h2, .ai-message h3 {
  color: #e2e8f0;
  font-weight: 700;
  margin: 16px 0 8px;
}

.ai-message h1 { font-size: 1.25rem; }
.ai-message h2 { font-size: 1.125rem; }
.ai-message h3 { font-size: 1rem; }

.ai-message a {
  color: #818cf8;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.ai-message a:hover {
  color: #a5b4fc;
}

.ai-message hr {
  border-color: #27273a;
  margin: 16px 0;
}

.ai-message blockquote {
  border-left: 3px solid #6366f1;
  padding-left: 12px;
  color: #a1a1aa;
  margin: 8px 0;
}

/* ===== Project Items ===== */
.project-item {
  transition: all 0.15s;
}

.project-item:hover .project-delete {
  opacity: 1;
}

.project-delete {
  opacity: 0;
  transition: opacity 0.15s;
}

/* ===== File Tab in Code View ===== */
.file-tab {
  transition: all 0.15s;
}

.file-tab.active {
  background: #6366f1;
  color: white;
}

/* ===== Pulse Animation for Loading ===== */
@keyframes pulse-ring {
  0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(99, 102, 241, 0.4); }
  70% { transform: scale(1); box-shadow: 0 0 0 10px rgba(99, 102, 241, 0); }
  100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(99, 102, 241, 0); }
}

.pulse-ring {
  animation: pulse-ring 2s cubic-bezier(0.455, 0.03, 0.515, 0.955) infinite;
}

/* ===== Toast Transitions ===== */
.toast-visible {
  transform: translateY(0) !important;
  opacity: 1 !important;
  pointer-events: auto !important;
}

/* ===== Mobile Preview Overlay ===== */
@media (max-width: 1023px) {
  #previewPanel.mobile-open {
    display: flex !important;
    position: fixed;
    inset: 0;
    width: 100% !important;
    max-width: 100% !important;
    z-index: 40;
  }
}

/* ===== Highlight.js Override ===== */
.hljs {
  background: #0f0f14 !important;
  padding: 0 !important;
}

/* ===== Smooth Layout Transitions ===== */
#sidebar {
  will-change: transform;
}

/* ===== Empty State ===== */
.empty-projects {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 32px 16px;
  text-align: center;
}

/* ===== Context Menu ===== */
.context-menu {
  position: fixed;
  background: #1e1e28;
  border: 1px solid #27273a;
  border-radius: 12px;
  padding: 4px;
  min-width: 180px;
  box-shadow: 0 16px 48px rgba(0,0,0,0.5);
  z-index: 100;
}

.context-menu-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  font-size: 13px;
  color: #a1a1aa;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.1s;
  width: 100%;
  border: none;
  background: none;
  text-align: left;
}

.context-menu-item:hover {
  background: #27273a;
  color: #e2e8f0;
}

.context-menu-item.danger:hover {
  background: rgba(239, 68, 68, 0.1);
  color: #f87171;
}