@import url("https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;800&family=JetBrains+Mono:wght@400;500;700&display=swap");

/* ═══════════════════════════════════════ */
/*  DESIGN TOKENS                         */
/* ═══════════════════════════════════════ */
:root {
  --bg-base: #070709;
  --bg-panel: #0e0e14;
  --bg-surface: #151520;
  --bg-surface-hover: #1c1c2a;
  --bg-elevated: #1e1e2e;

  --border-color: #1e1e30;
  --border-active: #2a2a44;

  --accent-primary: #00ffcc;
  --accent-hover: #00e6b8;
  --accent-glow: rgba(0, 255, 204, 0.15);
  --accent-danger: #ff4466;
  --accent-danger-glow: rgba(255, 68, 102, 0.15);
  --accent-warning: #ffaa00;
  --accent-info: #4da6ff;

  --text-main: #e2e2f0;
  --text-secondary: #a0a0bb;
  --text-muted: #5c5c78;
  --text-bright: #ffffff;

  --font-ui: "Inter", -apple-system, BlinkMacSystemFont, sans-serif;
  --font-code: "JetBrains Mono", "Fira Code", monospace;

  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;
  --radius-pill: 100px;

  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 20px 60px rgba(0, 0, 0, 0.6);

  --transition-fast: 0.15s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-normal: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-smooth: 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ═══════════════════════════════════════ */
/*  RESET & BASE                          */
/* ═══════════════════════════════════════ */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body,
html {
  font-family: var(--font-ui);
  height: 100vh;
  background-color: var(--bg-base);
  color: var(--text-main);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body.dragging {
  user-select: none;
}

body.dragging iframe {
  pointer-events: none;
}

/* 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(--text-muted);
}

/* ═══════════════════════════════════════ */
/*  TOAST NOTIFICATIONS                   */
/* ═══════════════════════════════════════ */
#toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 99999;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.toast {
  background: var(--bg-elevated);
  border: 1px solid var(--border-color);
  border-left: 3px solid var(--accent-primary);
  padding: 12px 20px;
  border-radius: var(--radius-md);
  color: var(--text-main);
  font-size: 13px;
  font-weight: 500;
  box-shadow: var(--shadow-md);
  pointer-events: auto;
  animation: toastIn 0.3s var(--transition-normal) forwards;
  max-width: 380px;
  backdrop-filter: blur(12px);
}

.toast.error {
  border-left-color: var(--accent-danger);
}

.toast.warning {
  border-left-color: var(--accent-warning);
}

.toast.info {
  border-left-color: var(--accent-info);
}

.toast.fade-out {
  animation: toastOut 0.3s ease forwards;
}

@keyframes toastIn {
  from {
    opacity: 0;
    transform: translateX(40px);
  }

  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes toastOut {
  from {
    opacity: 1;
    transform: translateX(0);
  }

  to {
    opacity: 0;
    transform: translateX(40px);
  }
}

/* ═══════════════════════════════════════ */
/*  MODALS                                */
/* ═══════════════════════════════════════ */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(8px);
  display: none;
  justify-content: center;
  align-items: center;
  z-index: 9999;
  opacity: 0;
  transition: opacity var(--transition-normal);
}

.modal-overlay.active {
  display: flex;
  opacity: 1;
}

.modal-box {
  background: var(--bg-panel);
  border: 1px solid var(--border-color);
  padding: 32px;
  border-radius: var(--radius-lg);
  width: 460px;
  text-align: center;
  box-shadow: var(--shadow-lg);
  transform: translateY(20px) scale(0.97);
  transition: transform var(--transition-normal);
  max-height: 90vh;
  overflow-y: auto;
}

.modal-overlay.active .modal-box {
  transform: translateY(0) scale(1);
}

.modal-box h3 {
  color: var(--text-bright);
  margin-bottom: 8px;
  font-weight: 800;
  letter-spacing: 0.5px;
  font-size: 16px;
}

.modal-box p {
  color: var(--text-secondary);
  font-size: 13px;
  margin-bottom: 20px;
  word-wrap: break-word;
  line-height: 1.5;
}

.modal-box input {
  width: 100%;
  padding: 12px 14px;
  margin-bottom: 20px;
  background: var(--bg-base);
  border: 1px solid var(--border-color);
  color: var(--text-bright);
  border-radius: var(--radius-md);
  font-family: var(--font-code);
  font-size: 14px;
  outline: none;
  transition: border-color var(--transition-fast);
}

.modal-box input:focus {
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.modal-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
}

.modal-btn {
  flex: 1;
  padding: 10px 16px;
  border: none;
  border-radius: var(--radius-md);
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.modal-btn.confirm {
  background: var(--accent-primary);
  color: #000;
}

.modal-btn.confirm:hover {
  background: var(--accent-hover);
  transform: translateY(-1px);
}

.modal-btn.danger {
  background: var(--accent-danger);
  color: #fff;
}

.modal-btn.danger:hover {
  background: #e6003d;
}

.modal-btn.cancel {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border-color);
}

.modal-btn.cancel:hover {
  background: var(--bg-surface);
  color: var(--text-bright);
}

/* ═══════════════════════════════════════ */
/*  LOGIN                                 */
/* ═══════════════════════════════════════ */
#login-screen {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background:
    radial-gradient(
      ellipse at 30% 50%,
      rgba(0, 255, 204, 0.04) 0%,
      transparent 50%
    ),
    radial-gradient(
      ellipse at 70% 60%,
      rgba(77, 166, 255, 0.03) 0%,
      transparent 50%
    ),
    var(--bg-base);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 100;
}

