/* =========================
   CSS VARIABLES
   ========================= */
:root {
  --bg-primary: #0d0d0d;
  --bg-secondary: #1a1a1a;
  --bg-tertiary: #242424;
  --bg-hover: #2a2a2a;
  --bg-code: #1e1e1e;
  --text-primary: #f5f5f5;
  --text-secondary: #b3b3b3;
  --text-muted: #737373;
  --border-color: #333333;
  --border-light: #404040;
  --accent-coral: #ff6b6b;
  --accent-blue: #4dabf7;
  --accent-green: #51cf66;
  --accent-purple: #9775fa;
  --shadow-soft: 0 4px 24px rgba(0, 0, 0, 0.4);
  --shadow-medium: 0 8px 32px rgba(0, 0, 0, 0.5);
  --sidebar-width: 260px;
  --header-height: 56px;
  --content-max-width: 1000px;
  --transition-fast: 0.15s ease;
  --transition-normal: 0.25s ease;
}

/* =========================
   RESET & BASE
   ========================= */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: 'DM Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  display: flex;
  overflow: hidden;
}

/* =========================
   SCROLLBAR
   ========================= */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--border-light);
}

/* =========================
   SIDEBAR
   ========================= */
.sidebar {
  width: var(--sidebar-width);
  height: 100vh;
  background: var(--bg-secondary);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  padding: 16px;
  flex-shrink: 0;
  transition: width 0.2s ease, padding 0.2s ease;
  overflow: visible;
}

.logo {
  font-family: 'Fraunces', Georgia, serif;
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--text-primary);
  padding: 8px 12px;
  margin-bottom: 20px;
}

/* Menu Section */
.menu-section {
  margin-bottom: 24px;
}

.section-label {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  padding: 8px 12px;
  margin-bottom: 4px;
}

.menu-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 10px;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition-fast);
  font-size: 0.9rem;
  font-weight: 500;
}

.menu-item:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.menu-item svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

.menu-item.new-chat {
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  margin-bottom: 8px;
}

.menu-item.new-chat:hover {
  background: var(--bg-hover);
  border-color: var(--border-light);
}

/* Recents List */
.recents-list {
  flex: 1;
  overflow-y: auto;
  overflow-x: visible;
  margin: 0 -8px;
  padding: 0 8px;
  position: relative;
}

.recents-empty {
  font-size: 0.85rem;
  color: var(--text-muted);
  padding: 12px;
  text-align: center;
}

.recent-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  border-radius: 8px;
  cursor: pointer;
  transition: all var(--transition-fast);
  position: relative;
  margin-bottom: 2px;
  overflow: visible;
}

.recent-item:hover {
  background: var(--bg-hover);
}

.recent-item.active {
  background: var(--bg-tertiary);
}

.recent-item-title {
  font-size: 0.85rem;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
  min-width: 0;
}

.recent-item.active .recent-item-title {
  color: var(--text-primary);
}

.recent-item-star {
  color: var(--accent-coral);
  margin-right: 6px;
}

.recent-item-menu-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
  opacity: 0;
  transition: all var(--transition-fast);
  display: flex;
  align-items: center;
  justify-content: center;
}

.recent-item:hover .recent-item-menu-btn {
  opacity: 1;
}

.recent-item-menu-btn:hover {
  background: var(--bg-tertiary);
  color: var(--text-primary);
}

/* Recent Item Dropdown */
.recent-item-dropdown {
  position: fixed;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  padding: 6px;
  min-width: 140px;
  box-shadow: var(--shadow-soft);
  z-index: 9999;
  display: none;
}

.recent-item-dropdown.active {
  display: block;
}

.dropdown-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: 6px;
  border: none;
  background: none;
  color: var(--text-secondary);
  font-size: 0.85rem;
  cursor: pointer;
  width: 100%;
  text-align: left;
  transition: all var(--transition-fast);
}

.dropdown-item:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.dropdown-item svg {
  width: 14px;
  height: 14px;
}

.dropdown-item.danger {
  color: var(--accent-coral);
}

.dropdown-item.danger:hover {
  background: rgba(255, 107, 107, 0.1);
}

