/* ═══════════════════════════════════════════════════════════════════════════
   Abhimanyu AI — Design System & Styles
   ═══════════════════════════════════════════════════════════════════════════ */

/* ─── CSS Custom Properties ──────────────────────────────────────────────── */

:root {
  /* Backgrounds */
  --bg-primary: #0d0d0d;
  --bg-secondary: #141414;
  --bg-sidebar: #141414;
  --bg-input: #1e1e1e;
  --bg-hover: #1e1e1e;
  --bg-message-user: #7c6aef;
  --bg-message-ai: #1a1a1a;
  --bg-code: #161616;
  --bg-thinking: rgba(245, 158, 11, 0.06);

  /* Text */
  --text-primary: #e8e8e8;
  --text-secondary: #888888;
  --text-muted: #555555;
  --text-inverse: #ffffff;

  /* Accent */
  --accent: #7c6aef;
  --accent-hover: #6b5ce7;
  --accent-glow: rgba(124, 106, 239, 0.15);
  --accent-subtle: rgba(124, 106, 239, 0.08);

  /* Thinking */
  --thinking-accent: #f59e0b;
  --thinking-bg: rgba(245, 158, 11, 0.05);
  --thinking-border: rgba(245, 158, 11, 0.2);

  /* Borders */
  --border: #222222;
  --border-light: #2a2a2a;

  /* Misc */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;
  --shadow: 0 4px 24px rgba(0, 0, 0, 0.3);
  --transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);

  /* Sizing */
  --sidebar-width: 280px;
  --header-height: 56px;
  --input-max-height: 200px;
}

/* ─── 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: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  overflow: hidden;
  height: 100vh;
  width: 100vw;
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

::selection {
  background: var(--accent);
  color: var(--text-inverse);
}

/* Scrollbar */
::-webkit-scrollbar {
  width: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--border-light);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

/* ─── App Layout ─────────────────────────────────────────────────────────── */

.app {
  display: flex;
  height: 100vh;
  width: 100vw;
  overflow: hidden;
}

/* ─── Sidebar ────────────────────────────────────────────────────────────── */

.sidebar {
  width: var(--sidebar-width);
  min-width: var(--sidebar-width);
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  transition: transform var(--transition), opacity var(--transition);
  z-index: 100;
}

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

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-icon {
  display: flex;
  align-items: center;
  justify-content: center;
}

.brand-name {
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  background: linear-gradient(135deg, var(--accent), #a78bfa);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.new-chat-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-light);
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition);
}

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

/* Sidebar Search */
.sidebar-search {
  padding: 12px 16px;
}

.sidebar-search input {
  width: 100%;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-primary);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.8125rem;
  outline: none;
  transition: border-color var(--transition);
}

.sidebar-search input::placeholder {
  color: var(--text-muted);
}

.sidebar-search input:focus {
  border-color: var(--accent);
}

/* Conversations List */
.conversations-list {
  flex: 1;
  overflow-y: auto;
  padding: 4px 8px;
}

.conversation-item {
  display: flex;
  align-items: center;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition);
  margin-bottom: 2px;
  gap: 10px;
  position: relative;
}

.conversation-item:hover {
  background: var(--bg-hover);
}

.conversation-item.active {
  background: var(--accent-subtle);
}

.conversation-item.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 60%;
  background: var(--accent);
  border-radius: 0 2px 2px 0;
}

.conversation-item-icon {
  flex-shrink: 0;
  color: var(--text-muted);
}

.conversation-item-title {
  flex: 1;
  font-size: 0.8125rem;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: color var(--transition);
}

.conversation-item:hover .conversation-item-title,
.conversation-item.active .conversation-item-title {
  color: var(--text-primary);
}

.conversation-item-delete {
  opacity: 0;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border: none;
  background: none;
  color: var(--text-muted);
  cursor: pointer;
  border-radius: 4px;
  transition: all var(--transition);
}

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

.conversation-item-delete:hover {
  color: #ef4444;
  background: rgba(239, 68, 68, 0.1);
}

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

