/**
 * Conversation History UI Styles
 * Based on MOCKUP_Conversation_History_UI_v8.html
 * RTL/LTR aware, WCAG 2.2 AAA compliant
 */

/* ===========================================
   CSS CUSTOM PROPERTIES
   =========================================== */
:root {
    --ch-font-scale: 1.0;
    --ch-base-font-size: calc(14px * var(--ch-font-scale));
    --ch-large-font-size: calc(18px * var(--ch-font-scale));
    --ch-xlarge-font-size: calc(24px * var(--ch-font-scale));
    --ch-doc-title-size: calc(26px * var(--ch-font-scale));
    --ch-section-title-size: calc(20px * var(--ch-font-scale));

    /* Evenly brand colors - WCAG 2.2 AAA compliant */
    --ch-evenly-blue: #1565C0;
    --ch-evenly-blue-dark: #0D47A1;
    --ch-evenly-blue-light: #1976D2;
    --ch-evenly-orange: #E65100;
    --ch-evenly-orange-dark: #BF360C;
    --ch-evenly-green: #2E7D32;
    --ch-evenly-green-dark: #1B5E20;
    --ch-evenly-red: #C62828;
    --ch-evenly-red-dark: #B71C1C;

    /* Focus indicator color - high contrast */
    --ch-focus-color: #0D47A1;
    --ch-focus-outline: 3px solid var(--ch-focus-color);
}

/* ===========================================
   BASE LAYOUT
   =========================================== */
body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: #f5f7fa;
    color: #212121;
    overflow-y: auto; /* Allow vertical scrolling when content exceeds viewport */
    font-size: var(--ch-base-font-size);
}

/* ===========================================
   TOP BAR
   =========================================== */
.ch-top-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    background: white;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.ch-logo-section {
    display: flex;
    align-items: center;
    gap: 16px;
}

.ch-logo-img {
    height: calc(50px * var(--ch-font-scale));
    width: auto;
}

.ch-product-name {
    font-size: calc(32px * var(--ch-font-scale));
    font-weight: 700;
    color: var(--ch-evenly-blue);
}

.ch-top-bar-controls {
    display: flex;
    align-items: center;
    gap: 16px;
    position: relative;  /* Creates positioning context for language menu */
}

/* RTL: Reverse order of top bar controls */
[dir="rtl"] .ch-top-bar-controls {
    flex-direction: row-reverse;
}

/* ===========================================
   KEYBOARD INDICATOR
   =========================================== */
.ch-keyboard-indicator {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: calc(11px * var(--ch-font-scale));
    color: #616161;
    padding: 4px 8px;
    background: #f5f5f5;
    border-radius: 3px;
    border: 1px solid #e0e0e0;
}

.ch-keyboard-indicator .ch-icon {
    font-size: calc(14px * var(--ch-font-scale));
}

/* ===========================================
   FONT SIZE CONTROLS
   =========================================== */
.ch-font-controls {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 6px 10px;
    background: #f5f5f5;
    border-radius: 4px;
    border: 1px solid #999;
}

.ch-font-control-btn {
    background: white;
    border: 2px solid #666;
    border-radius: 4px;
    width: 32px;
    height: 32px;
    cursor: pointer;
    font-size: var(--ch-large-font-size);
    font-weight: bold;
    color: #212121;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.ch-font-control-btn:hover {
    background: var(--ch-evenly-blue);
    color: white;
    border-color: var(--ch-evenly-blue);
}

.ch-font-control-btn:focus {
    outline: var(--ch-focus-outline);
    outline-offset: 2px;
}

.ch-font-control-label {
    font-size: calc(12px * var(--ch-font-scale));
    color: #212121;
    margin-left: 4px;
    font-weight: 500;
}

/* RTL: Reverse margin */
[dir="rtl"] .ch-font-control-label {
    margin-left: 0;
    margin-right: 4px;
}

/* ===========================================
   LANGUAGE SELECTOR
   =========================================== */
.ch-language-selector {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: #f5f5f5;
    border-radius: 4px;
    cursor: pointer;
    border: 2px solid #999;
    position: relative;
}

