html, body {
    font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
}

/* Mobile-specific responsive utilities */
@media (max-width: 640px) {
    /* Reduce padding on mobile */
    .rz-p-4 {
        padding: 1rem !important;
    }

    /* Make dialogs full-width on mobile */
    .dialog-content {
        width: 100% !important;
        max-width: 100% !important;
        margin: 0 !important;
        max-height: 100vh !important;
        border-radius: 0 !important;
    }

    .dialog-overlay {
        padding: 0 !important;
    }

    /* Make Radzen cards adapt better */
    .rz-card {
        margin-bottom: 0.5rem;
    }

    /* Stack horizontal stacks vertically on mobile */
    .mobile-stack-vertical {
        flex-direction: column !important;
    }

    /* Hide elements on mobile */
    .mobile-hide {
        display: none !important;
    }

    /* Make buttons full width on mobile when needed */
    .mobile-full-width {
        width: 100% !important;
    }

    /* Adjust text sizes for mobile */
    h1, .rz-text-h1 {
        font-size: 1.75rem !important;
    }

    h2, .rz-text-h2 {
        font-size: 1.5rem !important;
    }

    h3, .rz-text-h3 {
        font-size: 1.25rem !important;
    }

    h4, .rz-text-h4 {
        font-size: 1.1rem !important;
    }

    h5, .rz-text-h5 {
        font-size: 1rem !important;
    }

    /* Improve table responsiveness */
    .rz-datatable {
        font-size: 0.85rem;
    }

    /* Make forms more mobile friendly */
    .rz-textbox,
    .rz-textarea,
    .rz-dropdown,
    .rz-numeric {
        font-size: 16px !important; /* Prevents zoom on iOS */
    }
}

/* Unified theme colors */
:root {
    --theme-primary: #1e3a8a;
    --theme-primary-light: #3b82f6;
    --theme-primary-lighter: #60a5fa;
    --theme-gray-light: #f3f4f6;
    --theme-gray: #6b7280;
    --theme-gray-dark: #374151;
    --theme-white: #ffffff;
}

a, .btn-link {
    color: var(--theme-primary);
}

.btn-primary {
    color: var(--theme-white);
    background-color: var(--theme-primary-light);
    border-color: var(--theme-primary);
}

.btn:focus, .btn:active:focus, .btn-link.nav-link:focus, .form-control:focus, .form-check-input:focus {
  box-shadow: 0 0 0 0.1rem white, 0 0 0 0.25rem var(--theme-primary-lighter);
}

.content {
    padding-top: 1.1rem;
}

h1:focus {
    outline: none;
}

.valid.modified:not([type=checkbox]) {
    outline: 1px solid #26b050;
}

.invalid {
    outline: 1px solid #e50000;
}

.validation-message {
    color: #e50000;
}

