/* Custom CSS for Claude Chat App - Dark Theme */

:root {
    --bs-dark-rgb: 33, 37, 41;
    --chat-sidebar-width: 280px;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

/* Sidebar styling */
.chat-sidebar {
    width: var(--chat-sidebar-width);
    height: 100vh;
    background-color: var(--bs-gray-900);
    border-right: 1px solid var(--bs-gray-700);
    overflow-y: auto;
}

.chat-main {
    margin-left: var(--chat-sidebar-width);
    height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Chat list items */
.chat-item-container {
    position: relative;
    border-bottom: 1px solid var(--bs-gray-700);
    display: flex;
    align-items: center;
}

.chat-item-container:hover .chat-item-edit-btn {
    opacity: 1;
}

.chat-item-container.active {
    background-color: var(--bs-primary);
}

.chat-item-container.active .chat-item-edit-btn {
    border-color: rgba(255, 255, 255, 0.3);
    color: white;
}

.chat-item {
    padding: 12px 16px;
    cursor: pointer;
    transition: background-color 0.2s;
    text-decoration: none;
    color: inherit;
    display: block;
    flex: 1;
}

.chat-item:hover {
    background-color: var(--bs-gray-800);
    color: inherit;
    text-decoration: none;
}

.chat-item-container.active .chat-item {
    color: white;
}

.chat-item-edit-btn {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    opacity: 0;
    transition: all 0.2s ease;
    z-index: 10;
    padding: 0.25rem;
    font-size: 0.75rem;
}

.chat-item-title {
    font-weight: 500;
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-item-meta {
    font-size: 0.875rem;
    color: var(--bs-gray-400);
}

/* Chat messages */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
}

.message {
    margin-bottom: 24px;
    max-width: 100%;
}

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

.message-assistant {
    text-align: left;
}

.message-content {
    display: inline-block;
    max-width: 80%;
    padding: 12px 16px;
    border-radius: 12px;
    word-wrap: break-word;
}

.message-user .message-content {
    background-color: var(--bs-primary);
    color: white;
    text-align: left;
}

.message-assistant .message-content {
    background-color: var(--bs-gray-800);
    color: var(--bs-gray-100);
    text-align: left;
}

.message-meta {
    font-size: 0.75rem;
    color: var(--bs-gray-500);
    margin-top: 4px;
}

/* Code blocks */
.message-content pre {
    background-color: var(--bs-gray-900);
    border: 1px solid var(--bs-gray-700);
    border-radius: 6px;
    padding: 12px;
    margin: 8px 0;
    overflow-x: auto;
    position: relative;
}

.message-content code {
    background-color: var(--bs-gray-800);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.875rem;
}

.message-content pre code {
    background: none;
    padding: 0;
}

/* Copy buttons */
.copy-btn {
    position: absolute;
    top: 8px;
    right: 8px;
    background: var(--bs-gray-700);
    border: none;
    color: var(--bs-gray-300);
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 0.75rem;
    cursor: pointer;
    opacity: 0.7;
    transition: opacity 0.2s;
}

.copy-btn:hover {
    opacity: 1;
    background: var(--bs-gray-600);
}

/* Chat input area */
.chat-input-area {
    border-top: 1px solid var(--bs-gray-700);
    padding: 20px;
    background-color: var(--bs-gray-900);
}

.chat-input {
    resize: none;
    min-height: 60px;
    max-height: 200px;
}

/* System prompt area */
.system-prompt-area {
    border-bottom: 1px solid var(--bs-gray-700);
    padding: 16px 20px;
    background-color: var(--bs-gray-900);
}

/* Responsive design */
@media (max-width: 768px) {
    .chat-sidebar {
        position: fixed;
        left: -100%;
        z-index: 1050;
        transition: left 0.3s;
    }

    .chat-sidebar.show {
        left: 0;
    }

    .chat-main {
        margin-left: 0;
    }

    .mobile-menu-btn {
        display: block !important;
    }
}

@media (min-width: 769px) {
    .mobile-menu-btn {
        display: none !important;
    }
}

/* Loading spinner */
.loading-spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid var(--bs-gray-600);
    border-radius: 50%;
    border-top-color: var(--bs-primary);
    animation: spin 1s ease-in-out infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Utility classes */
.text-truncate-2 {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.cursor-pointer {
    cursor: pointer;
}

/* Scrollbar styling for webkit browsers */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bs-gray-800);
}

::-webkit-scrollbar-thumb {
    background: var(--bs-gray-600);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--bs-gray-500);
}

