/* New search button enhancements */
.btn-primary {
    transition: all 0.2s ease;
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 0.25rem 0.75rem rgba(var(--bs-primary-rgb), 0.3);
}


/* Bottom search section styling */
.border-top {
    border-color: rgba(var(--bs-primary-rgb), 0.1) !important;
}

.btn-lg {
    padding: 0.75rem 2rem;
    font-size: 1.1rem;
}

/* Query message styles */
.query-message {
    display: flex;
    align-items: flex-start;
    margin-bottom: 1.5rem;
    max-width: 90%;
}

.user-avatar {
    width: 36px;
    height: 36px;
    min-width: 36px;
    border-radius: 50%;
    margin-right: 0.75rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.query-text {
    position: relative;
    border-top-left-radius: 4px;
    border-radius: var(--tri-radius-md);
    white-space: pre-wrap;
    word-wrap: break-word;
}

.query-text::before {
    content: '';
    position: absolute;
    left: -8px;
    top: 15px;
    width: 0;
    height: 0;
    border-top: 8px solid transparent;
    border-bottom: 8px solid transparent;
    border-right: 8px solid var(--bs-gray-200);
}

/* Badge styles */
.trifolia-badge-wrapper {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}

.section-badge {
    display: inline-flex;
    align-items: center;
    padding: 0.5rem 0.75rem;
    border-radius: 50px;
    font-weight: 500;
    font-size: 0.9rem;
}

.jurisprudence-badge {
    background-color: rgba(var(--bs-primary-rgb), 0.1);
    color: var(--petal-accent);
}

.legislation-badge {
    background-color: rgba(91, 125, 82, 0.1);
    color: var(--leaf-green);
}

.doctrine-badge {
    background-color: rgba(26, 35, 50, 0.1);
    color: var(--law-navy);
}

/* Source styles */
.source-title {
    font-family: var(--bs-font-monospace);
    color: var(--clover-purple);
}

.source-type-tag {
    font-size: 0.75rem;
}

.source-relevance, .keyword-matches {
    font-size: 0.8rem;
}

/* Tab specific content styling */
#jurisprudence-tab .card-header {
    border-left: 4px solid var(--petal-accent);
}

#legislation-tab .card-header {
    border-left: 4px solid var(--leaf-green);
}

#doctrine-tab .card-header {
    border-left: 4px solid var(--law-navy);
}

#integral-tab .card-header {
    border-left: 4px solid var(--clover-purple);
}

/* Tab content styles for proper markdown rendering */
.tab-content .card-body h1 {
    font-size: 1.8rem;
    margin-top: 1.5rem;
    margin-bottom: 0.75rem;
}

.tab-content .card-body h2 {
    font-size: 1.5rem;
    margin-top: 1.25rem;
    margin-bottom: 0.75rem;
}

.tab-content .card-body h3 {
    font-size: 1.3rem;
    margin-top: 1rem;
    margin-bottom: 0.5rem;
}

.tab-content .card-body blockquote {
    border-left: 4px solid var(--tri-border);
    padding-left: 1rem;
    margin: 1rem 0;
    color: var(--tri-fg-2);
    font-style: italic;
}

.tab-content .card-body pre {
    background-color: var(--tri-bg-subtle);
    padding: 1rem;
    border-radius: var(--tri-radius-sm);
    margin: 1rem 0;
    overflow-x: auto;
}

.tab-content .card-body code {
    padding: 0.2rem 0.4rem;
    border-radius: var(--tri-radius-xs);
    font-size: 0.875em;
}

/* Chat-like interface styles */
.chat-container {
    /* Reading measure: full-width bot answers at 1200px ran ~140 characters
       per line; ~900px keeps long legal answers inside a comfortable measure
       on wide screens (mobile is unaffected — this is a max). */
    max-width: 900px;
    margin: 0 auto;
    padding: 1rem;
}

.chat-message {
    display: flex;
    margin-bottom: 1.5rem;
    align-items: flex-start;
}

.chat-message.user {
    justify-content: flex-end;
}

.chat-message.bot {
    justify-content: flex-start;
}

