/* ==================== BASE & RESET ==================== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* Basier Circle — the product typeface (same files as lexi-frontend) */
@font-face {
    font-family: 'Basier Circle';
    src: url('/assets/fonts/BasierCircle-Regular.woff2') format('woff2');
    font-weight: 400;
    font-style: normal;
    font-display: swap;
}
@font-face {
    font-family: 'Basier Circle';
    src: url('/assets/fonts/BasierCircle-Medium.woff2') format('woff2');
    font-weight: 500;
    font-style: normal;
    font-display: swap;
}
@font-face {
    font-family: 'Basier Circle';
    src: url('/assets/fonts/BasierCircle-SemiBold.woff2') format('woff2');
    font-weight: 600;
    font-style: normal;
    font-display: swap;
}
@font-face {
    font-family: 'Basier Circle';
    src: url('/assets/fonts/BasierCircle-Bold.woff2') format('woff2');
    font-weight: 700;
    font-style: normal;
    font-display: swap;
}

body {
    margin: 0;
    padding: 0;
    height: 100vh;
    overflow: hidden;
    font-family: 'Basier Circle', -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Inter', Roboto, 'Helvetica Neue', Arial, sans-serif;
}

/* Tactile press feedback on every button (mirrors the frontend's global rule) */
button {
    transition: transform 150ms cubic-bezier(0.2, 0, 0, 1);
}
button:active:not(:disabled) {
    transform: scale(0.97);
}

/* ==================== BACKGROUND & LAYOUT ==================== */
/* Product page tone (slate-50) with logo watermark */
.bg-gradient {
    background: linear-gradient(180deg, #f8fafc 0%, #ffffff 100%);
    position: relative;
    overflow: hidden;
}

/* Logo watermark in background */
.bg-gradient::before {
    content: '';
    position: absolute;
    width: 100%;
    height: 100%;
    background-image: url('/assets/lexi-logo.png');
    background-repeat: no-repeat;
    background-position: center center;
    background-size: 40%;
    opacity: 0.08;
    filter: grayscale(100%) brightness(0.3);
    pointer-events: none;
}

@keyframes backgroundShift {
    0%, 100% { transform: translate(0, 0) scale(1); }
    50% { transform: translate(-10px, -10px) scale(1.01); }
}

/* ==================== GLASSMORPHISM EFFECTS ==================== */
/* Header on the product's slate-50 page tone */
.glass-header {
    background: rgba(248, 250, 252, 0.95);
    border-bottom: 1px solid rgba(226, 232, 240, 0.7) !important;
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    border-bottom: none;
    box-shadow: none;
    position: relative;
    z-index: 20;
}

/* Input area */
.glass-input {
    background: rgba(255, 255, 255, 1);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    border: 1px solid rgba(226, 232, 240, 0.8);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
    min-height: 36px;
    overflow: visible;
}

/* Footer area */
.glass-footer {
    background: rgba(255, 255, 255, 0.98);
    backdrop-filter: blur(16px) saturate(180%);
    -webkit-backdrop-filter: blur(16px) saturate(180%);
    border-top: 1px solid rgba(226, 232, 240, 0.6);
}

/* ==================== CONTENT AREAS ==================== */
/* Content area styling for tab merge - no gaps */
#chatContent {
    background: #ffffff;
    margin-top: 0 !important;
    padding-top: 0 !important;
}

#redliningContent {
    background: #ffffff;
    margin-top: 0 !important;
    padding-top: 0 !important;
}

#settingsContent {
    background: #ffffff;
    margin-top: 0 !important;
    padding-top: 0 !important;
}

#draftingContent {
    background: #ffffff;
    margin-top: 0 !important;
    padding-top: 0 !important;
}

/* ==================== SCROLLBARS ==================== */
/* Custom scrollbar - Subtle modern */
#chatContainer::-webkit-scrollbar {
    width: 6px;
}

#chatContainer::-webkit-scrollbar-track {
    background: transparent;
}