.blazor-error-boundary {
    background: url(data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNTYiIGhlaWdodD0iNDkiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM6eGxpbms9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiIG92ZXJmbG93PSJoaWRkZW4iPjxkZWZzPjxjbGlwUGF0aCBpZD0iY2xpcDAiPjxyZWN0IHg9IjIzNSIgeT0iNTEiIHdpZHRoPSI1NiIgaGVpZ2h0PSI0OSIvPjwvY2xpcFBhdGg+PC9kZWZzPjxnIGNsaXAtcGF0aD0idXJsKCNjbGlwMCkiIHRyYW5zZm9ybT0idHJhbnNsYXRlKC0yMzUgLTUxKSI+PHBhdGggZD0iTTI2My41MDYgNTFDMjY0LjcxNyA1MSAyNjUuODEzIDUxLjQ4MzcgMjY2LjYwNiA1Mi4yNjU4TDI2Ny4wNTIgNTIuNzk4NyAyNjcuNTM5IDUzLjYyODMgMjkwLjE4NSA5Mi4xODMxIDI5MC41NDUgOTIuNzk1IDI5MC42NTYgOTIuOTk2QzI5MC44NzcgOTMuNTEzIDI5MSA5NC4wODE1IDI5MSA9NC42NzgyIDI5MSA5Ny4wNjUxIDI4OS4wMzggOTkgMjg2LjYxNyA5OUwyNDAuMzgzIDk5QzIzNy45NjMgOTkgMjM2IDk3LjA2NTEgMjM2IDk0LjY3ODIgMjM2IDk0LjM3OTkgMjM2LjAzMSA5NC4wODg2IDIzNi4wODkgOTMuODA3MkwyMzYuMzM4IDkzLjAxNjIgMjM2Ljg1OCA5Mi4xMzE0IDI1OS40NzMgNTMuNjI5NCAyNTkuOTYxIDUyLjc5ODUgMjYwLjQwNyA1Mi4yNjU4QzI2MS4yIDUxLjQ4MzcgMjYyLjI5NiA1MSAyNjMuNTA2IDUxWk0yNjMuNTg2IDY2LjAxODNDMjYwLjczNyA2Ni4wMTgzIDI1OS4zMTMgNjcuMTI0NSAyNTkuMzEzIDY5LjMzNyAyNTkuMzEzIDY5LjYxMDIgMjU5LjMzMiA2OS44NjA4IDI1OS4zNzEgNzAuMDg4N0wyNjEuNzk1IDg0LjAxNjEgMjY1LjM4IDg0LjAxNjEgMjY3LjgyMSA2OS43NDc1QzI2Ny44NiA2OS43MzA5IDI2Ny44NzkgNjkuNTg3NyAyNjcuODc5IDY5LjMxNzkgMjY3Ljg3OSA2Ny4xMTgyIDI2Ni40NDggNjYuMDE4MyAyNjMuNTg2IDY2LjAxODNaTTI2My41NzYgODYuMDU0N0MyNjEuMDQ5IDg2LjA1NDcgMjU5Ljc4NiA4Ny4zMDA1IDI1OS43ODYgODkuNzkyMSAyNTkuNzg2IDkyLjI4MzcgMjYxLjA0OSA5My41Mjk1IDI2My41NzYgOTMuNTI5NSAyNjYuMTE2IDkzLjUyOTUgMjY3LjM4NyA5Mi4yODM3IDI2Ny4zODcgODkuNzkyMSAyNjcuMzg3IDg3LjMwMDUgMjY2LjExNiA4Ni4wNTQ3IDI2My41NzYgODYuMDU0N1oiIGZpbGw9IiNGRkU1MDAiIGZpbGwtcnVsZT0iZXZlbm9kZCIvPjwvZz48L3N2Zz4=) no-repeat 1rem/1.8rem, #b32121;
    padding: 1rem 1rem 1rem 3.7rem;
    color: white;
}

    .blazor-error-boundary::after {
        content: "An error has occurred."
    }

.darker-border-checkbox.form-check-input {
    border-color: #929292;
}

.form-floating > .form-control-plaintext::placeholder, .form-floating > .form-control::placeholder {
    color: var(--bs-secondary-color);
    text-align: end;
}

.form-floating > .form-control-plaintext:focus::placeholder, .form-floating > .form-control:focus::placeholder {
    text-align: start;
}

/* Markdown Viewer Styles */
.markdown-viewer {
    line-height: 1.6;
}

.markdown-viewer h1,
.markdown-viewer h2,
.markdown-viewer h3,
.markdown-viewer h4,
.markdown-viewer h5,
.markdown-viewer h6 {
    margin-top: 1em;
    margin-bottom: 0.5em;
    font-weight: 600;
}

.markdown-viewer h1 {
    font-size: 2em;
    border-bottom: 1px solid #eaecef;
    padding-bottom: 0.3em;
}

.markdown-viewer h2 {
    font-size: 1.5em;
    border-bottom: 1px solid #eaecef;
    padding-bottom: 0.3em;
}

.markdown-viewer h3 {
    font-size: 1.25em;
}

.markdown-viewer h4 {
    font-size: 1em;
}

.markdown-viewer p {
    margin-bottom: 1em;
}

.markdown-viewer ul,
.markdown-viewer ol {
    margin-bottom: 1em;
    padding-left: 2em;
}

.markdown-viewer code {
    background-color: rgba(27, 31, 35, 0.05);
    border-radius: 3px;
    font-size: 85%;
    margin: 0;
    padding: 0.2em 0.4em;
    font-family: 'Courier New', Courier, monospace;
}

.markdown-viewer pre {
    background-color: #f6f8fa;
    border-radius: 6px;
    padding: 16px;
    overflow-x: auto;
    margin-bottom: 1em;
}

.markdown-viewer pre code {
    background-color: transparent;
    padding: 0;
    font-size: 100%;
}

.markdown-viewer blockquote {
    border-left: 4px solid #dfe2e5;
    padding-left: 1em;
    margin-left: 0;
    color: #6a737d;
    margin-bottom: 1em;
}