/* Full-width bot messages (like Claude/ChatGPT) */
.chat-message.bot-full-width {
    display: block;
    margin-bottom: 2rem;
}

/* Removed absolute positioning that was causing avatar to appear in top-left corner */
/* .chat-message.bot-full-width .message-avatar {
    position: absolute;
    left: 0;
    top: 0;
} */

.chat-message.bot-full-width .message-content {
    max-width: 100%;
    background: transparent;
    border: none;
    border-radius: 0;
    padding: 0;
    margin-left: 0; /* Avatar removed - no margin needed */
    color: var(--tri-fg-1);
    line-height: 1.7;
    position: relative;
}

.message-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.9rem;
    flex-shrink: 0;
}

.user .message-avatar {
    background: var(--clover-purple);
    color: white;
    margin-left: 0.75rem;
    order: 2;
}

/* Bot avatar styling removed - no longer needed since avatars are removed from bot messages */
/* .bot .message-avatar {
    background: var(--tri-bg-subtle);
    color: var(--tri-fg-1);
    border: 2px solid var(--tri-border);
    margin-right: 0.75rem;
} */

.message-content {
    max-width: 85%;
    padding: 1rem 1.25rem;
    border-radius: var(--tri-radius-xl);
    position: relative;
    word-wrap: break-word;
}

.user .message-content {
    background: var(--clover-purple);
    color: white;
    border-bottom-right-radius: var(--tri-radius-sm);
}

/* File attachment styles */
.message-attachments {
    background: rgba(0, 0, 0, 0.2);
    border-radius: var(--tri-radius-md);
    padding: 0.75rem;
}

.user .message-attachments {
    background: rgba(255, 255, 255, 0.1);
}

.attachment-card {
    background-color: rgba(255, 255, 255, 0.98) !important;
    border: 1px solid rgba(255, 255, 255, 0.5) !important;
    transition: all 0.2s ease;
}

.attachment-card:hover {
    background-color: white !important;
    transform: translateY(-1px);
    box-shadow: var(--tri-shadow-sm);
}

.attachment-card:last-child {
    margin-bottom: 0 !important;
}

.attachment-details {
    min-width: 0; /* Enable text truncation */
}

.attachment-name {
    color: var(--tri-fg-1) !important;
    font-weight: 500 !important;
    max-width: 200px;
}

.attachment-size {
    color: var(--tri-fg-2) !important;
    font-weight: 400;
}

.bot .message-content {
    background: var(--parchment);
    color: var(--tri-fg-1);
    border: 1px solid var(--tri-border-strong);
    border-bottom-left-radius: var(--tri-radius-sm);
}

.progress-item {
    display: flex;
    align-items: center;
    padding: 0.75rem 0;
    border-bottom: 1px solid var(--tri-border);
    animation: slideIn 0.3s ease-out;
}

.progress-item:last-child {
    border-bottom: none;
}

.progress-item .icon {
    width: 24px;
    height: 24px;
    margin-right: 0.75rem;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
}

/* Function buttons within bot messages */
.adk-function-button {
    background-color: transparent;
    border: none;
    border-radius: var(--tri-radius-sm);
    padding: 0.5rem 0;
    margin: 0.25rem 0;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: default;
    font-size: 0.875rem;
    color: var(--tri-fg-1);
    width: 100%;
    text-align: left;
}

.adk-function-button.completed {
    color: var(--tri-success-800);
}

.adk-function-button.completed i {
    color: var(--tri-success-600);
}

.adk-function-button i {
    font-size: 1rem;
    flex-shrink: 0;
}

/* Bot thought messages */
.bot-thought {
    background-color: transparent;
    border: 1px solid var(--tri-border-strong);
    border-radius: 1rem;
    padding: 0.75rem 1rem;
    font-size: 0.875rem;
    line-height: 1.4;
    font-style: italic;
    color: var(--tri-fg-2);
}

.bot-thought .thought-label {
    background-color: var(--clover-purple);
    color: white;
    padding: 0.2rem 0.4rem;
    border-radius: var(--tri-radius-xs);
    font-size: 0.75rem;
    display: inline-block;
    margin-bottom: 0.5rem;
    font-style: normal;
}