.dropdown-divider {
  height: 1px;
  background: var(--border-color);
  margin: 6px 0;
}

/* Rename Input */
.rename-input {
  background: var(--bg-tertiary);
  border: 1px solid var(--accent-blue);
  border-radius: 4px;
  color: var(--text-primary);
  font-size: 0.85rem;
  padding: 4px 8px;
  width: 100%;
  outline: none;
}

/* User Profile */
.user-profile {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border-top: 1px solid var(--border-color);
  margin-top: auto;
  cursor: pointer;
  border-radius: 10px;
  transition: all var(--transition-fast);
}

.user-profile:hover {
  background: var(--bg-hover);
}

.avatar {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--accent-coral), var(--accent-purple));
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 0.9rem;
  color: white;
}

.user-info {
  flex: 1;
  min-width: 0;
}

.user-name {
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-primary);
}

.user-plan {
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* =========================
   MAIN CONTENT
   ========================= */
.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
  position: relative;
}

/* Header */
.header {
  height: var(--header-height);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  border-bottom: 1px solid var(--border-color);
  flex-shrink: 0;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Sidebar Toggle Button */
.sidebar-toggle-btn {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-fast);
}

.sidebar-toggle-btn:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.sidebar-toggle-btn svg {
  width: 20px;
  height: 20px;
}

/* Collapsed Sidebar */
.sidebar.collapsed {
  width: 0;
  padding: 0;
  overflow: hidden;
  border-right: none;
}

.sidebar.collapsed * {
  opacity: 0;
  visibility: hidden;
}

.header-icon {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.header-icon:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.header-icon svg {
  width: 20px;
  height: 20px;
}

/* =========================
   CHAT AREA
   ========================= */
.chat-area {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
  display: flex;
  flex-direction: column;
  position: relative;
}

/* Welcome Section */
.welcome-section {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 40px 20px;
  max-width: var(--content-max-width);
  margin: 0 auto;
  width: 100%;
}

.welcome-icon {
  font-size: 3.5rem;
  margin-bottom: 20px;
  opacity: 0.9;
}

.welcome-title {
  font-family: 'Fraunces', Georgia, serif;
  font-size: 2rem;
  font-weight: 500;
  color: var(--text-primary);
  margin-bottom: 12px;
}

.welcome-subtitle {
  font-size: 1rem;
  color: var(--text-muted);
  max-width: 400px;
}

/* Messages Container */
.messages-container {
  display: flex;
  flex-direction: column;
  gap: 24px;
  max-width: var(--content-max-width);
  width: 100%;
  margin: 0 auto;
  padding-bottom: 24px;
}

/* Message */
.message {
  display: flex;
  gap: 16px;
  animation: fadeIn 0.3s ease;
  width: 100%;
}

.message-content {
  flex: 1;
  min-width: 0;
  max-width: 100%;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.message-avatar {
  display: none;
}

.message-content {
  flex: 1;
  min-width: 0;
}

/* User message bubble - HIJAU */
.message.user .message-content {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
}

.message.user .message-text {
  background: linear-gradient(135deg, #22c55e, #16a34a);
  color: white;
  padding: 12px 16px;
  border-radius: 18px 18px 4px 18px;
  max-width: 80%;
  font-size: 0.95rem;
  line-height: 1.6;
}

/* Assistant message - normal */
.message.assistant .message-text {
  font-size: 0.95rem;
  line-height: 1.7;
  color: var(--text-primary);
}

.message-text p {
  margin-bottom: 12px;
}

.message-text p:last-child {
  margin-bottom: 0;
}

/* =========================
   COLLAPSIBLE SECTIONS
   ========================= */
.collapsible-section {
  margin: 12px 0;
  border: 1px solid var(--border-color);
  border-radius: 12px;
  overflow: hidden;
  background: var(--bg-tertiary);
}

.collapsible-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  background: var(--bg-secondary);
  cursor: pointer;
  user-select: none;
  transition: background 0.2s ease;
}

.collapsible-header:hover {
  background: var(--bg-hover);
}

.collapsible-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-secondary);
}

.collapsible-title svg {
  width: 16px;
  height: 16px;
}

