/* ===== Chat Panel ===== */
.chat-panel {
    display: flex;
    flex-direction: column;
    height: 100%;
    background: var(--neutral-layer-1);
    border-left: 1px solid var(--neutral-stroke-rest);
    transition: width 0.3s ease;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

.chat-panel.collapsed {
    width: 48px;
    min-width: 48px;
}

.chat-panel.expanded {
    width: 380px;
    min-width: 380px;
}

/* Collapsed sidebar tab */
.chat-sidebar-collapsed {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    padding-top: 1rem;
    gap: 1rem;
    cursor: pointer;
    height: 100%;
    width: 48px;
    background: var(--neutral-layer-2);
    transition: background 0.2s;
    position: relative;
}

.chat-sidebar-collapsed:hover {
    background: var(--neutral-layer-3);
}

.chat-sidebar-collapsed .chat-icon {
    width: 24px;
    height: 24px;
    color: var(--accent-fill-rest);
    flex-shrink: 0;
}

.sidebar-text {
    writing-mode: vertical-rl;
    text-orientation: mixed;
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--neutral-foreground-rest);
    user-select: none;
    letter-spacing: 0.05em;
}

.chat-sidebar-collapsed .badge-count {
    position: absolute;
    top: 0.75rem;
    right: 0.25rem;
    background: #ef4444;
    color: white;
    border-radius: 10px;
    min-width: 18px;
    height: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    font-weight: 600;
    padding: 0 4px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.chat-container {
    display: flex;
    flex-direction: column;
    height: 100%;
    background: var(--neutral-layer-floating);
    overflow: hidden;
}

.chat-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    background: var(--neutral-layer-2);
    border-bottom: 1px solid var(--neutral-stroke-rest);
}

.chat-header-left {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.chat-header .chat-icon {
    width: 24px;
    height: 24px;
    color: var(--accent-fill-rest);
}

.chat-title {
    font-size: 1rem;
    font-weight: 600;
    margin: 0;
    color: var(--neutral-foreground-rest);
}

.chat-header-actions {
    display: flex;
    gap: 0.25rem;
}

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

.chat-welcome {
    text-align: center;
    padding: 2rem 1rem;
    color: var(--neutral-foreground-hint);
}

.chat-welcome p {
    margin: 0.5rem 0;
}

.chat-suggestions {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-top: 1.5rem;
}

.suggestion-chip {
    background: var(--neutral-layer-2);
    border: 1px solid var(--neutral-stroke-rest);
    border-radius: 16px;
    padding: 0.5rem 1rem;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s;
    color: var(--neutral-foreground-rest);
}

.suggestion-chip:hover {
    background: var(--neutral-layer-3);
    border-color: var(--accent-fill-rest);
}

.chat-message {
    display: flex;
    gap: 0.75rem;
    animation: fadeIn 0.3s ease-in;
}

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

.user-message {
    flex-direction: row-reverse;
}

.message-avatar {
    flex-shrink: 0;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
}

.user-message .message-avatar {
    background: var(--accent-fill-rest);
}

.assistant-message .message-avatar {
    background: var(--neutral-layer-2);
}

.message-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.message-text {
    background: var(--neutral-layer-2);
    padding: 0.75rem 1rem;
    border-radius: 12px;
    color: var(--neutral-foreground-rest);
    line-height: 1.5;
    word-wrap: break-word;
}

.user-message .message-text {
    background: var(--accent-fill-rest);
    color: white;
}

.message-timestamp {
    font-size: 0.7rem;
    color: var(--neutral-foreground-hint);
    padding: 0 0.5rem;
}

.user-message .message-timestamp {
    text-align: right;
}

.typing-indicator {
    display: flex;
    gap: 4px;
    padding: 0.75rem 1rem;
}

.typing-indicator span {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--neutral-foreground-hint);
    animation: bounce 1.4s infinite;
}

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

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

@keyframes bounce {
    0%, 60%, 100% {
        transform: translateY(0);
    }
    30% {
        transform: translateY(-8px);
    }
}

.chat-input-container {
    padding: 0.5rem;
    background: var(--neutral-layer-2);
    border-top: 1px solid var(--neutral-stroke-rest);
}

.chat-error {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    padding: 0.5rem;
    margin-bottom: 0.5rem;
    background: #fef2f2;
    border: 1px solid #fca5a5;
    border-radius: 6px;
    color: #991b1b;
    font-size: 0.85rem;
}

