@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=Noto+Sans+TC:wght@400;500;600;700&display=swap');

:root {
  /* Professional UI Color Palette */
  --primary-indigo: #5E639B;
  --primary-indigo-dark: #4A4F85;
  --primary-indigo-light: #6667AB;
  
  /* Accent Colors */
  --accent-yellow: #FDE047;
  --accent-yellow-dark: #FBBF24;
  --accent-yellow-light: #FEF08A;
  
  /* Background Colors */
  --bg-light-gray: #F4F5F7;
  --bg-off-white: #EFF1F5;
  --bg-white: #FFFFFF;
  --bg-panel: #FFFFFF;
  
  /* Text Colors */
  --text-primary: #1F2937;
  --text-secondary: #6B7280;
  --text-muted: #9CA3AF;
  --text-white: #FFFFFF;
  
  /* Border and Divider Colors */
  --border-light: #E5E7EB;
  --border-medium: #D1D5DB;
  --divider: #F3F4F6;
  
  /* Shadow Colors */
  --shadow-soft: rgba(31, 41, 55, 0.08);
  --shadow-medium: rgba(31, 41, 55, 0.12);
  --shadow-strong: rgba(31, 41, 55, 0.16);
  
  /* Legacy compatibility (keep some old variables for smooth transition) */
  --espresso: var(--text-primary);
  --caramel: var(--primary-indigo);
  --steam: var(--bg-white);
  --foam: var(--bg-light-gray);
  --cream: var(--bg-off-white);
  --bg-warm: var(--bg-light-gray);
  --bg-glass: rgba(255, 255, 255, 0.9);
}

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

html, body {
  height: 100%;
  overflow: hidden;
}

body {
  font-family: 'Inter', 'Noto Sans TC', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  background: var(--bg-light-gray);
  color: var(--text-primary);
  line-height: 1.6;
  position: relative;
}

/* P5.js Canvas Background */
#p5-background {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  opacity: 0.7;
  pointer-events: none; /* 確保不會阻擋點擊事件 */
}

/* Auth Root Container */
#auth-root {
  position: relative;
  z-index: 1000;
  pointer-events: auto;
}

/* Main App Container */
.app-container {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 1;
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100vh;
  overflow: hidden;
}

/* Top Navigation Header */
.top-nav-header {
  height: 60px;
  background: #2D3748;
  border-bottom: 1px solid #4A5568;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.5rem;
  flex-shrink: 0;
  z-index: 100;
}

.nav-left {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.nav-right {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.app-title {
  font-family: 'Inter', 'Noto Sans TC', sans-serif;
  font-size: 1.5rem;
  font-weight: 600;
  color: #FFFFFF;
  margin: 0;
}

.version-number {
  font-size: 0.75rem;
  font-weight: 400;
  color: rgba(255, 255, 255, 0.7);
  margin-left: 8px;
  vertical-align: middle;
}

.nav-icon-button {
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 0.5rem;
  border-radius: 8px;
  color: #E2E8F0;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.nav-icon-button:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #FFFFFF;
}

.nav-button {
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.2);
  cursor: pointer;
  padding: 0.5rem 1rem;
  border-radius: 8px;
  color: #E2E8F0;
  font-family: 'Inter', 'Noto Sans TC', sans-serif;
  font-size: 0.875rem;
  transition: all 0.2s ease;
}

.nav-button:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #FFFFFF;
  border-color: rgba(255, 255, 255, 0.3);
}

/* User Menu Styles */
.nav-user-container {
  position: relative;
}

.nav-user-info {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: #E2E8F0;
  font-size: 0.875rem;
}

#nav-user-greeting {
  color: #FFFFFF;
  font-weight: 500;
}

.nav-user-button {
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 0.5rem;
  border-radius: 8px;
  color: #E2E8F0;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.nav-user-button:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #FFFFFF;
}

.dropdown-arrow {
  width: 16px;
  height: 16px;
  transition: transform 0.2s ease;
}

.nav-user-button.active .dropdown-arrow {
  transform: rotate(180deg);
}

.nav-user-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 120px;
  background: #FFFFFF;
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
  overflow: hidden;
  opacity: 0;
  transform: translateY(-10px);
  transition: all 0.2s ease;
  pointer-events: none;
  z-index: 1000;
}

.nav-user-dropdown.show {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

.nav-dropdown-item {
  width: 100%;
  padding: 0.75rem 1rem;
  background: transparent;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--text-primary);
  font-size: 0.875rem;
  font-family: 'Inter', 'Noto Sans TC', sans-serif;
  transition: background 0.2s ease;
  text-align: left;
}

.nav-dropdown-item:hover {
  background: var(--bg-light-gray);
}

.nav-dropdown-item i {
  width: 16px;
  height: 16px;
  color: var(--text-secondary);
}

/* Special styling for clear chat option */
#nav-clear-chat:hover {
  background: rgba(239, 68, 68, 0.1);
  color: #dc2626;
}

#nav-clear-chat:hover i {
  color: #dc2626;
}

/* System message styling */
.message.system {
  background: rgba(59, 130, 246, 0.1);
  border-left: 3px solid #3b82f6;
  margin: 12px 0;
  padding: 12px 16px;
  border-radius: 8px;
}

.message.system .message-content {
  color: #1e40af;
  font-size: 0.9rem;
  line-height: 1.5;
}

.message.system.project-info {
  background: rgba(16, 185, 129, 0.1);
  border-left-color: #10b981;
}

.message.system.project-info .message-content {
  color: #047857;
}

/* App Content Container */
.app-content {
  flex: 1;
  display: flex;
  height: calc(100vh - 60px);
  overflow: hidden;
  position: relative;
  transition: margin-left 0.3s ease;
}

.app-content.sidebar-collapsed {
  margin-left: -350px; /* 完全隱藏 sidebar，使用 project-explorer 的寬度 */
}

/* When editor is open, hide main chat area and let editor take full right side */
.app-content.editor-open .main-chat-area {
  display: none;
}

/* Hide main chat area when editor is open on mobile */
@media (max-width: 768px) {
  .app-content.editor-open .main-chat-area {
    display: none;
  }
}

/* Chat Container */
.chat-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-height: 0; /* 確保 flex 子元素可以收縮 */
  position: relative;
  height: 100%;
}

/* Chat Messages Area */
.chat-messages {
  flex: 1 1 auto;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 2rem;
  padding-top: 2rem; /* 移除頂部額外空間 */
  padding-bottom: 250px; /* 增加底部空間以避免被輸入框遮擋 */
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
  min-height: 0; /* 確保可以正確捲動 */
  max-width: 1200px;
  margin: 0 auto;
  width: 100%;
  position: relative;
  height: 100%;
}

/* Custom Scrollbar */
.chat-messages::-webkit-scrollbar {
  width: 8px;
}

.chat-messages::-webkit-scrollbar-track {
  background: transparent;
}

.chat-messages::-webkit-scrollbar-thumb {
  background: var(--latte);
  border-radius: 20px;
  opacity: 0.5;
}

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

/* Messages */
.message {
  margin-bottom: 2rem;
  animation: fadeInUp 0.6s ease-out;
  width: 100%;
  overflow: hidden;
}

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

.message-content {
  display: inline-block;
  max-width: 70%;
  padding: 0.3rem 0.8rem;
  position: relative;
  font-size: 1rem;
  line-height: 1.3;
  word-wrap: break-word;
  word-break: break-word;
  overflow-wrap: break-word;
  hyphens: auto;
  white-space: pre-wrap;
}

/* User Messages - Modern style */
.message.user {
  text-align: right;
}