.collapsible-header-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.collapsible-icon {
  width: 20px;
  height: 20px;
  color: var(--text-muted);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.collapsible-section.open .collapsible-icon {
  transform: rotate(180deg);
}

.collapsible-content {
  max-height: 0;
  opacity: 0;
  overflow: hidden;
  transition: max-height 0.4s cubic-bezier(0.4, 0, 0.2, 1), 
              opacity 0.3s ease,
              padding 0.3s ease;
}

.collapsible-section.open .collapsible-content {
  max-height: 2000px;
  opacity: 1;
}

.collapsible-body {
  padding: 14px;
  font-size: 0.9rem;
  line-height: 1.6;
  color: var(--text-secondary);
}

/* Thinking Section Specific */
.thinking-section .collapsible-header {
  background: rgba(151, 117, 250, 0.1);
  border-bottom: 1px solid rgba(151, 117, 250, 0.2);
}

.thinking-section .collapsible-title {
  color: var(--accent-purple);
}

.thinking-section .collapsible-title svg {
  animation: pulse-slow 2s ease-in-out infinite;
}

@keyframes pulse-slow {
  0%, 100% { opacity: 0.7; }
  50% { opacity: 1; }
}

/* Tool/Action Section */
.tool-section .collapsible-header {
  background: rgba(77, 171, 247, 0.1);
  border-bottom: 1px solid rgba(77, 171, 247, 0.2);
}

.tool-section .collapsible-title {
  color: var(--accent-blue);
}

.tool-section .collapsible-body {
  background: var(--bg-code);
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.8rem;
  padding: 0;
}

/* Status indicator */
.section-status {
  font-size: 0.75rem;
  padding: 2px 8px;
  border-radius: 4px;
  background: rgba(81, 207, 102, 0.2);
  color: var(--accent-green);
}

/* =========================
   CHANGE TABLE (Perubahan)
   ========================= */
.change-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

.change-table tr {
  border-bottom: 1px solid var(--border-color);
}

.change-table tr:last-child {
  border-bottom: none;
}

.change-table td {
  padding: 10px 14px;
  vertical-align: top;
}

.change-table td:first-child {
  color: var(--text-muted);
  font-weight: 500;
  width: 60px;
  white-space: nowrap;
}

.change-table td:last-child {
  color: var(--text-primary);
}

.change-table code {
  background: var(--bg-primary);
  padding: 2px 8px;
  border-radius: 4px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.8rem;
  color: var(--accent-coral);
}

.change-table .code-from {
  color: #f87171;
  text-decoration: line-through;
  opacity: 0.8;
}

.change-table .code-to {
  color: var(--accent-green);
}

/* =========================
   DIFF VIEWER
   ========================= */
.diff-viewer-modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s;
}

.diff-viewer-modal.open {
  opacity: 1;
  visibility: visible;
}

.diff-viewer-content {
  width: 95%;
  max-width: 1400px;
  height: 85vh;
  max-height: 85vh;
  background: var(--bg-secondary);
  border-radius: 16px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transform: scale(0.9);
  transition: transform 0.3s;
}

.diff-viewer-modal.open .diff-viewer-content {
  transform: scale(1);
}

.diff-viewer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-color);
  background: var(--bg-tertiary);
}

.diff-viewer-title {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 1rem;
  font-weight: 600;
}

.diff-viewer-title svg {
  width: 20px;
  height: 20px;
  color: var(--accent-purple);
}

.diff-viewer-filename {
  background: var(--bg-code);
  padding: 4px 12px;
  border-radius: 6px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.85rem;
  color: var(--accent-blue);
}

.diff-viewer-stats {
  display: flex;
  gap: 16px;
  font-size: 0.85rem;
}

.diff-stat {
  display: flex;
  align-items: center;
  gap: 4px;
}

.diff-stat.additions {
  color: var(--accent-green);
}

.diff-stat.deletions {
  color: var(--accent-coral);
}

.diff-viewer-actions {
  display: flex;
  gap: 8px;
}

.diff-viewer-body {
  flex: 1;
  overflow: hidden;
  display: flex !important;
  flex-direction: row !important;
  min-height: 0;
  gap: 0;
}

