/* Chat styles - Messages and markdown */

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    min-height: 0;
}

.message {
    margin-bottom: 20px;
    display: flex;
    flex-direction: column;
}

.message-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}

.message-role {
    font-weight: 600;
    font-size: 14px;
}

.message-role.user {
    color: #007bff;
}

.message-role.assistant {
    color: #28a745;
}

.message-timestamp {
    font-size: 12px;
    color: #999;
}

.message-content {
    background: #f8f9fa;
    padding: 15px;
    border-radius: 8px;
    border-left: 3px solid #007bff;
    white-space: pre-wrap;
    line-height: 1.5;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.message.assistant .message-content {
    border-left-color: #28a745;
}

/* Markdown rendering styles */
.message-content.markdown {
    white-space: normal;
}

.message-content.markdown h1,
.message-content.markdown h2,
.message-content.markdown h3,
.message-content.markdown h4,
.message-content.markdown h5,
.message-content.markdown h6 {
    margin-top: 16px;
    margin-bottom: 8px;
    font-weight: 600;
    line-height: 1.25;
}

.message-content.markdown h1 { font-size: 1.8em; border-bottom: 1px solid #ddd; padding-bottom: 8px; }
.message-content.markdown h2 { font-size: 1.5em; border-bottom: 1px solid #ddd; padding-bottom: 6px; }
.message-content.markdown h3 { font-size: 1.25em; }
.message-content.markdown h4 { font-size: 1.1em; }
.message-content.markdown h5 { font-size: 1em; }
.message-content.markdown h6 { font-size: 0.9em; color: #666; }

.message-content.markdown p {
    margin-bottom: 12px;
}

.message-content.markdown ul,
.message-content.markdown ol {
    margin-bottom: 12px;
    padding-left: 24px;
}

.message-content.markdown li {
    margin-bottom: 4px;
}

.message-content.markdown code {
    background: #2d2d2d;
    color: #f8f8f2;
    padding: 2px 6px;
    border-radius: 3px;
    font-family: 'Courier New', Courier, monospace;
    font-size: 0.9em;
}

.message-content.markdown pre {
    background: #2d2d2d;
    color: #f8f8f2;
    padding: 12px;
    border-radius: 6px;
    overflow-x: auto;
    margin-bottom: 12px;
}

.message-content.markdown pre code {
    background: transparent;
    padding: 0;
    font-size: 0.9em;
    line-height: 1.5;
}

.message-content.markdown blockquote {
    border-left: 4px solid #ddd;
    padding-left: 16px;
    margin: 12px 0;
    color: #666;
    font-style: italic;
}

.message-content.markdown table {
    border-collapse: collapse;
    width: 100%;
    margin-bottom: 12px;
}

.message-content.markdown table th,
.message-content.markdown table td {
    border: 1px solid #ddd;
    padding: 8px 12px;
    text-align: left;
}

.message-content.markdown table th {
    background: #f0f0f0;
    font-weight: 600;
}

.message-content.markdown table tr:nth-child(even) {
    background: #fafafa;
}

.message-content.markdown a {
    color: #007bff;
    text-decoration: none;
}

.message-content.markdown a:hover {
    text-decoration: underline;
}

.message-content.markdown hr {
    border: none;
    border-top: 2px solid #ddd;
    margin: 16px 0;
}

.message-content.markdown img {
    max-width: 100%;
    height: auto;
    border-radius: 4px;
    margin: 8px 0;
}

/* Image display in messages */
.message-image {
    max-width: 400px;
    max-height: 400px;
    width: auto;
    height: auto;
    object-fit: contain;
    border-radius: 8px;
    margin: 8px 0;
    cursor: pointer;
    transition: opacity 0.2s, transform 0.2s;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.message-image:hover {
    opacity: 0.95;
    transform: scale(1.02);
}

.message-image:active {
    transform: scale(0.98);
}

/* Mobile responsive images */
@media (max-width: 768px) {
    .message-image {
        max-width: 100%;
        max-height: 300px;
    }
}

/* Image modal for full-size viewing */
.image-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.image-modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.9);
    cursor: pointer;
}

.image-modal-content {
    position: relative;
    z-index: 10001;
    max-width: 95vw;
    max-height: 95vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

.image-modal-content img {
    max-width: 100%;
    max-height: 95vh;
    object-fit: contain;
    border-radius: 4px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
}

.image-modal-close {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.9);
    color: #333;
    border: none;
    font-size: 28px;
    line-height: 1;
    cursor: pointer;
    transition: background 0.2s;
    z-index: 10002;
}

.image-modal-close:hover {
    background: white;
}