.message.user .message-content {
  background: var(--primary-indigo);
  color: var(--text-white);
  border-radius: 18px 18px 4px 18px;
  box-shadow: 0 2px 8px var(--shadow-soft);
  font-family: 'Inter', 'Noto Sans TC', sans-serif;
  font-size: 1rem;
  font-weight: 400;
  transition: transform 0.2s ease;
  text-align: left;
}

.message.user .message-content:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px var(--shadow-medium);
}

/* Assistant Messages - Clean modern style */
.message.assistant .message-content {
  background: var(--bg-white);
  color: var(--text-primary);
  border: 1px solid var(--border-light);
  border-radius: 18px 18px 18px 4px;
  box-shadow: 0 2px 8px var(--shadow-soft);
  font-family: 'Inter', 'Noto Sans TC', sans-serif;
  position: relative;
  text-align: left;
  transition: transform 0.2s ease;
}

.message.assistant .message-content:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px var(--shadow-medium);
}

/* Code blocks in messages */
.message-content pre {
  background: var(--bg-light-gray);
  border: 1px solid var(--border-light);
  border-radius: 8px;
  padding: 1rem;
  margin: 0.5rem 0;
  overflow-x: auto;
  font-family: 'SF Mono', 'Monaco', 'Inconsolata', 'Roboto Mono', monospace;
  font-size: 0.875rem;
  line-height: 1.4;
  white-space: pre;
  max-width: 100%;
  color: var(--text-primary);
}

.message-content code {
  background: var(--bg-light-gray);
  padding: 0.2rem 0.4rem;
  border-radius: 4px;
  font-family: 'SF Mono', 'Monaco', 'Inconsolata', 'Roboto Mono', monospace;
  font-size: 0.875em;
  color: var(--text-primary);
}

/* Lists in messages */
.message-content ul,
.message-content ol {
  margin: 0.5rem 0;
  padding-left: 1.5rem;
  list-style-position: outside;
}

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

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

.message-content li {
  margin: 0.25rem 0;
  list-style: inherit;
}

/* 移除列表後多餘的空行 */
.message-content ul + br,
.message-content ol + br {
  display: none;
}

/* Markdown 段落樣式 */
.message-content p {
  margin: 0.5rem 0;
  line-height: 1.6;
}

.message-content p:first-child {
  margin-top: 0;
}

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

/* 標題樣式 */
.message-content h1,
.message-content h2,
.message-content h3,
.message-content h4,
.message-content h5,
.message-content h6 {
  margin: 1rem 0 0.5rem 0;
  font-weight: 600;
  line-height: 1.3;
  color: var(--espresso);
}

.message-content h1 { font-size: 1.5rem; }
.message-content h2 { font-size: 1.3rem; }
.message-content h3 { font-size: 1.1rem; }

/* 引用區塊 */
.message-content blockquote {
  margin: 0.5rem 0;
  padding: 0.5rem 1rem;
  border-left: 3px solid var(--caramel);
  background: rgba(125, 79, 57, 0.05);
  font-style: italic;
}

/* 表格樣式 */
.message-content table {
  border-collapse: collapse;
  margin: 0.5rem 0;
  width: 100%;
}

.message-content th,
.message-content td {
  border: 1px solid var(--foam);
  padding: 0.5rem;
  text-align: left;
}

.message-content th {
  background: rgba(125, 79, 57, 0.1);
  font-weight: 600;
}

/* 水平線 */
.message-content hr {
  margin: 1rem 0;
  border: none;
  border-top: 1px solid var(--foam);
}

/* Links in messages */
.message-content a {
  color: var(--caramel);
  text-decoration: underline;
  word-break: break-all;
}

.message-content a:hover {
  color: var(--medium-roast);
}

/* Input Container */
.chat-input-container {
  position: relative;
  padding: 1.5rem 2rem 2rem;
  max-width: 1200px;
  margin: 0 auto;
  width: 100%;
  background: var(--bg-white);
  border-top: 1px solid var(--border-light);
  flex-shrink: 0;
  z-index: 100;
}

#chat-form {
  width: 100%;
}

/* Modern Input Area */
.input-glass {
  background: var(--bg-white);
  border: 1px solid var(--border-light);
  border-radius: 12px;
  padding: 0.875rem 1rem;
  box-shadow: 0 2px 8px var(--shadow-soft);
  display: flex;
  align-items: flex-end;
  gap: 0.75rem;
  transition: all 0.3s ease;
}

.input-glass:focus-within {
  border-color: var(--primary-indigo);
  box-shadow: 0 4px 12px var(--shadow-medium);
}

/* Textarea */
#message-input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  font-family: 'Inter', 'Noto Sans TC', sans-serif;
  font-size: 1rem;
  color: var(--text-primary);
  resize: none;
  min-height: 24px;
  max-height: 120px;
  line-height: 1.5;
  padding: 0.25rem 0;
}

#message-input::placeholder {
  color: var(--text-muted);
  font-style: italic;
}

