/* =============================================
   Metrolink Brand Variables
   ============================================= */

:root {
    --ml-navy:        #003087; /* PANTONE 280 C  — Primary Navy        */
    --ml-orange:      #FF6720; /* PANTONE 1655 C — Orange Accent       */
    --ml-sky:         #009FDB; /* PANTONE 2995 C — Sky Blue            */
    --ml-charcoal:    #2C3139; /* PANTONE 433 C  — Dark Charcoal       */
    --ml-cool-gray:   #C8C9C7; /* Pantone Cool Gray 4 C                */
    --ml-light-gray:  #F5F6F8; /* Off-white page background            */
    --ml-error:       #A6192E; /* PANTONE 1805 C — Deep Red            */
    --ml-white:       #FFFFFF;
    --app-bar-height: 48px;
    --top-nav-height: 38px;
}

/* =============================================
   Chat Layout
   ============================================= */

.mud-main-content.chat-page-host,
.mud-appbar-dense ~ .mud-main-content.chat-page-host {
    padding-top: 0 !important;
    height: calc(100dvh - var(--app-bar-height) - var(--top-nav-height));
    min-height: calc(100dvh - var(--app-bar-height) - var(--top-nav-height));
    overflow: hidden;
}

.chat-layout {
    display: flex;
    height: 100%;
    min-height: 100%;
    overflow: hidden;
}

.sessions-panel {
    width: 280px;
    flex-shrink: 0;
    border-right: 1px solid rgba(0, 0, 0, 0.12);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: width 0.2s ease;
}

    .sessions-panel.collapsed {
        width: 48px;
    }

.sessions-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.12);
    flex-shrink: 0;
}

    .sessions-panel.collapsed .sessions-header {
        padding: 12px 8px;
        justify-content: center;
    }

.sessions-list {
    flex: 1;
    overflow-y: auto;
}

.session-item {
    display: flex;
    align-items: center;
    padding: 8px 16px;
    cursor: pointer;
    transition: background 0.15s ease;
}

.session-item:hover {
    background: rgba(0, 0, 0, 0.04);
}

.session-item.active {
    background: rgba(0, 48, 135, 0.08);
    border-left: 3px solid var(--ml-navy);
}

.session-title {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 0.875rem;
}

/* Inline rename field inside a session item */
.session-rename-field {
    flex: 1;
    min-width: 0;
}

.session-rename-field .mud-input-root {
    font-size: 0.875rem;
}

.session-rename-field .mud-input-slot {
    padding-top: 0;
    padding-bottom: 0;
}

/* =============================================
   Chat Main Area
   ============================================= */

.chat-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.welcome-state {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 24px;
    gap: 16px;
    background: linear-gradient(160deg, rgba(0,48,135,0.04) 0%, rgba(255,103,32,0.04) 100%);
}

.messages-area {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
}

.empty-messages {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    opacity: 0.5;
}

/* =============================================
   Message Bubbles
   ============================================= */

.message {
    display: flex;
    margin-bottom: 16px;
}

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

.message.assistant {
    justify-content: flex-start;
}

.message-bubble {
    max-width: 75%;
    padding: 12px 16px;
    border-radius: 12px;
    background: rgba(0, 0, 0, 0.06);
    line-height: 1.5;
    word-break: break-word;
}

.message.user .message-bubble {
    background: var(--ml-navy);
    color: var(--ml-white);
    border-bottom-right-radius: 4px;
}

.message.assistant .message-bubble {
    border-bottom-left-radius: 4px;
    border-left: 3px solid var(--ml-orange);
    background: rgba(0, 48, 135, 0.05);
}

/* =============================================
   Citations
   ============================================= */

.citations {
    margin-top: 8px;
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}

.citations-label {
    width: 100%;
    font-size: 0.75rem;
    margin-bottom: 2px;
    opacity: 0.7;
}

/* Inline citation links in message content */
.message-content-with-citations {
    white-space: pre-wrap;
    line-height: 1.5;
}

.citation-link {
    color: var(--ml-navy);
    text-decoration: none;
    font-weight: 600;
    cursor: pointer;
    padding: 0 2px;
    border-radius: 3px;
    transition: background 0.15s ease;
}

.citation-link:hover {
    background: rgba(0, 48, 135, 0.12);
    text-decoration: underline;
}

.citation-missing {
    color: var(--ml-error);
    opacity: 0.6;
}

.citation-outdated {
    color: var(--ml-warning, #b26a00);
    border-bottom: 1px dashed currentColor;
}

.citation-anchor {
    position: relative;
    display: inline-block;
}

/* Popover content shown when a citation link is clicked */
.citation-popover {
    max-width: 380px;
    padding: 0.75rem 1rem 1rem;
    border-radius: 8px;
}

.citation-popover-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.5rem;
    padding-bottom: 0.5rem;
    margin-bottom: 0.5rem;
    border-bottom: 1px solid rgba(0, 0, 0, 0.08);
}

.citation-popover-title {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    font-weight: 700;
    color: var(--ml-navy);
    text-decoration: underline;
    cursor: pointer;
    word-break: break-word;
}

.citation-popover-title-icon {
    flex-shrink: 0;
}

.citation-popover-close {
    margin: -0.5rem -0.5rem 0 0;
    flex-shrink: 0;
}