.ch-language-selector:hover {
    background: #e0e0e0;
    border-color: #666;
}

.ch-language-selector:focus {
    outline: var(--ch-focus-outline);
    outline-offset: 2px;
}

.ch-language-flag {
    font-size: calc(20px * var(--ch-font-scale));
}

.ch-language-name {
    font-size: var(--ch-base-font-size);
    font-weight: 600;
    color: #212121;
}

/* Language menu dropdown - hidden by default, shown via JS */
#languageMenu {
    display: none;
}

.ch-language-menu {
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 8px;
    background: white;
    border: 3px solid #2E7D32;
    border-radius: 4px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.3);
    padding: 8px;
    z-index: 1000;
    max-height: 400px;
    overflow-y: auto;
    min-width: 200px;
}

/* RTL: Position from left instead of right */
[dir="rtl"] .ch-language-menu {
    right: auto;
    left: 0;
}

.ch-language-option {
    padding: 10px 16px;
    cursor: pointer;
    border-radius: 4px;
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: var(--ch-base-font-size);
    color: #212121;
    font-weight: 500;
}

.ch-language-option:hover {
    background: #e0e0e0;
}

.ch-language-option:focus {
    outline: var(--ch-focus-outline);
    outline-offset: -2px;
}

/* ===========================================
   WORKFLOW CONTROL BAR
   =========================================== */
.ch-voice-control-bar {
    background: linear-gradient(135deg, var(--ch-evenly-blue) 0%, var(--ch-evenly-blue-dark) 100%);
    padding: 20px;
    margin: 10px 20px;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(21, 101, 192, 0.3);
}

.ch-voice-actions {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
}

/* RTL: Reverse flow direction */
[dir="rtl"] .ch-voice-actions {
    flex-direction: row-reverse;
}

/* ===========================================
   MULTI-STATE DRAG & DROP UPLOAD BUTTON
   =========================================== */
.ch-upload-drop-zone {
    position: relative;
    width: 250px;
    min-height: 65px;
    padding: 12px 16px;
    background: white;
    border: 3px solid var(--ch-evenly-green);
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    overflow: hidden;
}

/* Breathe animation for idle state */
@keyframes ch-breathe {
    0%, 100% {
        border-color: var(--ch-evenly-green);
        box-shadow: 0 4px 12px rgba(46, 125, 50, 0.15);
    }
    50% {
        border-color: var(--ch-evenly-green-dark);
        box-shadow: 0 4px 16px rgba(46, 125, 50, 0.3);
    }
}

.ch-upload-drop-zone:not(.dragging):not(.uploading):not(.processing):not(.ready):not(.error) {
    animation: ch-breathe 3s ease-in-out infinite;
}

.ch-upload-drop-zone:hover:not(.uploading):not(.processing) {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(0,0,0,0.2);
}

.ch-upload-drop-zone:focus {
    outline: 4px solid white;
    outline-offset: 2px;
}

.ch-upload-icon {
    font-size: calc(24px * var(--ch-font-scale));
    line-height: 1;
    transition: all 0.3s ease;
}

.ch-upload-text-primary {
    font-size: calc(16px * var(--ch-font-scale));
    font-weight: 700;
    color: var(--ch-evenly-green);
    line-height: 1.2;
    transition: all 0.3s ease;
}

.ch-upload-text-secondary {
    font-size: calc(11px * var(--ch-font-scale));
    color: #616161;
    line-height: 1;
    transition: all 0.3s ease;
}

/* Drag-over state - blue glow */
.ch-upload-drop-zone.dragging {
    border-style: solid;
    border-color: var(--ch-evenly-blue);
    background: #E3F2FD;
    box-shadow: 0 0 20px rgba(21, 101, 192, 0.6);
    animation: none;
}

.ch-upload-drop-zone.dragging .ch-upload-icon {
    font-size: calc(32px * var(--ch-font-scale));
}

.ch-upload-drop-zone.dragging .ch-upload-text-primary {
    color: var(--ch-evenly-blue);
    font-size: calc(18px * var(--ch-font-scale));
}

.ch-upload-drop-zone.dragging .ch-upload-text-secondary {
    display: none;
}