/* Bot final response */
.bot-response {
    background-color: transparent;
    color: var(--tri-fg-1);
    font-size: 0.875rem;
    line-height: 1.6;
}

/* Bot responses in full-width messages */
.bot-full-width .bot-response {
    background-color: transparent;
    color: var(--tri-fg-1);
    font-size: 0.95rem;
    line-height: 1.7;
    padding: 0;
    margin: 0;
}

/* Wider bot messages for final responses */
.bot .message-content.wide {
    max-width: 95%;
}

/* Full-width final responses */
.bot-full-width .final-response {
    border-top: none;
    padding-top: 0;
    margin-top: 0;
}

/* Message actions (copy/thumbs): quiet ghost buttons bottom-left, directly
   under where reading ends. Quietness comes from color, not opacity, so the
   labels keep readable contrast. */
.message-copy-container {
    display: flex;
    justify-content: flex-start;
    gap: 0.25rem;
    margin-top: 0.5rem;
}

.copy-button {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.375rem 0.75rem;
    background: transparent;
    border: 1px solid transparent;
    border-radius: var(--tri-radius-sm);
    color: var(--tri-fg-2);
    font-size: 0.875rem;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
}

.copy-button:hover {
    background: var(--tri-bg-hover);
    color: var(--tri-fg-1);
    text-decoration: none;
}

.copy-button:active {
    transform: scale(0.95);
}

.copy-button.copied {
    color: var(--tri-success-600);
    border-color: var(--tri-success-600);
    background: rgba(var(--tri-success-rgb), 0.05);
}

.copy-button.copied:hover {
    background: rgba(var(--tri-success-rgb), 0.1);
}

/* Message feedback buttons (thumbs up/down) */
.message-feedback-btn {
    min-width: 2rem;
    justify-content: center;
    transition: all 0.2s ease-in-out;
}

.message-feedback-btn:hover {
    transform: scale(1.05);
}

.message-feedback-btn.active {
    background: var(--tri-info-100);
    border-color: var(--tri-info-600);
    color: var(--tri-info-600);
}

.message-feedback-btn.active:hover {
    background: var(--tri-info-200);
    border-color: var(--tri-info-700);
    color: var(--tri-info-700);
}

/* Error-report box opened by a thumbs down ("¿qué estuvo mal?") */
.feedback-comment-box {
    margin-top: 0.5rem;
    padding: 0.75rem;
    max-width: 480px;
    background: var(--parchment);
    border: 1px solid rgba(0, 0, 0, 0.08);
    border-radius: var(--tri-radius-md);
}

.feedback-comment-label {
    display: block;
    margin-bottom: 0.35rem;
    font-size: 0.85rem;
    color: var(--neutral-gray);
}

.feedback-comment-thanks {
    font-size: 0.9rem;
    color: var(--leaf-green);
}

/* Continue button used state */
.continue-response-btn-used {
    color: var(--tri-fg-2) !important;
    border-color: var(--tri-border-strong) !important;
    background: var(--tri-bg-subtle) !important;
    cursor: not-allowed !important;
}

.continue-response-btn-used:hover {
    color: var(--tri-fg-2) !important;
    border-color: var(--tri-border-strong) !important;
    background: var(--tri-bg-subtle) !important;
    transform: none !important;
}

/* Mobile responsiveness */
@media (max-width: 576px) {
    .chat-message {
        margin-bottom: 1rem;
    }

    .message-content {
        max-width: 90%;
        padding: 0.75rem 1rem;
        font-size: 0.875rem;
    }

    .bot .message-content.wide {
        max-width: 95%;
    }

    /* Full-width bot messages on mobile */
    .chat-message.bot-full-width .message-content {
        margin-left: 0; /* Avatar removed - no margin needed */
        font-size: 0.875rem;
    }

    .message-avatar {
        width: 32px;
        height: 32px;
        font-size: 0.8rem;
    }

    .adk-function-button {
        font-size: 0.8rem;
        padding: 0.4rem 0;
    }

    /* Copy button mobile adjustments */
    .copy-button {
        padding: 0.25rem 0.5rem;
        font-size: 0.8rem;
        gap: 0.25rem;
    }
}

