/* Chat Page Styles */

/* Sidebar Layout */
.chat-sidebar {
    width: 280px;
    flex-shrink: 0;
}

/* Mobile sidebar behavior */
@media (max-width: 640px) {
    .chat-sidebar {
        position: fixed;
        left: 0;
        top: 0;
        bottom: 0;
        width: 280px;
        z-index: 40;
        transform: translateX(-100%);
        transition: transform 0.3s ease;
    }

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

    .sidebar-overlay {
        position: fixed;
        inset: 0;
        background-color: rgba(0, 0, 0, 0.5);
        z-index: 30;
    }

    .sidebar-overlay.hidden {
        display: none;
    }

    /* Safe area padding for input on mobile */
    #chatForm {
        padding-bottom: env(safe-area-inset-bottom);
    }

    /* Prevent zoom on input focus on iOS */
    #messageInput {
        font-size: 16px;
    }
}

/* Messages area scrollbar */
#messagesArea::-webkit-scrollbar {
    width: 6px;
}
#messagesArea::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 3px;
}
#messagesArea::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

/* Conversation list scrollbar */
.chat-sidebar .overflow-y-auto::-webkit-scrollbar {
    width: 4px;
}
.chat-sidebar .overflow-y-auto::-webkit-scrollbar-thumb {
    background: #e2e8f0;
    border-radius: 2px;
}

/* Conversation item styling */
.conversation-item {
    padding: 0.625rem 0.75rem;
    border-radius: 0.5rem;
    cursor: pointer;
    transition: background-color 0.15s ease;
}
.conversation-item:hover {
    background-color: #f3f4f6;
}
.conversation-item.active {
    background-color: #eff6ff;
    border-left: 3px solid #2563eb;
    padding-left: calc(0.75rem - 3px);
}
.conversation-item .title {
    font-size: 0.875rem;
    font-weight: 500;
    color: #1f2937;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.conversation-item .meta {
    font-size: 0.75rem;
    color: #6b7280;
    margin-top: 0.125rem;
}
.conversation-item .delete-btn {
    opacity: 0;
    transition: opacity 0.15s ease;
}
.conversation-item:hover .delete-btn {
    opacity: 1;
}

/* Message bubbles */
.message {
    max-width: 85%;
    padding: 0.875rem 1rem;
    border-radius: 1rem;
    line-height: 1.5;
}
.message.user {
    background-color: #2563eb;
    color: white;
    margin-left: auto;
    border-bottom-right-radius: 0.25rem;
}
.message.assistant {
    background-color: #f3f4f6;
    color: #1f2937;
    border-bottom-left-radius: 0.25rem;
}

/* Markdown in chat messages */
.chat-markdown p {
    margin-bottom: 0.5em;
}
.chat-markdown p:last-child {
    margin-bottom: 0;
}
.chat-markdown ul,
.chat-markdown ol {
    margin-left: 1.5em;
    margin-bottom: 0.5em;
}
.chat-markdown ul {
    list-style-type: disc;
}
.chat-markdown ol {
    list-style-type: decimal;
}
.chat-markdown li {
    margin-bottom: 0.25em;
}
.chat-markdown code {
    background: rgba(0, 0, 0, 0.1);
    padding: 0.125rem 0.375rem;
    border-radius: 0.25rem;
    font-size: 0.9em;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}
.chat-markdown pre {
    background: rgba(0, 0, 0, 0.05);
    padding: 0.75rem;
    border-radius: 0.5rem;
    overflow-x: auto;
    margin-bottom: 0.5em;
}
.chat-markdown pre code {
    background: none;
    padding: 0;
}
.chat-markdown a {
    color: #2563eb;
    text-decoration: underline;
}
.message.user .chat-markdown a {
    color: #bfdbfe;
}
.chat-markdown blockquote {
    border-left: 3px solid #d1d5db;
    padding-left: 1rem;
    margin-left: 0;
    margin-bottom: 0.5em;
    color: #6b7280;
}

/* Citations */
.citations {
    margin-top: 0.75rem;
    padding-top: 0.75rem;
    border-top: 1px solid #e5e7eb;
}
.citation {
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
    font-size: 0.75rem;
    color: #6b7280;
    margin-bottom: 0.375rem;
}
.citation-number {
    background-color: #e5e7eb;
    color: #374151;
    font-weight: 600;
    width: 1.25rem;
    height: 1.25rem;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 0.625rem;
}
.citation-text {
    flex: 1;
}
.citation-link {
    flex: 1;
    color: #2563eb;
    text-decoration: none;
    transition: color 0.15s ease;
}
.citation-link:hover {
    color: #1d4ed8;
    text-decoration: underline;
}

/* Tool activity indicator */
.tool-activity {
    margin-bottom: 0.5rem;
    padding: 0.75rem;
    background-color: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 0.5rem;
    font-size: 0.875rem;
}
.tool-activity.complete {
    margin-bottom: 0.75rem;
    padding: 0.5rem 0.75rem;
    background-color: #f1f5f9;
    border: 1px solid #e2e8f0;
    border-radius: 0.375rem;
    font-size: 0.75rem;
    opacity: 0.8;
}
.tool-activity-header {
    font-weight: 600;
    color: #475569;
    margin-bottom: 0.25rem;
}
.tool-activity.complete .tool-activity-header {
    display: none;
}
.tool-step {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.25rem 0;
    color: #64748b;
}
.tool-step.running {
    color: #3b82f6;
}
.tool-step.complete {
    color: #22c55e;
}
.tool-step.complete:not([data-success="true"]) {
    color: #ef4444;
}
.tool-icon {
    font-size: 0.75rem;
    width: 1rem;
    text-align: center;
}
.tool-text {
    flex: 1;
}

/* Typing indicator */
.typing-indicator {
    display: flex;
    gap: 0.25rem;
    padding: 1rem;
    background-color: #f3f4f6;
    border-radius: 1rem;
    border-bottom-left-radius: 0.25rem;
    width: fit-content;
}
.typing-dot {
    width: 0.5rem;
    height: 0.5rem;
    background-color: #9ca3af;
    border-radius: 50%;
    animation: pulse 1.4s ease-in-out infinite;
}
.typing-dot:nth-child(2) {
    animation-delay: 0.2s;
}
.typing-dot:nth-child(3) {
    animation-delay: 0.4s;
}

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

/* Scope badge */
.scope-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.125rem 0.5rem;
    background-color: #f3f4f6;
    border-radius: 9999px;
    font-size: 0.625rem;
    color: #6b7280;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* Empty state */
.empty-conversations {
    text-align: center;
    padding: 2rem 1rem;
    color: #9ca3af;
}
.empty-conversations svg {
    width: 3rem;
    height: 3rem;
    margin: 0 auto 0.75rem;
    opacity: 0.5;
}

/* Loading skeleton */
@keyframes shimmer {
    0% {
        background-position: -200% 0;
    }
    100% {
        background-position: 200% 0;
    }
}
.skeleton {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: 0.25rem;
}