/* Input Actions */
.input-actions {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

/* Icon Buttons */
.icon-button {
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 0.5rem;
  border-radius: 50%;
  color: var(--text-secondary);
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.icon-button:hover {
  background: var(--foam);
  color: var(--text-primary);
  transform: scale(1.1);
}

.icon-button:active {
  transform: scale(0.95);
}

.send-button {
  background: var(--accent-yellow);
  color: var(--text-primary);
  border-radius: 8px;
  padding: 0.625rem;
}

.send-button:hover {
  background: var(--accent-yellow-dark);
  color: var(--text-primary);
  transform: scale(1.05);
}

/* Stop Button State */
.send-button.stop-button {
  background: rgba(139, 69, 19, 0.9);
  color: var(--cream);
  animation: subtlePulse 1.5s ease-in-out infinite;
}

.send-button.stop-button:hover {
  background: var(--caramel);
  color: var(--steam);
  animation: none;
}

@keyframes subtlePulse {
  0%, 100% {
    opacity: 0.9;
    transform: scale(1);
  }
  50% {
    opacity: 1;
    transform: scale(1.05);
  }
}

/* Voice Recording Active State */
.icon-button.recording {
  background: var(--caramel);
  color: var(--steam);
  animation: pulse 1.5s infinite;
}

@keyframes pulse {
  0% {
    box-shadow: 0 0 0 0 rgba(125, 79, 57, 0.4);
  }
  70% {
    box-shadow: 0 0 0 10px rgba(125, 79, 57, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(125, 79, 57, 0);
  }
}

/* Loading Indicator - Coffee Cup with Steam */
.loading-indicator {
  display: inline-flex;
  align-items: flex-end;
  gap: 0.2rem;
  padding: 0.4rem 0.6rem;
  position: relative;
}

/* Coffee Cup */
.loading-indicator::before {
  content: '☕';
  font-size: 1.5rem;
  position: relative;
  animation: cupTilt 3s ease-in-out infinite;
}

/* Steam wisps */
.steam-wisp {
  position: absolute;
  width: 3px;
  height: 15px;
  background: linear-gradient(to top, 
    rgba(139, 69, 19, 0.4) 0%, 
    rgba(139, 69, 19, 0.2) 50%, 
    transparent 100%);
  border-radius: 50%;
  opacity: 0;
  top: -5px;
  filter: blur(1px);
}

.steam-wisp:nth-child(1) {
  left: 50%;
  animation: steamFloat 2.5s infinite;
}

.steam-wisp:nth-child(2) {
  left: 55%;
  animation: steamFloat 2.5s 0.8s infinite;
}

.steam-wisp:nth-child(3) {
  left: 45%;
  animation: steamFloat 2.5s 1.6s infinite;
}

@keyframes cupTilt {
  0%, 100% { transform: rotate(0deg); }
  25% { transform: rotate(-5deg); }
  75% { transform: rotate(5deg); }
}

@keyframes steamFloat {
  0% {
    opacity: 0;
    transform: translateY(0) translateX(0) scaleY(0.5);
  }
  15% {
    opacity: 0.7;
    transform: translateY(-8px) translateX(2px) scaleY(1);
  }
  50% {
    opacity: 0.4;
    transform: translateY(-20px) translateX(-2px) scaleY(1.5) scaleX(1.2);
  }
  85% {
    opacity: 0.1;
    transform: translateY(-35px) translateX(3px) scaleY(2) scaleX(1.5);
  }
  100% {
    opacity: 0;
    transform: translateY(-45px) translateX(0) scaleY(2.5) scaleX(2);
  }
}

/* Error State */
.message-content.error {
  background: rgba(139, 69, 19, 0.1);
  color: var(--caramel);
  font-style: italic;
}

/* Responsive Design */
@media (max-width: 768px) {
  .top-nav-header {
    padding: 0 1rem;
  }
  
  .app-title {
    font-size: 1.25rem;
  }
  
  .version-number {
    font-size: 0.65rem;
  }
  
  .nav-user-info span {
    display: none; /* Hide email on mobile */
  }
  
  .app-content {
    height: calc(100vh - 60px);
  }
  
  /* 修正手機版 main-chat-area 高度 */
  .main-chat-area {
    height: calc(100vh - 60px);
    max-height: calc(100vh - 60px);
    overflow: hidden;
  }
  
  .chat-container {
    height: calc(100vh - 60px);
    max-height: calc(100vh - 60px);
  }
  
  .project-explorer {
    position: fixed;
    left: -100%;
    top: 60px;
    height: calc(100vh - 60px);
    width: 100%;
    z-index: 1010; /* Above backdrop and input */
    transition: left 0.3s ease;
  }
  
  .project-explorer.show {
    left: 0;
  }
  
  /* Add backdrop overlay for mobile sidebar */
  .sidebar-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 999;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
  }
  
  .sidebar-backdrop.show {
    opacity: 1;
    pointer-events: auto;
  }
  
  /* Editor backdrop for mobile */
  .editor-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1005; /* Between sidebar and editor */
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
  }
  
  .editor-backdrop.show {
    opacity: 1;
    pointer-events: auto;
  }
  
  .chat-messages {
    padding: 1rem;
    padding-bottom: 120px; /* 為固定輸入框留出空間 */
    height: calc(100vh - 60px); /* 減去 header 高度 */
    max-height: calc(100vh - 60px);
    overflow-y: auto;
  }
  
  .message-content {
    max-width: 90%;
    padding: 0.75rem 1rem;
    font-size: 0.95rem;
  }
  
  .message-content pre {
    font-size: 0.8rem;
    padding: 0.75rem;
  }
  
  .chat-input-container {
    padding: 1rem;
    z-index: 1000; /* Higher z-index to ensure visibility */
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--bg-white);
    border-top: 1px solid var(--border-light);
    box-shadow: 0 -2px 8px var(--shadow-soft);
  }
  
  /* 隱藏手機版的 expand-project-btn */
  #expand-project-btn {
    display: none !important;
  }
}

/* Tablet view */
@media (min-width: 769px) and (max-width: 1024px) {
  .right-panel {
    width: calc(100% - 350px); /* 維持與桌面版相同的計算方式 */
  }
  
  .message-content {
    max-width: 80%;
  }
}

/* Large desktop view */
@media (min-width: 1400px) {
  .project-explorer {
    width: 320px; /* Wider sidebar on large screens */
  }
  
  .right-panel {
    width: calc(100% - 320px); /* 總寬度減去 project explorer 的寬度 */
  }
  
  .chat-messages {
    padding: 2rem 3rem;
  }
  
  .chat-input-container {
    padding: 1.5rem 3rem 2rem;
  }
}

/* Smooth transitions for all interactive elements */
* {
  transition: color 0.2s ease, background-color 0.2s ease;
}

/* Remove focus outlines and add custom focus styles */
*:focus {
  outline: none;
}

/* === Vditor Markdown Editor Styles === */

/* Vditor 編輯器容器 */
.vditor-container {
  width: 100%;
  height: 100%;
}

/* 覆蓋 Vditor 預設樣式 */
.vditor {
  border: none !important;
  height: 100% !important;
}

.vditor-content {
  background: var(--bg-white) !important;
}

/* 右鍵選單樣式 */
.context-menu {
  position: absolute;
  background: var(--bg-white);
  border: 1px solid var(--border-light);
  border-radius: 8px;
  box-shadow: 0 4px 12px var(--shadow-soft);
  z-index: 2000;
  min-width: 150px;
  padding: 0.5rem 0;
}

.context-menu-item {
  display: flex;
  align-items: center;
  padding: 0.75rem 1rem;
  cursor: pointer;
  transition: background-color 0.2s ease;
  font-size: 0.9rem;
  color: var(--text-primary);
}

.context-menu-item:hover {
  background: var(--bg-light-gray);
}

.context-menu-item i {
  width: 16px;
  height: 16px;
  margin-right: 0.5rem;
  color: var(--text-secondary);
}

/* 指令輸入框模態 */
.command-input-modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2100;
}

.command-input-content {
  background: var(--bg-white);
  border-radius: 12px;
  padding: 1.5rem;
  min-width: 500px;
  max-width: 600px;
  max-height: 80vh;
  overflow-y: auto;
  box-shadow: 0 8px 24px var(--shadow-soft);
  position: relative;
}

.command-input-content h4 {
  margin: 0 0 1rem 0;
  font-size: 1.2rem;
  font-weight: 600;
  color: var(--text-primary);
}

.command-close-btn {
  position: absolute;
  top: 1rem;
  right: 1rem;
  background: none;
  border: none;
  padding: 0.25rem;
  cursor: pointer;
  border-radius: 4px;
  color: var(--text-secondary);
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.command-close-btn:hover {
  background: var(--bg-light-gray);
  color: var(--text-primary);
}

.selected-file-path {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem;
  background: #f0f9ff;
  border: 1px solid #bae6fd;
  border-radius: 8px;
  margin-bottom: 1rem;
  font-size: 0.85rem;
  color: #0369a1;
}

.selected-file-path i {
  flex-shrink: 0;
  width: 16px;
  height: 16px;
}

.selected-file-path span {
  font-family: 'Courier New', monospace;
  word-break: break-all;
}

.command-input-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
}

.command-input-header h4 {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text-primary);
}

.close-button {
  background: none;
  border: none;
  padding: 0.25rem;
  cursor: pointer;
  border-radius: 4px;
  color: var(--text-secondary);
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.close-button:hover {
  background: var(--bg-light-gray);
  color: var(--text-primary);
}

.selected-text-preview {
  background: #fefce8;
  border: 1px solid #fde047;
  border-radius: 8px;
  padding: 0.75rem;
  margin-bottom: 1rem;
  font-size: 0.85rem;
  max-height: 200px;
  overflow-y: auto;
}

.selected-text-preview .preview-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
  font-weight: 600;
  color: #854d0e;
}

.selected-text-preview .preview-header i {
  width: 16px;
  height: 16px;
}

.selected-text-preview .preview-header span {
  font-size: 0.85rem;
}

.preview-label {
  font-weight: 500;
  color: var(--text-secondary);
  display: block;
  margin-bottom: 0.5rem;
}

.preview-text, #preview-text {
  color: var(--text-primary);
  line-height: 1.4;
  white-space: pre-wrap;
  word-break: break-word;
  margin: 0;
  font-family: 'Courier New', monospace;
  font-size: 0.85rem;
  color: #713f12;
}

.command-input-section {
  margin-bottom: 1rem;
}

