/* Message styles */
.message {
    display: flex;
    padding: 24px;
    margin-bottom: 16px;
    border-radius: 20px;
    position: relative;
    backdrop-filter: blur(10px);
    border: 1px solid var(--border-color);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.message.user {
    background: var(--user-message-bg);
    box-shadow: var(--shadow-soft);
}

.message.assistant {
    background: var(--assistant-message-bg);
    box-shadow: var(--shadow-soft);
}

.message:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-medium);
}

.message-avatar {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    margin-right: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 1.1rem;
    box-shadow: var(--shadow-soft);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.message-avatar.user {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-light) 100%);
    color: white;
}

.message-avatar.assistant {
    background: linear-gradient(135deg, var(--deep-navy) 0%, var(--primary-dark) 100%);
    color: white;
}

.message-content {
    flex: 1;
}

.message-sender {
    font-family: 'Outfit', sans-serif;
    font-weight: 600;
    margin-bottom: 8px;
    font-size: 1.0625rem;
    color: var(--primary-dark);
    letter-spacing: 0.01em;
}

.message-text {
    font-family: 'Outfit', sans-serif;
    font-size: 1.0625rem;
    line-height: 1.7;
    color: var(--text-primary);
    font-weight: 400;
    letter-spacing: 0.005em;
}

.message-text a {
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 500;
    transition: all 0.3s ease;
}

.message-text a:hover {
    color: var(--primary-dark);
    text-decoration: underline;
}

.message-text p {
    margin-bottom: 0.75em;
}

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

.message-text h1, 
.message-text h2, 
.message-text h3, 
.message-text h4, 
.message-text h5, 
.message-text h6 {
    font-family: 'Outfit', sans-serif;
    margin-top: 1em;
    margin-bottom: 0.5em;
    font-weight: 600;
    letter-spacing: 0.01em;
}

.message-text pre {
    background: linear-gradient(135deg, #F8FAFF 0%, #F0F2FF 100%);
    padding: 1.25em;
    border-radius: 12px;
    overflow-x: auto;
    margin-bottom: 1.25em;
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-soft);
    backdrop-filter: blur(10px);
}

.message-text code {
    background: linear-gradient(135deg, #F0F2FF 0%, #E6EDFF 100%);
    padding: 0.25em 0.5em;
    border-radius: 6px;
    font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, Courier, monospace;
    font-size: 0.9em;
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-soft);
}

.message-text pre code {
    padding: 0;
    background-color: transparent;
    display: block;
    line-height: 1.5;
}

.citation {
    color: var(--primary-color);
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.citation:hover {
    color: var(--primary-dark);
}

/* Message actions */
.message-actions {
    position: absolute;
    top: 10px;
    right: 10px;
    opacity: 1;
    transition: all 0.3s ease;
    display: flex;
    gap: 8px;
}

.message-action-btn {
    background: linear-gradient(135deg, #ffffff 0%, #f8faff 100%);
    border: 2px solid var(--border-color);
    color: var(--text-primary);
    cursor: pointer;
    padding: 8px 12px;
    border-radius: 12px;
    font-family: 'Outfit', sans-serif;
    font-size: 1rem;
    font-weight: 500;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: var(--shadow-soft);
    display: flex;
    align-items: center;
    gap: 6px;
    min-width: 44px;
    height: 44px;
    justify-content: center;
    letter-spacing: 0.005em;
}

.message-action-btn:hover {
    background: rgba(255, 255, 255, 0.9);
    color: var(--deep-navy);
    border-color: rgba(107, 126, 232, 0.3);
    transform: translateY(-1px);
    box-shadow: 0 12px 40px rgba(107, 126, 232, 0.15);
    backdrop-filter: blur(16px);
}

.message-action-btn:active {
    transform: translateY(0) scale(1);
}

.message-action-btn.text-primary {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-light) 100%);
    color: white;
    border-color: var(--primary-color);
    box-shadow: var(--shadow-medium);
}

.message-action-btn.text-primary:hover {
    background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary-color) 100%);
    transform: translateY(-2px) scale(1.05);
}

/* Enhanced feedback states */
.message-action-btn.feedback-positive {
    background: linear-gradient(135deg, #2D5A3D 0%, #4A7C59 100%);
    color: white;
    border-color: #2D5A3D;
    box-shadow: 0 4px 12px rgba(45, 90, 61, 0.3);
    position: relative;
}

.message-action-btn.feedback-positive:hover {
    background: linear-gradient(135deg, #1F3D2B 0%, #35543F 100%);
    transform: translateY(-2px) scale(1.05);
    box-shadow: 0 6px 16px rgba(45, 90, 61, 0.4);
}

.message-action-btn.feedback-positive::after {
    content: "✓";
    position: absolute;
    top: -4px;
    right: -4px;
    background: #2D5A3D;
    color: white;
    border-radius: 50%;
    width: 18px;
    height: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    font-weight: bold;
    box-shadow: 0 2px 6px rgba(45, 90, 61, 0.3);
}

.message-action-btn.feedback-negative {
    background: linear-gradient(135deg, #800040 0%, #99004D 100%);
    color: white;
    border-color: #800040;
    box-shadow: 0 4px 12px rgba(128, 0, 64, 0.3);
    position: relative;
}

.message-action-btn.feedback-negative:hover {
    background: linear-gradient(135deg, #660033 0%, #800040 100%);
    transform: translateY(-2px) scale(1.05);
    box-shadow: 0 6px 16px rgba(128, 0, 64, 0.4);
}

.message-action-btn.feedback-negative::after {
    content: "✓";
    position: absolute;
    top: -4px;
    right: -4px;
    background: #800040;
    color: white;
    border-radius: 50%;
    width: 18px;
    height: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    font-weight: bold;
    box-shadow: 0 2px 6px rgba(128, 0, 64, 0.3);
}

/* Dim the opposite button when feedback is given */
.message-actions.has-feedback .message-action-btn:not(.feedback-positive):not(.feedback-negative) {
    opacity: 0.4;
    transform: scale(0.95);
    transition: all 0.3s ease;
}

.btn-text {
    font-size: 0.9rem;
    font-weight: 600;
    white-space: nowrap;
}

/* Mobile responsive for feedback buttons */
@media (max-width: 768px) {
    .message-actions {
        position: relative;
        top: auto;
        right: auto;
        margin-top: 12px;
        justify-content: flex-end;
        opacity: 1;
    }
    
    .message-action-btn {
        min-width: 38px;
        height: 38px;
        padding: 6px 10px;
        font-size: 0.9rem;
    }
    
    .btn-text {
        display: none;
    }
}