#chatContainer::-webkit-scrollbar-thumb {
    background: rgba(203, 213, 225, 0.5);
    border-radius: 10px;
}

#chatContainer::-webkit-scrollbar-thumb:hover {
    background: rgba(148, 163, 184, 0.6);
}

/* Custom scrollbar for drafting chat container */
#draftChatContainer::-webkit-scrollbar {
    width: 6px;
}

#draftChatContainer::-webkit-scrollbar-track {
    background: transparent;
}

#draftChatContainer::-webkit-scrollbar-thumb {
    background: rgba(203, 213, 225, 0.5);
    border-radius: 10px;
}

#draftChatContainer::-webkit-scrollbar-thumb:hover {
    background: rgba(148, 163, 184, 0.6);
}

/* Custom scrollbar for redlining list */
#redliningIssuesList::-webkit-scrollbar {
    width: 5px;
}

#redliningIssuesList::-webkit-scrollbar-track {
    background: rgba(214, 211, 209, 0.3);
    border-radius: 10px;
}

#redliningIssuesList::-webkit-scrollbar-thumb {
    background: rgba(168, 162, 158, 0.4);
    border-radius: 10px;
}

#redliningIssuesList::-webkit-scrollbar-thumb:hover {
    background: rgba(120, 113, 108, 0.5);
}

/* Custom scrollbar for settings panel */
#settingsPanel::-webkit-scrollbar {
    width: 6px;
}

#settingsPanel::-webkit-scrollbar-track {
    background: transparent;
}

#settingsPanel::-webkit-scrollbar-thumb {
    background: rgba(203, 213, 225, 0.5);
    border-radius: 10px;
}

#settingsPanel::-webkit-scrollbar-thumb:hover {
    background: rgba(148, 163, 184, 0.6);
}

/* ==================== ANIMATIONS ==================== */
/* Smooth animations */
.fade-in {
    animation: fadeIn 0.4s ease-out;
}

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

.spinner {
    width: 16px;
    height: 16px;
    background-image: url('/assets/lexi-logo.png');
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    animation: spin 1s linear infinite;
}

/* Larger spinner for email search, redlining, etc. */
#emailSearchLoadingState .spinner {
    width: 24px;
    height: 24px;
}

/* Small spinner for inline loading states */
.spinner-small {
    width: 12px;
    height: 12px;
    background-image: url('/assets/lexi-logo.png');
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    animation: spin 1s linear infinite;
    display: inline-block;
    vertical-align: middle;
}

/* Inverted spinner for dark backgrounds */
.spinner-inverted {
    filter: invert(1) brightness(2);
}

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

/* Tailwind-style animate-spin for compatibility */
.animate-spin {
    animation: spin 1s linear infinite;
}

/* ==================== MESSAGE BUBBLES ==================== */
/* Product design: user gets a soft grey bubble (#e7e7e6, the frontend's
   bg_color.messagebox); assistant text is bubble-less and full width —
   at taskpane width every pixel of line length matters. */
.message-user {
    background: #e7e7e6;
    box-shadow: none;
    color: #0f172a;
}

.message-assistant {
    background: transparent;
    box-shadow: none;
    border: none;
    max-width: 100% !important;
    padding-left: 4px !important;
    padding-right: 4px !important;
    padding-top: 6px !important;
    padding-bottom: 6px !important;
}

/* Assistant body text tone (frontend: text-gray-800) */
.message-assistant .markdown-content {
    color: #1f2937;
}

/* Narration text blocks — the prose the model emits between tool calls.
   Visible but muted (frontend TextBlockRenderer: text-gray-500), never
   hidden or dropped at completion. */
.message-assistant .markdown-content.msg-narration {
    color: #6b7280;
}

/* Per-block streamed text elements stack inside one bubble */
.message-assistant .stream-text-block + .stream-text-block {
    margin-top: 10px;
}