.sidebar-footer-text {
  font-size: 0.6875rem;
  color: var(--text-muted);
  text-align: center;
}

/* ─── Sidebar Overlay (Mobile) ───────────────────────────────────────────── */

.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 99;
  backdrop-filter: blur(4px);
}

/* ─── Chat Main ──────────────────────────────────────────────────────────── */

.chat-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: var(--bg-primary);
}

/* ─── Chat Header ────────────────────────────────────────────────────────── */

.chat-header {
  height: var(--header-height);
  display: flex;
  align-items: center;
  padding: 0 16px;
  gap: 12px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-primary);
  flex-shrink: 0;
}

.menu-btn {
  display: none;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: none;
  background: none;
  color: var(--text-secondary);
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: all var(--transition);
}

.menu-btn:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.chat-title {
  flex: 1;
  font-size: 0.9375rem;
  font-weight: 500;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}

.icon-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border: none;
  background: none;
  color: var(--text-muted);
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: all var(--transition);
}

.icon-btn:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.icon-btn.danger:hover {
  color: #ef4444;
  background: rgba(239, 68, 68, 0.1);
}

/* ─── Messages Container ─────────────────────────────────────────────────── */

.messages-container {
  flex: 1;
  overflow-y: auto;
  scroll-behavior: smooth;
}

.messages {
  max-width: 768px;
  margin: 0 auto;
  padding: 24px 16px;
}

/* ─── Welcome Screen ─────────────────────────────────────────────────────── */

.welcome {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 60vh;
  text-align: center;
  animation: fadeInUp 0.6s ease;
}

.welcome-icon {
  width: 72px;
  height: 72px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 24px;
  animation: float 3s ease-in-out infinite;
}

.welcome-icon svg {
  filter: drop-shadow(0 4px 16px rgba(124, 106, 239, 0.3));
}

.welcome h2 {
  font-size: 1.75rem;
  font-weight: 600;
  letter-spacing: -0.03em;
  margin-bottom: 8px;
  color: var(--text-primary);
}

.welcome p {
  font-size: 0.9375rem;
  color: var(--text-secondary);
  margin-bottom: 32px;
}

.suggestions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  width: 100%;
  max-width: 520px;
}

.suggestion-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  font-family: inherit;
  font-size: 0.8125rem;
  cursor: pointer;
  text-align: left;
  transition: all var(--transition);
}

.suggestion-chip:hover {
  background: var(--bg-hover);
  border-color: var(--accent);
  color: var(--text-primary);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.chip-icon {
  font-size: 1.1rem;
}

/* ─── Message Bubbles ────────────────────────────────────────────────────── */

.message {
  display: flex;
  gap: 12px;
  margin-bottom: 24px;
  animation: fadeIn 0.35s ease;
}

.message-avatar {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 600;
  margin-top: 2px;
}

.message-avatar.user {
  background: linear-gradient(135deg, #3b82f6, #1d4ed8);
  color: white;
}

.message-avatar.ai {
  background: linear-gradient(135deg, var(--accent), #a78bfa);
  color: white;
}

.message-body {
  flex: 1;
  min-width: 0;
}

.message-sender {
  font-size: 0.8125rem;
  font-weight: 600;
  margin-bottom: 4px;
  color: var(--text-primary);
}

.message-content {
  font-size: 0.9375rem;
  line-height: 1.7;
  color: var(--text-primary);
}

/* ─── Thinking Section ───────────────────────────────────────────────────── */

.thinking-section {
  margin-bottom: 12px;
  border: 1px solid var(--thinking-border);
  border-radius: var(--radius-md);
  overflow: hidden;
  background: var(--thinking-bg);
}

.thinking-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  cursor: pointer;
  user-select: none;
  transition: background var(--transition);
}

.thinking-header:hover {
  background: rgba(245, 158, 11, 0.08);
}

.thinking-indicator {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--thinking-accent);
}

.thinking-dots {
  display: inline-flex;
  gap: 3px;
}

.thinking-dots span {
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--thinking-accent);
  animation: pulse 1.4s ease-in-out infinite;
}

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