.chat-input-wrapper {
    display: flex;
    gap: 0.25rem;
    align-items: flex-end;
    width: 100%;
}

.chat-text-input {
    flex: 1;
    min-width: 0;
    padding: 8px 12px;
    border: 1px solid var(--neutral-stroke-rest);
    border-radius: 4px;
    background: var(--neutral-layer-1);
    color: var(--neutral-foreground-rest);
    font-size: 0.9rem;
    font-family: inherit;
    outline: none;
    resize: vertical;
    min-height: 38px;
    max-height: 120px;
    line-height: 1.4;
    box-sizing: border-box;
}

.chat-text-input:focus {
    border-color: var(--accent-fill-rest);
    box-shadow: 0 0 0 1px var(--accent-fill-rest);
}

.chat-text-input:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Markdown rendered content */
.message-text.markdown-body p {
    margin: 0.25rem 0;
}

.message-text.markdown-body p:first-child {
    margin-top: 0;
}

.message-text.markdown-body p:last-child {
    margin-bottom: 0;
}

.message-text.markdown-body ul,
.message-text.markdown-body ol {
    margin: 0.25rem 0;
    padding-left: 1.5rem;
}

.message-text.markdown-body li {
    margin: 0.15rem 0;
}

.message-text.markdown-body h1,
.message-text.markdown-body h2,
.message-text.markdown-body h3,
.message-text.markdown-body h4 {
    margin: 0.5rem 0 0.25rem;
    line-height: 1.3;
}

.message-text.markdown-body h1 { font-size: 1.15rem; }
.message-text.markdown-body h2 { font-size: 1.05rem; }
.message-text.markdown-body h3 { font-size: 0.95rem; }
.message-text.markdown-body h4 { font-size: 0.9rem; }

.message-text.markdown-body code {
    background: rgba(0, 0, 0, 0.08);
    padding: 0.15rem 0.35rem;
    border-radius: 3px;
    font-size: 0.85em;
    font-family: "Cascadia Code", "Fira Code", Consolas, monospace;
}

.message-text.markdown-body pre {
    background: rgba(0, 0, 0, 0.06);
    border-radius: 6px;
    padding: 0.6rem 0.8rem;
    overflow-x: auto;
    margin: 0.4rem 0;
}

.message-text.markdown-body pre code {
    background: none;
    padding: 0;
    font-size: 0.82em;
}

.message-text.markdown-body table {
    border-collapse: collapse;
    width: 100%;
    margin: 0.4rem 0;
    font-size: 0.85em;
}

.message-text.markdown-body th,
.message-text.markdown-body td {
    border: 1px solid var(--neutral-stroke-rest);
    padding: 0.35rem 0.5rem;
    text-align: left;
}

.message-text.markdown-body th {
    background: rgba(0, 0, 0, 0.04);
    font-weight: 600;
}

.message-text.markdown-body blockquote {
    margin: 0.4rem 0;
    padding: 0.25rem 0.75rem;
    border-left: 3px solid var(--accent-fill-rest);
    color: var(--neutral-foreground-hint);
}

.message-text.markdown-body hr {
    border: none;
    border-top: 1px solid var(--neutral-stroke-rest);
    margin: 0.5rem 0;
}

.message-text.markdown-body strong {
    font-weight: 600;
}

/* Scrollbar styling */
.chat-messages::-webkit-scrollbar,
.assigned-releases-list::-webkit-scrollbar,
.available-releases-list::-webkit-scrollbar {
    width: 8px;
}

.chat-messages::-webkit-scrollbar-track,
.assigned-releases-list::-webkit-scrollbar-track,
.available-releases-list::-webkit-scrollbar-track {
    background: var(--neutral-layer-1);
}

.chat-messages::-webkit-scrollbar-thumb,
.assigned-releases-list::-webkit-scrollbar-thumb,
.available-releases-list::-webkit-scrollbar-thumb {
    background: var(--neutral-stroke-rest);
    border-radius: 4px;
}

.chat-messages::-webkit-scrollbar-thumb:hover,
.assigned-releases-list::-webkit-scrollbar-thumb:hover,
.available-releases-list::-webkit-scrollbar-thumb:hover {
    background: var(--neutral-stroke-hover);
}