/* Side by side view */
.diff-pane {
  flex: 1 1 50%;
  display: flex;
  flex-direction: column;
  min-width: 0;
  width: 50%;
  max-width: 50%;
  overflow: hidden;
  height: 100%;
}

.diff-pane-header {
  padding: 10px 16px;
  background: var(--bg-tertiary);
  border-bottom: 1px solid var(--border-color);
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 8px;
}

.diff-pane-header.old {
  border-right: 1px solid var(--border-color);
}

.diff-pane-header .label {
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 0.7rem;
}

.diff-pane-header.old .label {
  background: rgba(255, 107, 107, 0.2);
  color: var(--accent-coral);
}

.diff-pane-header.new .label {
  background: rgba(81, 207, 102, 0.2);
  color: var(--accent-green);
}

.diff-pane-content {
  flex: 1;
  overflow-y: auto;
  overflow-x: auto;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.8rem;
  line-height: 1.6;
  min-height: 0;
}

.diff-pane.old {
  border-right: 1px solid var(--border-color);
}

.diff-line {
  display: flex;
  min-height: 24px;
}

.diff-line-number {
  width: 50px;
  padding: 0 12px;
  text-align: right;
  color: var(--text-muted);
  background: var(--bg-tertiary);
  border-right: 1px solid var(--border-color);
  user-select: none;
  flex-shrink: 0;
}

.diff-line-content {
  flex: 1;
  padding: 0 12px;
  white-space: pre-wrap;
  word-break: break-all;
}

/* Line types */
.diff-line.unchanged {
  background: transparent;
}

.diff-line.added {
  background: rgba(81, 207, 102, 0.15);
}

.diff-line.added .diff-line-content {
  color: var(--accent-green);
}

.diff-line.added .diff-line-number {
  background: rgba(81, 207, 102, 0.2);
  color: var(--accent-green);
}

.diff-line.removed {
  background: rgba(255, 107, 107, 0.15);
}

.diff-line.removed .diff-line-content {
  color: var(--accent-coral);
}

.diff-line.removed .diff-line-number {
  background: rgba(255, 107, 107, 0.2);
  color: var(--accent-coral);
}

.diff-line.empty {
  background: var(--bg-tertiary);
}

.diff-line.empty .diff-line-content {
  color: var(--text-muted);
  font-style: italic;
}

/* Inline diff highlights */
.diff-highlight-add {
  background: rgba(81, 207, 102, 0.3);
  padding: 1px 2px;
  border-radius: 2px;
}

.diff-highlight-remove {
  background: rgba(255, 107, 107, 0.3);
  padding: 1px 2px;
  border-radius: 2px;
  text-decoration: line-through;
}

/* Unified view toggle */
.diff-view-toggle {
  display: flex;
  background: var(--bg-tertiary);
  border-radius: 6px;
  padding: 2px;
}

.diff-view-toggle button {
  padding: 6px 12px;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 0.8rem;
  cursor: pointer;
  border-radius: 4px;
  transition: all 0.2s;
}

.diff-view-toggle button.active {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.diff-view-toggle button:hover:not(.active) {
  color: var(--text-secondary);
}

/* Diff button in file explorer */
.file-item-btn.diff-btn {
  color: var(--accent-purple);
}

.file-item-btn.diff-btn:hover {
  background: rgba(151, 117, 250, 0.2);
}

/* =========================
   QUICK ACTIONS BAR
   ========================= */
.quick-actions-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 0;
  max-width: var(--content-max-width);
  margin: 0 auto 8px;
  overflow-x: auto;
  scrollbar-width: none;
}

.quick-actions-bar::-webkit-scrollbar {
  display: none;
}

.quick-actions-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  white-space: nowrap;
  margin-right: 4px;
}

.quick-action-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 20px;
  color: var(--text-secondary);
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.2s ease;
}

.quick-action-btn:hover {
  background: var(--bg-hover);
  border-color: var(--border-light);
  color: var(--text-primary);
  transform: translateY(-1px);
}

.quick-action-btn:active {
  transform: translateY(0);
}

