/* Dashboard styles for transformer visualization app */

/* Global styles */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', sans-serif;
    background-color: #f8f9fa;
    color: #333;
}

/* App wrapper */
.app-wrapper {
    min-height: 100vh;
    background-color: #f8f9fa;
}

.app-container {
    max-width: 1400px;
    margin: 0 auto;
    background-color: white;
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.1);
}

/* Header */
.header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 2rem;
    text-align: center;
}

.header-title {
    font-size: 2.5rem;
    font-weight: 300;
    margin-bottom: 0.5rem;
}

.header-subtitle {
    font-size: 1.1rem;
    opacity: 0.9;
}

/* Content container */
.content-container {
    display: flex;
    min-height: calc(100vh - 200px);
}

/* Sidebar */
.sidebar {
    width: 350px;
    background-color: #f8f9fa;
    border-right: 1px solid #e9ecef;
    padding: 2rem;
    transition: all 0.3s ease;
    position: relative;
}

.sidebar.collapsed {
    width: 50px;
    padding: 1rem 0.5rem;
}

.sidebar-toggle-button {
    background-color: #667eea;
    color: white;
    border: none;
    border-radius: 6px;
    padding: 0.75rem;
    cursor: pointer;
    margin-bottom: 1rem;
    width: 100%;
    font-size: 1.2rem;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.sidebar.collapsed .sidebar-toggle-button {
    padding: 0.5rem;
    font-size: 1rem;
}

.sidebar-toggle-button:hover {
    background-color: #5a67d8;
    transform: translateY(-1px);
}

.sidebar-content {
    position: sticky;
    top: 2rem;
}

.sidebar-title {
    color: #495057;
    margin-bottom: 1.5rem;
    font-size: 1.4rem;
    font-weight: 500;
}

/* Main panel */
.main-panel {
    flex: 1;
    padding: 2rem;
    background-color: white;
}

.main-panel-content {
    max-width: 1000px;
}

/* Section titles */
.section-title {
    color: #495057;
    margin-bottom: 1.5rem;
    font-size: 1.3rem;
    font-weight: 500;
    border-bottom: 2px solid #e9ecef;
    padding-bottom: 0.5rem;
}

/* Dropdown containers */
.dropdown-container {
    margin-bottom: 1.5rem;
}

.input-container {
    margin-bottom: 1.5rem;
}

.dropdown-label,
.input-label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: #495057;
}

/* Dropdowns */
.module-dropdown .Select-control,
.model-dropdown .Select-control {
    min-height: 45px;
    border: 2px solid #e9ecef;
    border-radius: 8px;
    font-size: 14px;
    padding: 4px 8px;
}

.model-dropdown {
    min-width: 350px !important;
}

.module-dropdown .Select-control:hover,
.model-dropdown .Select-control:hover {
    border-color: #667eea;
}