.command-input-section label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 500;
  color: var(--text-primary);
  margin-bottom: 0.5rem;
  font-size: 0.9rem;
}

.command-input-section label i {
  width: 16px;
  height: 16px;
}

.command-input-content textarea {
  width: 100%;
  padding: 0.75rem;
  border: 1px solid var(--border-light);
  border-radius: 8px;
  font-size: 0.9rem;
  margin-bottom: 1rem;
  outline: none;
  transition: border-color 0.2s ease;
  box-sizing: border-box;
  font-family: inherit;
  resize: vertical;
  min-height: 80px;
}

.command-input-content textarea:focus {
  border-color: var(--primary-indigo);
}

/* Keep the old input styles for backward compatibility */
.command-input-content input {
  width: 100%;
  padding: 0.75rem;
  border: 1px solid var(--border-light);
  border-radius: 8px;
  font-size: 0.9rem;
  margin-bottom: 1rem;
  outline: none;
  transition: border-color 0.2s ease;
  box-sizing: border-box;
}

.command-input-content input:focus {
  border-color: var(--primary-indigo);
}

.command-input-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
}

.btn-secondary, .btn-primary {
  padding: 0.5rem 1rem;
  border: none;
  border-radius: 6px;
  font-size: 0.9rem;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.btn-secondary i, .btn-primary i {
  width: 16px;
  height: 16px;
}

.btn-secondary {
  background: var(--bg-light-gray);
  color: var(--text-secondary);
}

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

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

.btn-primary:hover {
  background: #4338ca;
}

/* Custom confirm dialog styles */
.custom-confirm-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s ease;
}

.custom-confirm-overlay.show {
  opacity: 1;
  visibility: visible;
}

.custom-confirm-dialog {
  background: var(--bg-white);
  border-radius: 12px;
  padding: 1.5rem;
  min-width: 320px;
  max-width: 500px;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
  transform: scale(0.9) translateY(-20px);
  transition: all 0.3s ease;
}

.custom-confirm-overlay.show .custom-confirm-dialog {
  transform: scale(1) translateY(0);
}

.custom-confirm-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.custom-confirm-icon {
  width: 24px;
  height: 24px;
  color: #f59e0b;
  flex-shrink: 0;
}

.custom-confirm-title {
  font-family: 'Inter', 'Noto Sans TC', sans-serif;
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0;
}

.custom-confirm-message {
  color: var(--text-secondary);
  font-size: 0.95rem;
  line-height: 1.5;
  margin-bottom: 1.5rem;
  white-space: pre-line;
}

.custom-confirm-actions {
  display: flex;
  gap: 0.75rem;
  justify-content: flex-end;
}

.confirm-btn-cancel,
.confirm-btn-confirm {
  padding: 0.625rem 1.25rem;
  border: none;
  border-radius: 8px;
  font-family: 'Inter', 'Noto Sans TC', sans-serif;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  min-width: 80px;
}

.confirm-btn-cancel {
  background: var(--bg-light-gray);
  color: var(--text-secondary);
  border: 1px solid var(--border-light);
}

.confirm-btn-cancel:hover {
  background: var(--border-light);
  color: var(--text-primary);
}

.confirm-btn-confirm {
  background: #dc2626;
  color: white;
}

.confirm-btn-confirm:hover {
  background: #b91c1c;
  transform: translateY(-1px);
  box-shadow: 0 4px 8px rgba(220, 38, 38, 0.3);
}

/* Custom input dialog styles */
.custom-input-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s ease;
}

.custom-input-overlay.show {
  opacity: 1;
  visibility: visible;
}

.custom-input-dialog {
  background: var(--bg-white);
  border-radius: 12px;
  padding: 1.5rem;
  min-width: 320px;
  max-width: 500px;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
  transform: scale(0.9) translateY(-20px);
  transition: all 0.3s ease;
}

.custom-input-overlay.show .custom-input-dialog {
  transform: scale(1) translateY(0);
}

.custom-input-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.custom-input-icon {
  width: 24px;
  height: 24px;
  color: var(--primary-indigo);
  flex-shrink: 0;
}

.custom-input-title {
  font-family: 'Inter', 'Noto Sans TC', sans-serif;
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0;
}

.custom-input-field {
  width: 100%;
  padding: 0.75rem;
  border: 1px solid var(--border-light);
  border-radius: 8px;
  font-family: 'Inter', 'Noto Sans TC', sans-serif;
  font-size: 0.95rem;
  margin-bottom: 1.5rem;
  outline: none;
  transition: border-color 0.2s ease;
  box-sizing: border-box;
}

.custom-input-field:focus {
  border-color: var(--primary-indigo);
  box-shadow: 0 0 0 3px rgba(94, 99, 155, 0.1);
}

.custom-input-actions {
  display: flex;
  gap: 0.75rem;
  justify-content: flex-end;
}

.input-btn-cancel,
.input-btn-confirm {
  padding: 0.625rem 1.25rem;
  border: none;
  border-radius: 8px;
  font-family: 'Inter', 'Noto Sans TC', sans-serif;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  min-width: 80px;
}

.input-btn-cancel {
  background: var(--bg-light-gray);
  color: var(--text-secondary);
  border: 1px solid var(--border-light);
}

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

.input-btn-confirm {
  background: var(--primary-indigo);
  color: white;
}

.input-btn-confirm:hover {
  background: var(--primary-indigo-dark);
  transform: translateY(-1px);
  box-shadow: 0 4px 8px rgba(94, 99, 155, 0.3);
}

/* Add new folder button at bottom of file tree */
.add-folder-container {
  padding: 1rem;
  border-top: 1px solid rgba(255, 255, 255, 0.2);
  margin-top: 1rem;
}

.add-folder-btn {
  width: 100%;
  background: transparent;
  border: 1px dashed rgba(255, 255, 255, 0.3);
  border-radius: 8px;
  padding: 0.75rem;
  color: rgba(255, 255, 255, 0.7);
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  font-family: 'Inter', 'Noto Sans TC', sans-serif;
  font-size: 0.875rem;
}

.add-folder-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.5);
  color: rgba(255, 255, 255, 1);
}

.add-folder-btn i {
  width: 16px;
  height: 16px;
}

/* === File Upload Styles === */

/* File Upload Dialog Overlay */
.file-upload-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2100;
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s ease;
}

.file-upload-overlay.show {
  opacity: 1;
  visibility: visible;
}

/* File Upload Dialog */
.file-upload-dialog {
  background: var(--bg-white);
  border-radius: 16px;
  padding: 0;
  min-width: 480px;
  max-width: 600px;
  max-height: 80vh;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
  transform: scale(0.9) translateY(-20px);
  transition: all 0.3s ease;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.file-upload-overlay.show .file-upload-dialog {
  transform: scale(1) translateY(0);
}

/* File Upload Header */
.file-upload-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1.5rem;
  border-bottom: 1px solid var(--border-light);
  background: var(--bg-light-gray);
}

.file-upload-icon {
  width: 24px;
  height: 24px;
  color: var(--primary-indigo);
  flex-shrink: 0;
}

.file-upload-title {
  font-family: 'Inter', 'Noto Sans TC', sans-serif;
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0;
  flex: 1;
}