/* Uploading state - green pulse */
@keyframes ch-pulse-green {
    0%, 100% {
        transform: scale(1);
        box-shadow: 0 4px 12px rgba(46, 125, 50, 0.4);
    }
    50% {
        transform: scale(1.02);
        box-shadow: 0 4px 20px rgba(46, 125, 50, 0.8);
    }
}

.ch-upload-drop-zone.uploading {
    border-style: solid;
    border-color: var(--ch-evenly-green);
    background: var(--ch-evenly-green);
    animation: ch-pulse-green 1.5s infinite;
    cursor: wait;
}

.ch-upload-drop-zone.uploading .ch-upload-text-primary {
    color: white;
    font-size: calc(16px * var(--ch-font-scale));
}

.ch-upload-drop-zone.uploading .ch-upload-text-secondary {
    display: none;
}

/* Processing state - animated gear */
@keyframes ch-spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.ch-upload-drop-zone.processing {
    border-style: solid;
    border-color: var(--ch-evenly-blue);
    background: var(--ch-evenly-blue);
    cursor: wait;
}

.ch-upload-drop-zone.processing .ch-upload-icon {
    animation: ch-spin 2s linear infinite;
}

.ch-upload-drop-zone.processing .ch-upload-text-primary {
    color: white;
    font-size: calc(16px * var(--ch-font-scale));
}

.ch-upload-drop-zone.processing .ch-upload-text-secondary {
    display: none;
}

/* Active state (orange) for upload/processing - Task A */
.ch-upload-drop-zone.active {
    border-color: var(--ch-evenly-orange) !important;
    background: var(--ch-evenly-orange) !important;
    animation: ch-pulse-orange 1.5s infinite;
}

/* Ready state - solid green with checkmark */
.ch-upload-drop-zone.ready {
    border-style: solid;
    border-color: var(--ch-evenly-green);
    background: var(--ch-evenly-green);
    cursor: pointer;
}

.ch-upload-drop-zone.ready .ch-upload-icon {
    color: white;
}

.ch-upload-drop-zone.ready .ch-upload-text-primary {
    color: white;
    font-size: calc(16px * var(--ch-font-scale));
}

.ch-upload-drop-zone.ready .ch-upload-text-secondary {
    color: rgba(255, 255, 255, 0.9);
    font-size: calc(11px * var(--ch-font-scale));
}

/* Error state - red warning */
.ch-upload-drop-zone.error {
    border-style: solid;
    border-color: var(--ch-evenly-red);
    background: var(--ch-evenly-red);
    cursor: pointer;
}

.ch-upload-drop-zone.error .ch-upload-text-primary {
    color: white;
    font-size: calc(15px * var(--ch-font-scale));
}

.ch-upload-drop-zone.error .ch-upload-text-secondary {
    color: rgba(255, 255, 255, 0.9);
    font-size: calc(11px * var(--ch-font-scale));
}

/* Hidden file input */
.ch-file-input {
    display: none;
}

/* ===========================================
   VOICE CONVERSATION & READ BUTTONS
   =========================================== */
.ch-voice-conversation-btn,
.ch-action-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 16px 32px;
    background: white;
    color: var(--ch-evenly-blue);
    border: 3px solid white;
    border-radius: 4px;
    font-size: var(--ch-large-font-size);
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    white-space: nowrap;
    position: relative;
}

.ch-voice-conversation-btn:hover,
.ch-action-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(0,0,0,0.2);
}

.ch-voice-conversation-btn:focus,
.ch-action-btn:focus {
    outline: 4px solid white;
    outline-offset: 2px;
}

/* Orange pulse for Voice and Read buttons when active */
@keyframes ch-pulse-orange {
    0%, 100% {
        transform: scale(1);
        box-shadow: 0 4px 12px rgba(230, 81, 0, 0.4);
    }
    50% {
        transform: scale(1.02);
        box-shadow: 0 4px 20px rgba(230, 81, 0, 0.8);
    }
}

.ch-voice-conversation-btn.active,
.ch-action-btn.active {
    background: var(--ch-evenly-orange);
    color: white;
    border-color: var(--ch-evenly-orange);
    animation: ch-pulse-orange 1.5s infinite;
}