.login-box {
  background: var(--bg-panel);
  padding: 48px 40px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-color);
  width: 400px;
  text-align: center;
  box-shadow: var(--shadow-lg);
  animation: fadeInUp 0.5s ease forwards;
}

.login-logo {
  width: 100%;
  max-width: 180px;
  margin-bottom: 24px;
  border-radius: var(--radius-sm);
}

.login-box h2 {
  color: var(--accent-primary);
  margin-bottom: 28px;
  letter-spacing: 3px;
  font-weight: 800;
  font-size: 1.3rem;
}

.login-box h2 span {
  color: var(--text-secondary);
}

.login-box input {
  width: 100%;
  padding: 14px 16px;
  margin: 8px 0;
  background: var(--bg-base);
  border: 1px solid var(--border-color);
  color: var(--text-bright);
  border-radius: var(--radius-md);
  font-family: var(--font-code);
  font-size: 13px;
  outline: none;
  transition: border-color var(--transition-fast);
}

.login-box input:focus {
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.login-box button {
  width: 100%;
  padding: 14px;
  margin-top: 24px;
  background: var(--accent-primary);
  border: none;
  font-weight: 800;
  cursor: pointer;
  color: #000;
  border-radius: var(--radius-md);
  font-size: 13px;
  letter-spacing: 1px;
  transition: all var(--transition-fast);
}

.login-box button:hover {
  background: var(--accent-hover);
  transform: translateY(-1px);
  box-shadow: 0 4px 20px var(--accent-glow);
}

.error-msg {
  color: var(--accent-danger);
  font-size: 12px;
  display: none;
  margin-top: 16px;
  font-weight: 600;
}

@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(30px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ═══════════════════════════════════════ */
/*  WORKSPACE LAYOUT                      */
/* ═══════════════════════════════════════ */
#workspace {
  display: none;
  height: 100%;
  flex-direction: column;
}

/* --- Status Bar --- */
.status-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--bg-panel);
  padding: 0 20px;
  border-bottom: 1px solid var(--border-color);
  height: 32px;
  flex-shrink: 0;
  font-size: 11px;
  color: var(--text-muted);
  font-family: var(--font-code);
}

.status-bar .status-left,
.status-bar .status-right {
  display: flex;
  align-items: center;
  gap: 16px;
}

.status-indicator {
  display: flex;
  align-items: center;
  gap: 5px;
}

.status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent-primary);
  animation: pulse 2s infinite;
}

.status-dot.disconnected {
  background: var(--accent-danger);
}

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

  50% {
    opacity: 0.4;
  }
}

/* --- Navbar --- */
.navbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--bg-panel);
  padding: 0 20px;
  border-bottom: 1px solid var(--border-color);
  height: 56px;
  flex-shrink: 0;
  z-index: 20;
}

.logo {
  display: flex;
  align-items: center;
  height: 100%;
  gap: 12px;
}

.logo img {
  max-height: 28px;
}