.module-dropdown .Select-control.is-focused,
.model-dropdown .Select-control.is-focused {
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

/* Dropdown options styling */
.module-dropdown .Select-option,
.model-dropdown .Select-option {
    padding: 12px 16px;
    line-height: 1.5;
    border-bottom: 1px solid #f1f3f4;
    font-size: 14px;
}

.module-dropdown .Select-option:hover,
.model-dropdown .Select-option:hover {
    background-color: #f8f9fa;
}

.module-dropdown .Select-option.is-selected,
.model-dropdown .Select-option.is-selected {
    background-color: #667eea;
    color: white;
}

.module-dropdown .Select-option.is-disabled,
.model-dropdown .Select-option.is-disabled {
    background-color: #f8f9fa;
    color: #6c757d;
    font-weight: 500;
    text-align: center;
    font-style: italic;
    cursor: default;
}

/* Multi-select value styling */
.module-dropdown .Select-value,
.model-dropdown .Select-value {
    margin: 2px 4px;
    padding: 4px 8px;
    background-color: #e3f2fd;
    border: 1px solid #bbdefb;
    border-radius: 4px;
    font-size: 13px;
}

.module-dropdown .Select-value-label,
.model-dropdown .Select-value-label {
    color: #1565c0;
}

/* Dropdown menu container */
.module-dropdown .Select-menu-outer,
.model-dropdown .Select-menu-outer {
    border: 2px solid #e9ecef;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    margin-top: 4px;
}

.module-dropdown .Select-menu,
.model-dropdown .Select-menu {
    max-height: 300px;
}

/* Prompt input */
.prompt-input {
    border: 2px solid #e9ecef;
    border-radius: 6px;
    padding: 0.75rem;
    font-size: 14px;
    font-family: inherit;
}

.prompt-input:focus {
    border-color: #667eea;
    outline: none;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

/* Buttons */
.button-container {
    margin-top: 2rem;
    display: flex;
    gap: 1rem;
    flex-direction: column;
}

.action-button {
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.primary-button {
    background-color: #667eea;
    color: white;
}

.primary-button:hover:not(:disabled) {
    background-color: #5a67d8;
    transform: translateY(-1px);
}

.primary-button:disabled {
    background-color: #cbd5e0;
    cursor: not-allowed;
}

.secondary-button {
    background-color: #e2e8f0;
    color: #4a5568;
}

.secondary-button:hover {
    background-color: #cbd5e0;
}

.compare-button {
    padding: 0.5rem 1rem;
    background-color: #48bb78;
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
}

.compare-button:hover {
    background-color: #38a169;
    transform: translateY(-1px);
}

.compare-button.remove {
    background-color: #e53e3e;
}

.compare-button.remove:hover {
    background-color: #c53030;
}

/* Sections */
.config-section {
    margin-bottom: 3rem;
}

.visualization-section {
    margin-bottom: 3rem;
}

.results-section {
    margin-bottom: 2rem;
}

/* Placeholder areas */
.visualization-area,
.results-area {
    background-color: #f8f9fa;
    border: 2px dashed #dee2e6;
    border-radius: 8px;
    padding: 3rem;
    text-align: center;
    min-height: 200px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.placeholder-text {
    color: #6c757d;
    font-size: 1.1rem;
}

/* Status indicator */
.status-container {
    margin-top: 1rem;
}

.status-indicator {
    padding: 0.5rem 1rem;
    border-radius: 4px;
    font-size: 14px;
    font-weight: 500;
}

/* Loading indicator */
.loading-container {
    margin-bottom: 1.5rem;
    min-height: 40px;
    display: flex;
    align-items: center;
}

.status-loading {
    padding: 12px 16px;
    background-color: #fff3cd;
    border: 1px solid #ffeaa7;
    border-radius: 6px;
    color: #856404;
    font-size: 14px;
    font-weight: 500;
    display: flex;
    align-items: center;
    animation: pulse 2s infinite;
}

.status-success {
    padding: 12px 16px;
    background-color: #d4edda;
    border: 1px solid #c3e6cb;
    border-radius: 6px;
    color: #155724;
    font-size: 14px;
    font-weight: 500;
    display: flex;
    align-items: center;
}

.status-error {
    padding: 12px 16px;
    background-color: #f8d7da;
    border: 1px solid #f5c6cb;
    border-radius: 6px;
    color: #721c24;
    font-size: 14px;
    font-weight: 500;
    display: flex;
    align-items: center;
}

.status-cleared {
    padding: 12px 16px;
    background-color: #e2e3e5;
    border: 1px solid #d6d8db;
    border-radius: 6px;
    color: #383d41;
    font-size: 14px;
    font-weight: 500;
    display: flex;
    align-items: center;
}

/* Loading animation */
@keyframes pulse {
    0% {
        opacity: 1;
    }

    50% {
        opacity: 0.7;
    }

    100% {
        opacity: 1;
    }
}

/* FontAwesome icons fallback */
.fas {
    font-family: "Font Awesome 5 Free";
    font-weight: 900;
}

/* Spinner animation */
.fa-spin {
    animation: fa-spin 2s infinite linear;
}

@keyframes fa-spin {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}


/* Layer accordion styles */
.layer-accordions {
    margin-top: 1rem;
}

.layer-accordion {
    margin-bottom: 0.25rem;
    border: 1px solid #e9ecef;
    border-radius: 6px;
    overflow: hidden;
}

.layer-summary {
    padding: 0.75rem 1rem;
    background-color: #f8f9fa;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    color: #495057;
    list-style: none;
    transition: background-color 0.2s ease;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    user-select: none;
}

.layer-summary:hover {
    background-color: #e9ecef;
}

.layer-summary::-webkit-details-marker {
    display: none;
}

.layer-summary::before {
    content: '▶';
    display: inline-block;
    margin-right: 0.5rem;
    transition: transform 0.2s ease;
    font-size: 0.8em;
}

details[open] .layer-summary::before {
    transform: rotate(90deg);
}

.layer-content {
    padding: 1rem;
    background-color: white;
    border-top: 1px solid #e9ecef;
}

/* Flow diagram boxes */
.flow-box {
    display: inline-block;
    padding: 8px 12px;
    border: 2px solid #667eea;
    border-radius: 6px;
    background-color: white;
    font-size: 13px;
    font-weight: 500;
    color: #495057;
    cursor: help;
    transition: all 0.2s;
}

.flow-box:hover {
    background-color: #667eea;
    color: white;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(102, 126, 234, 0.3);
}

.attention-box {
    border-color: #667eea;
}

.attention-box:hover {
    background-color: #667eea;
}

.ffn-box {
    border-color: #764ba2;
}

.ffn-box:hover {
    background-color: #764ba2;
}

/* Token chips between layers */
.token-chips-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    margin: 0.25rem 0 1.5rem 0;
    background-color: #f8f9fa;
    border-left: 3px solid #667eea;
}

.token-arrow {
    color: #667eea;
    font-size: 1.2em;
    font-weight: bold;
}

.token-chip {
    display: inline-block;
    padding: 0.25rem 0.5rem;
    background-color: white;
    border: 1px solid #dee2e6;
    border-radius: 4px;
    font-size: 12px;
    color: #495057;
    white-space: nowrap;
}

/* Tokenization panel styles */
.tokenization-section {
    margin-bottom: 3rem;
    padding: 1.5rem;
    background-color: #f8f9fa;
    border-radius: 8px;
    border: 1px solid #dee2e6;
}

/* Vertical tokenization rows layout */
.tokenization-rows {
    display: flex;
    flex-direction: column;
    gap: 0;
}

.token-row {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-bottom: 8px;
    padding: 4px 0;
}

.token-row:last-child {
    margin-bottom: 0;
}

.token-row-box {
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    cursor: help;
}

.token-row-box:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
    z-index: 10;
}

.token-row-arrow {
    flex-shrink: 0;
}

/* Header row styling */
.tokenization-header-row {
    padding: 0 4px;
}

/* Legacy three-column grid styles (kept for backwards compatibility) */
.tokenization-grid {
    display: flex;
    gap: 2rem;
    align-items: flex-start;
    margin-top: 1rem;
}

.tokenization-col {
    flex: 1;
    min-width: 0;
    /* Allow flex items to shrink */
}

.token-column {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.token-box {
    position: relative;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    cursor: help;
}

.token-box:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
    z-index: 10;
}

/* Example diagram styling */
.example-text {
    transition: background-color 0.2s ease;
}

.example-text:hover {
    background-color: #d4e3f7 !important;
}

/* Responsive design */
@media (max-width: 768px) {
    .content-container {
        flex-direction: column;
    }

    .sidebar {
        width: 100%;
        border-right: none;
        border-bottom: 1px solid #e9ecef;
    }

    .model-dropdown {
        min-width: 100% !important;
    }

    .header-title {
        font-size: 2rem;
    }

    .token-chips-row {
        flex-wrap: wrap;
    }

    /* Stack tokenization columns vertically on small screens */
    .tokenization-grid {
        flex-direction: column;
        gap: 1rem;
    }

    /* Vertical token rows - stack boxes on very small screens */
    .token-row {
        flex-wrap: wrap;
        gap: 4px;
    }

    .token-row-box {
        flex: 1 1 auto;
        min-width: 80px;
    }

    .token-row-arrow {
        display: none;
    }

    .tokenization-header-row {
        display: none;
    }
}

/* PHASE 4: Transformer Layers Panel Redesign */

/* Significant layer highlighting - neon yellow border */
.layer-accordion.significant-layer {
    border: 3px solid #FFFF00;
    box-shadow: 0 0 8px rgba(255, 255, 0, 0.3);
}

.layer-accordion.significant-layer .layer-summary {
    background-color: #fffef0;
}

.layer-accordion.significant-layer .layer-summary:hover {
    background-color: #fffacd;
}

/* Transformer layers collapsible container */
.transformer-layers-container {
    margin-top: 1rem;
    border: 2px solid #e9ecef;
    border-radius: 8px;
    overflow: hidden;
}

.transformer-layers-summary {
    padding: 1rem;
    background-color: #f8f9fa;
    cursor: pointer;
    user-select: none;
}

.transformer-layers-summary:hover {
    background-color: #e9ecef;
}

/* Hide native details marker to prevent double arrow */
.transformer-layers-summary::-webkit-details-marker {
    display: none;
}

.transformer-layers-summary::marker {
    display: none;
}

.transformer-layers-summary::before {
    content: '▶';
    display: inline-block;
    margin-right: 1rem;
    transition: transform 0.2s ease;
    font-size: 1.2em;
    color: #667eea;
}

details[open].transformer-layers-container .transformer-layers-summary::before {
    transform: rotate(90deg);
}

/* Stacked layers visual */
.stacked-layers-visual {
    display: flex;
    gap: 4px;
    align-items: center;
}

.stacked-layer-card {
    padding: 8px 12px;
    background-color: #667eea;
    color: white;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 600;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    transition: transform 0.2s ease;
}

.stacked-layer-card:hover {
    transform: translateY(-2px);
}

.transformer-layers-content {
    padding: 1rem;
    background-color: white;
    border-top: 1px solid #e9ecef;
}

/* Smooth expand/collapse animation */
.transformer-layers-container[open] .transformer-layers-content {
    animation: expandContent 0.3s ease-out;
}

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

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* PHASE 6: Full BertViz Button Styling */

/* Full BertViz button */
#full-bertviz-btn {
    transition: all 0.2s ease;
}

#full-bertviz-btn:hover {
    background-color: #6a3d99 !important;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(118, 75, 162, 0.3);
}