/* Disabled state */
.ch-voice-conversation-btn:disabled,
.ch-action-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    transform: none;
}

.ch-voice-conversation-btn:disabled:hover,
.ch-action-btn:disabled:hover {
    transform: none;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

/* ===========================================
   FLOW ARROW INDICATOR
   =========================================== */
.ch-flow-arrow {
    font-size: calc(24px * var(--ch-font-scale));
    color: rgba(255, 255, 255, 0.6);
    font-weight: bold;
    -webkit-user-select: none;
    user-select: none;
    transition: all 0.3s ease;
}

/* RTL: Flip arrow direction */
[dir="rtl"] .ch-flow-arrow {
    transform: scaleX(-1);
}

.ch-flow-arrow.active {
    color: rgba(255, 255, 255, 1);
    animation: ch-arrow-pulse 1s ease-in-out;
}

@keyframes ch-arrow-pulse {
    0%, 100% { transform: translateX(0); opacity: 1; }
    50% { transform: translateX(5px); opacity: 0.7; }
}

/* RTL: Reverse arrow pulse direction */
[dir="rtl"] .ch-flow-arrow.active {
    animation: ch-arrow-pulse-rtl 1s ease-in-out;
}

@keyframes ch-arrow-pulse-rtl {
    0%, 100% { transform: translateX(0) scaleX(-1); opacity: 1; }
    50% { transform: translateX(-5px) scaleX(-1); opacity: 0.7; }
}

/* Voice icon */
.ch-voice-icon {
    font-size: calc(28px * var(--ch-font-scale));
    display: flex;
    align-items: center;
}

/* ===========================================
   MAIN CONTAINER WITH RESIZABLE PANELS
   =========================================== */
.ch-main-container {
    display: flex;
    height: calc(100vh - 240px);
    max-height: calc(100vh - 240px);
    padding: 0 20px 20px 20px;
    gap: 0;
    overflow: hidden;
}

/* RTL: Reverse panel order */
[dir="rtl"] .ch-main-container {
    flex-direction: row-reverse;
}

/* ===========================================
   CHAT PANEL (LEFT / RIGHT IN RTL)
   =========================================== */
.ch-chat-panel {
    background: white;
    border-radius: 8px 0 0 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-width: 300px;
    max-width: 600px;
    flex: 0 0 400px;
    height: 100%;
    max-height: 100%;
}

/* RTL: Reverse border radius */
[dir="rtl"] .ch-chat-panel {
    border-radius: 0 8px 8px 0;
}

/* Chat header */
.ch-chat-header {
    background: linear-gradient(135deg, var(--ch-evenly-blue) 0%, var(--ch-evenly-blue-dark) 100%);
    color: white;
    padding: 16px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}

.ch-chat-title {
    font-size: calc(20px * var(--ch-font-scale));
    font-weight: 700;
    color: white;
}

.ch-chat-title-icon {
    font-size: 24px;
}

.ch-chat-actions {
    display: flex;
    gap: 8px;
}

/* Icon buttons with white background */
.ch-icon-btn {
    background: white;
    border: 2px solid white;
    color: var(--ch-evenly-blue);
    padding: 10px 16px;
    border-radius: 4px;
    cursor: pointer;
    font-size: calc(15px * var(--ch-font-scale));
    display: flex;
    align-items: center;
    gap: 6px;
    transition: all 0.2s;
    font-weight: 600;
}

.ch-icon-btn:hover {
    background: #f5f5f5;
    transform: translateY(-1px);
}

.ch-icon-btn:focus {
    outline: 4px solid white;
    outline-offset: 2px;
}

.ch-icon-btn .ch-icon {
    font-size: calc(16px * var(--ch-font-scale));
}

/* ===========================================
   CHAT MESSAGES AREA
   =========================================== */
.ch-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.ch-message {
    display: flex;
    flex-direction: column;
    gap: 6px;
    max-width: 85%;
}

.ch-message.user {
    align-self: flex-end;
}

.ch-message.assistant {
    align-self: flex-start;
}

/* RTL: Swap message alignment */
[dir="rtl"] .ch-message.user {
    align-self: flex-start;
}

[dir="rtl"] .ch-message.assistant {
    align-self: flex-end;
}

.ch-message-header {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: calc(12px * var(--ch-font-scale));
    color: #424242;
}

.ch-message-sender {
    font-weight: 600;
}

.ch-message-time {
    color: #616161;
}

.ch-message-content {
    padding: 12px 16px;
    border-radius: 8px;
    font-size: var(--ch-base-font-size);
    line-height: 1.6;
}

.ch-message.user .ch-message-content {
    background: #E3F2FD;
    color: #0D47A1;
    border-bottom-right-radius: 2px;
}

.ch-message.assistant .ch-message-content {
    background: #f5f5f5;
    color: #212121;
    border-bottom-left-radius: 2px;
}

/* Narration messages - full width, minimal background */
.ch-message.narration {
    align-self: stretch;
    max-width: 100%;
}

.ch-message.narration .ch-message-content {
    /* Seamlessly integrated with chat - minimal styling to avoid "pane within pane" appearance */
    background: transparent;
    color: #212121;
    padding: 0.5rem 1rem;
    font-size: 0.9rem;
    line-height: 1.6;
    white-space: pre-wrap;
    /* No border-radius, no distinct background - flows naturally with chat */
}

/* System messages - no background, minimal styling */
.ch-message.system {
    align-self: stretch;
    max-width: 100%;
}

.ch-message.system .ch-message-content {
    background: transparent;
    padding: 0.5rem 0;
    border-radius: 0;
}

/* RTL: Swap bubble corners */
[dir="rtl"] .ch-message.user .ch-message-content {
    border-bottom-right-radius: 8px;
    border-bottom-left-radius: 2px;
}

[dir="rtl"] .ch-message.assistant .ch-message-content {
    border-bottom-left-radius: 8px;
    border-bottom-right-radius: 2px;
}

/* ===========================================
   CHAT INPUT AREA
   =========================================== */
.ch-chat-input-wrapper {
    padding: 12px 20px 12px 20px;
    border-top: 1px solid #bdbdbd;
    display: flex;
    gap: 10px;
    align-items: flex-end;
    flex-shrink: 0;
}

.ch-chat-input {
    flex: 1;
    padding: 12px 16px;
    border: 2px solid #757575;
    border-radius: 4px;
    font-size: var(--ch-base-font-size);
    font-family: inherit;
    line-height: 1.5;
    resize: vertical;
    min-height: 90px;
    max-height: 200px;
    color: #212121;
}

.ch-chat-input:focus {
    outline: none;
    border-color: var(--ch-evenly-blue);
    box-shadow: 0 0 0 3px rgba(21, 101, 192, 0.2);
}

.ch-send-btn {
    background: var(--ch-evenly-blue);
    color: white;
    border: none;
    padding: 12px 20px;
    border-radius: 4px;
    cursor: pointer;
    font-size: var(--ch-base-font-size);
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
    flex-shrink: 0;
}

.ch-send-btn:hover {
    background: var(--ch-evenly-blue-dark);
}

.ch-send-btn:focus {
    outline: var(--ch-focus-outline);
    outline-offset: 2px;
}

/* ===========================================
   RESIZER
   =========================================== */
.ch-resizer {
    width: 8px;
    background: #bdbdbd;
    cursor: col-resize;
    position: relative;
    flex-shrink: 0;
}

.ch-resizer:hover,
.ch-resizer:focus {
    background: var(--ch-evenly-blue);
}

.ch-resizer:focus {
    outline: var(--ch-focus-outline);
    outline-offset: 0;
}

.ch-resizer::before {
    content: '⋮';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: #424242;
    font-size: calc(20px * var(--ch-font-scale));
}

/* ===========================================
   DOCUMENT PANEL (RIGHT / LEFT IN RTL)
   =========================================== */
.ch-document-panel {
    background: white;
    border-radius: 0 8px 8px 0;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-width: 400px;
    flex: 1;
}

/* RTL: Reverse border radius */
[dir="rtl"] .ch-document-panel {
    border-radius: 8px 0 0 8px;
}

/* ===========================================
   EMPTY STATE
   =========================================== */
.ch-empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    padding: 40px;
    text-align: center;
    color: #616161;
}