.file-upload-close {
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 0.5rem;
  border-radius: 6px;
  color: var(--text-secondary);
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.file-upload-close:hover {
  background: var(--bg-light-gray);
  color: var(--text-primary);
}

.file-upload-close i {
  width: 18px;
  height: 18px;
}

/* File Upload Content */
.file-upload-content {
  padding: 1.5rem;
  flex: 1;
  overflow-y: auto;
  max-height: calc(80vh - 140px);
}

/* Drag Drop Zone */
.drag-drop-zone {
  border: 2px dashed var(--border-medium);
  border-radius: 12px;
  padding: 2rem;
  text-align: center;
  background: var(--bg-off-white);
  transition: all 0.3s ease;
  cursor: pointer;
  margin-bottom: 1.5rem;
  position: relative;
}

.drag-drop-zone:hover {
  border-color: var(--primary-indigo);
  background: rgba(94, 99, 155, 0.05);
}

.drag-drop-zone.drag-over {
  border-color: var(--primary-indigo);
  background: rgba(94, 99, 155, 0.1);
  transform: scale(1.02);
}

.drag-drop-zone.uploading {
  opacity: 0.7;
  cursor: not-allowed;
}

.drag-drop-zone.error {
  border-color: #dc2626;
  background: rgba(220, 38, 38, 0.05);
}

.drag-drop-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
}

.drag-drop-icon {
  width: 48px;
  height: 48px;
  color: var(--primary-indigo);
  opacity: 0.7;
}

.drag-drop-icon i {
  width: 100%;
  height: 100%;
}

.drag-drop-text {
  text-align: center;
}

.drag-drop-primary {
  font-size: 1.1rem;
  font-weight: 500;
  color: var(--text-primary);
  margin: 0 0 0.25rem 0;
}

.drag-drop-secondary {
  font-size: 0.9rem;
  color: var(--text-secondary);
  margin: 0;
}

.drag-drop-button {
  background: var(--primary-indigo);
  color: white;
  border: none;
  padding: 0.75rem 1.5rem;
  border-radius: 8px;
  font-family: 'Inter', 'Noto Sans TC', sans-serif;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.drag-drop-button:hover {
  background: var(--primary-indigo-dark);
  transform: translateY(-1px);
  box-shadow: 0 4px 8px rgba(94, 99, 155, 0.3);
}

.drag-drop-button:disabled {
  background: var(--bg-light-gray);
  color: var(--text-muted);
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.drag-drop-button i {
  width: 16px;
  height: 16px;
}

/* File Upload Info */
.file-upload-info {
  margin-bottom: 1.5rem;
}

.file-upload-info h4 {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0 0 0.75rem 0;
}

.file-upload-restrictions {
  background: var(--bg-light-gray);
  padding: 1rem;
  border-radius: 8px;
  border-left: 3px solid var(--primary-indigo);
}

.file-upload-restrictions p {
  margin: 0.25rem 0;
  font-size: 0.875rem;
  color: var(--text-secondary);
  line-height: 1.4;
}

/* File Upload List */
.file-upload-list-container h4 {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0 0 0.75rem 0;
}

.file-upload-list {
  border: 1px solid var(--border-light);
  border-radius: 8px;
  overflow: hidden;
  margin-bottom: 1rem;
}

.file-upload-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem;
  border-bottom: 1px solid var(--border-light);
  background: var(--bg-white);
  transition: background 0.2s ease;
}

.file-upload-item:last-child {
  border-bottom: none;
}

.file-upload-item:hover {
  background: var(--bg-off-white);
}

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

.file-info i {
  width: 20px;
  height: 20px;
  color: var(--primary-indigo);
  flex-shrink: 0;
}

.file-details {
  flex: 1;
  min-width: 0;
}

.file-name {
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.file-size {
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.file-remove {
  background: transparent;
  border: 1px solid var(--border-light);
  border-radius: 4px;
  padding: 0.25rem;
  cursor: pointer;
  color: var(--text-secondary);
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.file-remove:hover {
  background: rgba(220, 38, 38, 0.1);
  border-color: #dc2626;
  color: #dc2626;
}

.file-remove i {
  width: 14px;
  height: 14px;
}

/* File Upload Errors */
.file-upload-errors {
  margin-bottom: 1rem;
}

.error-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem;
  background: rgba(220, 38, 38, 0.1);
  border: 1px solid rgba(220, 38, 38, 0.2);
  border-radius: 6px;
  margin-bottom: 0.5rem;
  color: #dc2626;
  font-size: 0.875rem;
}

.error-item:last-child {
  margin-bottom: 0;
}

.error-item i {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

/* File Upload Progress */
.file-upload-progress {
  margin-bottom: 1rem;
}

.progress-bar {
  width: 100%;
  height: 8px;
  background: var(--bg-light-gray);
  border-radius: 4px;
  overflow: hidden;
  margin-bottom: 0.5rem;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary-indigo), var(--primary-indigo-light));
  width: 0%;
  transition: width 0.3s ease;
  border-radius: 4px;
}

.progress-text {
  text-align: center;
  font-size: 0.875rem;
  color: var(--text-secondary);
}

/* File Upload Actions */
.file-upload-actions {
  display: flex;
  gap: 0.75rem;
  justify-content: flex-end;
  padding: 1.5rem;
  border-top: 1px solid var(--border-light);
  background: var(--bg-light-gray);
}

.file-upload-btn-cancel,
.file-upload-btn-upload {
  padding: 0.75rem 1.5rem;
  border: none;
  border-radius: 8px;
  font-family: 'Inter', 'Noto Sans TC', sans-serif;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  min-width: 100px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
}

.file-upload-btn-cancel {
  background: var(--bg-white);
  color: var(--text-secondary);
  border: 1px solid var(--border-light);
}

.file-upload-btn-cancel:hover {
  background: var(--bg-light-gray);
  color: var(--text-primary);
}

.file-upload-btn-upload {
  background: var(--primary-indigo);
  color: white;
}

.file-upload-btn-upload:hover:not(:disabled) {
  background: var(--primary-indigo-dark);
  transform: translateY(-1px);
  box-shadow: 0 4px 8px rgba(94, 99, 155, 0.3);
}

.file-upload-btn-upload:disabled {
  background: var(--bg-light-gray);
  color: var(--text-muted);
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.file-upload-btn-upload i {
  width: 16px;
  height: 16px;
}

/* Mobile Responsive */
@media (max-width: 640px) {
  .file-upload-dialog {
    min-width: 320px;
    max-width: 90vw;
    margin: 1rem;
  }
  
  .drag-drop-zone {
    padding: 1.5rem;
  }
  
  .file-upload-actions {
    flex-direction: column;
  }
  
  .file-upload-btn-cancel,
  .file-upload-btn-upload {
    width: 100%;
  }
}

.icon-button:focus {
  box-shadow: 0 0 0 2px var(--latte);
}

#message-input:focus {
  /* Subtle glow effect */
  filter: drop-shadow(0 0 5px rgba(196, 165, 123, 0.3));
}
/* User Menu Styles */
.user-menu-container {
  position: relative;
  z-index: 1001;
}

.user-menu-icon {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--bg-glass);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid rgba(125, 79, 57, 0.2);
  color: var(--caramel);
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 8px var(--shadow-soft);
  pointer-events: auto;
  position: relative;
  z-index: 1002;
}

.user-menu-icon:hover {
  background: var(--foam);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px var(--shadow-medium);
}

.user-menu-icon:active {
  transform: translateY(0);
}

/* Dropdown Menu */
.user-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 200px;
  background: var(--steam);
  border-radius: 12px;
  box-shadow: 0 8px 24px var(--shadow-medium);
  overflow: hidden;
  opacity: 0;
  transform: translateY(-10px);
  transition: all 0.2s ease;
  pointer-events: none;
  display: none;
}

.user-dropdown.show {
  display: block;
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

.user-info {
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-primary);
  font-size: 14px;
  font-family: "Lora", serif;
}

.dropdown-divider {
  height: 1px;
  background: var(--foam);
  margin: 0;
}

.dropdown-item {
  width: 100%;
  padding: 12px 16px;
  background: transparent;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-primary);
  font-size: 14px;
  font-family: "Lora", serif;
  transition: background 0.2s ease;
  text-align: left;
}