#full-bertviz-btn:active {
    transform: translateY(0);
}

/* Full BertViz container styling */
#full-bertviz-container {
    animation: fadeIn 0.3s ease-out;
}

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

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Heatmap visualization styles */
.heatmap-visualization {
    margin-top: 1rem;
    border-radius: 8px;
    overflow: hidden;
}

#heatmap-graph {
    width: 100%;
}

/* Heatmap toggle buttons */
.heatmap-toggle-btn {
    transition: all 0.2s ease;
}

.heatmap-toggle-btn:hover {
    filter: brightness(0.95);
}

/* Heatmap modal styles */
#heatmap-modal-overlay {
    animation: fadeIn 0.2s ease-out;
}

#heatmap-modal-inner {
    animation: slideIn 0.2s ease-out;
}

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

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

#heatmap-modal-close:hover {
    color: #333;
    transform: scale(1.1);
}

/* Modal content scrollbar styling */
#heatmap-modal-content::-webkit-scrollbar {
    width: 8px;
}

#heatmap-modal-content::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

#heatmap-modal-content::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 4px;
}

#heatmap-modal-content::-webkit-scrollbar-thumb:hover {
    background: #a1a1a1;
}

/* ============================================================================
   PIPELINE VISUALIZATION STYLES
   ============================================================================ */