.ch-empty-state-icon {
    font-size: calc(64px * var(--ch-font-scale));
    margin-bottom: 20px;
    opacity: 0.5;
}

.ch-empty-state-title {
    font-size: var(--ch-xlarge-font-size);
    font-weight: 600;
    color: #424242;
    margin-bottom: 12px;
}

.ch-empty-state-description {
    font-size: var(--ch-base-font-size);
    line-height: 1.6;
    max-width: 400px;
}

/* ===========================================
   DOCUMENT HEADER
   =========================================== */
.ch-document-header {
    background: #f9f9f9;
    padding: 20px;
    border-bottom: 2px solid #bdbdbd;
}

.ch-document-info-container {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
}

/* RTL: Reverse flex direction */
[dir="rtl"] .ch-document-info-container {
    flex-direction: row-reverse;
}

.ch-document-info {
    flex: 1;
}

.ch-document-title {
    font-size: var(--ch-doc-title-size);
    font-weight: 600;
    color: #212121;
    margin-bottom: 12px;
    line-height: 1.3;
}

.ch-document-description {
    font-size: calc(16px * var(--ch-font-scale));
    color: #424242;
    line-height: 1.5;
    margin-bottom: 16px;
}

.ch-document-metadata {
    font-size: var(--ch-base-font-size);
    color: #424242;
    line-height: 1.6;
}