/* Streaming caret at the end of the live assistant message (last block only) */
.message-wrapper[data-streaming="true"] .markdown-content:last-child > :last-child::after {
    content: '';
    display: inline-block;
    width: 7px;
    height: 13px;
    margin-left: 3px;
    vertical-align: baseline;
    background: #cbd5e1;
    border-radius: 2px;
    animation: caretBlink 1s steps(1) infinite;
}

@keyframes caretBlink {
    0%, 60% { opacity: 1; }
    61%, 100% { opacity: 0; }
}

/* ==================== BUTTONS ==================== */
/* Modern focus effect with stone/beige */
.glow-focus:focus {
    outline: none;
    border-color: rgba(87, 83, 78, 0.5);
    box-shadow: 0 0 0 3px rgba(87, 83, 78, 0.1);
}

/* Button styles - product brand action color */
.btn-primary {
    background: #0f172a;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.btn-primary:hover:not(:disabled) {
    background: #1e293b;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(15, 23, 42, 0.25);
}

.btn-primary:active:not(:disabled) {
    transform: translateY(0);
}

.btn-primary:disabled {
    background: #94a3b8;
    cursor: not-allowed;
    opacity: 0.6;
}

/* Header action buttons */
.header-action-btn {
    color: #64748b;
    font-size: 13px;
    font-weight: 500;
    padding: 6px 12px;
    border-radius: 8px;
    transition: all 0.2s ease;
    background: transparent;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
}

.header-action-btn:hover {
    background: rgba(241, 245, 249, 0.8);
    color: #475569;
}

.header-action-btn svg {
    width: 16px;
    height: 16px;
}

/* Icon button styling */
.icon-btn {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    background: transparent;
    color: #64748b;
    cursor: pointer;
    transition: all 0.2s ease;
}

.icon-btn:hover {
    background: rgba(241, 245, 249, 0.8);
    color: #475569;
}

/* ==================== ATTACHMENT INDICATORS ==================== */
.attachment-indicators {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 6px;
}
.attachment-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    border-radius: 12px;
    background: #f1f5f9;
    color: #64748b;
    font-size: 11px;
    font-weight: 500;
}
.attachment-badge svg {
    flex-shrink: 0;
}
.attachment-badge-count {
    font-weight: 600;
}

/* ==================== MESSAGE ATTACHMENT CHIPS (inside user bubble) ==================== */
.msg-attach-row {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    margin-top: 6px;
    padding-top: 6px;
    border-top: 1px solid rgba(0, 0, 0, 0.08);
}
.msg-attach-chip {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    font-size: 10px;
    font-weight: 500;
    color: #78716c;
    background: rgba(0, 0, 0, 0.05);
    border-radius: 4px;
    padding: 2px 6px;
    line-height: 1;
    letter-spacing: 0.01em;
}
.msg-attach-chip svg {
    opacity: 0.7;
    flex-shrink: 0;
}

/* ==================== TOOL STATUS OVERLAY ==================== */
.tool-status-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 5;
    pointer-events: none;
    overflow: hidden;
}
.tool-status-overlay:not(:empty) {
    padding: 6px 12px;
    background: linear-gradient(transparent, rgba(255,255,255,0.95) 20%);
}
.tool-status-overlay > * {
    pointer-events: auto;
}

/* ==================== NARROW-WIDTH GUARDS ==================== */
/* The pane is a fixed ~320-450px column. Mirror the frontend's
   .contract-review-chat clamp: nothing inside the transcript may force
   horizontal scroll; wide content scrolls inside its own container. */
#chatContainer,
#draftChatContainer {
    overflow-x: hidden;
}
#chatContainer .markdown-content,
#draftChatContainer .markdown-content {
    overflow-wrap: break-word;
    word-break: break-word;
    min-width: 0;
}
.markdown-content img {
    max-width: 100%;
}