.thinking-toggle {
  margin-left: auto;
  color: var(--text-muted);
  transition: transform var(--transition);
}

.thinking-toggle.expanded {
  transform: rotate(180deg);
}

.thinking-content {
  padding: 0 14px 14px;
  font-size: 0.8125rem;
  line-height: 1.6;
  color: var(--text-secondary);
  border-top: 1px solid var(--thinking-border);
  max-height: 300px;
  overflow-y: auto;
  display: none;
}

.thinking-content.visible {
  display: block;
  animation: fadeIn 0.3s ease;
}

/* ─── Markdown Content ───────────────────────────────────────────────────── */

.message-content h1,
.message-content h2,
.message-content h3,
.message-content h4 {
  margin-top: 16px;
  margin-bottom: 8px;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.message-content h1 { font-size: 1.4rem; }
.message-content h2 { font-size: 1.2rem; }
.message-content h3 { font-size: 1.05rem; }

.message-content p {
  margin-bottom: 12px;
}

.message-content ul,
.message-content ol {
  margin-bottom: 12px;
  padding-left: 20px;
}

.message-content li {
  margin-bottom: 4px;
}

.message-content blockquote {
  border-left: 3px solid var(--accent);
  padding: 8px 16px;
  margin: 12px 0;
  background: var(--accent-subtle);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  color: var(--text-secondary);
}

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

.message-content th,
.message-content td {
  padding: 8px 12px;
  border: 1px solid var(--border-light);
  text-align: left;
}

.message-content th {
  background: var(--bg-secondary);
  font-weight: 600;
}

.message-content hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 16px 0;
}

/* Inline code */
.message-content code:not(pre code) {
  background: var(--bg-code);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.85em;
  font-family: 'SF Mono', 'Fira Code', 'Cascadia Code', monospace;
  color: #e2b3ff;
  border: 1px solid var(--border);
}

/* Code blocks */
.code-block-wrapper {
  position: relative;
  margin: 12px 0;
  border-radius: var(--radius-md);
  overflow: hidden;
  border: 1px solid var(--border);
}

.code-block-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 14px;
  background: #1a1a1a;
  border-bottom: 1px solid var(--border);
  font-size: 0.75rem;
  color: var(--text-muted);
  font-family: 'SF Mono', 'Fira Code', monospace;
}

.copy-btn {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border: none;
  background: var(--bg-hover);
  color: var(--text-secondary);
  border-radius: 4px;
  cursor: pointer;
  font-family: inherit;
  font-size: 0.75rem;
  transition: all var(--transition);
}

.copy-btn:hover {
  background: var(--accent);
  color: var(--text-inverse);
}

.copy-btn.copied {
  background: #22c55e;
  color: white;
}

.code-block-wrapper pre {
  margin: 0;
  padding: 14px;
  overflow-x: auto;
  background: var(--bg-code) !important;
}

.code-block-wrapper pre code {
  font-family: 'SF Mono', 'Fira Code', 'Cascadia Code', monospace;
  font-size: 0.8125rem;
  line-height: 1.6;
  background: none !important;
  padding: 0 !important;
  border: none !important;
  color: inherit !important;
}

/* ─── Typing Indicator ───────────────────────────────────────────────────── */

.typing-indicator {
  display: inline-flex;
  gap: 5px;
  padding: 8px 0;
}

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

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

/* ─── Input Area ─────────────────────────────────────────────────────────── */

.input-area {
  padding: 0 16px 16px;
  background: var(--bg-primary);
  flex-shrink: 0;
}

.input-wrapper {
  max-width: 768px;
  margin: 0 auto;
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 4px;
  transition: border-color var(--transition), box-shadow var(--transition);
}

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

.input-wrapper textarea {
  flex: 1;
  padding: 10px 12px;
  border: none;
  background: transparent;
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.9375rem;
  line-height: 1.5;
  resize: none;
  outline: none;
  max-height: var(--input-max-height);
  scrollbar-width: thin;
}

.input-wrapper textarea::placeholder {
  color: var(--text-muted);
}