.markdown-viewer a {
    color: var(--theme-primary-light);
    text-decoration: none;
}

.markdown-viewer a:hover {
    text-decoration: underline;
}

.markdown-viewer table {
    border-collapse: collapse;
    width: 100%;
    margin-bottom: 1em;
}

.markdown-viewer table th,
.markdown-viewer table td {
    border: 1px solid #dfe2e5;
    padding: 6px 13px;
}

.markdown-viewer table th {
    background-color: #f6f8fa;
    font-weight: 600;
}

.markdown-viewer img {
    max-width: 100%;
    height: auto;
}

.markdown-viewer hr {
    border: 0;
    border-top: 2px solid #eaecef;
    margin: 1.5em 0;
}

/* Radzen ContextMenu - compact styling */
.rz-context-menu {
    min-width: 160px;
    font-size: 0.85rem;
}

.rz-context-menu .rz-menuitem-link {
    padding: 0.35rem 0.6rem;
}

.rz-context-menu .rz-menuitem-icon {
    font-size: 1rem;
    width: 1.25rem;
}

/* Agent status message animations */
.agent-status-message {
    font-weight: bold;
    background: linear-gradient(90deg, #1e3a8a, #3b82f6, #60a5fa, #3b82f6, #1e3a8a);
    background-size: 200% 100%;
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    animation: gradient-shift 8s ease-in-out infinite;
    display: inline-block;
}

@keyframes gradient-shift {
    0%, 100% {
        background-position: 0% 50%;
    }
    50% {
        background-position: 100% 50%;
    }
}


/* ===== Chat page layout (Chat + AgentChat) ===== */

/* Base styles (all screen sizes) */
.chat-page-container {
    display: flex;
    flex-direction: row;
    gap: 1rem;
    height: calc(100vh - 2.2rem);
}

.chat-sidebar {
    background-color: var(--bs-body-bg) !important;
    width: 300px;
    flex-shrink: 0;
    overflow-y: auto;
}

.chat-sidebar-toggle {
    display: none !important;
}

.chat-sidebar-overlay {
    display: none;
}

.chat-main {
    flex: 1;
    min-width: 0;
    overflow: hidden;
}

.chat-content-stack {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    padding: 1rem;
    overflow: hidden;
    height: 100%;
    box-sizing: border-box;
}

.chat-header-area {
    flex-shrink: 0;
}

.chat-messages-area {
    flex: 1;
    overflow-y: auto;
    min-height: 0;
}

.chat-input-area {
    flex-shrink: 0;
}

.chat-input-wrapper {
    position: relative;
    width: 100%;
}

.chat-mode-selector {
    position: absolute;
    top: 0.5rem;
    left: 0.5rem;
}

/* Mobile styles for chat pages */
@media (max-width: 768px) {
    /* Remove content padding when showing chat pages */
    .content:has(.chat-page-container) {
        padding: 0 !important;
    }

    .chat-page-container {
        /*height: calc(100vh - 3.5rem);*/
        height: 100vh;
        gap: 0;
        overflow: hidden;
    }

    /* Chat sidebar - off-screen by default */
    .chat-sidebar {
        position: fixed !important;
        left: 0 !important;
        top: 0 !important;
        width: 280px !important;
        height: 100vh !important;
        z-index: 1001 !important;
        transform: translateX(-100%);
        transition: transform 0.3s ease-in-out;
        box-shadow: 2px 0 10px rgba(0, 0, 0, 0.3);
    }

    .chat-sidebar.show {
        transform: translateX(0) !important;
    }

    /* Toggle button visible on mobile */
    .chat-sidebar-toggle {
        display: flex !important;
        position: absolute !important;
        bottom: -2rem;
        left: -.5rem;
        z-index: 100;
        border-radius: 50%;
        width: 44px !important;
        height: 44px !important;
        min-width: 44px !important;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    }

    /* Overlay when sidebar is open */
    .chat-sidebar-overlay.show {
        display: block;
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background: rgba(0, 0, 0, 0.5);
        z-index: 1000;
    }

    /* Main area fills everything */
    .chat-main {
        width: 100%;
    }

    /* Reduce padding in content stack */
    .chat-content-stack {
        padding: 0.5rem;
        gap: 0.5rem;
    }

    /* Header: wrap items and reduce sizes */
    .chat-header-area .rz-stack {
        flex-wrap: wrap !important;
        gap: 0.5rem !important;
    }

    .chat-header-area .rz-dropdown {
        width: auto !important;
        min-width: 120px;
        max-width: 180px;
    }

    .chat-header-area img {
        width: 48px !important;
        height: 48px !important;
    }

    .agent-avatar {
        width: 48px !important;
        height: 48px !important;
    }

    /* Messages: ensure word-break for long content */
    .chat-messages-area .rz-card {
        word-break: break-word;
        overflow-wrap: break-word;
    }

    /* Images in messages scale to container width */
    .chat-messages-area img {
        max-width: 100%;
        height: auto;
    }

    /* Input area: stack mode selector above textarea on mobile */
    .chat-input-wrapper {
        display: flex;
        flex-direction: column;
    }

    .chat-mode-selector {
        position: static;
        margin-bottom: 0.25rem;
        align-self: flex-start;
    }

    .chat-input-wrapper .rz-textarea {
        padding-left: 0.5rem !important;
    }

    /* Send button: just icon on mobile */
    .chat-input-area .rz-stack {
        gap: 0.5rem !important;
    }
}

@media (max-width: 640px) {
    .chat-page-container {
        height: calc(100vh - 3.5rem);
    }
}

/* ===== Floating plan overlay panel ===== */

.plan-overlay-panel {
    position: fixed;
    right: 0;
    top: 50%;
    transform: translateY(-50%);
    z-index: 500;
    display: flex;
    flex-direction: row;
    align-items: flex-start;
    pointer-events: auto;
}

.plan-overlay-tab {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.3rem;
    padding: 0.75rem 0.35rem;
    background: var(--rz-primary);
    color: #fff;
    border-radius: 0.5rem 0 0 0.5rem;
    cursor: pointer;
    user-select: none;
    box-shadow: -2px 0 8px rgba(0, 0, 0, 0.22);
    min-width: 1.9rem;
    transition: background 0.15s;
}

.plan-overlay-tab:hover {
    background: var(--rz-primary-dark, #1565c0);
}

.plan-overlay-tab-label {
    writing-mode: vertical-rl;
    transform: rotate(180deg);
    font-size: 0.68rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.07em;
}

.plan-overlay-tab-icon {
    font-size: 0.95rem;
    line-height: 1;
}

.plan-overlay-tab-count {
    font-size: 0.7rem;
    font-weight: 700;
    background: rgba(255,255,255,0.25);
    border-radius: 0.75rem;
    padding: 0.05rem 0.3rem;
    min-width: 1.2rem;
    text-align: center;
}

.plan-overlay-content {
    background: var(--rz-base-background-color);
    border: 1px solid var(--rz-border-color);
    border-right: none;
    border-radius: 0.5rem 0 0 0.5rem;
    padding: 0.75rem 0.9rem;
    overflow-y: auto;
    max-height: 70vh;
    width: 300px;
    min-width: 220px;
    box-shadow: -3px 0 14px rgba(0, 0, 0, 0.13);
    position: relative;
    transition: width 0.2s ease;
}

.plan-overlay-content.expanded {
    width: 50vw;
    transition: width 0.2s ease;
}

.plan-overlay-drag-handle {
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 5px;
    cursor: ew-resize;
    background: transparent;
    border-radius: 0.5rem 0 0 0.5rem;
    z-index: 2;
}

.plan-overlay-drag-handle:hover,
.plan-overlay-drag-handle:active {
    background: rgba(25, 118, 210, 0.3);
}

.plan-overlay-content-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.4rem;
}

.plan-overlay-expand-btn {
    background: none;
    border: none;
    cursor: pointer;
    color: #90caf9;
    font-size: 0.8rem;
    padding: 0 0.15rem;
    line-height: 1;
    flex-shrink: 0;
    user-select: none;
}

.plan-overlay-expand-btn:hover {
    color: #1976d2;
}

@media (max-width: 768px) {
    .plan-overlay-content {
        width: 260px;
        max-height: 55vh;
    }
    .plan-overlay-content.expanded {
        width: 90vw;
    }
}

/* Lazy image placeholder & reveal */
.lazy-image-container {
    display: inline-block;
    position: relative;
}

.lazy-image-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #e2e8f0, #f1f5f9);
    border: 2px dashed #94a3b8;
    border-radius: 8px;
    cursor: pointer;
    transition: border-color .2s, background .5s;
    gap: 0.5rem;
}