/* ==================== MARKDOWN CONTENT ==================== */
.markdown-content h1 { font-size: 16px; font-weight: 700; margin: 8px 0 4px; }
.markdown-content h2 { font-size: 14px; font-weight: 700; margin: 8px 0 4px; }
.markdown-content h3 { font-size: 13px; font-weight: 600; margin: 6px 0 3px; }
.markdown-content p { margin: 4px 0; }
.markdown-content > :first-child { margin-top: 0; padding-top: 0; line-height: 1.4; }
.markdown-content ul { margin: 4px 0; padding-left: 20px; list-style-type: disc; }
.markdown-content ol { margin: 4px 0; padding-left: 20px; list-style-type: decimal; }
.markdown-content li { margin: 2px 0; display: list-item; }
.markdown-content strong { font-weight: 600; }
.markdown-content em { font-style: italic; }
.markdown-content code {
    background: #f1f5f9;
    padding: 1px 4px;
    border-radius: 3px;
    font-size: 12px;
    font-family: 'Consolas', 'Monaco', monospace;
}
.markdown-content pre {
    background: #f1f5f9;
    padding: 8px;
    border-radius: 6px;
    overflow-x: auto;
    margin: 6px 0;
}
.markdown-content pre code {
    background: none;
    padding: 0;
}
.markdown-content blockquote {
    border-left: 3px solid #cbd5e1;
    padding-left: 10px;
    margin: 6px 0;
    color: #64748b;
}
.markdown-content a {
    color: #2563eb;
    text-decoration: underline;
}
.markdown-content hr {
    border: none;
    border-top: 1px solid #e2e8f0;
    margin: 8px 0;
}
.markdown-content table {
    border-collapse: collapse;
    margin: 6px 0;
    font-size: 12px;
    width: 100%;
    /* Wide tables scroll inside their own box instead of overflowing the pane */
    display: block;
    overflow-x: auto;
    max-width: 100%;
}
.markdown-content th, .markdown-content td {
    border: 1px solid #e2e8f0;
    padding: 4px 8px;
    text-align: left;
}
.markdown-content th {
    background: #f8fafc;
    font-weight: 600;
}

/* ==================== LOADING STATUS ==================== */
.loading-pulse-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #64748b;
    animation: loadingPulse 1.5s ease-in-out infinite;
    flex-shrink: 0;
}

@keyframes loadingPulse {
    0%, 100% { opacity: 0.4; transform: scale(0.85); }
    50% { opacity: 1; transform: scale(1.1); }
}

/* ==================== TRUNCATED TEXT ==================== */
.truncated-text {
    display: -webkit-box;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.truncate-expand-btn {
    cursor: pointer;
    background: none;
    border: none;
    padding: 0;
    font-size: 12px;
    color: #b45309;
    font-weight: 500;
}

.truncate-expand-btn:hover {
    color: #92400e;
}

/* Hidden state */
.hidden {
    display: none;
}

/* ==================== CITATION MARKER CHIPS ==================== */
/* v2 citation markers ([KB1]/[WS2]...) render as icon+number chips:
   globe = web, page = KB/document, lined page = current doc, scales = precedent */
.cite-marker {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    /* Sit on the text baseline with a slight lift — vertical-align: super
       pushed pills above the line and broke alignment */
    vertical-align: 0.18em;
    font-size: 9px;
    font-weight: 600;
    line-height: 1;
    letter-spacing: 0.02em;
    white-space: nowrap;
    color: #475569;
    background: #e2e8f0;
    border-radius: 999px;
    padding: 2.5px 5px;
    margin: 0 2px;
    cursor: pointer;
    transition: background 0.12s ease, color 0.12s ease;
    user-select: none;
}

.cite-marker svg {
    display: block;
    flex: none;
    opacity: 0.75;
}

.cite-marker-num {
    display: block;
}

.cite-marker:hover {
    background: #cbd5e1;
    color: #1e293b;
}

.cite-marker.cite-marker-busy {
    opacity: 0.55;
    cursor: progress;
}

.cite-marker-pin {
    display: block;
    margin-left: 3px;
    opacity: 0.8;
}