.progress-item.completed .icon {
    color: var(--tri-success-600);
}

.progress-item.active .icon {
    color: var(--clover-purple);
    animation: pulse 2s infinite;
}

.progress-text {
    flex: 1;
}

.progress-title {
    font-weight: 500;
    margin-bottom: 0.25rem;
    font-size: 0.95rem;
}

.progress-description {
    color: var(--tri-fg-2);
    font-size: 0.85rem;
    margin: 0;
}

.timestamp {
    font-size: 0.75rem;
    color: var(--tri-fg-2);
    margin-top: 0.25rem;
}

.bot .message-content .final-response {
    line-height: 1.6;
    border-top: 1px solid var(--tri-border);
    padding-top: 1.5rem;
    margin-top: 1.5rem;
}

.bot .message-content .final-response h2 {
    color: var(--tri-fg-1);
    margin-top: 1.5rem;
    margin-bottom: 1rem;
    font-size: 1.25rem;
}

.bot .message-content .final-response h3 {
    color: var(--tri-fg-2);
    margin-top: 1rem;
    margin-bottom: 0.75rem;
    font-size: 1.1rem;
}

/* Progress timeline separator */
#progressContainer {
    position: relative;
    padding-bottom: 1rem;
}

#progressContainer::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 24px;
    right: 0;
    height: 1px;
    background: var(--tri-border);
    display: none;
}

#progressContainer.has-items::after {
    display: block;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}

/* Tool batch container styles - subtle integrated block */
.tool-batch-block {
    background: var(--tri-bg-subtle);
    border: 1px solid var(--tri-border);
    border-left: 4px solid var(--clover-purple);
    border-radius: var(--tri-radius-md);
    padding: 0.75rem 1rem;
    margin: 0.75rem 0;
    box-shadow: var(--tri-shadow-xs);
    color: var(--tri-fg-1);
    font-size: 0.9rem;
}

/* Completed tool batch - green accent, slightly muted */
.tool-batch-block--completed {
    border-left-color: var(--tri-success-600);
    background: var(--tri-success-50);
    border-color: var(--tri-success-200);
}

.tool-batch-block--completed .tool-batch-header {
    color: var(--tri-success-800);
}

.tool-batch-block--completed .tool-batch-item {
    background: rgba(var(--tri-success-rgb), 0.03);
}

.tool-batch-block--completed .tool-batch-item i {
    color: var(--tri-success-600);
}

/* Live (in-progress) tool batch - explicit blue */
.tool-batch-block--live {
    border-left-color: var(--clover-purple);
}

/* Thinking card: ONE bordered card hosting both the live status (typing
   indicator / tool batch / bridge) and the stop control, status left,
   "Detener" right — the control is visually part of the thing it stops.
   The inner blocks keep their own card chrome in the transcript (completed
   tool batches); inside this card it is stripped so they read as content,
   not a card-within-a-card. */
.thinking-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    background: var(--tri-bg-subtle);
    border: 1px solid var(--tri-border);
    border-left: 4px solid var(--clover-purple);
    border-radius: var(--tri-radius-md);
    padding: 0.75rem 1rem;
    box-shadow: var(--tri-shadow-xs);
}

.thinking-card .thinking-status {
    flex: 1 1 auto;
    min-width: 0;
}

.thinking-card .typing-indicator,
.thinking-card .tool-batch-block {
    background: none;
    border: none;
    border-radius: 0;
    box-shadow: none;
    padding: 0;
    margin: 0;
}

.thinking-card .tool-batch-bridge {
    margin-bottom: 0;
}

.thinking-card .stop-generation-btn {
    flex-shrink: 0;
    white-space: nowrap;
    align-self: center;
}


/* Bridge pill - compact tool summary shown during streaming */
.tool-batch-bridge {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.8rem;
    color: var(--tri-fg-2);
    background: var(--tri-bg-hover);
    border: 1px solid var(--tri-border);
    border-radius: 2rem;
    padding: 0.2rem 0.7rem;
    margin-bottom: 0.5rem;
}