.nav-actions {
  display: flex;
  gap: 8px;
}

.btn {
  border: none;
  padding: 7px 14px;
  border-radius: var(--radius-md);
  font-weight: 600;
  font-size: 12px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: all var(--transition-fast);
  font-family: var(--font-ui);
}

.save-btn {
  background: var(--accent-glow);
  color: var(--accent-primary);
  border: 1px solid rgba(0, 255, 204, 0.25);
}

.save-btn:hover {
  background: var(--accent-primary);
  color: #000;
  transform: translateY(-1px);
}

.download-btn {
  background: var(--bg-surface);
  color: var(--text-secondary);
  border: 1px solid var(--border-color);
}

.download-btn:hover {
  background: var(--bg-surface-hover);
  color: var(--text-bright);
}

.deploy-btn {
  background: linear-gradient(135deg, #ff4500, #ff6a33);
  color: #fff;
}

.deploy-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 16px rgba(255, 69, 0, 0.3);
}

.logout-btn {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border-color);
}

.logout-btn:hover {
  color: var(--accent-danger);
  border-color: var(--accent-danger);
  background: var(--accent-danger-glow);
}

/* --- Main Content (2-panel) --- */
.main-content {
  display: flex;
  flex: 1;
  height: calc(100vh - 88px);
  width: 100%;
  min-height: 0;
  overflow: hidden;
}

/* LEFT PANEL: Explorer + Code + Preview stacked */
.left-panel {
  display: flex;
  flex-direction: column;
  width: 55%;
  min-width: 30%;
  max-width: 75%;
  background: var(--bg-base);
}

.left-panel-top {
  display: flex;
  flex: 1;
  min-height: 0;
}

/* RIGHT PANEL: AI Chat */
.right-panel {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-width: 0;
  min-height: 0;
  max-width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--bg-base);
  border-left: 1px solid var(--border-color);
}

/* --- Resizers --- */
.resizer-v {
  width: 5px;
  background: var(--bg-base);
  cursor: col-resize;
  z-index: 10;
  transition: background var(--transition-fast);
  position: relative;
}

.resizer-v::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 2px;
  height: 32px;
  border-radius: 1px;
  background: var(--border-color);
  transition: background var(--transition-fast);
}

.resizer-v:hover {
  background: var(--accent-glow);
}

.resizer-v:hover::after {
  background: var(--accent-primary);
}

.resizer-h {
  height: 5px;
  width: 100%;
  background: var(--bg-base);
  cursor: row-resize;
  z-index: 10;
  position: relative;
  transition: background var(--transition-fast);
}

.resizer-h::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 32px;
  height: 2px;
  border-radius: 1px;
  background: var(--border-color);
  transition: background var(--transition-fast);
}

.resizer-h:hover {
  background: var(--accent-glow);
}

.resizer-h:hover::after {
  background: var(--accent-primary);
}

/* ═══════════════════════════════════════ */
/*  1. EXPLORER PANE                      */
/* ═══════════════════════════════════════ */
.explorer-pane {
  width: 200px;
  min-width: 140px;
  max-width: 320px;
  background: var(--bg-panel);
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--border-color);
}

.explorer-header {
  padding: 10px 14px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--border-color);
}

.explorer-title {
  font-size: 10px;
  font-weight: 800;
  color: var(--text-muted);
  letter-spacing: 1.5px;
  text-transform: uppercase;
}

.explorer-actions button {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 13px;
  padding: 2px 4px;
  transition: all var(--transition-fast);
  border-radius: var(--radius-sm);
}

.explorer-actions button:hover {
  color: var(--accent-primary);
  background: var(--accent-glow);
}

#trashZone.drag-over-danger {
  color: var(--accent-danger);
  transform: scale(1.2);
  text-shadow: 0 0 10px var(--accent-danger-glow);
}

.file-tree {
  padding: 8px;
  font-size: 12px;
  color: var(--text-secondary);
  overflow-y: auto;
  font-family: var(--font-code);
  flex: 1;
}

.folder-title {
  padding: 5px 8px;
  font-weight: 700;
  color: var(--text-main);
  cursor: pointer;
  font-size: 12px;
  border-radius: var(--radius-sm);
  transition: background var(--transition-fast);
}