.lazy-image-placeholder:hover {
    border-color: var(--theme-primary-light);
    background: linear-gradient(135deg, #dbeafe, #e0e7ff);
}

.lazy-image-placeholder-icon {
    font-size: 2.5rem;
    opacity: 0.6;
}

.lazy-image-placeholder-text {
    font-size: 0.85rem;
    color: var(--theme-gray);
    font-weight: 500;
}

.lazy-image-reveal {
    animation: lazy-image-fade-in .5s ease-out;
}

@keyframes lazy-image-fade-in {
    from {
        opacity: 0;
        transform: scale(0.96);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* Lazy video placeholder & reveal */
.lazy-video-container {
    display: inline-block;
    position: relative;
}

.lazy-video-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #e2e8f0, #f1f5f9);
    border: 2px dashed #94a3b8;
    border-radius: 8px;
    cursor: pointer;
    transition: border-color .2s, background .5s;
    gap: 0.5rem;
}

.lazy-video-placeholder:hover {
    border-color: var(--theme-primary-light);
    background: linear-gradient(135deg, #dbeafe, #e0e7ff);
}

.lazy-video-placeholder-icon {
    font-size: 2.5rem;
    opacity: 0.6;
}

.lazy-video-placeholder-text {
    font-size: 0.85rem;
    color: var(--theme-gray);
    font-weight: 500;
}

.lazy-video-reveal {
    animation: lazy-video-fade-in .5s ease-out;
}

@keyframes lazy-video-fade-in {
    from {
        opacity: 0;
        transform: scale(0.96);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* Focused message (J/K navigation or click) */
.chat-message-focused {
    box-shadow: 0 6px 24px rgba(59, 130, 246, 0.45), 0 0 0 2px rgba(59, 130, 246, 0.3) !important;
    transform: translateY(-1px);
    transition: box-shadow 0.25s ease, transform 0.25s ease;
    animation: message-focus-glow 0.3s ease-out;
    position: relative;
    z-index: 1;
}

@keyframes message-focus-glow {
    0%   { box-shadow: 0 2px 8px rgba(59, 130, 246, 0.15); }
    60%  { box-shadow: 0 8px 32px rgba(59, 130, 246, 0.65), 0 0 0 3px rgba(59, 130, 246, 0.4); }
    100% { box-shadow: 0 6px 24px rgba(59, 130, 246, 0.45), 0 0 0 2px rgba(59, 130, 246, 0.3); }
}
/* ── Code block copy button (Feature 2) ───────────────────────── */
.code-copy-btn {
    position: absolute;
    top: 0.25rem;
    right: 0.5rem;
    font-size: 1.1rem;
    background: rgba(var(--rz-primary-light), 0.12);
    color: var(--bs-code-color, #b00);
    border: none;
    border-radius: 4px;
    cursor: pointer;
    opacity: 0;
    transition: all 0.2s ease;
    z-index: 10;
    align-items: center;
    justify-content: center;
    min-width: 2rem;
    min-height: 1.8rem;
}

.code-copy-btn:hover {
    background: rgba(var(--rz-primary-light), 0.2);
    transform: translateY(-1px);
}

.code-copy-btn i {
    font-size: 1rem;
    line-height: 1;
}

pre:hover .code-copy-btn {
    opacity: 1;
}

/* ── Code language indicator ──────────────────────────────────── */
.code-language-indicator {
    position: absolute;
    top: 0.25rem;
    left: 0.5rem;
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--bs-code-color, #b00);
    border-radius: 4px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    z-index: 10;
    pointer-events: none;
}

/* ── Thinking-mode pulse badge (Feature 6) ────────────────────── */
.thinking-pulse-badge {
    display: inline-block;
    padding: 0.1rem 0.55rem;
    border-radius: 1rem;
    font-size: 0.7rem;
    background: var(--rz-primary-lighter, rgba(99, 102, 241, 0.15));
    color: var(--rz-primary, #6366f1);
    animation: thinking-pulse 1.4s ease-in-out infinite;
}

@keyframes thinking-pulse {
    0%,  100% { opacity: 1; }
    50%        { opacity: 0.35; }
}

/* ── Search term highlighting (Feature 3) ───────────────────────── */
.search-highlight {
    background-color: rgba(96, 165, 250, 0.35); /* light blue background */
    padding: 0.05rem 0;
    border-radius: 2px;
}