.tool-batch-container {
    background: transparent;
    border: none;
    border-radius: 0;
    padding: 0;
    margin: 0;
}

.tool-batch-header {
    font-weight: 500;
    margin-bottom: 0.5rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--tri-fg-1);
    font-size: 0.9rem;
}

.tool-batch-list {
    font-size: 0.85rem;
}

.tool-batch-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.25rem 0.5rem;
    color: var(--tri-fg-2);
    background: rgba(var(--bs-primary-rgb), 0.03);
    border-radius: var(--tri-radius-xs);
    margin-bottom: 0.25rem;
    border-left: 2px solid transparent;
}

.tool-batch-item:last-of-type {
    margin-bottom: 0;
}

.tool-batch-item i {
    width: 16px;
    height: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    color: var(--clover-purple);
}

.tool-batch-more {
    color: var(--tri-fg-2);
    font-style: italic;
    font-size: 0.8rem;
    margin-top: 0.25rem;
    display: flex;
    align-items: center;
    gap: 0.375rem;
    padding-left: 0.5rem;
}

.tool-batch-spinner {
    animation: tool-spin 1.5s linear infinite;
}

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

/* Tool batch status colors for subtle theme */
.tool-batch-block .text-success,
.tool-batch-container .text-success {
    color: var(--tri-success-600) !important;
}

.tool-batch-block .text-warning,
.tool-batch-container .text-warning {
    color: var(--tri-warning-600) !important;
}

.tool-batch-block .text-primary,
.tool-batch-container .text-primary {
    color: var(--clover-purple) !important;
}

.tool-batch-block .text-muted,
.tool-batch-container .text-muted {
    color: var(--tri-fg-2) !important;
}

/* Optional animation class for tool batch blocks */
.tool-batch-block.animate-in {
    animation: slideInUp 0.4s ease-out;
}

@keyframes slideInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Responsive adjustments for tool batch */
@media (max-width: 576px) {
    .tool-batch-block {
        margin: 0.5rem 0;
        padding: 0.5rem 0.75rem;
        font-size: 0.85rem;
    }

    .tool-batch-bridge {
        font-size: 0.75rem;
        padding: 0.15rem 0.5rem;
    }

    .tool-batch-header {
        font-size: 0.85rem;
        margin-bottom: 0.375rem;
        gap: 0.375rem;
    }

    .tool-batch-list {
        font-size: 0.8rem;
    }

    .tool-batch-item {
        padding: 0.2rem 0.375rem;
        gap: 0.375rem;
        margin-bottom: 0.2rem;
    }

    .tool-batch-item i {
        width: 14px;
        height: 14px;
    }
}

/* Research details collapsible section */
.research-details {
    margin-top: 2rem;
    border-top: 1px solid var(--tri-border);
    padding-top: 1rem;
}

.research-details .btn-link {
    color: var(--tri-fg-2);
    text-decoration: none;
    font-size: 0.9rem;
}

.research-details .btn-link:hover {
    color: var(--tri-fg-1);
}

.research-summary {
    background: var(--tri-bg-subtle);
    border-radius: var(--tri-radius-md);
    padding: 1rem;
    margin-bottom: 1rem;
    font-size: 0.9rem;
}

.research-summary .stat-item {
    display: inline-block;
    margin-right: 1.5rem;
    margin-bottom: 0.5rem;
}

.research-summary .stat-label {
    color: var(--tri-fg-2);
    font-weight: 500;
}

.research-summary .stat-value {
    color: var(--tri-fg-1);
    font-weight: 600;
    margin-left: 0.25rem;
}

/* ========================================
   Bibliography Section Styles - Numbered List (Academic Style)
   ======================================== */

.bibliography-section {
    margin-top: 1.5rem;
    margin-bottom: 1rem;
}

.bibliography-section .card {
    border: 1px solid var(--tri-border);
    background: var(--tri-bg-subtle);
    box-shadow: none;
    border-radius: var(--tri-radius-md);
}