/* ===========================================
   EXPAND ALL BUTTON
   =========================================== */
.ch-expand-all-btn {
    padding: 10px 20px;
    background: white;
    color: var(--ch-evenly-blue);
    border: 2px solid #999;
    border-radius: 4px;
    cursor: pointer;
    font-size: var(--ch-base-font-size);
    font-weight: 600;
    white-space: nowrap;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 8px;
    margin-left: 16px;
    align-self: flex-start;
}

/* RTL: Swap margin */
[dir="rtl"] .ch-expand-all-btn {
    margin-left: 0;
    margin-right: 16px;
}

.ch-expand-all-btn:hover {
    background: #f5f5f5;
    border-color: #666;
}

.ch-expand-all-btn:focus {
    outline: var(--ch-focus-outline);
    outline-offset: 2px;
}

/* ===========================================
   DOCUMENT SECTIONS
   =========================================== */
.ch-document-content {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
}

.ch-section {
    background: #f9f9f9;
    border: 2px solid #bdbdbd;
    border-radius: 4px;
    margin-bottom: 16px;
    overflow: hidden;
}

.ch-section-header {
    padding: 16px 20px;
    background: white;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: background 0.2s;
}

.ch-section-header:hover {
    background: #f5f5f5;
}

.ch-section-header:focus {
    outline: var(--ch-focus-outline);
    outline-offset: -3px;
}

.ch-section-title {
    font-size: var(--ch-section-title-size);
    font-weight: 600;
    color: #212121;
    flex: 1;
}

.ch-section-toggle {
    color: var(--ch-evenly-blue);
    font-size: var(--ch-base-font-size);
    font-weight: 600;
    margin-left: 16px;
}

/* RTL: Swap margin */
[dir="rtl"] .ch-section-toggle {
    margin-left: 0;
    margin-right: 16px;
}

.ch-section-content {
    padding: 16px 20px;
    /* Always visible - no collapsing */
    display: block;
}

.ch-section.expanded .ch-section-toggle::before {
    content: 'Details ▼';
}

.ch-section-toggle::before {
    content: 'Details >';
}

/* RTL: Reverse arrow direction */
[dir="rtl"] .ch-section-toggle::before {
    content: 'Details <';
}

[dir="rtl"] .ch-section.expanded .ch-section-toggle::before {
    content: 'Details ▼';
}

.ch-section-pages {
    font-size: var(--ch-base-font-size);
    color: #424242;
    margin-bottom: 12px;
    font-weight: 500;
}

.ch-section-entities {
    font-size: var(--ch-base-font-size);
    color: #212121;
    line-height: 1.8;
}