.quick-action-btn svg {
  width: 14px;
  height: 14px;
}

.quick-action-btn.review { border-color: rgba(77, 171, 247, 0.4); }
.quick-action-btn.review:hover { 
  background: rgba(77, 171, 247, 0.15); 
  border-color: var(--accent-blue);
  color: var(--accent-blue);
}

.quick-action-btn.fix-bug { border-color: rgba(255, 107, 107, 0.4); }
.quick-action-btn.fix-bug:hover { 
  background: rgba(255, 107, 107, 0.15); 
  border-color: var(--accent-coral);
  color: var(--accent-coral);
}

.quick-action-btn.optimize { border-color: rgba(81, 207, 102, 0.4); }
.quick-action-btn.optimize:hover { 
  background: rgba(81, 207, 102, 0.15); 
  border-color: var(--accent-green);
  color: var(--accent-green);
}

.quick-action-btn.docs { border-color: rgba(151, 117, 250, 0.4); }
.quick-action-btn.docs:hover { 
  background: rgba(151, 117, 250, 0.15); 
  border-color: var(--accent-purple);
  color: var(--accent-purple);
}

.quick-action-btn.explain { border-color: rgba(255, 193, 7, 0.4); }
.quick-action-btn.explain:hover { 
  background: rgba(255, 193, 7, 0.15); 
  border-color: #ffc107;
  color: #ffc107;
}

.quick-action-btn.refactor { border-color: rgba(0, 188, 212, 0.4); }
.quick-action-btn.refactor:hover { 
  background: rgba(0, 188, 212, 0.15); 
  border-color: #00bcd4;
  color: #00bcd4;
}

/* Hide quick actions when no files */
.quick-actions-bar.hidden {
  display: none;
}

/* =========================
   FILE EXPLORER PANEL
   ========================= */
.file-explorer {
  position: fixed;
  top: 0;
  right: 0;
  width: 300px;
  height: 100vh;
  background: var(--bg-secondary);
  border-left: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  z-index: 1000;
  transform: translateX(100%);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.file-explorer.open {
  transform: translateX(0);
}

.file-explorer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px;
  border-bottom: 1px solid var(--border-color);
}

.file-explorer-title {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 8px;
}

.file-explorer-title svg {
  width: 18px;
  height: 18px;
  color: var(--accent-blue);
}

.file-explorer-close {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
  transition: all 0.2s;
}

.file-explorer-close:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.file-explorer-actions {
  display: flex;
  gap: 8px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-color);
}

.file-action-btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 12px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  color: var(--text-secondary);
  font-size: 0.8rem;
  cursor: pointer;
  transition: all 0.2s;
}

.file-action-btn:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
  border-color: var(--border-light);
}

.file-action-btn.primary {
  background: var(--accent-blue);
  border-color: var(--accent-blue);
  color: white;
}

.file-action-btn.primary:hover {
  background: #3a9ae8;
}

.file-action-btn svg {
  width: 14px;
  height: 14px;
}

.file-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
}

.file-list-empty {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-muted);
  font-size: 0.85rem;
}

.file-list-empty svg {
  width: 48px;
  height: 48px;
  margin-bottom: 12px;
  opacity: 0.5;
}

.file-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.15s;
  margin-bottom: 4px;
}

.file-item:hover {
  background: var(--bg-hover);
}

.file-item.active {
  background: rgba(77, 171, 247, 0.15);
  border: 1px solid rgba(77, 171, 247, 0.3);
}

.file-item-icon {
  width: 32px;
  height: 32px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 600;
  flex-shrink: 0;
}