.folder-title:hover {
  background: var(--bg-surface);
}

.folder-contents {
  padding-left: 12px;
  border-left: 1px solid var(--border-color);
  margin-left: 12px;
  margin-top: 2px;
  min-height: 16px;
}

.file-item {
  padding: 4px 8px;
  cursor: pointer;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 1px;
  border: 1px solid transparent;
  font-size: 12px;
  transition: all var(--transition-fast);
}

.file-item:hover {
  background: var(--bg-surface);
  color: var(--text-bright);
}

.file-item.active-file {
  background: var(--accent-glow);
  color: var(--accent-primary);
  border-left: 2px solid var(--accent-primary);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

.drag-over {
  background: var(--accent-glow) !important;
  border: 1px dashed var(--accent-primary) !important;
}

/* ═══════════════════════════════════════ */
/*  2. CODE PANE                          */
/* ═══════════════════════════════════════ */
.code-pane {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: var(--bg-surface);
  min-width: 200px;
}

.tab-header {
  display: flex;
  background: var(--bg-panel);
  border-bottom: 1px solid var(--border-color);
  padding-left: 8px;
  align-items: flex-end;
  overflow-x: auto;
  min-height: 36px;
}

.tab {
  padding: 6px 14px;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 11px;
  font-family: var(--font-code);
  font-weight: 500;
  background: transparent;
  border: 1px solid transparent;
  border-bottom: none;
  margin-top: 6px;
  border-radius: var(--radius-md) var(--radius-md) 0 0;
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: all var(--transition-fast);
}

.tab:hover {
  color: var(--text-secondary);
  background: var(--bg-surface);
}

.tab.active {
  color: var(--accent-primary);
  background: var(--bg-surface);
  border-color: var(--border-color);
  border-bottom: 2px solid var(--accent-primary);
}

.tab-close {
  color: var(--text-muted);
  font-size: 13px;
  cursor: pointer;
  border-radius: 50%;
  width: 16px;
  height: 16px;
  display: inline-flex;
  justify-content: center;
  align-items: center;
  transition: all var(--transition-fast);
}

.tab-close:hover {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-bright);
}

.run-btn {
  margin-left: auto;
  margin-right: 12px;
  margin-bottom: 4px;
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border-color);
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-weight: 600;
  font-size: 10px;
  transition: all var(--transition-fast);
  font-family: var(--font-ui);
}

.run-btn:hover {
  border-color: var(--accent-primary);
  color: var(--accent-primary);
  background: var(--accent-glow);
}

.editor-container {
  flex: 1;
  display: none;
  height: 100%;
  position: relative;
}

.editor-container.active {
  display: block;
}

.CodeMirror {
  height: 100% !important;
  font-size: 13px;
  font-family: var(--font-code);
  background: var(--bg-surface) !important;
}

.CodeMirror-gutters {
  border-right: 1px solid var(--border-color) !important;
  background: var(--bg-panel) !important;
}

.CodeMirror-dialog {
  background: var(--bg-panel);
  color: var(--text-bright);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 10px;
  font-family: var(--font-ui);
}

.CodeMirror-dialog input {
  background: var(--bg-base);
  border: 1px solid var(--border-color);
  color: var(--text-bright);
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  font-family: var(--font-code);
  outline: none;
}

.CodeMirror-dialog input:focus {
  border-color: var(--accent-primary);
}

.CodeMirror-dialog button {
  background: var(--bg-surface);
  color: var(--text-bright);
  border: 1px solid var(--border-color);
  cursor: pointer;
  border-radius: var(--radius-sm);
  padding: 4px 8px;
}

.CodeMirror-dialog button:hover {
  background: var(--accent-primary);
  color: #000;
}

/* ═══════════════════════════════════════ */
/*  3. PREVIEW & CONSOLE                  */
/* ═══════════════════════════════════════ */
.preview-section {
  display: flex;
  flex-direction: column;
  background: #fff;
  width: 100%;
  position: relative;
  overflow: hidden;
  min-height: 120px;
  height: 40%;
}

.preview-header {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 28px;
  background: var(--bg-panel);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 14px;
  font-size: 10px;
  color: var(--text-muted);
  z-index: 5;
  font-family: var(--font-code);
}

.preview-route {
  color: var(--accent-primary);
  font-family: var(--font-code);
}