.bibliography-section .card-header {
    padding: 0.875rem 1rem;
    border-bottom: 1px solid var(--tri-border);
    background: white;
}

.bibliography-section .card-header .btn-link {
    color: var(--tri-fg-1);
    font-size: 0.95rem;
    font-weight: 600;
}

.bibliography-section .card-header .btn-link:hover {
    color: var(--clover-purple);
}

.bibliography-section .card-body {
    padding: 1rem 1.25rem;
    background: white;
}

/* Source Type Sections */
.source-type-section {
    padding-bottom: 1rem;
    margin-bottom: 1rem;
    border-bottom: 1px solid var(--tri-bg-hover);
}

.source-type-section:last-child {
    border-bottom: none;
    padding-bottom: 0;
    margin-bottom: 0;
}

.source-type-header {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--tri-fg-2);
    margin-bottom: 0.75rem;
    display: flex;
    align-items: center;
}

.source-type-header .badge {
    margin-left: 0.5rem;
    font-size: 0.7rem;
    padding: 0.25rem 0.5rem;
}

/* Numbered List Styling */
.source-list {
    counter-reset: source-counter;
    display: flex;
    flex-direction: column;
    gap: 0;
}

.source-entry {
    counter-increment: source-counter;
    padding: 0.5rem 0 0.5rem 0;
    border-bottom: 1px solid var(--tri-bg-hover);
    transition: background-color 0.15s ease;
    margin-left: -0.5rem;
    margin-right: -0.5rem;
    padding-left: 0.5rem;
    padding-right: 0.5rem;
}

.source-entry:last-child {
    border-bottom: none;
}

.source-entry:hover {
    background-color: var(--tri-bg-subtle);
}

.source-entry::before {
    content: counter(source-counter) ". ";
    color: var(--tri-fg-3);
    font-weight: 500;
    font-size: 0.85rem;
    margin-right: 0.5rem;
    min-width: 1.5rem;
    display: inline-block;
}

.source-entry a {
    color: var(--tri-fg-1);
    text-decoration: none;
    font-size: 0.875rem;
    line-height: 1.6;
    transition: color 0.15s ease;
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
}

.source-entry a:hover {
    color: var(--clover-purple);
}

.source-entry a .fw-medium {
    font-weight: 500;
}

.source-entry a i {
    opacity: 0.4;
    transition: opacity 0.15s ease;
    font-size: 0.7rem;
}

.source-entry a:hover i {
    opacity: 0.8;
}

.source-title {
    font-weight: 500;
    font-size: 0.875rem;
    line-height: 1.6;
}

.source-title a {
    color: var(--tri-fg-1);
    text-decoration: none;
    transition: color 0.15s ease;
}

.source-title a:hover {
    color: var(--clover-purple);
}

.source-citation {
    font-size: 0.8rem;
    color: var(--tri-fg-3);
    line-height: 1.4;
}

.source-citation em {
    font-style: italic;
}

.source-relevance {
    font-size: 0.8rem;
    line-height: 1.4;
}

.source-relevance .text-muted {
    color: var(--tri-fg-3) !important;
}

.source-provider {
    margin-top: 0.25rem;
}

.source-provider .badge {
    font-size: 0.65rem;
    font-weight: 500;
    padding: 0.2rem 0.4rem;
}

/* Chevron Animation */
#bibliographyChevron {
    transition: transform 0.3s ease;
    font-size: 0.875rem;
}

/* Mobile Responsiveness */
@media (max-width: 768px) {
    .bibliography-section .card-header {
        padding: 0.75rem 0.875rem;
    }

    .bibliography-section .card-body {
        padding: 0.875rem 1rem;
    }

    .source-type-header {
        font-size: 0.8rem;
        margin-bottom: 0.5rem;
    }

    .source-entry {
        padding: 0.375rem 0 0.375rem 0.375rem;
        margin-left: -0.375rem;
        margin-right: -0.375rem;
        padding-right: 0.375rem;
    }

    .source-entry::before {
        font-size: 0.8rem;
        min-width: 1.25rem;
        margin-right: 0.375rem;
    }

    .source-entry a {
        font-size: 0.8rem;
        line-height: 1.5;
    }
}