.send-btn,
.stop-btn {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition);
  margin: 2px;
}

.send-btn {
  background: var(--accent);
  color: white;
  opacity: 0.4;
  pointer-events: none;
}

.send-btn.active {
  opacity: 1;
  pointer-events: all;
}

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

.stop-btn {
  background: #ef4444;
  color: white;
}

.stop-btn:hover {
  background: #dc2626;
}

.input-footer {
  text-align: center;
  font-size: 0.6875rem;
  color: var(--text-muted);
  margin-top: 8px;
  max-width: 768px;
  margin-left: auto;
  margin-right: auto;
}

/* ─── Modals ─────────────────────────────────────────────────────────────── */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  animation: fadeIn 0.2s ease;
}

.modal {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  width: 90%;
  max-width: 400px;
  box-shadow: var(--shadow);
  animation: scaleIn 0.2s ease;
}

.modal h3 {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 12px;
}

.modal p {
  color: var(--text-secondary);
  font-size: 0.875rem;
  margin-bottom: 16px;
}

.modal input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-primary);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.875rem;
  outline: none;
  margin-bottom: 16px;
  transition: border-color var(--transition);
}

.modal input:focus {
  border-color: var(--accent);
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.modal-btn {
  padding: 8px 18px;
  border: none;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 0.8125rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
}

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

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

.modal-btn.confirm {
  background: var(--accent);
  color: white;
}

.modal-btn.confirm:hover {
  background: var(--accent-hover);
}

.modal-btn.danger {
  background: #ef4444;
  color: white;
}

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

/* ─── Animations ─────────────────────────────────────────────────────────── */

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

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

@keyframes scaleIn {
  from {
    opacity: 0;
    transform: scale(0.95);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-8px); }
}

@keyframes typing {
  0%, 100% { opacity: 0.4; transform: scale(1); }
  50% { opacity: 1; transform: scale(1.2); }
}

@keyframes pulse {
  0%, 100% { opacity: 0.3; transform: scale(1); }
  50% { opacity: 1; transform: scale(1.3); }
}

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

/* ─── Responsive ─────────────────────────────────────────────────────────── */

@media (max-width: 768px) {
  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    transform: translateX(-100%);
    box-shadow: var(--shadow);
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .sidebar-overlay.visible {
    display: block;
  }

  .menu-btn {
    display: flex;
  }

  .suggestions {
    grid-template-columns: 1fr;
  }

  .welcome h2 {
    font-size: 1.35rem;
  }

  .messages {
    padding: 16px 12px;
  }
}

@media (max-width: 480px) {
  .message {
    gap: 8px;
  }

  .message-avatar {
    width: 28px;
    height: 28px;
    font-size: 0.65rem;
  }

  .message-content {
    font-size: 0.875rem;
  }
}

/* ─── Empty State for No Conversations ────────────────────────────────────── */

.no-conversations {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 32px 16px;
  color: var(--text-muted);
  font-size: 0.8125rem;
  text-align: center;
  gap: 8px;
}

/* ─── Loading Shimmer ────────────────────────────────────────────────────── */

.loading-shimmer {
  background: linear-gradient(
    90deg,
    var(--bg-secondary) 25%,
    var(--bg-hover) 50%,
    var(--bg-secondary) 75%
  );
  background-size: 200% 100%;
  animation: shimmer 1.5s ease-in-out infinite;
  border-radius: var(--radius-sm);
  height: 16px;
  margin-bottom: 8px;
}

/* ─── Error message ──────────────────────────────────────────────────────── */

.error-message {
  background: rgba(239, 68, 68, 0.08);
  border: 1px solid rgba(239, 68, 68, 0.2);
  border-radius: var(--radius-md);
  padding: 12px 16px;
  color: #fca5a5;
  font-size: 0.875rem;
  margin-top: 8px;
}

/* ─── File Attachment Features ────────────────────────────────────────────── */

.input-row {
  display: flex;
  align-items: flex-end;
  width: 100%;
}

.attach-btn {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: all var(--transition);
  margin: 2px;
}