.preview-frame {
  flex: 1;
  width: 100%;
  border: none;
  margin-top: 28px;
  background: #fff;
}

.preview-console {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: rgba(14, 14, 20, 0.98);
  border-top: 1px solid var(--accent-primary);
  backdrop-filter: blur(8px);
  z-index: 50;
  display: flex;
  flex-direction: column;
  transition: height var(--transition-smooth);
  height: 35%;
}

.preview-console.collapsed {
  height: 26px;
}

.console-header {
  height: 26px;
  background: var(--bg-base);
  color: var(--text-muted);
  font-size: 10px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 12px;
  cursor: pointer;
  font-family: var(--font-code);
  transition: all var(--transition-fast);
}

.console-header:hover {
  color: var(--text-bright);
  background: var(--bg-panel);
}

.console-badge {
  background: var(--bg-surface);
  color: var(--text-muted);
  padding: 1px 6px;
  border-radius: 10px;
  font-size: 9px;
  font-weight: 700;
}

.console-badge.has-errors {
  background: var(--accent-danger);
  color: #fff;
}

.console-logs {
  flex: 1;
  overflow-y: auto;
  padding: 8px 12px;
  font-family: var(--font-code);
  font-size: 11px;
}

.log-entry {
  margin-bottom: 3px;
  padding-bottom: 3px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.03);
  color: var(--text-secondary);
  word-wrap: break-word;
}

.log-error {
  color: var(--accent-danger);
}

.log-warn {
  color: var(--accent-warning);
}

.log-info {
  color: var(--accent-primary);
}

/* ═══════════════════════════════════════ */
/*  4. AI CHAT PANEL                      */
/* ═══════════════════════════════════════ */
.ai-pane {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  overflow: hidden;
  background: var(--bg-base);
}

.ai-header {
  padding: 10px 14px;
  font-size: 10px;
  font-weight: 800;
  color: var(--text-muted);
  letter-spacing: 1px;
  border-bottom: 1px solid var(--border-color);
  background: var(--bg-panel);
  text-transform: uppercase;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.ai-header .header-controls {
  display: flex;
  align-items: center;
  gap: 10px;
}

.sidebar-toggle {
  background: transparent;
  border: 1px solid var(--border-color);
  color: var(--text-muted);
  padding: 3px 7px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition-fast);
  font-size: 12px;
}

.sidebar-toggle:hover {
  color: var(--text-bright);
  background: var(--bg-surface);
  border-color: var(--border-active);
}

.model-select {
  background: var(--bg-base);
  color: var(--accent-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 3px 8px;
  font-family: var(--font-code);
  font-size: 10px;
  font-weight: 600;
  cursor: pointer;
  outline: none;
  max-width: 220px;
  transition: border-color var(--transition-fast);
}

.model-select:focus {
  border-color: var(--accent-primary);
}

.model-select optgroup {
  color: var(--text-muted);
  background: var(--bg-panel);
  font-style: normal;
}

.model-select option {
  color: var(--text-bright);
  background: var(--bg-panel);
}

.ai-body {
  display: flex;
  flex: 1;
  min-height: 0;
  overflow: hidden;
  background: var(--bg-base);
}

/* Chat History Sidebar */
.chat-sidebar {
  width: 200px;
  background: var(--bg-panel);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  transition: width var(--transition-smooth);
  overflow: hidden;
}

.chat-sidebar.collapsed {
  width: 0;
  border-right: none;
}

.sidebar-top {
  padding: 12px;
  border-bottom: 1px solid var(--border-color);
}

.new-chat-btn {
  width: 100%;
  background: var(--bg-surface);
  color: var(--text-main);
  border: 1px solid var(--border-color);
  padding: 8px 12px;
  border-radius: var(--radius-pill);
  cursor: pointer;
  text-align: left;
  font-size: 12px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: all var(--transition-fast);
}

.new-chat-btn:hover {
  background: var(--accent-glow);
  border-color: var(--accent-primary);
  color: var(--accent-primary);
}

.history-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.history-item {
  padding: 8px 10px;
  font-size: 11px;
  color: var(--text-muted);
  cursor: pointer;
  border-radius: var(--radius-md);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: all var(--transition-fast);
}

.history-item:hover {
  background: var(--bg-surface);
  color: var(--text-bright);
}

.history-item.active {
  background: var(--accent-glow);
  color: var(--accent-primary);
  font-weight: 600;
}

.history-item-del {
  float: right;
  display: none;
  color: var(--accent-danger);
  font-weight: bold;
  font-size: 13px;
}

.history-item:hover .history-item-del {
  display: inline;
}

.sidebar-footer {
  padding: 12px;
  border-top: 1px solid var(--border-color);
}

/* Main Chat Window */
.chat-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
  min-height: 0;
}