/* Enhanced markdown formatting for Claude responses */
.code-block-container {
    position: relative;
    margin: 1rem 0;
}

.code-block-container .copy-btn {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    background: rgba(0, 0, 0, 0.7);
    border: 1px solid var(--bs-gray-600);
    z-index: 10;
}

.code-block-container pre {
    margin: 0;
    padding: 1rem 3rem 1rem 1rem; /* Extra right padding for copy button */
    background: var(--bs-gray-900);
    border: 1px solid var(--bs-gray-700);
    border-radius: 8px;
    overflow-x: auto;
}

.code-block-container code {
    background: transparent;
    padding: 0;
    color: var(--bs-light);
    font-size: 0.9rem;
    line-height: 1.5;
}

/* Markdown formatting improvements */
.message-text h1,
.message-text h2,
.message-text h3,
.message-text h4,
.message-text h5,
.message-text h6 {
    margin-top: 1.5rem;
    margin-bottom: 0.75rem;
    font-weight: 600;
    line-height: 1.25;
    color: var(--bs-light);
}

.message-text h1 { font-size: 1.5rem; border-bottom: 2px solid var(--bs-primary); padding-bottom: 0.5rem; }
.message-text h2 { font-size: 1.3rem; border-bottom: 1px solid var(--bs-gray-600); padding-bottom: 0.3rem; }
.message-text h3 { font-size: 1.1rem; color: var(--bs-info); }

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

.message-text li {
    margin-bottom: 0.25rem;
    line-height: 1.6;
}

.message-text blockquote {
    border-left: 4px solid var(--bs-primary);
    padding-left: 1rem;
    margin: 1rem 0;
    color: var(--bs-gray-300);
    font-style: italic;
    background: var(--bs-gray-800);
    padding: 0.75rem 1rem;
    border-radius: 0 6px 6px 0;
}

.message-text table {
    width: 100%;
    border-collapse: collapse;
    margin: 1rem 0;
    background: var(--bs-gray-800);
    border-radius: 6px;
    overflow: hidden;
}

.message-text th,
.message-text td {
    border: 1px solid var(--bs-gray-600);
    padding: 0.75rem;
    text-align: left;
}

.message-text th {
    background: var(--bs-gray-700);
    font-weight: 600;
    color: var(--bs-light);
}

.message-text code:not(pre code) {
    background: var(--bs-gray-800);
    color: var(--bs-warning);
    padding: 0.2rem 0.4rem;
    border-radius: 4px;
    font-size: 0.9em;
    border: 1px solid var(--bs-gray-700);
}

.message-text p {
    margin-bottom: 1rem;
    line-height: 1.6;
}

.message-text a {
    color: var(--bs-info);
    text-decoration: underline;
}

.message-text a:hover {
    color: var(--bs-primary);
}

/* Syntax highlighting improvements */
.hljs {
    background: var(--bs-gray-900) !important;
    color: var(--bs-light) !important;
}

/* Better spacing for nested elements */
.message-text > *:first-child {
    margin-top: 0;
}

.message-text > *:last-child {
    margin-bottom: 0;
}

/* Streaming and formatting indicators */
.message-text.streaming {
    position: relative;
    opacity: 0.8;
}

.message-text.streaming::after {
    content: "▊";
    animation: blink 1s infinite;
    color: var(--bs-primary);
    margin-left: 2px;
}

.formatting-indicator {
    margin-top: 0.5rem;
    padding: 0.25rem 0.5rem;
    background: rgba(var(--bs-primary-rgb), 0.1);
    border: 1px solid rgba(var(--bs-primary-rgb), 0.2);
    border-radius: 4px;
    display: inline-block;
}

.spinning {
    animation: spin 1s linear infinite;
}

@keyframes blink {
    0%, 50% { opacity: 1; }
    51%, 100% { opacity: 0; }
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* Chat title editing styles */
.chat-title-editable {
    cursor: pointer;
    transition: all 0.2s ease;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    border: 2px solid transparent;
}

.chat-title-editable:hover {
    background-color: var(--bs-gray-800);
    border-color: var(--bs-gray-600);
    color: var(--bs-info);
}

.chat-title-editing {
    background-color: var(--bs-gray-800);
    border-color: var(--bs-primary);
}

/* Input field when editing title */
.chat-title-input {
    background: var(--bs-gray-800) !important;
    border: 2px solid var(--bs-primary) !important;
    color: white !important;
    font-size: 1.25rem !important;
    font-weight: 500 !important;
    padding: 0.25rem 0.5rem !important;
    border-radius: 4px !important;
    width: 100% !important;
    min-width: 200px !important;
}