/* Pipeline container */
.pipeline-container {
    margin-top: 1.5rem;
}

.pipeline-stages {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* Stage container */
.stage-container {
    border-radius: 8px;
    overflow: hidden;
    transition: all 0.2s ease;
}

.stage-container[open] {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

/* Stage summary (clickable header) */
.stage-summary {
    list-style: none;
}

.stage-summary::-webkit-details-marker {
    display: none;
}

.stage-summary:hover {
    background-color: #f8f9fa !important;
}

.stage-container[open] .stage-summary {
    border-bottom: 1px solid #e2e8f0;
    border-radius: 8px 8px 0 0;
}

/* Expand indicator rotation */
.stage-container[open] .expand-indicator {
    transform: rotate(90deg);
}

/* Stage content animation */
.stage-content {
    animation: stageExpand 0.2s ease-out;
}

@keyframes stageExpand {
    from {
        opacity: 0;
        max-height: 0;
    }

    to {
        opacity: 1;
        max-height: 1000px;
    }
}

/* Flow indicator bar */
.flow-indicator {
    background: linear-gradient(90deg, #f8f9fa 0%, #ffffff 50%, #f8f9fa 100%);
}

.flow-stage-chip {
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    transition: transform 0.2s ease;
}

.flow-stage-chip:hover {
    transform: translateY(-2px);
}

/* Stage number badge */
.stage-number {
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.15);
}

/* ============================================================================
   INVESTIGATION PANEL STYLES
   ============================================================================ */

.investigation-panel {
    margin-top: 1.5rem;
}

.investigation-tabs {
    border-bottom: 2px solid #e9ecef;
    padding-bottom: 12px;
}

.investigation-tab {
    transition: all 0.2s ease;
}

.investigation-tab:hover {
    transform: translateY(-1px);
}

.investigation-content {
    margin-top: 1.5rem;
}

/* Ablation tool styles */
.ablation-tool {
    padding: 1rem;
    background-color: #fafbfc;
    border-radius: 8px;
}

/* Attribution tool styles */
.attribution-tool {
    padding: 1rem;
    background-color: #fafbfc;
    border-radius: 8px;
}

/* Head selection buttons */
.ablation-head-btn {
    transition: all 0.15s ease;
}

.ablation-head-btn:hover {
    transform: scale(1.05);
}

/* Warning button style */
.warning-button {
    background-color: #f6ad55;
    color: white;
}

.warning-button:hover {
    background-color: #ed8936;
}

/* Radio items styling */
#attribution-method-radio label {
    cursor: pointer;
    padding: 8px 12px;
    border-radius: 6px;
    transition: background-color 0.2s ease;
}

#attribution-method-radio label:hover {
    background-color: #f8f9fa;
}