.chat-messages {
  flex: 1;
  padding: 16px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 0;
}

.chat-bubble {
  max-width: 90%;
  padding: 12px 16px;
  border-radius: var(--radius-lg);
  font-size: 13px;
  line-height: 1.6;
  word-wrap: break-word;
  overflow-wrap: break-word;
  word-break: break-word;
  animation: bubbleIn 0.25s ease forwards;
}

@keyframes bubbleIn {
  from {
    opacity: 0;
    transform: translateY(8px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.chat-bubble pre {
  background: var(--bg-base);
  padding: 12px;
  border-radius: var(--radius-md);
  overflow-x: auto;
  border: 1px solid var(--border-color);
  margin: 10px 0;
  position: relative;
  max-width: 100%;
}

.chat-bubble code {
  font-family: var(--font-code);
  color: var(--accent-primary);
  font-size: 12px;
  word-break: normal;
  overflow-wrap: normal;
}

.chat-bubble p {
  margin: 0 0 8px 0;
}

.chat-bubble p:last-child {
  margin: 0;
}

.chat-bubble ul,
.chat-bubble ol {
  margin: 8px 0;
  padding-left: 20px;
}

.chat-bubble li {
  margin-bottom: 4px;
}

.chat-bubble.ai {
  background: var(--bg-panel);
  color: var(--text-main);
  border: 1px solid var(--border-color);
  align-self: flex-start;
  border-bottom-left-radius: var(--radius-sm);
}

.chat-bubble.user {
  background: linear-gradient(
    135deg,
    var(--accent-primary),
    var(--accent-hover)
  );
  color: #000;
  align-self: flex-end;
  border-bottom-right-radius: var(--radius-sm);
  font-weight: 500;
}

/* Thinking Indicator */
.thinking-indicator {
  display: flex;
  gap: 4px;
  align-items: center;
  padding: 4px 0;
}

.thinking-indicator span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent-primary);
  opacity: 0.3;
  animation: thinking 1.4s ease-in-out infinite;
}

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

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

@keyframes thinking {
  0%,
  100% {
    opacity: 0.3;
    transform: scale(0.8);
  }

  50% {
    opacity: 1;
    transform: scale(1);
  }
}

/* Apply Code Button */
.apply-code-btn {
  position: absolute;
  top: 6px;
  right: 6px;
  background: var(--accent-primary);
  color: #000;
  border: none;
  padding: 3px 10px;
  border-radius: var(--radius-sm);
  font-size: 10px;
  font-weight: 700;
  cursor: pointer;
  opacity: 0;
  transition: all var(--transition-fast);
  z-index: 10;
  font-family: var(--font-ui);
}

pre:hover .apply-code-btn {
  opacity: 0.85;
}

.apply-code-btn:hover {
  opacity: 1;
  transform: scale(1.05);
}

/* Chat Input */
.chat-input-wrapper {
  padding: 10px 12px;
  background: var(--bg-panel);
  border-top: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex-shrink: 0;
}

.chat-staging-area {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.staged-file {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  padding: 3px 8px;
  border-radius: var(--radius-sm);
  font-size: 10px;
  display: flex;
  align-items: center;
  gap: 5px;
  color: var(--accent-primary);
  font-family: var(--font-code);
}

.staged-file span.remove {
  cursor: pointer;
  color: var(--accent-danger);
  font-weight: bold;
}

.chat-input-box {
  display: flex;
  background: var(--bg-base);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 4px;
  align-items: flex-end;
  transition: border-color var(--transition-fast);
  flex-shrink: 0;
}

.chat-input-box:focus-within {
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 2px var(--accent-glow);
}

.chat-tools {
  display: flex;
  padding-bottom: 4px;
  padding-left: 4px;
  position: relative;
}

.chat-tools button {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 14px;
  cursor: pointer;
  padding: 4px;
  border-radius: var(--radius-sm);
  transition: all var(--transition-fast);
}

.chat-tools button:hover {
  background: var(--bg-surface);
  color: var(--accent-primary);
}

#chatFileAttach,
#chatImageAttach {
  display: none;
}

.chat-input-box textarea {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--text-bright);
  padding: 8px 10px;
  font-size: 13px;
  font-family: var(--font-ui);
  resize: none;
  outline: none;
  max-height: 120px;
  line-height: 1.5;
}

