/* Message styles */
.message {
    display: flex;
    align-items: flex-start;
    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);
}

@media (max-width: 480px) {
    .message {
        padding: 14px 12px;
        border-radius: 14px;
        margin-bottom: 12px;
    }
}

.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-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.message-sender {
    font-family: 'Outfit', sans-serif;
    font-weight: 600;
    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 footer: timestamp left, feedback buttons right */
.message-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
}

.message-timestamp {
    font-size: 0.85rem;
}

/* Message actions */
.message-actions {
    position: static;
    display: flex;
    gap: 8px;
    justify-content: flex-end;
    flex-wrap: wrap;
}

.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);
}

/* Common ::after styles for all feedback states */
.message-action-btn.feedback-positive::after,
.message-action-btn.feedback-negative::after {
    content: "✓";
    position: absolute;
    top: -4px;
    right: -4px;
    color: white;
    border-radius: 50%;
    width: 18px;
    height: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    font-weight: bold;
}

.message-action-btn.feedback-positive::after {
    background: #2D5A3D;
    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 {
    background: #800040;
    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;
}

/* Inline feedback status */
.feedback-status {
    margin-top: 12px;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    border-radius: 12px;
    font-size: 0.9rem;
    font-weight: 600;
    box-shadow: var(--shadow-soft);
    opacity: 0;
    transform: translateY(4px);
    transition: opacity 0.25s ease, transform 0.25s ease;
}

.feedback-status.show {
    opacity: 1;
    transform: translateY(0);
}

.feedback-status.fade-out {
    opacity: 0;
    transform: translateY(4px);
}

.feedback-status i {
    font-size: 1rem;
}

.feedback-status-success {
    background: linear-gradient(135deg, #2D5A3D 0%, #4A7C59 100%);
    color: #ffffff;
}

.feedback-status-neutral {
    background: linear-gradient(135deg, rgba(107, 126, 232, 0.12) 0%, rgba(107, 126, 232, 0.2) 100%);
    color: var(--text-primary);
}

.feedback-status-error {
    background: linear-gradient(135deg, #800040 0%, #99004D 100%);
    color: #ffffff;
}

.conversation-feedback-area .feedback-status {
    justify-content: center;
    width: 100%;
}

/* Mobile responsive for feedback buttons */
@media (max-width: 768px) {
    .message-action-btn {
        min-width: 38px;
        height: 38px;
        padding: 6px 10px;
        font-size: 0.9rem;
    }

    .btn-text {
        display: none;
    }
}

/* Conversation feedback buttons - base styles */
.conversation-feedback-btn {
    min-width: 160px;
}

/* Always show button text for conversation feedback */
.conversation-feedback-btn .btn-text {
    display: inline !important;
}

/* Stack conversation feedback buttons on small mobile */
@media (max-width: 576px) {
    .conversation-feedback-area > .d-flex {
        flex-direction: column !important;
        align-items: stretch !important;
        gap: 16px !important;
    }

    .conversation-feedback-btn {
        width: 100%;
        min-width: unset;
        flex-shrink: 0;
    }
}

/* ===========================================
   Message Layout: Indent style
   - No avatars
   - User messages: 90% width, right-aligned
   - Rasto messages: full width
   =========================================== */

/* User messages: narrower, right-aligned */
.message.user {
    width: 90%;
    margin-left: auto;
    margin-right: 0;
}

/* Rasto messages: full width */
.message.assistant {
    width: 100%;
}