.citation-popover-meta {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.85rem;
    color: rgba(0, 0, 0, 0.6);
    margin-bottom: 0.5rem;
}

.citation-popover-meta-sep {
    opacity: 0.5;
}

.citation-popover-text {
    font-size: 0.85rem;
    line-height: 1.45;
    color: #444;
    white-space: pre-wrap;
    max-height: 220px;
    overflow-y: auto;
}

.citation-popover-outdated {
    display: flex;
    align-items: flex-start;
    gap: 0.4rem;
    font-size: 0.8rem;
    color: #7a4a00;
    background: rgba(255, 193, 7, 0.15);
    border: 1px solid rgba(255, 193, 7, 0.4);
    border-radius: 6px;
    padding: 0.4rem 0.6rem;
    margin-bottom: 0.5rem;
}

.citation-popover-outdated-icon {
    flex-shrink: 0;
    color: #b26a00;
}

/* =============================================
   Input Area
   ============================================= */

.input-area {
    display: flex;
    flex-direction: column;
    padding: 12px 16px;
    border-top: 1px solid rgba(0, 0, 0, 0.12);
    gap: 8px;
    flex-shrink: 0;
}

.input-row {
    display: flex;
    align-items: flex-end;
    gap: 8px;
}

.mode-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    padding-bottom: 4px;
}

/* =============================================
   Agentic Reasoning Panel
   ============================================= */

.reasoning-panel {
    margin-bottom: 12px;
    background: transparent;
}

.reasoning-panel .mud-expand-panel {
    background: rgba(0, 48, 135, 0.03);
    border-radius: 8px;
    box-shadow: none;
}

.reasoning-panel .mud-expand-panel-header {
    padding: 8px 12px;
    min-height: auto;
}

.reasoning-header {
    display: flex;
    align-items: center;
    gap: 8px;
}

.reasoning-steps {
    padding: 0 8px 8px 8px;
}

.reasoning-step,
.search-step {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    padding: 4px 0;
    font-size: 0.875rem;
}

.reasoning-step .mud-icon-root,
.search-step .mud-icon-root {
    flex-shrink: 0;
    margin-top: 2px;
}

/* =============================================
   Streaming Cursor
   ============================================= */

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

.cursor {
    display: inline-block;
    animation: blink 1s infinite;
    color: var(--ml-orange);
    font-weight: bold;
    margin-left: 1px;
}

/* =============================================
   Blazor System Styles (loading / error)
   ============================================= */

#blazor-error-ui {
    color-scheme: light only;
    background: lightyellow;
    bottom: 0;
    box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.2);
    box-sizing: border-box;
    display: none;
    left: 0;
    padding: 0.6rem 1.25rem 0.7rem 1.25rem;
    position: fixed;
    width: 100%;
    z-index: 1000;
}

    #blazor-error-ui .dismiss {
        cursor: pointer;
        position: absolute;
        right: 0.75rem;
        top: 0.5rem;
    }

.blazor-error-boundary {
    background: url(data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNTYiIGhlaWdodD0iNDkiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM6eGxpbms9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiIG92ZXJmbG93PSJoaWRkZW4iPjxkZWZzPjxjbGlwUGF0aCBpZD0iY2xpcDAiPjxyZWN0IHg9IjIzNSIgeT0iNTEiIHdpZHRoPSI1NiIgaGVpZ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uMDQ5IDg2LjA1NDcgMjU5Ljc4NiA4Ny4zMDA1IDI1OS43ODYgODkuNzkyMSAyNTkuNzg2IDkyLjI4MzcgMjYxLjA0OSA5My41Mjk1IDI2My41NzYgOTMuNTI5NSAyNjYuMTE2IDkzLjUyOTUgMjY3LjM4NyA5Mi4yODM3IDI2Ny4zODcgODkuNzkyMSAyNjcuMzg3IDg3LjMwMDUgMjY2LjExNiA4Ni4wNTQ3IDI2My41NzYgODYuMDU0N1oiIGZpbGw9IiNGRkU1MDAiIGZpbGwtcnVsZT0iZXZlbm9kZCIvPjwvZz48L3N2Zz4=) no-repeat 1rem/1.8rem, #b32121;
    padding: 1rem 1rem 1rem 3.7rem;
    color: white;
}

    .blazor-error-boundary::after {
        content: "An error has occurred."
    }

.loading-progress {
    position: absolute;
    display: block;
    width: 8rem;
    height: 8rem;
    inset: 20vh 0 auto 0;
    margin: 0 auto 0 auto;
}

    .loading-progress circle {
        fill: none;
        stroke: #e0e0e0;
        stroke-width: 0.6rem;
        transform-origin: 50% 50%;
        transform: rotate(-90deg);
    }

        .loading-progress circle:last-child {
            stroke: var(--ml-navy);
            stroke-dasharray: calc(3.141 * var(--blazor-load-percentage, 0%) * 0.8), 500%;
            transition: stroke-dasharray 0.05s ease-in-out;
        }

.loading-progress-text {
    position: absolute;
    text-align: center;
    font-weight: bold;
    inset: calc(20vh + 3.25rem) 0 auto 0.2rem;
}

    .loading-progress-text:after {
        content: var(--blazor-load-percentage-text, "Loading");
    }

/* end */