.dropdown-item:hover {
  background: var(--foam);
}

.dropdown-item i {
  color: var(--caramel);
}

/* --- Project Explorer Styles --- */

.project-explorer {
  width: 350px;
  flex-shrink: 0;
  background: var(--primary-indigo);
  border-right: none;
  display: flex;
  flex-direction: column;
  height: 100%;
  padding: 1.5rem 1rem;
  box-shadow: 2px 0 15px var(--shadow-medium);
  z-index: 2;
  overflow: hidden; /* Ensures the container clips its content */
  transition: width 0.3s ease;
}

.project-explorer.expanded {
  width: auto;
  min-width: 500px;
  max-width: 60vw;
}

.project-explorer-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-bottom: 1rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.2);
  margin-bottom: 1rem;
}

.project-explorer-header h3,
.project-explorer-header .project-title-truncate {
  font-family: 'Inter', 'Noto Sans TC', sans-serif;
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--text-white);
  margin: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex-grow: 1;
  text-align: center;
}

.project-explorer-header .icon-button {
  flex-shrink: 0;
  color: rgba(255, 255, 255, 0.8);
  background: transparent;
}

.project-explorer-header .icon-button:hover {
  color: var(--text-white);
  background: rgba(255, 255, 255, 0.1);
}

.project-list-container {
  flex-grow: 1;
  overflow-y: auto;
  overflow-x: auto;
  min-height: 0; /* Prevents flexbox from overflowing its container */
}

/* Custom scrollbar for project list */
.project-list-container::-webkit-scrollbar {
  width: 6px;
}
.project-list-container::-webkit-scrollbar-track {
  background: transparent;
}
.project-list-container::-webkit-scrollbar-thumb {
  background: var(--latte);
  border-radius: 10px;
}

.project-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.875rem;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
  color: rgba(255, 255, 255, 0.8);
  font-weight: 400;
  position: relative;
}

.project-item:hover {
  background-color: rgba(255, 255, 255, 0.1);
  color: var(--text-white);
}

.project-item.active {
  background-color: rgba(255, 255, 255, 0.15);
  color: var(--text-white);
  font-weight: 500;
}

.project-item i {
  flex-shrink: 0;
  width: 18px;
  height: 18px;
}

/* Project item settings button */
.project-item .settings-btn {
  position: absolute;
  right: 0.5rem;
  top: 0.5rem;
  opacity: 0;
  visibility: hidden;
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 4px;
  padding: 0.25rem;
  cursor: pointer;
  transition: all 0.2s ease;
  color: rgba(255, 255, 255, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
}

.project-item:hover .settings-btn {
  opacity: 1;
  visibility: visible;
}

.project-item .settings-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.5);
  color: rgba(255, 255, 255, 1);
  transform: scale(1.05);
}

.project-item .settings-btn i {
  width: 12px;
  height: 12px;
  color: inherit;
}

/* --- File Tree Styles --- */
.file-tree {
  list-style: none;
  padding: 0;
  margin: 0;
  color: rgba(255, 255, 255, 0.9);
}

.file-tree li {
  margin: 0;
  padding: 0;
  color: rgba(255, 255, 255, 0.9);
}

.tree-item {
  display: flex;
  align-items: flex-start;
  padding: 0.5rem 0.75rem;
  cursor: pointer;
  transition: all 0.2s ease;
  border-radius: 6px;
  margin: 0.125rem 0.5rem;
  gap: 0.5rem;
  font-size: 0.875rem;
  position: relative;
  min-height: 2rem;
}

.tree-item:hover {
  background-color: rgba(255, 255, 255, 0.1);
  color: rgba(255, 255, 255, 1);
}

.tree-item i {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  color: rgba(255, 255, 255, 0.7);
  margin-top: 0.125rem; /* 對齊圖標與第一行文字 */
}

.tree-item span {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.4;
  margin-right: 2rem; /* 為設定按鈕留出空間 */
  padding-right: 0.5rem;
  transition: all 0.3s ease;
  max-width: calc(100% - 3rem);
}

.tree-item:hover span {
  white-space: normal;
  word-wrap: break-word;
  word-break: break-all;
  overflow: visible;
}

/* Folder specific styling */
.tree-item.folder {
  font-weight: 500;
}

.tree-item.folder i {
  color: #60A5FA; /* Blue folder icon */
}

.tree-item.folder.expanded i[data-lucide="folder"] {
  display: none;
}

.tree-item.folder.expanded i[data-lucide="folder-open"] {
  display: inline;
}

.tree-item.folder.collapsed i[data-lucide="folder-open"] {
  display: none;
}

.tree-item.folder.collapsed i[data-lucide="folder"] {
  display: inline;
}

/* File specific styling */
.tree-item.file {
  font-weight: 400;
}

.tree-item.file.txt-file i {
  color: #FDE047; /* Yellow for text files */
}

.tree-item.file:hover {
  background-color: rgba(253, 224, 71, 0.1);
  color: #FDE047;
}

/* Editing file highlight */
.tree-item.file.editing {
  background-color: rgba(253, 224, 71, 0.2);
  color: #FDE047;
  font-weight: 500;
}

.tree-item.file.editing i {
  color: #FDE047;
}

/* Settings button styles */
.tree-item .settings-btn {
  position: absolute;
  right: 0.5rem;
  top: 0.5rem;
  opacity: 0;
  visibility: hidden;
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 4px;
  padding: 0.25rem;
  cursor: pointer;
  transition: all 0.2s ease;
  color: rgba(255, 255, 255, 0.7);
  font-size: 0.75rem;
  z-index: 10;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.tree-item:hover .settings-btn {
  opacity: 1;
  visibility: visible;
}

.tree-item .settings-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.5);
  color: rgba(255, 255, 255, 1);
  transform: scale(1.05);
}

.tree-item .settings-btn i {
  width: 12px;
  height: 12px;
  color: inherit;
}

/* Context menu styles */
.file-context-menu {
  position: absolute;
  background: var(--bg-white);
  border: 1px solid var(--border-light);
  border-radius: 8px;
  box-shadow: 0 4px 12px var(--shadow-medium);
  z-index: 1000;
  min-width: 120px;
  padding: 0.25rem 0;
  display: none;
}

.file-context-menu.show {
  display: block;
}

.file-context-menu-item {
  display: flex;
  align-items: center;
  padding: 0.5rem 0.75rem;
  cursor: pointer;
  transition: background-color 0.2s ease;
  font-size: 0.875rem;
  color: var(--text-primary);
  gap: 0.5rem;
}

.file-context-menu-item:hover {
  background: var(--bg-light-gray);
}

.file-context-menu-item.delete-item {
  color: #dc2626;
}

.file-context-menu-item.delete-item:hover {
  background: rgba(220, 38, 38, 0.1);
}

.file-context-menu-item i {
  width: 14px;
  height: 14px;
  color: inherit;
}

/* Nested items */
.file-tree ul {
  list-style: none;
  padding-left: 1.25rem;
  margin: 0;
  border-left: 1px solid rgba(255, 255, 255, 0.15);
  margin-left: 1rem;
}

/* Expand/collapse animation */
.tree-children {
  overflow: hidden;
  transition: max-height 0.3s ease-out;
}

.tree-children.collapsed {
  max-height: 0;
}

.tree-children.expanded {
  max-height: 1000px; /* Adjust based on your needs */
}

/* --- Main Chat Area Layout --- */
.main-chat-area {
  flex-grow: 1;
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
  position: relative;
  background: var(--bg-off-white);
}

.chat-container {
  height: calc(100vh - 60px); /* Fixed height to prevent layout shift */
  display: flex;
  flex-direction: column;
}