/* ============================================================================
   RESPONSIVE ADJUSTMENTS FOR PIPELINE
   ============================================================================ */

@media (max-width: 768px) {
    .flow-indicator {
        flex-wrap: wrap;
        gap: 8px;
    }

    .flow-stage-chip {
        font-size: 10px;
        padding: 4px 10px;
    }

    .stage-summary {
        flex-wrap: wrap;
        gap: 8px;
    }

    .stage-number {
        width: 24px;
        height: 24px;
        font-size: 12px;
    }
}

/* ============================================================================
   AI CHATBOT STYLES
   ============================================================================ */

/* Chatbot container */
.chatbot-container {
    position: fixed;
    z-index: 2147483647;
    /* Maximum z-index to be above Dash debug menu */
}

/* Floating toggle button */
.chat-toggle-btn {
    position: fixed;
    bottom: 80px;
    /* Raised to avoid Dash debug menu */
    right: 24px;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    cursor: pointer;
    font-size: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 16px rgba(102, 126, 234, 0.4);
    transition: all 0.3s ease;
    z-index: 2147483647;
    /* Maximum z-index to be above Dash debug menu */
}

.chat-toggle-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 24px rgba(102, 126, 234, 0.5);
}

.chat-toggle-btn:active {
    transform: scale(0.95);
}

/* Chat window */
.chat-window {
    position: fixed;
    top: 0;
    right: 0;
    width: 25vw;
    min-width: 320px;
    max-width: 450px;
    height: 100vh;
    background-color: #ffffff;
    box-shadow: -4px 0 24px rgba(0, 0, 0, 0.15);
    display: flex;
    flex-direction: column;
    z-index: 2147483646;
    /* Just below toggle button */
    animation: slideInRight 0.3s ease-out;
}

/* Drag handle on left edge of chat window for resizing */
.chat-resize-handle {
    position: absolute;
    top: 0;
    left: 0;
    width: 5px;
    height: 100%;
    cursor: ew-resize;
    z-index: 10;
}

.chat-resize-handle:hover,
.chat-resize-handle.active {
    background-color: rgba(59, 130, 246, 0.5);
}

@keyframes slideInRight {
    from {
        transform: translateX(100%);
        opacity: 0;
    }

    to {
        transform: translateX(0);
        opacity: 1;
    }
}

.chat-window.closing {
    animation: slideOutRight 0.3s ease-in forwards;
}

@keyframes slideOutRight {
    from {
        transform: translateX(0);
        opacity: 1;
    }

    to {
        transform: translateX(100%);
        opacity: 0;
    }
}

/* Chat header */
.chat-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 16px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}

.chat-header-btn {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    width: 32px;
    height: 32px;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s ease;
}

.chat-header-btn:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* Messages container */
.chat-messages-container {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    background-color: #f8f9fa;
}

.chat-messages-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* Message wrapper */
.message-wrapper {
    display: flex;
    width: 100%;
}

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

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

/* Message bubbles */
.chat-message {
    max-width: 85%;
    padding: 12px 16px;
    border-radius: 16px;
    position: relative;
    word-wrap: break-word;
}

.user-message {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-bottom-right-radius: 4px;
}

.assistant-message {
    background-color: #ffffff;
    color: #333333;
    border: 1px solid #e9ecef;
    border-bottom-left-radius: 4px;
}

.message-content {
    font-size: 14px;
    line-height: 1.5;
}

.message-content p {
    margin: 0 0 8px 0;
}

.message-content ul,
.message-content ol {
    margin: 0 0 8px 0;
    padding-left: 20px;
    padding-right: 10px;
}

.message-content li {
    margin-bottom: 4px;
}

.message-content p:last-child,
.message-content ul:last-child,
.message-content ol:last-child {
    margin-bottom: 0;
}

