/* Chat Layout Rules */
.chat-layout {
    display: flex;
    gap: 16px;
    height: 100%;
    width: 100%;
}

.chat-sidebar {
    width: 260px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    padding: 1rem;
    min-height: 0;
}

.chat-main {
    flex: 1 1 0%;
    min-width: 0;
    min-height: 0;
    width: 100%;
    display: flex;
    flex-direction: column;
    padding: 0;
    overflow: hidden;
    position: relative;
}

.chat-history-list {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.chat-history-item {
    padding: 0.8rem 1rem;
    border-radius: 8px;
    cursor: pointer;
    background: var(--bg-panel-subtle);
    border: 1px solid transparent;
    transition: all 0.2s;
    color: var(--text-secondary);
    font-size: 0.9rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-history-item:hover {
    background: rgba(255, 255, 255, 0.08);
}

.chat-history-item.active {
    background: var(--bg-panel-hover);
    border-color: var(--border-subtle);
    color: var(--text-primary);
}

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

.chat-header h2 {
    font-size: 1.1rem;
    margin: 0;
    color: var(--text-primary);
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1.2rem;
}

.chat-message-placeholder {
    margin: auto;
    color: var(--text-muted);
    font-size: 0.9rem;
    font-family: 'Inter', -apple-system, sans-serif;
    text-align: center;
}

.chat-message {
    display: flex;
    gap: 1rem;
    width: 100%;
    max-width: 100%;
}

.chat-message.user {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.chat-message.model {
    align-self: flex-start;
}

.chat-avatar {
    width: 36px;
    height: 36px;
    border-radius: 12px;
    background: var(--bg-surface-elevated);
    border: 1px solid var(--border-glow);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.chat-message.user .chat-avatar {
    background: var(--bg-panel-subtle);
    border-color: var(--bg-panel);
    width: 24px;
    height: 24px;
    min-width: 24px;
}
.chat-message.user .chat-avatar svg {
    width: 14px;
    height: 14px;
}

.chat-bubble {
    background: var(--bg-panel-subtle);
    border: 1px solid var(--border-subtle);
    padding: 1rem;
    border-radius: 12px;
    color: var(--text-primary);
    line-height: 1.5;
    font-size: 0.9rem;
    font-family: 'Inter', -apple-system, sans-serif;
    word-break: break-word;
    white-space: pre-wrap;
    max-width: 85%;
}

.chat-message.model .chat-bubble {
    background: transparent;
    border: none;
    padding: 10px 0;
    color: var(--text-muted);
}

.chat-message.user .chat-bubble {
    background: var(--bg-panel-subtle);
    border-color: rgba(255, 255, 255, 0.08);
}

.chat-message.model .chat-bubble p {
    margin: 0 0 0.8rem 0;
}
.chat-message.model .chat-bubble p:last-child {
    margin: 0;
}

/* Base formatting for model Markdown output */
.chat-message.model .chat-bubble blockquote {
    border-left: 3px solid var(--accent-blue);
    padding-left: 1rem;
    margin: 0.5rem 0;
    color: var(--text-secondary);
}

.chat-message.model .chat-bubble pre,
.chat-message.model .chat-bubble code {
    background: var(--bg-color);
    padding: 0.2rem 0.4rem;
    border-radius: 4px;
    font-family: monospace;
    font-size: 0.85em;
}

.chat-message.model .chat-bubble pre {
    padding: 1rem;
    overflow-x: auto;
    border: 1px solid var(--border-subtle);
    margin: 0.8rem 0;
}

.chat-input-container {
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--border-subtle);
    display: flex;
    gap: 1rem;
    align-items: flex-end;
}

.chat-textarea {
    flex: 1;
    background: var(--bg-color);
    border: 1px solid var(--border-subtle);
    border-radius: 12px;
    padding: 12px 16px;
    color: var(--text-primary);
    font-size: 0.9rem;
    resize: none;
    min-height: 50px;
    max-height: 200px;
    overflow-y: auto;
    outline: none;
    transition: border-color 0.2s;
    font-family: 'Inter', -apple-system, sans-serif;
}

.chat-input-wrapper textarea.premium-input {
    font-size: 0.9rem !important;
    font-family: 'Inter', -apple-system, sans-serif !important;
}

.chat-textarea:focus {
    border-color: var(--border-glow);
}

.chat-send-btn, .chat-attach-btn {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    flex-shrink: 0;
    cursor: pointer;
    background: var(--bg-panel-subtle);
    border: 1px solid var(--border-subtle);
    color: var(--text-secondary);
    transition: all 0.2s;
}

.chat-send-btn:hover:not(:disabled), .chat-attach-btn:hover {
    background: var(--bg-panel);
    color: var(--text-primary);
}

.chat-send-btn:disabled {
    cursor: not-allowed;
}

/* Loader */
.chat-typing-indicator {
    display: inline-flex;
    gap: 0.3rem;
    padding: 0.5rem;
}
.chat-typing-indicator span {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background-color: var(--accent-blue);
    animation: typing 1s infinite;
}
.chat-typing-indicator span:nth-child(2) { animation-delay: 0.2s; }
.chat-typing-indicator span:nth-child(3) { animation-delay: 0.4s; }

@keyframes typing {
    0%, 100% { transform: translateY(0); opacity: 0.5; }
    50% { transform: translateY(-3px); opacity: 1; }
}

/* Attachments */
.chat-attachment-item {
    position: relative;
    border: 1px solid var(--border-subtle);
    border-radius: 8px;
    background: var(--bg-color);
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 60px;
    height: 60px;
    flex-shrink: 0;
}
.chat-attachment-item img {
    width: 100%;
    height: 100%;
    object-fit:cover;
}
.chat-attachment-item .file-icon {
    font-size: 0.8rem;
    color: var(--text-secondary);
    padding: 0 4px;
    text-align: center;
    word-break: break-all;
}
.chat-attachment-item .remove-btn {
    position: absolute;
    top: 2px;
    right: 2px;
    background: var(--bg-color);
    color: var(--error-color);
    border: none;
    border-radius: 50%;
    width: 18px;
    height: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 0.7rem;
    padding: 0;
}


.chat-bubble-attachments {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 8px;
}
.chat-bubble-attachment {
    max-width: 250px;
    max-height: 250px;
    border-radius: 8px;
    border: 1px solid var(--border-subtle);
}


/* Unified Chat Prompt Interface */
.chat-prompt-layout {
  display: flex;
  gap: 8px;
  align-items: flex-end;
  width: 100%;
  padding: 0;
  border: none;
  background: transparent;
}

.chat-prompt-input {
  min-height: 64px !important;
  max-height: 160px;
  resize: none;
  flex: 1;
  line-height: 1.4;
  margin: 0;
}

.chat-prompt-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  justify-content: flex-end;
}

.chat-prompt-btn {
  opacity: 1 !important;
  cursor: pointer !important;
}

.chat-prompt-btn[data-inactive="true"] {
  cursor: not-allowed !important;
  color: var(--text-muted) !important;
}

/* Elegant Typography for Chat pane */
.chat-prompt-input {
  font-family: 'Inter', -apple-system, sans-serif !important;
  font-size: 12px !important;
  font-weight: 400 !important;
}

.chat-messages .empty-state p {
  font-family: 'Inter', -apple-system, sans-serif !important;
  font-size: 12px !important;
  font-weight: 400 !important;
  letter-spacing: 0.2px;
}

/* ── Document attachment in message bubble ────────────────────────────────── */
.doc-attachment {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    background: rgba(255,255,255,0.08);
    border-radius: 8px;
    border: 1px solid var(--border-subtle);
    color: var(--text-secondary);
    font-size: 0.85rem;
    margin-right: 8px;
    margin-bottom: 8px;
    max-width: 250px;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}
.doc-attachment svg { flex-shrink: 0; }
.doc-attachment__name {
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ── Sidebar empty state ─────────────────────────────────────────────────── */
.chat-sidebar-empty {
    color: var(--text-muted);
    font-size: 0.85rem;
    padding: 10px;
    text-align: center;
}