.ch-section-entities strong {
    color: #212121;
    font-weight: 700;
}

/* ===========================================
   SCROLLBAR STYLING
   =========================================== */
.ch-chat-messages::-webkit-scrollbar,
.ch-document-content::-webkit-scrollbar {
    width: 12px;
}

.ch-chat-messages::-webkit-scrollbar-track,
.ch-document-content::-webkit-scrollbar-track {
    background: #e0e0e0;
    border-radius: 4px;
}

.ch-chat-messages::-webkit-scrollbar-thumb,
.ch-document-content::-webkit-scrollbar-thumb {
    background: #9e9e9e;
    border-radius: 4px;
}

.ch-chat-messages::-webkit-scrollbar-thumb:hover,
.ch-document-content::-webkit-scrollbar-thumb:hover {
    background: #757575;
}

/* ===========================================
   ACCESSIBILITY - REDUCED MOTION
   =========================================== */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* ===========================================
   DOCUMENT LOADED STATE - LAYOUT FIXES
   =========================================== */
/* Hidden by default, shown via JS when document is loaded */
#documentLoaded {
    display: none;
}

.ch-document-loaded {
    flex-direction: column;
    height: 100%;
    overflow: hidden;
}

.ch-document-header {
    flex-shrink: 0;
    position: relative;
    z-index: 1;
}

/* Document info container - full width layout */
.ch-document-info-container {
    width: 100%;
    max-width: 100%;
    display: flex;
    flex-direction: column;
}

.ch-document-info {
    width: 100%;
    max-width: 100%;
    flex: 1;
}

.ch-document-description {
    width: 100%;
    max-width: 100%;
}

.ch-document-metadata {
    width: 100%;
    max-width: 100%;
    margin-top: 12px;
}

/* Document title - increased font size */
.ch-document-title {
    font-size: 28px;
}

/* Section title - increased font size */
.ch-section-title {
    font-size: 20px;
}

/* Document content scroll area */
.ch-document-content {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 20px;
    position: relative;
    z-index: 0;
}

/* Document panel - hide overflow */
.ch-document-panel {
    overflow: hidden;
}

/* ===========================================
   COLLAPSIBLE SECTIONS
   =========================================== */
.ch-section {
    background: #f9f9f9;
    border: 1px solid #e0e0e0;
    border-radius: 4px;
    margin-bottom: 12px;
    position: relative;
}

.ch-section-header {
    padding: 12px 16px;
    background: #f0f0f0;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #e0e0e0;
}

.ch-section-header:hover {
    background: #e8e8e8;
}

/* Section title row - stacked layout */
.ch-section-title-row {
    display: flex;
    flex-direction: column;
    gap: 6px;
    flex: 1;
}

.ch-section-pages {
    font-size: 13px;
    color: #757575;
    font-weight: normal;
}

.ch-section-title {
    font-size: 16px;
    font-weight: 600;
    color: #212121;
    margin: 0;
}

.ch-section-toggle {
    font-size: 14px;
    color: #666;
    -webkit-user-select: none;
    user-select: none;
}

/* Hide default toggle text, use arrow from JS */
.ch-section-toggle::before {
    content: '';
}

/* Section content - visible by default */
.ch-section-content {
    display: block;
    padding: 16px 20px;
    background: #ffffff;
}

.ch-section-summary {
    font-size: 14px;
    line-height: 1.6;
    color: #424242;
    margin-bottom: 12px;
}

/* Section entities */
.ch-section-entities {
    margin-top: 16px;
}

.ch-section-entities-title {
    font-size: 13px;
    font-weight: 600;
    color: #616161;
    margin-bottom: 8px;
}

.ch-entity-item {
    font-size: 13px;
    padding: 6px 10px;
    margin-bottom: 4px;
    background: #f5f5f5;
    border-left: 3px solid #2196f3;
    border-radius: 2px;
}

.ch-entity-name {
    font-weight: 600;
    color: #1976d2;
}

.ch-entity-value {
    color: #424242;
}

/* Collapsed section - hide content */
.ch-section.collapsed .ch-section-content {
    display: none;
}