.attach-btn:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.attachments-preview-container {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  max-height: 120px;
  overflow-y: auto;
}

.attachment-preview-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  font-size: 0.75rem;
  color: var(--text-primary);
  max-width: 200px;
  position: relative;
}

.attachment-preview-chip .file-name {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 110px;
}

.attachment-preview-chip img {
  width: 20px;
  height: 20px;
  object-fit: cover;
  border-radius: var(--radius-xs);
}

.attachment-preview-chip .file-icon-preview {
  font-size: 1rem;
}

.attachment-preview-chip .remove-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  transition: all var(--transition);
}

.attachment-preview-chip .remove-btn:hover {
  background: rgba(239, 68, 68, 0.15);
  color: #ef4444;
}

/* User message attachments grid */
.message-attachments {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 10px;
}

.message-attachment-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-md);
  max-width: 250px;
  text-decoration: none;
  color: inherit;
  font-size: 0.8125rem;
  transition: all var(--transition);
}

.message-attachment-card:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: var(--accent);
}

.message-attachment-card img {
  width: 36px;
  height: 36px;
  object-fit: cover;
  border-radius: var(--radius-xs);
}

.message-attachment-card .file-icon {
  font-size: 1.5rem;
  flex-shrink: 0;
}

.message-attachment-card .file-details {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.message-attachment-card .file-name {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-weight: 500;
}

.message-attachment-card .file-type {
  font-size: 0.6875rem;
  color: var(--text-muted);
  text-transform: uppercase;
}

/* Audio attachment player style */
.audio-attachment-player {
  margin-top: 8px;
  max-width: 320px;
  display: block;
}

/* ─── Preview Panel & Workspace ────────────────────────────────────────── */

.chat-workspace {
  display: flex;
  flex: 1;
  height: 100%;
  width: 100%;
  min-width: 0;
  overflow: hidden;
}

.chat-conversation-container {
  display: flex;
  flex-direction: column;
  flex: 1;
  height: 100%;
  min-width: 0;
  overflow: hidden;
}

.preview-panel {
  width: 50%;
  min-width: 320px;
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  height: 100%;
  background: #111111;
  z-index: 10;
  box-shadow: -4px 0 24px rgba(0, 0, 0, 0.3);
}

.preview-header {
  height: var(--header-height);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-secondary);
  flex-shrink: 0;
}

.preview-tabs {
  display: flex;
  gap: 4px;
}

.preview-tab-btn {
  padding: 6px 12px;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-family: inherit;
  font-size: 0.8125rem;
  font-weight: 500;
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: all var(--transition);
}

.preview-tab-btn:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.preview-tab-btn.active {
  background: var(--accent-subtle);
  color: var(--accent);
}

.preview-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}

.preview-action-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: all var(--transition);
}

.preview-action-btn:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.preview-content {
  flex: 1;
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.preview-tab-content {
  display: none;
  width: 100%;
  height: 100%;
  flex: 1;
  position: relative;
  overflow: hidden;
}

.preview-tab-content.active {
  display: flex;
  flex-direction: column;
}

#previewIframe {
  width: 100%;
  height: 100%;
  border: none;
  background: white;
}

#tabContentCode {
  overflow: auto;
  background: var(--bg-code);
}

#previewCodeBlock {
  margin: 0;
  padding: 16px;
  font-family: 'SF Mono', 'Fira Code', monospace;
  font-size: 0.8125rem;
  line-height: 1.6;
  white-space: pre-wrap;
  word-wrap: break-word;
}

.preview-btn-action {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border: none;
  background: var(--accent-subtle);
  color: var(--accent);
  border-radius: 4px;
  cursor: pointer;
  font-family: inherit;
  font-size: 0.75rem;
  transition: all var(--transition);
}

.preview-btn-action:hover {
  background: var(--accent);
  color: white;
}

/* Responsiveness for Preview Panel */
@media (max-width: 992px) {
  .preview-panel {
    position: fixed;
    right: 0;
    top: 0;
    bottom: 0;
    width: 100%;
    z-index: 150;
    border-left: none;
    box-shadow: none;
  }
}