.file-item-icon.html { background: #e34c26; color: white; }
.file-item-icon.css { background: #264de4; color: white; }
.file-item-icon.js { background: #f7df1e; color: #000; }
.file-item-icon.php { background: #777bb4; color: white; }
.file-item-icon.json { background: #292929; color: #f5f5f5; }
.file-item-icon.other { background: var(--bg-tertiary); color: var(--text-secondary); }

.file-item-info {
  flex: 1;
  min-width: 0;
}

.file-item-name {
  font-size: 0.85rem;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.file-item-meta {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 2px;
}

.file-item-actions {
  display: flex;
  gap: 4px;
  opacity: 0;
  transition: opacity 0.15s;
}

.file-item:hover .file-item-actions {
  opacity: 1;
}

.file-item-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
  transition: all 0.15s;
}

.file-item-btn:hover {
  background: var(--bg-tertiary);
  color: var(--text-primary);
}

.file-item-btn svg {
  width: 14px;
  height: 14px;
}

/* File Preview Modal */
.file-preview-modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s;
}

.file-preview-modal.open {
  opacity: 1;
  visibility: visible;
}

.file-preview-content {
  width: 90%;
  max-width: 900px;
  max-height: 85vh;
  background: var(--bg-secondary);
  border-radius: 16px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transform: scale(0.9);
  transition: transform 0.3s;
}

.file-preview-modal.open .file-preview-content {
  transform: scale(1);
}

.file-preview-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-color);
}

.file-preview-title {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.95rem;
  font-weight: 500;
}

.file-preview-actions {
  display: flex;
  gap: 8px;
}

.file-preview-body {
  flex: 1;
  overflow: auto;
  padding: 0;
}

.file-preview-body pre {
  margin: 0;
  padding: 20px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.85rem;
  line-height: 1.6;
  white-space: pre-wrap;
  word-wrap: break-word;
}

/* Toggle Button for File Explorer */
.file-explorer-toggle {
  position: fixed;
  top: 50%;
  right: 0;
  transform: translateY(-50%);
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-right: none;
  border-radius: 8px 0 0 8px;
  padding: 12px 8px;
  cursor: pointer;
  z-index: 999;
  transition: all 0.2s;
  color: var(--text-muted);
}

.file-explorer-toggle:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.file-explorer-toggle svg {
  width: 20px;
  height: 20px;
}

.file-explorer-toggle .badge {
  position: absolute;
  top: -5px;
  left: -5px;
  background: var(--accent-blue);
  color: white;
  font-size: 0.7rem;
  padding: 2px 6px;
  border-radius: 10px;
  font-weight: 600;
}

/* =========================
   CODE BLOCK STYLING
   ========================= */
.code-block-wrapper {
  position: relative;
  margin: 12px 0;
  border-radius: 12px;
  overflow: hidden;
  background: var(--bg-code);
  border: 1px solid var(--border-color);
  width: 100%;
}

.code-block-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  background: var(--bg-tertiary);
  border-bottom: 1px solid var(--border-color);
}

.code-block-lang {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-muted);
  text-transform: lowercase;
}

.code-copy-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 0.75rem;
  cursor: pointer;
  border-radius: 6px;
  transition: all var(--transition-fast);
}

.code-copy-btn:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.code-copy-btn svg {
  width: 14px;
  height: 14px;
}

.code-copy-btn.copied {
  color: var(--accent-green);
}

.code-block-content {
  position: relative;
  max-height: 300px;
  overflow: hidden;
  transition: max-height 0.3s ease;
}

.code-block-content.expanded {
  max-height: none;
}

.code-block-content pre {
  margin: 0;
  padding: 16px;
  overflow-x: auto;
  background: transparent;
  border: none;
  border-radius: 0;
}

.code-block-content code {
  font-family: 'JetBrains Mono', 'Fira Code', monospace;
  font-size: 0.85rem;
  line-height: 1.6;
  color: var(--text-primary);
}

/* Code gradient overlay */
.code-block-content:not(.expanded)::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 60px;
  background: linear-gradient(transparent, var(--bg-code));
  pointer-events: none;
}

.code-block-content.expanded::after {
  display: none;
}