/* --- Right Panel Styles --- */
.right-panel {
  width: calc(100% - 350px); /* 總寬度減去 project explorer 的寬度 */
  flex-shrink: 0;
  background: var(--bg-white);
  border-left: 1px solid var(--border-light);
  display: none; /* Hidden by default */
  flex-direction: column;
  height: calc(100vh - 60px);
  box-shadow: -2px 0 15px var(--shadow-soft);
  position: fixed;
  top: 60px;
  right: calc(-100% + 350px); /* 調整初始位置 */
  z-index: 100;
  transition: right 0.3s ease;
}

.right-panel.show {
  display: flex;
  right: 0;
}

/* When sidebar is collapsed, editor should take full width */
.app-content.sidebar-collapsed .right-panel.show {
  width: 100%;
  right: 0;
}

/* Large screen: when sidebar is collapsed, editor takes full width */
@media (min-width: 1400px) {
  .app-content.sidebar-collapsed .right-panel.show {
    width: 100%;
    right: 0;
  }
}

/* Removed - now using app-content.editor-open instead */

/* Mobile version - add backdrop for right panel */
@media (max-width: 768px) {
  .right-panel {
    width: 100%;
    right: -100%;
    z-index: 1020; /* Above sidebar backdrop */
  }
  
  .right-panel.show {
    right: 0;
  }
}

/* Desktop version - slide from right */
@media (min-width: 769px) {
  .right-panel {
    position: fixed;
    right: -350px;
    transition: right 0.3s ease;
    z-index: 100;
  }
  
  .right-panel.show {
    right: 0;
  }
}

.right-panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--border-light);
  background: var(--bg-white);
}

.right-panel-header h3 {
  font-family: 'Inter', 'Noto Sans TC', sans-serif;
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0;
}

.panel-close-btn {
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 0.5rem;
  border-radius: 8px;
  color: var(--text-secondary);
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.panel-close-btn:hover {
  background: var(--bg-light-gray);
  color: var(--text-primary);
}

.right-panel-content {
  flex: 1;
  padding: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* Text Editor Styles */
#text-editor {
  flex: 1;
  width: 100%;
  border: none;
  outline: none;
  padding: 1.5rem;
  font-family: 'SF Mono', 'Monaco', 'Inconsolata', 'Roboto Mono', monospace;
  font-size: 0.875rem;
  line-height: 1.6;
  color: var(--text-primary);
  background: transparent;
  resize: none;
  overflow-y: auto;
}

#text-editor::placeholder {
  color: var(--text-muted);
  font-style: italic;
}

/* Editor Actions */
.editor-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.save-button {
  background: var(--accent-yellow);
  color: var(--text-primary);
  border: none;
  cursor: pointer;
  padding: 0.5rem 1rem;
  border-radius: 6px;
  font-family: 'Inter', 'Noto Sans TC', sans-serif;
  font-size: 0.875rem;
  font-weight: 500;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  gap: 0.375rem;
}

.save-button:hover {
  background: var(--accent-yellow-dark);
  transform: translateY(-1px);
  box-shadow: 0 2px 8px var(--shadow-soft);
}