/* Code blocks in messages */
.message-content pre {
    background-color: #1e1e1e;
    color: #d4d4d4;
    padding: 12px;
    border-radius: 8px;
    overflow-x: auto;
    font-size: 13px;
    margin: 8px 0;
}

.message-content code {
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
}

.message-content p code {
    background-color: rgba(0, 0, 0, 0.1);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 13px;
}

.user-message .message-content p code {
    background-color: rgba(255, 255, 255, 0.2);
}

/* Copy button */
.copy-message-btn {
    position: absolute;
    top: 8px;
    right: 8px;
    background: rgba(0, 0, 0, 0.05);
    border: none;
    color: #6c757d;
    width: 28px;
    height: 28px;
    border-radius: 4px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.2s ease, background-color 0.2s ease;
    font-size: 12px;
}

.assistant-message:hover .copy-message-btn {
    opacity: 1;
}

.copy-message-btn:hover {
    background: rgba(0, 0, 0, 0.1);
    color: #495057;
}

.copy-message-btn.copied {
    color: #28a745;
}

/* Typing indicator */
.typing-indicator {
    display: flex;
    gap: 4px;
    padding: 12px 16px;
    background-color: #ffffff;
    border: 1px solid #e9ecef;
    border-radius: 16px;
    border-bottom-left-radius: 4px;
    width: fit-content;
}

.typing-dot {
    width: 8px;
    height: 8px;
    background-color: #667eea;
    border-radius: 50%;
    animation: typingBounce 1.4s ease-in-out infinite;
}

.typing-dot:nth-child(2) {
    animation-delay: 0.2s;
}

.typing-dot:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typingBounce {

    0%,
    60%,
    100% {
        transform: translateY(0);
    }

    30% {
        transform: translateY(-8px);
    }
}

/* Input area */
.chat-input-area {
    padding: 16px;
    background-color: #ffffff;
    border-top: 1px solid #e9ecef;
    flex-shrink: 0;
}

.chat-input-wrapper {
    display: flex;
    gap: 8px;
    align-items: flex-end;
    position: relative;
    z-index: 2147483647;
    /* Ensure above toggle button */
}

.chat-input-textarea {
    flex: 1;
    min-height: 44px;
    max-height: 120px;
    padding: 12px 16px;
    border: 2px solid #e9ecef;
    border-radius: 22px;
    font-size: 14px;
    font-family: inherit;
    resize: none;
    outline: none;
    transition: border-color 0.2s ease;
}

.chat-input-textarea:focus {
    border-color: #667eea;
}

.chat-input-textarea::placeholder {
    color: #adb5bd;
}

.chat-send-btn {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    flex-shrink: 0;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.chat-send-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.chat-send-btn:active {
    transform: scale(0.95);
}

.chat-send-btn:disabled {
    background: #cbd5e0;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* Scrollbar styling for chat messages */
.chat-messages-container::-webkit-scrollbar {
    width: 6px;
}

.chat-messages-container::-webkit-scrollbar-track {
    background: transparent;
}

.chat-messages-container::-webkit-scrollbar-thumb {
    background-color: #cbd5e0;
    border-radius: 3px;
}

.chat-messages-container::-webkit-scrollbar-thumb:hover {
    background-color: #adb5bd;
}

/* Responsive adjustments for chat */
@media (max-width: 768px) {
    .chat-window {
        width: 100vw;
        max-width: 100vw;
    }

    .chat-toggle-btn {
        bottom: 16px;
        right: 16px;
        width: 48px;
        height: 48px;
        font-size: 20px;
    }
}

@media (max-width: 480px) {
    .chat-message {
        max-width: 90%;
    }

    .chat-input-textarea {
        font-size: 16px;
        /* Prevents zoom on iOS */
    }
}

/* Glossary Drawer Styles */
.glossary-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.glossary-overlay.open {
    opacity: 1;
    visibility: visible;
}

.glossary-drawer {
    position: fixed;
    top: 0;
    right: 0;
    height: 100vh;
    width: 100%;
    max-width: 500px;
    background-color: white;
    box-shadow: -4px 0 15px rgba(0, 0, 0, 0.1);
    z-index: 1001;
    transform: translateX(100%);
    transition: transform 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    display: flex;
    flex-direction: column;
}

.glossary-drawer.open {
    transform: translateX(0);
}

.glossary-header {
    padding: 20px 25px;
    border-bottom: 1px solid #e2e8f0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.glossary-content-area {
    padding: 25px;
    overflow-y: auto;
    flex: 1;
}