/* Expand button */
.code-expand-btn {
  display: none;
  width: 100%;
  padding: 10px;
  border: none;
  background: var(--bg-tertiary);
  border-top: 1px solid var(--border-color);
  color: var(--text-secondary);
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.code-expand-btn:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.code-expand-btn.visible {
  display: block;
}

/* Inline code */
.inline-code {
  background: var(--bg-tertiary);
  padding: 2px 6px;
  border-radius: 4px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.85em;
  color: var(--accent-coral);
}

/* Message Image */
.message-image {
  max-width: 100%;
  max-height: 400px;
  border-radius: 12px;
  margin-top: 12px;
  border: 1px solid var(--border-color);
}

/* Typing Indicator */
.typing-dots {
  display: flex;
  gap: 4px;
  padding: 8px 0;
}

.typing-dots span {
  font-size: 0.6rem;
  color: var(--text-muted);
  animation: bounce 1.4s infinite ease-in-out;
}

.typing-dots .dot-1 { animation-delay: 0s; }
.typing-dots .dot-2 { animation-delay: 0.2s; }
.typing-dots .dot-3 { animation-delay: 0.4s; }

@keyframes bounce {
  0%, 80%, 100% {
    transform: translateY(0);
    opacity: 0.4;
  }
  40% {
    transform: translateY(-6px);
    opacity: 1;
  }
}

/* =========================
   INPUT AREA
   ========================= */
.input-area {
  padding: 16px 24px 24px;
  flex-shrink: 0;
}

.input-container {
  max-width: var(--content-max-width);
  margin: 0 auto;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 28px;
  padding: 8px 16px;
  transition: all var(--transition-fast);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.input-container:focus-within {
  border-color: var(--border-light);
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.05);
}

/* Single Line Input Layout */
.input-single-line {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
}

.input-single-line .text-input {
  flex: 1;
  min-width: 0;
  background: transparent;
  border: none;
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.95rem;
  line-height: 1.5;
  resize: none;
  outline: none;
  min-height: 24px;
  max-height: 200px;
  padding: 8px 0;
}

.input-single-line .text-input::placeholder {
  color: var(--text-muted);
}

.input-single-line .input-actions-right {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

/* Action Buttons */
.action-btn {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-fast);
}

.action-btn:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.action-btn svg {
  width: 18px;
  height: 18px;
}

/* Model Selector */
.model-selector {
  position: relative;
}

.model-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 8px;
  border: 1px solid var(--border-color);
  background: var(--bg-tertiary);
  color: var(--text-secondary);
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.model-badge:hover {
  border-color: var(--border-light);
  color: var(--text-primary);
}

.model-badge svg {
  width: 14px;
  height: 14px;
}

/* Model Dropdown */
.model-dropdown {
  position: absolute;
  bottom: calc(100% + 8px);
  right: 0;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 14px;
  padding: 8px;
  min-width: 220px;
  box-shadow: var(--shadow-medium);
  z-index: 100;
  display: none;
}

.model-dropdown.active {
  display: block;
}

.model-option {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  border-radius: 10px;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.model-option:hover {
  background: var(--bg-hover);
}

.model-option > div:first-child {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.model-option > div:first-child > div:first-child {
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-primary);
}

.model-option-info {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.model-option .check {
  color: var(--accent-green);
  font-size: 0.9rem;
  opacity: 0;
}

.model-option.selected .check {
  opacity: 1;
}

/* Send Button */
.send-btn {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  border: none;
  background: var(--text-primary);
  color: var(--bg-primary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-fast);
}

.send-btn:hover:not(:disabled) {
  transform: scale(1.05);
  box-shadow: 0 4px 12px rgba(255, 255, 255, 0.2);
}

.send-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.send-btn svg {
  width: 18px;
  height: 18px;
}

/* Disclaimer */
.disclaimer {
  text-align: center;
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 12px;
  max-width: var(--content-max-width);
  margin-left: auto;
  margin-right: auto;
}

/* Hidden File Input */
.file-input {
  display: none;
}

/* =========================
   EXTENDED THINKING TOGGLE
   ========================= */
.thinking-toggle {
  position: relative;
  transition: all var(--transition-fast);
}

.thinking-toggle.active {
  background: var(--accent-coral);
  color: white;
}

.thinking-toggle.active:hover {
  background: #ff5252;
}

.thinking-toggle.active svg {
  animation: pulse-glow 2s ease-in-out infinite;
}

@keyframes pulse-glow {
  0%, 100% { 
    filter: drop-shadow(0 0 2px currentColor);
    transform: scale(1);
  }
  50% { 
    filter: drop-shadow(0 0 6px currentColor);
    transform: scale(1.05);
  }
}

/* =========================
   ATTACHMENTS PREVIEW
   ========================= */
.attachments-preview-container {
  display: none;
  margin-bottom: 12px;
  position: relative;
  flex-wrap: wrap;
  gap: 8px;
}

.attachments-preview-container.active {
  display: flex;
}

.attachment-preview-item {
  position: relative;
}

.image-preview {
  width: 80px;
  height: 80px;
  object-fit: cover;
  border-radius: 12px;
  border: 1px solid var(--border-color);
}

.attachment-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 12px;
  border: 1px solid var(--border-color);
  background: var(--bg-primary);
  min-width: 220px;
  max-width: 320px;
}

.chip-icon {
  width: 28px;
  height: 28px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  flex-shrink: 0;
}

.chip-meta {
  flex: 1;
  min-width: 0;
}

.chip-name {
  font-size: 0.85rem;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chip-size {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 2px;
}

.remove-attachment {
  position: absolute;
  top: -6px;
  right: -6px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-fast);
  font-size: 10px;
}

.remove-attachment:hover {
  background: var(--accent-coral);
  color: var(--bg-primary);
  border-color: var(--accent-coral);
}

.chip-remove {
  position: static;
  width: 28px;
  height: 28px;
  border-radius: 10px;
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-muted);
  font-size: 12px;
}

.chip-remove:hover {
  background: var(--bg-hover);
  border-color: var(--border-color);
  color: var(--text-primary);
}

/* =========================
   MESSAGE FILE DISPLAY
   ========================= */
.message-file {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--border-color);
  border-radius: 12px;
  background: var(--bg-tertiary);
  margin-top: 10px;
  max-width: 520px;
}