.save-button:disabled {
  background: var(--bg-light-gray);
  color: var(--text-muted);
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.save-button i {
  width: 16px;
  height: 16px;
}

/* Test button styles */
.test-button {
  background: var(--primary-indigo);
  color: white;
  border: none;
  cursor: pointer;
  padding: 0.5rem 1rem;
  border-radius: 6px;
  font-family: 'Inter', 'Noto Sans TC', sans-serif;
  font-size: 0.875rem;
  font-weight: 500;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.test-button:hover {
  background: #4338ca;
  transform: translateY(-1px);
  box-shadow: 0 2px 8px var(--shadow-soft);
}

.test-button i {
  width: 16px;
  height: 16px;
}

/* Reload button styles (similar to test button but with teal color) */
.reload-button {
  background: #0F766E;
  color: white;
  border: none;
  cursor: pointer;
  padding: 0.5rem 1rem;
  border-radius: 6px;
  font-family: 'Inter', 'Noto Sans TC', sans-serif;
  font-size: 0.875rem;
  font-weight: 500;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.reload-button:hover {
  background: #0D9488;
  transform: translateY(-1px);
  box-shadow: 0 2px 8px var(--shadow-soft);
}

.reload-button:disabled {
  background: var(--border-medium);
  color: var(--text-muted);
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.reload-button i {
  width: 16px;
  height: 16px;
}

/* =========================== */
/* AI 對話按鈕系統樣式         */
/* =========================== */

/* 按鈕容器 */
.chat-buttons-container {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 1rem;
  margin-bottom: 0.5rem;
  padding: 0;
  opacity: 0;
  animation: fadeInUp 0.3s ease-out forwards;
}

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

/* 基礎按鈕樣式 */
.chat-button {
  padding: 0.5rem 1rem;
  border: none;
  border-radius: 20px;
  cursor: pointer;
  font-size: 0.875rem;
  font-weight: 500;
  font-family: 'Inter', 'Noto Sans TC', sans-serif;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  backdrop-filter: blur(10px);
  border: 1px solid transparent;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 36px;
  position: relative;
  overflow: hidden;
  user-select: none;
}

.chat-button:before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
  transition: left 0.5s;
}

.chat-button:hover:before {
  left: 100%;
}

/* 按鈕 hover 效果 */
.chat-button:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.chat-button:active {
  transform: translateY(-1px);
  transition: transform 0.1s;
}

/* 按鈕變體樣式 */
.chat-button--primary {
  background: linear-gradient(135deg, var(--primary-indigo), var(--primary-indigo-dark));
  color: var(--text-white);
  box-shadow: 0 2px 8px rgba(94, 99, 155, 0.3);
}

.chat-button--primary:hover {
  background: linear-gradient(135deg, var(--primary-indigo-light), var(--primary-indigo));
  box-shadow: 0 4px 16px rgba(94, 99, 155, 0.4);
}

.chat-button--secondary {
  background: rgba(108, 117, 125, 0.1);
  color: var(--text-primary);
  border-color: var(--border-light);
  backdrop-filter: blur(10px);
}

.chat-button--secondary:hover {
  background: rgba(108, 117, 125, 0.15);
  border-color: var(--border-medium);
}

.chat-button--success {
  background: linear-gradient(135deg, #10B981, #059669);
  color: var(--text-white);
  box-shadow: 0 2px 8px rgba(16, 185, 129, 0.3);
}

.chat-button--success:hover {
  background: linear-gradient(135deg, #34D399, #10B981);
  box-shadow: 0 4px 16px rgba(16, 185, 129, 0.4);
}

.chat-button--warning {
  background: linear-gradient(135deg, #F59E0B, #D97706);
  color: var(--text-white);
  box-shadow: 0 2px 8px rgba(245, 158, 11, 0.3);
}

.chat-button--warning:hover {
  background: linear-gradient(135deg, #FBBF24, #F59E0B);
  box-shadow: 0 4px 16px rgba(245, 158, 11, 0.4);
}

.chat-button--danger {
  background: linear-gradient(135deg, #EF4444, #DC2626);
  color: var(--text-white);
  box-shadow: 0 2px 8px rgba(239, 68, 68, 0.3);
}

.chat-button--danger:hover {
  background: linear-gradient(135deg, #F87171, #EF4444);
  box-shadow: 0 4px 16px rgba(239, 68, 68, 0.4);
}

/* 禁用狀態 */
.chat-button:disabled,
.chat-button--disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none !important;
  box-shadow: none !important;
  background: var(--bg-light-gray) !important;
  color: var(--text-muted) !important;
  border-color: var(--border-light) !important;
}

.chat-button:disabled:before,
.chat-button--disabled:before {
  display: none;
}

/* 從按鈕觸發的訊息樣式 */
.message--from-button {
  position: relative;
}

.message--from-button:before {
  content: '';
  position: absolute;
  left: -4px;
  top: 0;
  width: 3px;
  height: 100%;
  background: linear-gradient(135deg, var(--primary-indigo), var(--accent-yellow));
  border-radius: 2px;
  opacity: 0.7;
}

/* 響應式設計 */
@media (max-width: 768px) {
  .chat-buttons-container {
    gap: 0.375rem;
  }
  
  .chat-button {
    font-size: 0.8125rem;
    padding: 0.4375rem 0.875rem;
    min-height: 32px;
  }
}

@media (max-width: 480px) {
  .chat-buttons-container {
    flex-direction: column;
    align-items: stretch;
  }
  
  .chat-button {
    width: 100%;
    justify-content: center;
  }
}

/* 固定進度檢查按鈕區域（在訊息內容內部） */
.fixed-progress-check-container {
  margin-top: 1rem;
  margin-bottom: 0;
  padding: 0.75rem 0;
  animation: fadeInUp 0.3s ease-out;
}

.progress-check-label {
  font-size: 0.875rem;
  color: var(--text-secondary);
  margin-bottom: 0.5rem;
  font-weight: 500;
  text-align: center;
}

.fixed-progress-check-container .chat-buttons-container {
  margin-top: 0;
  margin-bottom: 0;
  justify-content: flex-start;
}

/* 串流轉轉動畫容器（在訊息框框外部，緊靠框框下緣） */
.streaming-spinner-container {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 0.5rem 0;
  margin-top: 0.25rem;
  margin-bottom: 0.5rem;
  width: 100%;
}

.streaming-spinner {
  width: 20px;
  height: 20px;
  border: 3px solid var(--border-light);
  border-top-color: var(--primary-indigo);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

/* 深色模式支援（如果將來需要） */
@media (prefers-color-scheme: dark) {
  .chat-button--secondary {
    background: rgba(255, 255, 255, 0.1);
    color: #E5E7EB;
    border-color: rgba(255, 255, 255, 0.2);
  }
  
  .chat-button--secondary:hover {
    background: rgba(255, 255, 255, 0.15);
    border-color: rgba(255, 255, 255, 0.3);
  }
}

/* 按鈕載入狀態（預留） */
.chat-button--loading {
  position: relative;
  pointer-events: none;
}

.chat-button--loading:after {
  content: '';
  position: absolute;
  width: 16px;
  height: 16px;
  margin: auto;
  border: 2px solid transparent;
  border-top-color: currentColor;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* ============================= */
/* 程式碼折疊功能樣式             */
/* ============================= */

/* Button placeholder 容器 */
.button-placeholder {
  display: inline-block;
  width: 100%;
}

.button-content-container {
  display: block;
  margin: 0;
}

.collapsible-code-container {
  margin: 0.75rem 0;
}

.code-toggle-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.25rem 0.5rem;
  background: rgba(139, 69, 19, 0.1);
  border: 1px solid rgba(139, 69, 19, 0.2);
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.75rem;
  color: var(--caramel);
  transition: all 0.2s ease;
  font-family: 'SF Mono', 'Monaco', 'Inconsolata', 'Roboto Mono', monospace;
}

.code-toggle-btn:hover {
  background: rgba(139, 69, 19, 0.15);
  border-color: rgba(139, 69, 19, 0.3);
  transform: translateY(-1px);
}

.code-toggle-btn.expanded {
  background: rgba(139, 69, 19, 0.2);
  border-color: rgba(139, 69, 19, 0.4);
}

.code-icon {
  font-weight: bold;
  color: var(--medium-roast);
}

.code-label {
  font-weight: 500;
  font-size: 0.6875rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.code-content {
  margin-top: 0.5rem;
  border: 1px solid var(--border-light);
  border-radius: 6px;
  overflow: hidden;
  animation: slideDown 0.2s ease-out;
}

.code-content pre {
  margin: 0;
  padding: 0.75rem;
  background: var(--bg-light-gray);
  font-size: 0.8125rem;
  line-height: 1.4;
  overflow-x: auto;
}

.code-content code {
  color: var(--text-primary);
  font-family: 'SF Mono', 'Monaco', 'Inconsolata', 'Roboto Mono', monospace;
}

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

/* =========================== */
/* 管理者模式樣式               */
/* =========================== */

/* 管理者模式：專案瀏覽器背景色 */
.project-explorer.admin-mode {
  background: linear-gradient(135deg, #DC2626, #B91C1C);
  box-shadow: 0 0 20px rgba(220, 38, 38, 0.3);
  position: relative;
}

/* 管理者模式：標題樣式 */
.project-explorer.admin-mode .project-explorer-header {
  border-bottom-color: rgba(255, 255, 255, 0.3);
}

.project-explorer.admin-mode .project-explorer-header h3,
.project-explorer.admin-mode .project-explorer-header .project-title-truncate {
  color: #FEF2F2;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

/* 管理者模式：檔案樹樣式 */
.project-explorer.admin-mode .tree-item {
  color: rgba(255, 255, 255, 0.95);
}

.project-explorer.admin-mode .tree-item:hover {
  background-color: rgba(255, 255, 255, 0.15);
  color: rgba(255, 255, 255, 1);
}

.project-explorer.admin-mode .tree-item.folder i {
  color: #FBBF24; /* 金色資料夾圖示 */
}

.project-explorer.admin-mode .tree-item.file.txt-file i {
  color: #FCD34D; /* 金色文字檔案圖示 */
}

.project-explorer.admin-mode .tree-item.file:hover {
  background-color: rgba(252, 211, 77, 0.15);
  color: #FCD34D;
}

.project-explorer.admin-mode .tree-item.file.editing {
  background-color: rgba(252, 211, 77, 0.25);
  color: #FCD34D;
}

/* 管理者模式：按鈕樣式 */
.project-explorer.admin-mode .icon-button,
.project-explorer.admin-mode .tree-item .settings-btn {
  border-color: rgba(255, 255, 255, 0.4);
  color: rgba(255, 255, 255, 0.9);
}

.project-explorer.admin-mode .icon-button:hover,
.project-explorer.admin-mode .tree-item .settings-btn:hover {
  background: rgba(255, 255, 255, 0.2);
  border-color: rgba(255, 255, 255, 0.6);
  color: rgba(255, 255, 255, 1);
}

/* 管理者模式：滾動條樣式 */
.project-explorer.admin-mode .project-list-container::-webkit-scrollbar-thumb {
  background: rgba(254, 242, 242, 0.6);
}

.project-explorer.admin-mode .project-list-container::-webkit-scrollbar-thumb:hover {
  background: rgba(254, 242, 242, 0.8);
}

/* 管理者模式：新增資料夾按鈕 */
.project-explorer.admin-mode .add-folder-btn {
  border-color: rgba(255, 255, 255, 0.4);
  color: rgba(255, 255, 255, 0.9);
}

.project-explorer.admin-mode .add-folder-btn:hover {
  background: rgba(255, 255, 255, 0.15);
  border-color: rgba(255, 255, 255, 0.6);
  color: rgba(255, 255, 255, 1);
}

/* 管理者模式：admin 按鈕特殊樣式 */
#nav-admin-template {
  background: linear-gradient(135deg, rgba(220, 38, 38, 0.1), rgba(185, 28, 28, 0.1));
  border-left: 3px solid #DC2626;
}

#nav-admin-template:hover {
  background: linear-gradient(135deg, rgba(220, 38, 38, 0.15), rgba(185, 28, 28, 0.15));
}

#nav-admin-template i {
  color: #DC2626;
}