/* ========================================
   Sticky Input Container Styles
   ======================================== */

.sticky-input-container {
    position: sticky;
    bottom: 0;
    z-index: 10;

    /* Solid-enough backdrop so scrolled conversation text doesn't bleed
       through; blur is progressive enhancement where supported */
    background: rgba(255, 255, 255, 0.88);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border-top: 1px solid rgba(0, 0, 0, 0.06);

    margin-left: -1rem;
    margin-right: -1rem;
    padding: 0.5rem 1rem;
}

/* Inline usage info inside search input */
.usage-info-inline {
    position: absolute;
    bottom: 6px;
    right: 70px; /* Left of send button */
    font-size: 0.7rem;
    color: var(--tri-fg-3);
    opacity: 0.7;
    pointer-events: none; /* Don't interfere with input */
    white-space: nowrap;
    transition: opacity 0.2s ease;
}

/* Allow links inside usage info to be clickable */
.usage-info-inline a {
    pointer-events: auto; /* Re-enable pointer events for links */
    cursor: pointer;
    text-decoration: underline;
}

.usage-info-inline a:hover {
    opacity: 1;
    text-decoration: underline;
}

/* Warning state for usage info */
.usage-info-inline.warning {
    color: var(--tri-warning-700);
    opacity: 0.85;
    font-weight: 500;
}

/* Unlimited state */
.usage-info-inline.unlimited {
    color: var(--tri-success-600);
    opacity: 0.6;
}

/* Collapsible sections container */
.collapsible-sections {
    margin-bottom: 1rem;
}

/* Ensure bibliography and feedback cards have proper spacing */
.collapsible-sections .bibliography-section,
.collapsible-sections .feedback-section {
    margin-top: 1rem;
    margin-bottom: 1rem;
}

/* Small buffer between the last message and whatever follows (feedback row,
   sticky input). Kept tight: the post-answer gap should read as one rhythm,
   not stacked wrapper margins. */
.chat-container #conversationContainer {
    padding-bottom: 0.5rem;
}

/* Server-rendered prerender wrappers (CLS fix, wiki B2). display:contents
   removes the wrapper from layout so the prerendered children sit in the
   exact grid/flow position their Alpine-rendered twins will occupy — even
   margin-collapse arithmetic matches, so the hydration swap is pixel-exact. */
#ssrConversation,
#ssrBanners,
#ssrBibliography,
#ssrViewerBanner {
    display: contents;
}

/* Search input with glassmorphism effect */
.sticky-input-container .search-input-wrapper {
    /* Glassmorphism (Claude/Perplexity style) */
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);

    /* Rounded corners for card effect */
    border-radius: var(--tri-radius-lg);
    border: 1px solid rgba(229, 231, 235, 0.6);

    /* Soft shadow */
    box-shadow: var(--tri-shadow-md);
}

.sticky-input-container .search-input-wrapper:hover {
    background: rgba(255, 255, 255, 0.95);
    border-color: rgba(209, 213, 219, 0.8);
    box-shadow: var(--tri-shadow-lg);
}

.sticky-input-container .search-input-wrapper:focus-within {
    background: rgba(255, 255, 255, 0.95);
    border-color: var(--clover-purple);
    box-shadow: 0 6px 24px rgba(60, 120, 253, 0.15);
}

/* Fallback for browsers without backdrop-filter support */
@supports not (backdrop-filter: blur(16px)) {
    .sticky-input-container .search-input-wrapper {
        background: rgba(255, 255, 255, 0.98);
    }
}

/* Remove extra padding and make form/section/containers transparent */
.sticky-input-container #conversationInputSection {
    padding: 0;
    background: transparent;
}

.sticky-input-container #continueConversationForm {
    background: transparent;
}

.sticky-input-container .search-input-container {
    background: transparent;
}