.message-file .file-icon {
  width: 32px;
  height: 32px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  flex-shrink: 0;
}

.message-file .file-meta {
  flex: 1;
  min-width: 0;
}

.message-file .file-name {
  color: var(--text-primary);
  font-size: 0.9rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.message-file .file-size {
  color: var(--text-muted);
  font-size: 0.75rem;
  margin-top: 2px;
}

/* =========================
   DRAG & DROP OVERLAY
   ========================= */
.drop-overlay {
  position: absolute;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 50;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(6px);
}

.drop-overlay.active {
  display: flex;
}

.drop-card {
  width: min(520px, calc(100% - 48px));
  padding: 32px 24px;
  border-radius: 20px;
  background: var(--bg-secondary);
  border: 2px dashed var(--border-light);
  box-shadow: var(--shadow-soft);
  text-align: center;
}

.drop-title {
  font-family: 'Fraunces', Georgia, serif;
  font-size: 1.3rem;
  color: var(--text-primary);
  margin-bottom: 8px;
}

.drop-subtitle {
  font-size: 0.9rem;
  color: var(--text-muted);
}

/* =========================
   SYNTAX HIGHLIGHTING
   ========================= */
.token-keyword { color: #c678dd; }
.token-string { color: #98c379; }
.token-number { color: #d19a66; }
.token-comment { color: #5c6370; font-style: italic; }
.token-function { color: #61afef; }
.token-operator { color: #56b6c2; }
.token-punctuation { color: #abb2bf; }
.token-tag { color: #e06c75; }
.token-attr-name { color: #d19a66; }
.token-attr-value { color: #98c379; }

/* =========================
   RESPONSIVE
   ========================= */
@media (max-width: 768px) {
  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    z-index: 200;
    transform: translateX(-100%);
    transition: transform var(--transition-normal);
  }
  
  .sidebar.open {
    transform: translateX(0);
  }
  
  .main-content {
    width: 100%;
  }
  
  .chat-area {
    padding: 16px;
  }
  
  .input-area {
    padding: 12px 16px 20px;
  }
  
  .messages-container {
    gap: 16px;
  }
  
  .message {
    gap: 12px;
  }
  
  .message-avatar {
    width: 32px;
    height: 32px;
    font-size: 0.8rem;
  }
  
  .welcome-title {
    font-size: 1.5rem;
  }
  
  .welcome-icon {
    font-size: 2.5rem;
  }
}