/* ========================================
   ## CHAT CONTAINER
   ======================================== */
.chat-container {
    display: flex;
    flex-direction: column;
    height: 100%;
    max-width: 800px;
    margin: 0 auto;
    width: 100%;
}

/* ========================================
   ## MESSAGES AREA
   ======================================== */
.chats-bar {
    display: none;
    padding: 0.375rem 0.75rem;
    border-bottom: 1px solid hsl(var(--border));
    background: hsl(var(--background));
    flex-shrink: 0;
    overflow-x: auto;
    overflow-y: hidden;
}

.chats-bar.visible {
    display: block;
}

.chats-bar-list {
    display: flex;
    gap: 0.375rem;
    align-items: center;
    min-width: min-content;
}

.chats-bar-item {
    background: hsl(var(--card));
    border: 1px solid hsl(var(--border));
    border-radius: 0.375rem;
    padding: 0.3125rem 0.625rem;
    cursor: pointer;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    align-items: center;
    flex-shrink: 0;
    white-space: nowrap;
    font-size: 0.6875rem;
    color: hsl(var(--foreground));
    font-weight: 500;
    line-height: 1.2;
}

.chats-bar-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px hsl(var(--background) / 0.4);
    border-color: hsl(var(--primary) / 0.4);
}

.chats-bar-item.active {
    background: hsl(var(--primary) / 0.1);
    border-color: hsl(var(--primary));
    box-shadow: 0 2px 8px hsl(var(--primary) / 0.2);
    color: hsl(var(--primary));
}

.messages-area {
    flex: 1;
    overflow-y: auto;
    width: 100%;
    position: relative;
    outline: none;
    user-select: text;
    -webkit-user-select: text;
}

.messages-container {
    padding-left: 0.5rem;
    padding-right: 0.5rem;
    max-width: 42rem;
    margin-left: auto;
    margin-right: auto;
    margin-bottom: -1rem;
    padding-bottom: 2rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}


/* ========================================
   ## MESSAGE STYLES
   ======================================== */