/* Mobile adjustments for sticky input */
@media (max-width: 576px) {
    .sticky-input-container {
        margin-left: -0.75rem;
        margin-right: -0.75rem;
        padding: 0.375rem 0.75rem; /* Even more compact on mobile */
    }

    .usage-info-inline {
        font-size: 0.65rem;
        right: 60px; /* Adjust for smaller send button on mobile */
        bottom: 4px;
    }

}

/* ========================================
   Inline Feedback Section Styles
   ======================================== */

.feedback-inline {
    /* No background - blends into conversation flow. Its border-top is the
       single divider between the answer and the end-of-conversation UI; the
       gap above it comes from the last message's own margin. */
    background: transparent;
    border: none;
    padding: 1rem 0 0 0;
    border-top: 1px solid var(--tri-border);
    margin-top: 0;
}

.feedback-inline h6 {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--tri-fg-2);
    margin-bottom: 0.75rem;
}

/* Compact inline star rating */
.rating-stars-inline {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

/* Stars are <button>s (keyboard-operable); strip the button chrome */
.rating-stars-inline .star {
    background: none;
    border: none;
    padding: 0;
    font-size: 1.5rem;
    cursor: pointer;
    transition: all 0.15s ease;
    color: var(--tri-border-strong);
    min-height: 44px;
    min-width: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    touch-action: manipulation;
}

.rating-stars-inline .star:hover {
    transform: scale(1.15);
    color: var(--tri-rating-star);
}

.rating-stars-inline .star:focus-visible {
    outline: 2px solid var(--clover-purple);
    outline-offset: 2px;
    border-radius: var(--tri-radius-xs);
}

.rating-stars-inline .star.filled {
    color: var(--tri-rating-star);
}

/* Feedback header row */
.feedback-header-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.75rem;
}

.feedback-rating-section {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.feedback-rating-label {
    font-size: 0.875rem;
    color: var(--tri-fg-2);
    font-weight: 500;
}

/* Comment toggle: the row's single action, styled as a quiet ghost button */
.feedback-comment-toggle {
    font-size: 0.875rem;
    padding: 0.375rem 0.75rem;
    border: 1px solid transparent;
    background: transparent;
    border-radius: var(--tri-radius-sm);
    color: var(--tri-fg-2);
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    white-space: nowrap;
}

.feedback-comment-toggle:hover {
    background: var(--tri-bg-hover);
    color: var(--tri-fg-1);
}

.feedback-comment-toggle:focus-visible {
    outline: 2px solid var(--clover-purple);
    outline-offset: 2px;
}

/* Collapsible comment form */
.feedback-comment-collapse {
    margin-top: 0.75rem;
}

.feedback-comment-collapse textarea {
    border-radius: var(--tri-radius-md);
    border-color: var(--tri-border-strong);
    font-size: 0.875rem;
    resize: vertical;
    min-height: 80px;
}

.feedback-comment-collapse textarea:focus {
    border-color: var(--clover-purple);
    box-shadow: var(--tri-shadow-focus);
}

.feedback-submit-btn {
    margin-top: 0.5rem;
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
}

/* Suggestion pointer inside the comment collapse (kept out of the header row) */
.feedback-suggestion-line {
    margin: 0.75rem 0 0;
    font-size: 0.8125rem;
    color: var(--tri-fg-2);
}

.feedback-suggestion-line a {
    color: inherit;
    text-decoration: underline;
}

.feedback-suggestion-line a:hover,
.feedback-suggestion-line a:focus {
    color: var(--clover-purple);
}

/* Rating feedback messages */
.rating-feedback-msg {
    font-size: 0.8125rem;
    color: var(--tri-fg-2);
    margin-left: 0.5rem;
}

.rating-feedback-msg.success {
    color: var(--tri-success-600);
    font-weight: 500;
}

/* Mobile responsive adjustments */
@media (max-width: 576px) {
    .feedback-header-row {
        flex-direction: column;
        align-items: flex-start;
    }

    .feedback-rating-section {
        width: 100%;
    }

    .feedback-comment-toggle {
        width: 100%;
        justify-content: center;
    }

    .rating-stars-inline .star {
        font-size: 1.75rem;
        min-height: 48px;
        min-width: 48px;
    }
}