.chat-send-btn {
  background: var(--accent-primary);
  color: #000;
  border: none;
  width: 30px;
  height: 30px;
  border-radius: var(--radius-md);
  cursor: pointer;
  font-weight: bold;
  margin-bottom: 4px;
  margin-right: 4px;
  display: flex;
  justify-content: center;
  align-items: center;
  transition: all var(--transition-fast);
}

.chat-send-btn:hover {
  background: var(--accent-hover);
  transform: scale(1.05);
}

/* ═══════════════════════════════════════ */
/*  COMMAND PALETTE                       */
/* ═══════════════════════════════════════ */
.cmd-palette-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
  z-index: 99998;
  display: none;
  justify-content: center;
  padding-top: 15vh;
}

.cmd-palette-overlay.active {
  display: flex;
}

.cmd-palette {
  width: 520px;
  background: var(--bg-panel);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  max-height: 400px;
  animation: paletteIn 0.15s ease;
}

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

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.cmd-palette input {
  width: 100%;
  padding: 14px 18px;
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--border-color);
  color: var(--text-bright);
  font-size: 15px;
  font-family: var(--font-ui);
  outline: none;
}

.cmd-palette-results {
  max-height: 320px;
  overflow-y: auto;
  padding: 6px;
}

.cmd-palette-item {
  padding: 10px 14px;
  cursor: pointer;
  border-radius: var(--radius-md);
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 13px;
  color: var(--text-secondary);
  transition: all var(--transition-fast);
}

.cmd-palette-item:hover,
.cmd-palette-item.selected {
  background: var(--accent-glow);
  color: var(--accent-primary);
}

.cmd-palette-item .shortcut {
  font-family: var(--font-code);
  font-size: 10px;
  color: var(--text-muted);
  background: var(--bg-base);
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
}

/* ═══════════════════════════════════════ */
/*  SKELETON LOADERS                      */
/* ═══════════════════════════════════════ */
.skeleton {
  background: linear-gradient(
    90deg,
    var(--bg-surface) 25%,
    var(--bg-surface-hover) 50%,
    var(--bg-surface) 75%
  );
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: var(--radius-sm);
}

@keyframes shimmer {
  0% {
    background-position: 200% 0;
  }

  100% {
    background-position: -200% 0;
  }
}

.skeleton-line {
  height: 14px;
  margin-bottom: 8px;
  border-radius: var(--radius-sm);
}

.skeleton-line:last-child {
  width: 60%;
}

/* ═══════════════════════════════════════ */
/*  RESPONSIVE                            */
/* ═══════════════════════════════════════ */
@media (max-width: 900px) {
  .main-content {
    flex-direction: column;
  }

  .left-panel {
    width: 100% !important;
    max-width: 100% !important;
    height: 60%;
  }

  .right-panel {
    height: 40%;
    border-left: none;
    border-top: 1px solid var(--border-color);
  }

  .explorer-pane {
    width: 140px !important;
    min-width: 100px !important;
  }

  .chat-sidebar {
    width: 0;
    border-right: none;
  }

  .navbar {
    padding: 0 12px;
    height: 48px;
  }

  .logo img {
    max-height: 28px;
  }

  .btn {
    padding: 5px 10px;
    font-size: 11px;
  }

  .status-bar {
    display: none;
  }
}

@media (max-width: 600px) {
  .nav-actions {
    gap: 4px;
  }

  .btn span.btn-text {
    display: none;
  }

  .left-panel-top {
    flex-direction: column;
  }

  .explorer-pane {
    width: 100% !important;
    max-width: 100% !important;
    height: 100px;
  }

  .cmd-palette {
    width: 95vw;
  }
}