.message-group {
    position: relative;
    animation: messageSlideIn 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes messageSlideIn {
    from {
        opacity: 0;
        transform: translateY(15px) scale(0.98);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.user-message-wrapper {
    pointer-events: auto;
    position: sticky;
    top: 0;
    z-index: 10;
    background: hsl(var(--background));
    padding-top: 0.5rem;
    padding-bottom: 0.5rem;
    margin-top: -0.5rem;
    margin-bottom: 0.5rem;
    box-shadow: 0 2px 8px hsl(var(--background) / 0.8);
}

.user-message-wrapper > div {
    margin-bottom: 1rem !important;
}

.user-bubble-container {
    display: flex;
    justify-content: flex-start;
    filter: drop-shadow(0 10px 20px hsl(var(--background)));
}

.user-bubble-container .space-y-2 {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    width: 100%;
}

.user-bubble {
    position: relative;
    background: linear-gradient(135deg, hsl(var(--primary) / 0.08) 0%, hsl(var(--primary) / 0.05) 100%);
    border: 1px solid hsl(var(--primary) / 0.15);
    color: hsl(var(--foreground));
    padding: 0.75rem 1rem;
    border-radius: 0.5rem;
    white-space: pre-wrap;
    font-size: 0.875rem;
    line-height: 1.5;
    word-wrap: break-word;
    text-align: left;
    width: 100%;
    overflow: hidden;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.user-bubble:hover {
    transform: translateX(2px);
    background: linear-gradient(135deg, hsl(var(--primary) / 0.12) 0%, hsl(var(--primary) / 0.08) 100%);
    border-color: hsl(var(--primary) / 0.25);
}

.user-bubble::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: linear-gradient(90deg, hsl(var(--primary) / 0.5) 0%, transparent 100%);
}

.assistant-message {
    width: 100%;
    margin-bottom: 1rem;
}

.assistant-message-inner {
    display: flex;
    flex-direction: column;
    gap: 0.375rem;
}

.assistant-content {
    color: hsl(var(--foreground));
    padding-left: 0.5rem;
    padding-right: 0.5rem;
}

/* Message Actions */
.message-actions {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.5rem;
    padding-left: 0.5rem;
    opacity: 0;
    transition: opacity 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.message-group:hover .message-actions {
    opacity: 1;
}

.msg-action-btn {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.25rem 0.5rem;
    background: transparent;
    border: 1px solid hsl(var(--border));
    border-radius: 0.375rem;
    color: hsl(var(--muted-foreground));
    font-size: 0.75rem;
    cursor: pointer;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.msg-action-btn:hover {
    background: hsl(var(--muted) / 0.5);
    color: hsl(var(--foreground));
    border-color: hsl(var(--border));
    transform: translateY(-1px);
    box-shadow: 0 2px 8px hsl(var(--background) / 0.3);
}

.msg-action-btn.liked {
    color: hsl(var(--primary));
    border-color: hsl(var(--primary) / 0.5);
}

.msg-action-btn.liked svg {
    fill: currentColor;
}

/* Share Menu */
.share-menu-wrapper {
    position: relative;
}

.share-menu {
    position: absolute;
    bottom: 100%;
    left: 0;
    margin-bottom: 0.5rem;
    background: hsl(var(--card));
    border: 1px solid hsl(var(--border));
    border-radius: 0.5rem;
    box-shadow: 0 8px 24px hsl(var(--background) / 0.6);
    min-width: 200px;
    opacity: 0;
    visibility: hidden;
    transform: translateY(10px);
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 1000;
    overflow: hidden;
}

.prompt-card .share-menu-wrapper {
    position: relative;
}

.prompt-expanded-actions .share-menu-wrapper {
    position: relative;
}

.share-menu.active {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.share-menu-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    width: 100%;
    padding: 0.625rem 0.75rem;
    background: transparent;
    border: none;
    color: hsl(var(--foreground));
    font-size: 0.8125rem;
    text-align: left;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.share-menu-item:first-child {
    border-radius: 0.5rem 0.5rem 0 0;
}

.share-menu-item:last-child {
    border-radius: 0 0 0.5rem 0.5rem;
}

.share-menu-item:hover {
    background: hsl(var(--muted) / 0.5);
    color: hsl(var(--primary));
    transform: translateX(3px);
}

.share-menu-item svg {
    flex-shrink: 0;
    opacity: 0.7;
}

.share-menu-item:hover svg {
    opacity: 1;
}

.share-menu-item span {
    flex: 1;
}

/* ========================================
   ## MARKDOWN STYLES
   ======================================== */
.markdown-content {
    max-width: none;
    overflow: hidden;
    word-break: break-word;
    overflow-wrap: break-word;
}

.markdown-content h1,
.markdown-content h2 {
    font-size: 0.9375rem;
    font-weight: 600;
    color: hsl(var(--primary));
    margin-top: 1.4em;
    margin-bottom: 1px;
    line-height: 1.3;
}

.markdown-content h1:first-child,
.markdown-content h2:first-child {
    margin-top: 0;
}
.markdown-content h3 {
    font-size: 0.8125rem;
    font-weight: 600;
    color: hsl(var(--primary));
    margin-top: 1em;
    margin-bottom: 1px;
    line-height: 1.3;
}

.markdown-content h3:first-child {
    margin-top: 0;
}

.markdown-content h4,
.markdown-content h5,
.markdown-content h6 {
    font-size: 0.875rem;
    font-weight: 500;
    color: hsl(var(--primary));
    margin-top: 1em;
    margin-bottom: 1px;
    line-height: 1.3;
}

.markdown-content h4:first-child,
.markdown-content h5:first-child,
.markdown-content h6:first-child {
    margin-top: 0;
}

.markdown-content p {
    font-size: 0.8125rem;
    color: hsl(var(--foreground) / 0.9);
    margin: 1px 0;
    line-height: 1.5;
    padding: 3px 0;
}

.markdown-content ul,
.markdown-content ol {
    list-style-position: inside;
    font-size: 0.875rem;
    color: hsl(var(--foreground) / 0.8);
    margin-bottom: 1px;
}

.markdown-content ul {
    list-style-type: disc;
}

.markdown-content ol {
    list-style-type: decimal;
}

.markdown-content li {
    font-size: 0.875rem;
    color: hsl(var(--foreground) / 0.8);
    padding: 3px 0;
}

.markdown-content li > p {
    display: inline;
    margin: 0;
    padding: 0;
}

.markdown-content code {
    background: hsl(var(--foreground) / 0.06);
    font-family: 'SFMono-Regular', 'Menlo', 'Consolas', 'PT Mono', 'Liberation Mono', 'Courier', monospace;
    font-size: 85%;
    border-radius: 0.25rem;
    padding: 0.2em 0.4em;
    word-break: break-all;
}

.markdown-content pre {
    margin: 0.5rem 0 1rem;
    border-radius: 0.625rem;
    background: hsl(var(--muted) / 0.5);
    overflow: hidden;
    position: relative;
}

.markdown-content pre code {
    display: block;
    background: transparent;
    padding: 0.75rem 1rem;
    margin: 0;
    overflow-x: auto;
    white-space: pre;
    font-size: 0.875rem;
    line-height: 1.5;
    color: hsl(var(--foreground));
    word-break: normal;
    font-family: 'SFMono-Regular', 'Menlo', 'Consolas', 'PT Mono', 'Liberation Mono', 'Courier', monospace;
    tab-size: 2;
}

.markdown-content blockquote {
    border-left: 2px solid hsl(var(--primary) / 0.5);
    padding-left: 0.75rem;
    color: hsl(var(--foreground) / 0.7);
    margin: 0.5rem 0;
    font-size: 0.875rem;
    background: hsl(var(--muted) / 0.3);
    padding: 0.5rem 0.75rem;
    border-radius: 0 0.5rem 0.5rem 0;
}

.markdown-content hr {
    margin: 2rem 0 1rem;
    border-top: 1px solid hsl(var(--border));
    border-bottom: none;
    border-left: none;
    border-right: none;
}

.markdown-content a {
    text-decoration: none;
    color: hsl(var(--primary));
    font-weight: 500;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.markdown-content a:hover {
    text-decoration: underline;
    text-decoration-thickness: 1px;
    text-underline-offset: 2px;
    color: hsl(var(--primary) / 0.8);
}

.markdown-content strong {
    font-weight: 600;
    color: hsl(var(--primary));
}

.markdown-content em {
    font-style: italic;
}

.markdown-content table {
    width: 100%;
    font-size: 0.875rem;
    margin: 0.75rem 0;
    border-collapse: collapse;
    overflow-x: auto;
    display: block;
    border-radius: 0.5rem;
    border: 1px solid hsl(var(--border));
}

.markdown-content table thead {
    border-bottom: 1px solid hsl(var(--border));
}

.markdown-content table tbody tr:not(:last-child) {
    border-bottom: 1px solid hsl(var(--border));
}

.markdown-content table th {
    text-align: left;
    font-size: 0.875rem;
    font-weight: 600;
    color: hsl(var(--primary));
    padding: 0.5rem 0.75rem;
    background: hsl(var(--muted) / 0.5);
    border-right: 1px solid hsl(var(--border));
}

.markdown-content table th:last-child {
    border-right: none;
}

.markdown-content table td {
    font-size: 0.875rem;
    color: hsl(var(--foreground) / 0.8);
    padding: 0.5rem 0.75rem;
    border-right: 1px solid hsl(var(--border));
}

.markdown-content table td:last-child {
    border-right: none;
}

.markdown-content table thead,
.markdown-content table tbody {
    display: table;
    width: 100%;
}
