/* =============================================================================
   Estilos Melhorados para Interface Web de Teste LLM
   =============================================================================
   Design moderno, elegante e responsivo com melhor UX.
   ============================================================================= */

/* Reset e configurações base */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* Variáveis CSS para cores e espaçamentos (inspiradas no dashboard time.track) */
:root {
    --sidebar-bg: #1f242d;
    --sidebar-accent: #e53935;
    --primary-color: #2196f3;
    --primary-dark: #1976d2;
    --success-color: #27ae60;
    --danger-color: #e74c3c;
    --warning-color: #f39c12;
    --bg-main: #f5f6fa;
    --bg-card: #ffffff;
    --text-primary: #2c3e50;
    --text-secondary: #7f8c8d;
    --border-color: #e0e4eb;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 12px 24px rgba(0, 0, 0, 0.12);
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 14px;
    --transition: all 0.2s ease-in-out;
    --header-height: 62px;
    --sidebar-left-width: 240px;
    --sidebar-right-width: 320px;
}

/* Configurações do corpo da página */
html, body {
    height: 100%;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: var(--bg-main);
    height: 100vh;
    padding: 16px;
    color: var(--text-primary);
    line-height: 1.6;
    margin: 0;
    box-sizing: border-box;
    overflow: hidden;
}

/* Container principal - Grid com 3 colunas */
.container {
    max-width: 1600px;
    margin: 0 auto;
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    overflow: hidden;
    display: grid;
    grid-template-columns: var(--sidebar-left-width) 1fr 0fr;
    grid-template-rows: var(--header-height) 1fr;
    height: calc(100vh - 32px);
    max-height: calc(100vh - 32px);
    position: relative;
    transition: grid-template-columns 0.3s ease-in-out;
}

/* Quando o painel de configurações está aberto */
.container.config-open {
    grid-template-columns: var(--sidebar-left-width) 1fr var(--sidebar-right-width);
}

/* Sidebar esquerda (menu) */
.sidebar-left {
    grid-row: 1 / -1;
    background: var(--sidebar-bg);
    color: #e9ecf1;
    border-right: 1px solid #151821;
    overflow-y: auto;
    overflow-x: hidden;
    transition: var(--transition);
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.sidebar-left::-webkit-scrollbar {
    width: 6px;
}

.sidebar-left::-webkit-scrollbar-track {
    background: transparent;
}

.sidebar-left::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 3px;
}

.sidebar-left::-webkit-scrollbar-thumb:hover {
    background: var(--text-secondary);
}

.sidebar-header {
    padding: 18px 20px;
    border-bottom: 1px solid #151821;
    background: rgba(0, 0, 0, 0.08);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.logo {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
    color: #f5f7fb;
    font-weight: 700;
    font-size: 16px;
}

.logo i {
    font-size: 20px;
    color: var(--primary-color);
}

.sidebar-product label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
    margin-bottom: 0;
    color: #f5f7fb;
    font-size: 13px;
}

.sidebar-product .select_product {
    padding: 4px 8px;
    border-radius: var(--radius-sm);
    border: 1px solid #2c323f;
    background: #2c323f; /* Cinza escuro para contraste */
    color: #ffffff;       /* Texto branco para legibilidade */
    font-size: 12px;
    cursor: pointer;
}

.sidebar-product .select_product:focus,
.sidebar-product .select_product:active {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(33, 150, 243, 0.3);
    background: #1f242d !important;
    color: #ffffff !important;
}

.sidebar-product .select_product option {
    background: #1f242d !important;
    color: #ffffff !important;
    padding: 8px;
}

.menu-toggle {
    display: none;
    background: transparent;
    border: none;
    color: #c7cbd4;
    cursor: pointer;
    padding: 6px;
    border-radius: var(--radius-sm);
    transition: var(--transition);
}

.menu-toggle:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #ffffff;
}

.sidebar-menu {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 14px 12px;
    flex: 1;
}

.menu-item {
    color: #c7cbd4;
    text-decoration: none;
    padding: 12px 14px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    gap: 12px;
    transition: var(--transition);
    font-weight: 600;
    font-size: 14px;
}

.menu-item i {
    width: 20px;
    text-align: center;
    font-size: 16px;
}

.menu-item:hover {
    background: rgba(255, 255, 255, 0.08);
    color: #ffffff;
}

.menu-item.active {
    background: rgba(229, 57, 53, 0.2);
    color: #ffffff;
    border-left: 3px solid var(--sidebar-accent);
    padding-left: 11px;
}

.sidebar-footer {
    padding: 16px 20px;
    border-top: 1px solid #151821;
    background: rgba(0, 0, 0, 0.08);
}

.footer-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.app-name {
    font-weight: 600;
    font-size: 13px;
    color: #f5f7fb;
}

.copyright {
    font-size: 11px;
    color: #7f8c8d;
}

/* Cabeçalho melhorado */
.header {
    grid-column: 2;
    grid-row: 1;
    background: var(--bg-card);
    color: var(--text-primary);
    padding: 14px 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: var(--shadow-sm);
    border-bottom: 1px solid var(--border-color);
    min-height: var(--header-height);
}

.header-content {
    flex: 1;
}

.header-title h1 {
    font-size: 20px;
    font-weight: 700;
    margin: 0 0 2px 0;
}

.subtitle {
    font-size: 12px;
    color: var(--text-secondary);
    margin: 0;
}

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

.btn-icon {
    background: var(--bg-main);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    width: 38px;
    height: 38px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
    font-size: 15px;
    box-shadow: var(--shadow-sm);
}

.btn-icon:hover {
    background: var(--bg-card);
    border-color: var(--primary-color);
    color: var(--primary-color);
    transform: translateY(-1px);
}

.btn-icon.active {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
    box-shadow: 0 2px 8px rgba(33, 150, 243, 0.3);
}

.btn-icon:active {
    transform: translateY(0);
    box-shadow: var(--shadow-sm);
}

/* Sidebar direita (configurações) */
.sidebar-right {
    grid-column: 3;
    grid-row: 1 / -1;
    background: var(--sidebar-bg);
    color: #e9ecf1;
    border-left: 1px solid rgba(255, 255, 255, 0.1);
    overflow-y: auto;
    overflow-x: hidden;
    transition: width 0.3s ease, opacity 0.3s ease, visibility 0.3s ease;
    display: flex;
    flex-direction: column;
    min-width: 0;
    position: relative;
    width: 0;
    opacity: 0;
    visibility: hidden;
    overflow: hidden;
    box-shadow: -2px 0 8px rgba(0, 0, 0, 0.1);
}

.container.config-open .sidebar-right {
    width: var(--sidebar-right-width);
    opacity: 1 !important;
    visibility: visible !important;
    overflow-y: auto;
    overflow-x: hidden;
    z-index: 100;
    display: flex !important;
}

.sidebar-right::-webkit-scrollbar {
    width: 6px;
}

.sidebar-right::-webkit-scrollbar-track {
    background: transparent;
}

.sidebar-right::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 3px;
}

.sidebar-right::-webkit-scrollbar-thumb:hover {
    background: var(--text-secondary);
}

.config-header {
    padding: 20px 24px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(0, 0, 0, 0.15);
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}

/* Config header in chat-card (evaluation page) - more compact */
.chat-card .config-header {
    padding: 12px 16px; /* More compact */
    margin-bottom: 12px;
    border-bottom: 1px solid var(--border-color);
    background: transparent; /* No dark background in light card */
}

.chat-card .config-header h2 {
    font-size: 15px; /* Slightly smaller */
    margin: 0;
    color: var(--text-primary);
    font-weight: 600; /* Less bold */
}

.config-header h2 {
    font-size: 16px;
    font-weight: 700;
    color: #f5f7fb;
    display: flex;
}

/* Config header h2 in chat-card (evaluation page) */
.chat-card .config-header h2 {
    color: var(--text-primary); /* Dark text on light background */
    font-size: 15px; /* Slightly smaller */
    font-weight: 600; /* Less bold */
}
    align-items: center;
    gap: 10px;
    margin: 0;
    letter-spacing: 0.3px;
}

.config-header h2 i {
    color: var(--primary-color);
    font-size: 18px;
}

/* Config header inside chat-card (for evaluation page) */
.chat-card .config-header {
    border-bottom: 1px solid var(--border-color);
    background: transparent;
    padding: 16px 20px;
}

.chat-card .config-header h2 {
    color: var(--text-primary);
    font-size: 18px;
}

/* Ensure selects in config-content are readable */
.sidebar-right .config-group select.select_product {
    width: 100%;
    padding: 12px 14px;
    padding-right: 36px;
    border: 1px solid #2c323f;
    border-radius: var(--radius-sm);
    font-size: 14px;
    background: rgba(255, 255, 255, 0.08);
    color: #f5f7fb;
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23f5f7fb' d='M6 9L1 4h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    transition: var(--transition);
    margin-top: 4px;
}

.sidebar-right .config-group select.select_product:focus,
.sidebar-right .config-group select.select_product:active {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(33, 150, 243, 0.1);
    background-color: #1f242d !important;
    color: #f5f7fb !important;
}

.sidebar-right .config-group select.select_product option {
    background: #1f242d !important;
    color: #f5f7fb !important;
    padding: 8px;
}

.btn-close {
    background: transparent;
    border: none;
    color: #c7cbd4;
    cursor: pointer;
    padding: 6px;
    border-radius: var(--radius-sm);
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
}

.btn-close:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #ffffff;
}

.config-content {
    padding: 24px 20px;
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    scroll-behavior: smooth;
}

.config-content::-webkit-scrollbar {
    width: 8px;
}

.config-content::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.1);
    border-radius: 4px;
}

.config-content::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 4px;
}

.config-content::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.3);
}

.config-group {
    margin-bottom: 20px; /* Reduced from 28px */
    padding-bottom: 12px; /* Reduced from 20px */
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

/* Config groups in chat-card (evaluation page) - more compact */
.chat-card .config-group {
    margin-bottom: 16px; /* Even more compact */
    padding-bottom: 10px;
    border-bottom: 1px solid var(--border-color);
}

.config-group:last-child {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
}

.config-group label {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 600;
    margin-bottom: 10px;
    color: #f5f7fb;
    font-size: 14px;
    line-height: 1.5;
}

/* Labels in chat-card (main area) - dark text on light background */
.chat-card .config-group label {
    color: var(--text-primary) !important; /* Dark text for readability on white background */
    font-weight: 600;
}

/* Labels in sidebar-right (dark background) - light text */
.sidebar-right .config-group label {
    color: #f5f7fb;
    font-weight: 600;
}

.sidebar-right .config-group label i {
    color: var(--primary-color);
    width: 18px;
    text-align: center;
}

.value-display {
    margin-left: auto;
    font-weight: 700;
    color: #f5f7fb;
    background: rgba(255, 255, 255, 0.08);
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 12px;
}

.input-with-icon {
    position: relative;
    display: flex;
    align-items: center;
}

.input-with-icon input {
    flex: 1;
    padding-right: 40px;
    color: #e9ecf1;
    background: rgba(255, 255, 255, 0.05);
    border-color: #2c323f;
}

.icon-btn {
    position: absolute;
    right: 8px;
    background: transparent;
    border: none;
    color: #c7cbd4;
    cursor: pointer;
    padding: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}

.icon-btn:hover {
    color: #ffffff;
}

.config-group input[type="text"],
.config-group input[type="number"],
.config-group input[type="password"],
.config-group select {
    width: 100%;
    padding: 12px 14px;
    border: 1px solid #2c323f;
    border-radius: var(--radius-sm);
    font-size: 14px;
    transition: var(--transition);
    background: rgba(255, 255, 255, 0.08);
    box-sizing: border-box;
    color: #f5f7fb;
    margin-top: 4px;
}

/* Inputs and selects in chat-card (main area) - dark text on light background */
.chat-card .config-group input[type="text"],
.chat-card .config-group input[type="number"],
.chat-card .config-group input[type="password"],
.chat-card .config-group input[type="file"],
.chat-card .config-group select {
    color: var(--text-primary) !important; /* Dark text for readability */
    background: var(--bg-card) !important; /* White background */
    border: 1px solid var(--border-color) !important; /* Light border */
}

/* When chat-card select is open, use dark background for dropdown */
.chat-card .config-group select:focus,
.chat-card .config-group select:active {
    background: #1f242d !important;
    color: #f5f7fb !important;
}

.chat-card .config-group select option {
    background: #1f242d !important;
    color: #f5f7fb !important;
    padding: 8px;
}

.chat-card .config-group input[type="file"] {
    padding: 8px 12px;
    font-size: 14px;
    cursor: pointer;
}

.chat-card .config-group input[type="file"]::file-selector-button {
    padding: 6px 12px;
    margin-right: 12px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    background: var(--primary-color);
    color: white;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
}

.chat-card .config-group input[type="file"]::file-selector-button:hover {
    background: var(--primary-dark);
}

.config-group select {
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23f5f7fb' d='M6 9L1 4h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 36px;
}

.config-group select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(33, 150, 243, 0.1);
    background-color: rgba(255, 255, 255, 0.1);
}

/* Fix dropdown background when open - ensure dark background */
.config-group select:focus,
.config-group select:active,
.config-group select:hover {
    background-color: #1f242d !important;
    color: #f5f7fb !important;
}

/* Options in dropdown - dark background with light text */
.config-group select option {
    background: #1f242d !important;
    color: #f5f7fb !important;
    padding: 8px;
}

.config-group input[type="number"]::-webkit-inner-spin-button,
.config-group input[type="number"]::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.config-group input[type="number"] {
    -moz-appearance: textfield;
}

.config-group input[type="text"]:focus,
.config-group input[type="number"]:focus,
.config-group input[type="password"]:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(33, 150, 243, 0.1);
    background-color: rgba(255, 255, 255, 0.1);
}

/* Checkbox styling */
.config-group input[type="checkbox"] {
    width: 20px;
    height: 20px;
    cursor: pointer;
    accent-color: var(--primary-color);
    margin-right: 8px;
}

.config-group label[for*="enabled"] {
    cursor: pointer;
    user-select: none;
}

/* Warning message styling */
.warning-message {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 12px 16px;
    background: rgba(243, 156, 18, 0.15);
    border: 1px solid rgba(243, 156, 18, 0.3);
    border-radius: var(--radius-sm);
    color: #f39c12;
    font-size: 13px;
    line-height: 1.5;
    margin-top: 8px;
}

.warning-message i {
    font-size: 16px;
    margin-top: 2px;
    flex-shrink: 0;
}

.warning-message span {
    flex: 1;
}

.slider {
    width: 100%;
    height: 6px;
    border-radius: 3px;
    background: #2c323f;
    outline: none;
    -webkit-appearance: none;
    margin: 12px 0;
}

.slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--primary-color);
    cursor: pointer;
    box-shadow: var(--shadow-md);
    transition: var(--transition);
}

.slider::-webkit-slider-thumb:hover {
    transform: scale(1.1);
    background: var(--primary-dark);
}

.slider::-moz-range-thumb {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--primary-color);
    cursor: pointer;
    border: none;
    box-shadow: var(--shadow-md);
}

.slider-labels {
    display: flex;
    justify-content: space-between;
    font-size: 11px;
    color: #7f8c8d;
    margin-top: 4px;
}

.config-group small {
    display: block;
    color: #a0a8b0;
    font-size: 12px;
    margin-top: 8px;
    line-height: 1.5;
    font-style: italic;
}

/* Small text in chat-card - darker for readability */
.chat-card .config-group small {
    color: var(--text-secondary) !important; /* Darker gray for better contrast */
}

/* Status cards and other info elements in chat-card */
.chat-card .legal-status-card,
.chat-card .status-card {
    background: var(--bg-main);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 16px;
    margin-top: 8px;
}

.chat-card .status-item,
.chat-card .legal-status-card .status-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
    border-bottom: 1px solid var(--border-color);
}

.chat-card .status-item:last-child {
    border-bottom: none;
}

.chat-card .status-label,
.chat-card .legal-status-card .status-label {
    color: var(--text-secondary) !important;
    font-size: 14px;
    font-weight: 500;
}

.chat-card .status-value,
.chat-card .legal-status-card .status-value {
    color: var(--text-primary) !important;
    font-size: 14px;
    font-weight: 600;
}

.chat-card .status-value i {
    margin-right: 6px;
}

/* File input text in chat-card */
.chat-card .config-group input[type="file"] + label,
.chat-card .config-group label + input[type="file"] {
    color: var(--text-primary) !important;
}

/* Placeholder text in inputs */
.chat-card .config-group input::placeholder,
.chat-card .config-group textarea::placeholder {
    color: var(--text-secondary) !important;
    opacity: 0.7;
}

.config-actions {
    display: flex;
    flex-direction: row;
    gap: 10px;
    margin-top: 12px; /* Reduced from 20px */
    padding-top: 12px; /* Reduced from 20px */
    border-top: 1px solid var(--border-color); /* Use CSS variable */
}

/* Config actions in chat-card (evaluation page) */
.chat-card .config-actions {
    border-top: 1px solid var(--border-color);
}

/* Botões melhorados */
.btn-primary,
.btn-secondary {
    width: 100%;
    padding: 12px 20px;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary-color) 100%);
    color: white;
    box-shadow: var(--shadow-md);
    border: none;
}

.btn-primary:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

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

.btn-primary:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.btn-secondary {
    background: transparent;
    color: #f5f7fb;
    border: 1px solid #2c323f;
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.06);
    border-color: var(--primary-color);
    color: #ffffff;
}

.config-actions .btn-primary,
.config-actions .btn-secondary {
    width: auto;
    flex: 1;
}

/* CodeMirror custom highlighting for knowledge base sections */
/* Enhanced colors with stronger backgrounds for better visual separation */
.cm-kb-s {
    color: #3498db !important; /* Strong blue */
    background: rgba(52, 152, 219, 0.35) !important; /* Increased opacity from 0.15 to 0.35 */
    font-weight: 700;
    padding: 2px 4px;
    border-radius: 3px;
    border-left: 3px solid #3498db;
}

.cm-kb-ss {
    color: #2ecc71 !important; /* Strong green */
    background: rgba(46, 204, 113, 0.35) !important; /* Increased opacity from 0.15 to 0.35 */
    font-weight: 700;
    padding: 2px 4px;
    border-radius: 3px;
    border-left: 3px solid #2ecc71;
}

.cm-kb-sss {
    color: #9b59b6 !important; /* Strong purple */
    background: rgba(155, 89, 182, 0.35) !important; /* Increased opacity from 0.15 to 0.35 */
    font-weight: 700;
    padding: 2px 4px;
    border-radius: 3px;
    border-left: 3px solid #9b59b6;
}

.cm-kb-p {
    color: #e67e22 !important; /* Strong orange */
    background: rgba(230, 126, 34, 0.35) !important; /* Increased opacity from 0.15 to 0.35 */
    font-weight: 600;
    padding: 2px 4px;
    border-radius: 3px;
    border-left: 3px solid #e67e22;
}

.cm-kb-r {
    color: #1abc9c !important; /* Strong turquoise/cyan */
    background: rgba(26, 188, 156, 0.35) !important; /* Increased opacity from 0.15 to 0.35 */
    font-weight: 600;
    padding: 2px 4px;
    border-radius: 3px;
    border-left: 3px solid #1abc9c;
}

/* CodeMirror Search Toggle Button */
.codemirror-search-toggle-btn {
    background: var(--bg-main);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    padding: 6px 12px;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    margin-left: 12px;
}

.codemirror-search-toggle-btn:hover {
    background: var(--primary-color);
    border-color: var(--primary-color);
    color: white;
}

.codemirror-search-toggle-btn i {
    font-size: 14px;
}

/* CodeMirror Search Bar */
.codemirror-search-container {
    margin-bottom: 8px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    background: var(--bg-card);
    padding: 8px;
    box-shadow: var(--shadow-sm);
}

.codemirror-search-box {
    display: flex;
    align-items: center;
    gap: 8px;
}

.codemirror-search-icon {
    color: var(--text-secondary);
    font-size: 14px;
    flex-shrink: 0;
}

.codemirror-search-input {
    flex: 1;
    padding: 6px 10px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-size: 13px;
    background: var(--bg-main);
    color: var(--text-primary);
    font-family: inherit;
}

.codemirror-search-input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(33, 150, 243, 0.1);
}

.codemirror-search-input::placeholder {
    color: var(--text-secondary);
    opacity: 0.7;
}

.codemirror-search-count {
    color: var(--text-secondary);
    font-size: 12px;
    min-width: 60px;
    text-align: right;
    flex-shrink: 0;
}

.codemirror-search-btn {
    background: var(--bg-main);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    padding: 6px 10px;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    flex-shrink: 0;
}

.codemirror-search-btn:hover:not(:disabled) {
    background: var(--primary-color);
    border-color: var(--primary-color);
    color: white;
}

.codemirror-search-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.codemirror-search-close {
    background: transparent;
    border: none;
    color: var(--text-secondary);
}

.codemirror-search-close:hover {
    background: rgba(231, 76, 60, 0.1);
    color: var(--danger-color);
}

/* CodeMirror search highlighting */
.CodeMirror-searching {
    background: rgba(255, 255, 0, 0.4) !important;
    color: #000 !important;
    font-weight: 600;
    border-radius: 2px;
    padding: 1px 2px;
}

.CodeMirror-selectedtext {
    background: rgba(33, 150, 243, 0.4) !important;
}

/* Ensure search overlay works with section highlighting */
.CodeMirror .cm-searching {
    background: rgba(255, 255, 0, 0.4) !important;
    color: #000 !important;
    font-weight: 600;
}

/* Toast Notifications */
.toast-container {
    position: fixed;
    top: 80px;
    right: 20px;
    z-index: 10000;
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-width: 400px;
}

.toast {
    background: var(--bg-card);
    border-radius: var(--radius-md);
    padding: 16px 20px;
    box-shadow: var(--shadow-lg);
    display: flex;
    align-items: center;
    gap: 12px;
    animation: slideInRight 0.3s ease-out;
    border-left: 4px solid var(--primary-color);
    min-width: 300px;
}

.toast.success {
    border-left-color: var(--success-color);
}

.toast.error {
    border-left-color: var(--danger-color);
}

.toast.warning {
    border-left-color: var(--warning-color);
}

.toast.info {
    border-left-color: var(--primary-color);
}

.toast-icon {
    font-size: 20px;
    flex-shrink: 0;
}

.toast.success .toast-icon {
    color: var(--success-color);
}

.toast.error .toast-icon {
    color: var(--danger-color);
}

.toast.warning .toast-icon {
    color: var(--warning-color);
}

.toast.info .toast-icon {
    color: var(--primary-color);
}

.toast-content {
    flex: 1;
}

.toast-title {
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 4px;
    font-size: 14px;
}

.toast-message {
    color: var(--text-secondary);
    font-size: 13px;
    line-height: 1.4;
}

.toast-close {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 18px;
    padding: 0;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: var(--transition);
    flex-shrink: 0;
}

.toast-close:hover {
    background: rgba(0, 0, 0, 0.05);
    color: var(--text-primary);
}

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

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

.toast.hiding {
    animation: slideOutRight 0.3s ease-out forwards;
}

/* Loading Modal */
.loading-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    z-index: 20000;
    align-items: center;
    justify-content: center;
}

.loading-modal.active {
    display: flex;
}

.loading-modal-content {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    padding: 32px;
    max-width: 500px;
    width: 90%;
    box-shadow: var(--shadow-lg);
    text-align: center;
}

.loading-spinner {
    width: 48px;
    height: 48px;
    border: 4px solid var(--border-color);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 20px;
}

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

.loading-title {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 12px;
}

.loading-message {
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 20px;
    line-height: 1.5;
}

.loading-progress-info {
    margin: 16px 0;
    padding: 12px;
    background: var(--bg-main);
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
}

.loading-progress-stats {
    display: flex;
    justify-content: space-around;
    gap: 16px;
    flex-wrap: wrap;
}

.progress-stat {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    min-width: 80px;
}

.progress-stat .stat-label {
    font-size: 11px;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.progress-stat .stat-value {
    font-size: 16px;
    font-weight: 600;
    color: var(--primary-color);
}

.progress-stat .stat-total {
    font-size: 14px;
    color: var(--text-secondary);
}

.loading-current-question {
    margin: 16px 0;
    padding: 12px;
    background: var(--bg-main);
    border-radius: var(--radius-md);
    border-left: 3px solid var(--primary-color);
    text-align: left;
}

.loading-current-question .question-label {
    font-size: 11px;
    color: var(--text-secondary);
    text-transform: uppercase;
    margin-bottom: 6px;
    font-weight: 600;
}

.loading-current-question .question-text {
    font-size: 13px;
    color: var(--text-primary);
    line-height: 1.5;
}

.loading-progress {
    width: 100%;
    height: 8px;
    background: var(--border-color);
    border-radius: 4px;
    overflow: hidden;
    margin: 12px 0;
    position: relative;
}

.loading-progress-bar {
    height: 100%;
    background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary-color) 100%);
    width: 0%;
    transition: width 0.3s ease;
    border-radius: 4px;
}

.loading-progress-text {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 11px;
    font-weight: 600;
    color: var(--text-primary);
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
    pointer-events: none;
}

.loading-steps {
    font-size: 12px;
    color: var(--text-secondary);
    text-align: left;
    margin-top: 16px;
}

.loading-step {
    padding: 8px 0;
    display: flex;
    align-items: center;
    gap: 8px;
    opacity: 0.5;
    transition: opacity 0.3s;
}

.loading-step.active {
    opacity: 1;
    font-weight: 600;
    color: var(--primary-color);
}

.loading-step.completed {
    opacity: 0.7;
}

.loading-step-icon {
    width: 16px;
    text-align: center;
}

.loading-step-text {
    flex: 1;
}

/* CodeMirror full height for knowledge base editor */
.chat-card .config-content {
    display: flex;
    flex-direction: column;
    min-height: 0;
    flex: 1;
}

.chat-card .config-group:first-of-type {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.chat-card .config-group:first-of-type label {
    flex-shrink: 0;
}

.CodeMirror {
    flex: 1;
    height: auto;
    min-height: 500px;
}

/* CodeMirror text color - ensure readable text on dark monokai theme */
.CodeMirror,
.CodeMirror pre,
.CodeMirror-lines,
.CodeMirror-lines pre,
.CodeMirror-lines pre span {
    color: #f8f8f2 !important; /* Light gray text for readability */
}

/* CodeMirror default text (not highlighted) */
.CodeMirror .cm-default {
    color: #f8f8f2 !important; /* Ensure default text is readable */
}

/* CodeMirror line numbers */
.CodeMirror-linenumber {
    color: #75715e !important; /* Muted color for line numbers */
}

/* CodeMirror cursor */
.CodeMirror-cursor {
    border-left: 1px solid #f8f8f2 !important; /* Visible cursor */
}

/* Textarea fallback (when CodeMirror is not initialized) */
#knowledge-textarea,
#legal-preview-textarea {
    color: var(--text-primary) !important;
    background: var(--bg-card) !important;
    border: 1px solid var(--border-color) !important;
    padding: 12px !important;
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace !important;
    font-size: 14px !important;
    line-height: 1.6 !important;
}

/* Textarea in dark theme (monokai-like) */
.CodeMirror.cm-s-monokai,
.CodeMirror.cm-s-monokai .CodeMirror-gutters {
    background-color: #272822 !important;
}

.CodeMirror.cm-s-monokai .CodeMirror-lines,
.CodeMirror.cm-s-monokai .CodeMirror-lines pre,
.CodeMirror.cm-s-monokai .CodeMirror-lines pre span {
    color: #f8f8f2 !important; /* Light text on dark background */
}

/* Ensure all text in CodeMirror is readable */
.CodeMirror.cm-s-monokai .CodeMirror-line span:not(.cm-kb-s):not(.cm-kb-ss):not(.cm-kb-sss):not(.cm-kb-p):not(.cm-kb-r) {
    color: #f8f8f2 !important; /* Default text color for non-highlighted content */
}

/* Área de chat melhorada */
.chat-area {
    grid-column: 2;
    grid-row: 2;
    display: flex;
    flex-direction: column;
    height: 100%;
    max-height: 100%;
    background: var(--bg-main);
    position: relative;
    padding: 16px;
    /* Keep overflow hidden; individual pages provide their own scroll containers. */
    overflow: hidden;
    min-height: 0;
}

.chat-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    padding: 0;
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    max-height: 100%;
    overflow: hidden;
    position: relative;
}

.messages-container {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 20px;
    background: var(--bg-main);
    scroll-behavior: smooth;
    border-bottom: 1px solid var(--border-color);
    position: relative;
}

.messages-container::-webkit-scrollbar {
    width: 8px;
}

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

.messages-container::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 4px;
}

.messages-container::-webkit-scrollbar-thumb:hover {
    background: var(--text-secondary);
}

/* Mensagem de boas-vindas melhorada */
.welcome-message {
    text-align: center;
    color: var(--text-secondary);
    padding: 60px 20px;
    max-width: 520px;
    margin: 0 auto;
}

.welcome-icon {
    font-size: 64px;
    color: var(--primary-color);
    margin-bottom: 20px;
    opacity: 0.85;
}

.welcome-message h2 {
    font-size: 28px;
    color: var(--text-primary);
    margin-bottom: 12px;
    font-weight: 700;
}

.welcome-message p {
    margin-bottom: 8px;
    font-size: 15px;
}

.hint {
    font-size: 13px;
    color: var(--text-secondary);
    font-style: italic;
}

/* Estilos para mensagens melhorados */
.message {
    margin-bottom: 16px;
    display: flex;
    flex-direction: column;
    animation: fadeInUp 0.25s ease-out;
}

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

.message-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 6px;
    font-size: 12px;
}

.message-role {
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.message-role.user {
    background: rgba(33, 150, 243, 0.15);
    color: var(--primary-dark);
}

.message-role.assistant {
    background: rgba(46, 204, 113, 0.18);
    color: var(--success-color);
}

.message-time {
    color: var(--text-secondary);
    font-size: 11px;
}

.message-content {
    padding: 14px 18px;
    border-radius: var(--radius-md);
    line-height: 1.7;
    font-size: 15px;
    max-width: 85%;
    word-wrap: break-word;
    word-break: break-word;
    overflow-wrap: break-word;
}

.message-content strong {
    font-weight: 700;
    color: inherit;
}

.message.user .message-content {
    background: #e8f3ff;
    color: #114b8a;
    margin-left: auto;
    text-align: left;
    border: 1px solid #d3e5ff;
}

.message.assistant .message-content {
    background: #ffffff;
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
}

.message.error .message-content {
    background: #fdecea;
    color: #c0392b;
    border: 1px solid #f5c6cb;
}

/* Container for intent and sources in the same line */
.message-intent-sources {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 8px;
    flex-wrap: wrap;
}

/* Container for intent and sources in the same line */
.message-intent-sources {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 8px;
    flex-wrap: wrap;
}

/* Intent badge for assistant messages */
.message-intent {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    background: linear-gradient(135deg, #e3f2fd 0%, #bbdefb 100%);
    color: #1565c0;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 500;
    border: 1px solid #90caf9;
}

.intent-sources-separator {
    color: var(--text-secondary);
    opacity: 0.5;
    margin: 0 2px;
}

.message-intent i {
    font-size: 10px;
}

.message-intent .intent-sources {
    color: #64b5f6;
    font-weight: 400;
    font-size: 10px;
}

/* Sources container (legacy - kept for compatibility) */
.message-sources {
    margin-top: 10px;
    padding: 8px 12px;
    background: rgba(0, 0, 0, 0.05);
    border-radius: 6px;
    border-left: 3px solid #2196f3;
}

/* Sources list inside intent-sources container */
.message-intent-sources .sources-list {
    width: 100%;
    margin-top: 8px;
    padding: 8px 12px;
    background: rgba(0, 0, 0, 0.05);
    border-radius: 6px;
    border-left: 3px solid #2196f3;
    list-style: none;
}

.message-intent-sources .sources-header {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: #90caf9;
    font-size: 11px;
    font-weight: 500;
    user-select: none;
    padding: 4px 10px;
    background: rgba(33, 150, 243, 0.1);
    border-radius: 12px;
}

.sources-header i {
    font-size: 11px;
    transition: transform 0.2s;
}

.sources-list {
    margin-top: 8px;
    padding-left: 20px;
    list-style: decimal;
    color: #b0bec5;
    font-size: 11px;
    line-height: 1.6;
}

.sources-list li {
    margin-bottom: 4px;
    word-break: break-word;
}

/* Metrics container for performance information */
.message-metrics {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    margin-top: 8px;
    padding: 6px 10px;
    background: rgba(33, 150, 243, 0.08);
    border-radius: 6px;
    border-left: 3px solid #2196f3;
    font-size: 11px;
    color: #1565c0;
}

.metric-item {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-weight: 500;
}

.metric-separator {
    color: var(--text-secondary);
    opacity: 0.5;
    margin: 0 4px;
}

.metric-item i {
    font-size: 10px;
    opacity: 0.8;
}

/* Suggestions container for follow-up quick replies */
.message-suggestions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px dashed var(--border-color);
}

.suggestion-btn {
    display: inline-flex;
    align-items: center;
    padding: 8px 14px;
    background: linear-gradient(135deg, #e3f2fd 0%, #bbdefb 100%);
    color: #1565c0;
    border: 1px solid #90caf9;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease-in-out;
    max-width: 100%;
    text-align: left;
    word-break: break-word;
}

.suggestion-btn:hover:not(:disabled) {
    background: linear-gradient(135deg, #bbdefb 0%, #90caf9 100%);
    border-color: #64b5f6;
    transform: translateY(-1px);
    box-shadow: 0 2px 6px rgba(33, 150, 243, 0.2);
}

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

.suggestion-btn:disabled,
.suggestion-btn.used {
    opacity: 0.5;
    cursor: not-allowed;
    background: #e0e0e0;
    border-color: #bdbdbd;
    color: #757575;
}

/* Área de input melhorada - Campo de escrita moderno */
.input-area {
    background: var(--bg-card);
    border-top: 1px solid var(--border-color);
    padding: 16px 20px;
    box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.04);
    flex: 0 0 auto;
    flex-shrink: 0;
    flex-grow: 0;
    z-index: 10;
    position: relative;
    order: 999;
}

.loading-indicator {
    margin-bottom: 12px;
    display: none;
}

.loading-indicator[style*="display: flex"],
.loading-indicator[style*="display:block"] {
    display: flex !important;
}

.loading-content {
    display: flex;
    align-items: center;
    gap: 10px; /* Reduced from 12px */
    padding: 10px 12px; /* More compact */
    background: #e7f3ff;
    border-radius: var(--radius-sm);
    color: #004085;
    font-size: 13px; /* Reduced from 14px */
}

.spinner {
    width: 20px;
    height: 20px;
    border: 3px solid #e7f3ff;
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

.input-container {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.input-wrapper {
    display: flex;
    gap: 0;
    align-items: flex-end;
    width: 100%;
}

.input-box {
    flex: 1;
    display: flex;
    align-items: flex-end;
    background: var(--bg-card);
    border: 2px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 4px;
    transition: var(--transition);
    min-height: 56px;
}

.input-box:focus-within {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(33, 150, 243, 0.1);
}

#message-input {
    flex: 1;
    padding: 12px 14px;
    border: none;
    border-radius: var(--radius-md);
    font-size: 15px;
    font-family: inherit;
    resize: none;
    transition: var(--transition);
    background: transparent;
    min-height: 48px;
    max-height: 200px;
    line-height: 1.6;
    overflow-y: auto;
    box-sizing: border-box;
    color: var(--text-primary);
}

#message-input::placeholder {
    color: var(--text-secondary);
    opacity: 0.7;
}

#message-input:focus {
    outline: none;
}

#message-input::-webkit-scrollbar {
    width: 6px;
}

#message-input::-webkit-scrollbar-track {
    background: transparent;
}

#message-input::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 3px;
}

#message-input::-webkit-scrollbar-thumb:hover {
    background: var(--text-secondary);
}

.input-actions {
    display: flex;
    align-items: center;
    padding: 4px;
}

.btn-send {
    background: var(--primary-color);
    border: none;
    color: white;
    width: 44px;
    height: 44px;
    border-radius: var(--radius-md);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
    font-size: 16px;
    box-shadow: var(--shadow-sm);
    flex-shrink: 0;
}

.btn-send:hover:not(:disabled) {
    background: var(--primary-dark);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

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

.btn-send:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.input-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 12px;
    color: var(--text-secondary);
    flex-wrap: wrap;
    gap: 8px;
    padding: 0 4px;
}

.char-count {
    font-weight: 500;
}

.hint-text {
    font-style: italic;
    display: flex;
    align-items: center;
    gap: 4px;
}

.hint-text i {
    font-size: 11px;
}

/* Responsividade melhorada */
@media (max-width: 1024px) {
    .container.config-open {
        grid-template-columns: var(--sidebar-left-width) 1fr;
    }
    
    .sidebar-right {
        position: fixed;
        top: 0;
        right: 0;
        bottom: 0;
        width: var(--sidebar-right-width);
        z-index: 1000;
        box-shadow: -4px 0 12px rgba(0, 0, 0, 0.15);
    }
}

@media (max-width: 768px) {
    body {
        padding: 0;
    }

    .container {
        grid-template-columns: 1fr;
        grid-template-rows: var(--header-height) 1fr;
        min-height: 100vh;
        border-radius: 0;
    }
    
    .container.config-open {
        grid-template-columns: 1fr;
    }

    .sidebar-left {
        display: none;
        position: fixed;
        top: var(--header-height);
        left: 0;
        bottom: 0;
        width: var(--sidebar-left-width);
        z-index: 1000;
        box-shadow: 4px 0 12px rgba(0, 0, 0, 0.15);
    }
    
    .sidebar-left.active {
        display: flex;
    }
    
    .sidebar-right {
        position: fixed;
        top: var(--header-height);
        right: 0;
        bottom: 0;
        width: var(--sidebar-right-width);
        z-index: 1000;
        box-shadow: -4px 0 12px rgba(0, 0, 0, 0.15);
    }
    
    .container.config-open .sidebar-right {
        width: var(--sidebar-right-width);
        opacity: 1;
        visibility: visible;
    }

    .header {
        grid-column: 1 / -1;
    }
    
    .container.config-open .header {
        grid-column: 1 / -1;
    }

    .chat-area {
        grid-column: 1 / -1;
        grid-row: 2;
        padding: 12px;
    }

    .messages-container {
        padding: 12px;
    }

    .message-content {
        max-width: 100%;
    }

    .input-box {
        min-height: 52px;
    }
    
    #message-input {
        min-height: 44px;
        font-size: 14px;
    }
    
    .btn-send {
        width: 40px;
        height: 40px;
    }
}

/* Animações adicionais */
@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}

.loading .spinner {
    animation: spin 1s linear infinite, pulse 2s ease-in-out infinite;
}

/* Melhorias de acessibilidade */
*:focus-visible {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

/* Melhorias para inputs desabilitados */
input:disabled,
textarea:disabled,
button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* Melhorias para scroll suave */
html {
    scroll-behavior: smooth;
}

/* Prevenir seleção de texto em botões */
.btn-primary,
.btn-secondary,
.btn-icon,
.btn-send {
    user-select: none;
    -webkit-user-select: none;
}

/* Melhorias para impressão */
@media print {
    .sidebar-left,
    .sidebar-right,
    .header-actions,
    .input-area {
        display: none;
    }
    
    .container {
        box-shadow: none;
        border: 1px solid #ccc;
    }
}

/* =============================================================================
   RAG Evaluation Page Styles
   ============================================================================= */

/* Evaluation cards inside messages-container should stack properly */
.messages-container > .chat-card {
    margin-bottom: 12px; /* Reduced from 16px */
    flex: 0 0 auto;
    max-height: none;
    overflow: visible;
}

.messages-container > .chat-card:last-child {
    margin-bottom: 0;
}

.evaluation_card {
    margin-bottom: 16px;
    /* In the evaluation page we stack multiple cards; avoid flex-stretching. */
    flex: 0 0 auto;
    /* Let evaluation panels grow with content (page scroll handles overflow). */
    max-height: none;
    overflow: visible;
}

.evaluation_content {
    display: flex;
    flex-direction: column;
    gap: 8px; /* Reduced from 12px for more compact layout */
}

.evaluation_config_row {
    display: flex;
    gap: 20px;
    flex-wrap: wrap;
}

.evaluation_config_item {
    flex: 1;
    min-width: 200px;
}

.evaluation_config_item label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
    margin-bottom: 8px;
    color: var(--text-primary);
    font-size: 13px;
}

.evaluation_select {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-size: 14px;
    background: var(--bg-card);
    color: var(--text-primary);
    cursor: pointer;
}

.evaluation_select:focus,
.evaluation_select:active {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(33, 150, 243, 0.1);
    background: #1f242d !important;
    color: #f5f7fb !important;
}

.evaluation_select option {
    background: #1f242d !important;
    color: #f5f7fb !important;
    padding: 8px;
}

.evaluation_select[multiple] {
    min-height: 100px;
}

.evaluation_questions_group {
    flex: 1;
}

.evaluation_hint {
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 12px;
}

.evaluation_questions_container {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); /* Slightly smaller min width */
    gap: 10px; /* Compact grid layout */
    margin-bottom: 8px;
    /* Let the page scroll container handle vertical scrolling */
    max-height: none;
    overflow: visible;
}

/* Responsive grid for smaller screens */
@media (max-width: 768px) {
    .evaluation_questions_container {
        grid-template-columns: 1fr; /* Single column on mobile */
    }
}

.evaluation_question_item {
    background: var(--bg-main);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 10px;
}

.evaluation_question_header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.evaluation_question_number {
    font-weight: 700;
    color: var(--primary-color);
    font-size: 13px; /* Reduced from 14px */
}

.evaluation_question_remove {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 4px 8px;
    border-radius: var(--radius-sm);
    transition: var(--transition);
}

.evaluation_question_remove:hover {
    background: rgba(231, 76, 60, 0.1);
    color: var(--danger-color);
}

.evaluation_question_fields {
    display: flex;
    flex-direction: column;
    gap: 6px; /* Reduced from 8px */
}

.evaluation_field label {
    display: block;
    font-size: 11px; /* Reduced from 12px */
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 3px; /* Reduced from 4px */
}

.evaluation_required {
    color: var(--danger-color);
}

.evaluation_question_input,
.evaluation_ground_truth_input {
    width: 100%;
    padding: 6px 10px; /* Reduced vertical padding */
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-size: 12px; /* Slightly smaller font */
    font-family: inherit;
    resize: vertical;
    background: var(--bg-card);
    color: var(--text-primary);
    min-height: 32px; /* Compact height */
    line-height: 1.4;
}

.evaluation_question_input:focus,
.evaluation_ground_truth_input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(33, 150, 243, 0.1);
}

.evaluation_add_btn {
    align-self: flex-start;
}

.evaluation_actions {
    border-top: 1px solid var(--border-color);
    padding-top: 12px; /* Reduced from 20px */
    display: flex;
    gap: 10px; /* Reduced from 12px */
}

.evaluation_run_btn {
    flex: 2;
}

.evaluation_results_section {
    margin-top: 12px;
}

/* Aggregate Scores - More compact and modern */
.evaluation_aggregate_scores {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); /* Even smaller min width */
    gap: 8px; /* Reduced from 10px */
    margin-bottom: 12px; /* Reduced from 16px */
}

/* Responsive grid for aggregate scores */
@media (max-width: 768px) {
    .evaluation_aggregate_scores {
        grid-template-columns: repeat(2, 1fr); /* 2 columns on mobile */
    }
}

@media (max-width: 480px) {
    .evaluation_aggregate_scores {
        grid-template-columns: 1fr; /* Single column on very small screens */
    }
}

.evaluation_score_card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm); /* Smaller radius */
    padding: 10px 12px; /* More compact padding */
    display: flex;
    align-items: center; /* Center align for compact look */
    gap: 10px; /* Reduced from 12px */
    transition: var(--transition);
    box-shadow: var(--shadow-sm);
}

.evaluation_score_card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-1px); /* Subtle lift effect */
}

.evaluation_score_card.evaluation_score_good {
    border-left: 3px solid var(--success-color); /* Reduced from 4px */
}

.evaluation_score_card.evaluation_score_medium {
    border-left: 3px solid var(--warning-color); /* Reduced from 4px */
}

.evaluation_score_card.evaluation_score_low {
    border-left: 3px solid var(--danger-color); /* Reduced from 4px */
}

.evaluation_score_card.evaluation_score_na {
    border-left: 3px solid var(--text-secondary); /* Reduced from 4px */
}

.evaluation_score_icon {
    width: 36px; /* Reduced from 40px */
    height: 36px; /* Reduced from 40px */
    border-radius: 50%;
    background: var(--bg-main);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px; /* Reduced from 18px */
    color: var(--primary-color);
    flex-shrink: 0;
}

.evaluation_score_good .evaluation_score_icon {
    color: var(--success-color);
}

.evaluation_score_medium .evaluation_score_icon {
    color: var(--warning-color);
}

.evaluation_score_low .evaluation_score_icon {
    color: var(--danger-color);
}

.evaluation_score_content {
    flex: 1;
}

.evaluation_score_label {
    font-weight: 600;
    font-size: 12px; /* Reduced from 13px */
    color: var(--text-secondary);
    margin-bottom: 2px; /* Reduced from 4px */
}

.evaluation_score_value {
    font-size: 18px; /* Reduced from 20px */
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 2px; /* Reduced from 4px */
    line-height: 1.2;
}

.evaluation_score_description {
    font-size: 10px;
    color: var(--text-secondary);
    line-height: 1.4;
}

.evaluation_no_scores {
    color: var(--text-secondary);
    font-style: italic;
}

/* Detailed Results */
.evaluation_details_header {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.evaluation_result_item {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm); /* Smaller radius */
    margin-bottom: 10px; /* Reduced from 12px */
    overflow: hidden;
    box-shadow: var(--shadow-sm);
    transition: var(--transition);
}

.evaluation_result_item:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-1px); /* Subtle lift effect */
}

.evaluation_item_header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px; /* Reduced from 10px */
    background: var(--bg-main);
    border-bottom: 1px solid var(--border-color);
}

.evaluation_item_number {
    font-weight: 700;
    color: var(--primary-color);
    font-size: 13px; /* Reduced from 14px */
}

.evaluation_item_scores {
    display: flex;
    gap: 6px; /* Reduced from 8px */
    flex-wrap: wrap;
}

.evaluation_item_score {
    padding: 3px 8px; /* More compact */
    border-radius: 10px; /* Smaller radius */
    font-size: 10px; /* Slightly smaller */
    font-weight: 600;
    background: var(--bg-main);
}

.evaluation_item_score.evaluation_score_good {
    background: rgba(39, 174, 96, 0.15);
    color: var(--success-color);
}

.evaluation_item_score.evaluation_score_medium {
    background: rgba(243, 156, 18, 0.15);
    color: var(--warning-color);
}

.evaluation_item_score.evaluation_score_low {
    background: rgba(231, 76, 60, 0.15);
    color: var(--danger-color);
}

.evaluation_item_content {
    padding: 10px 12px; /* Reduced vertical padding */
}

.evaluation_item_question,
.evaluation_item_answer,
.evaluation_item_ground_truth,
.evaluation_item_contexts {
    margin-bottom: 10px; /* Reduced from 12px */
}

.evaluation_item_question strong,
.evaluation_item_answer strong,
.evaluation_item_ground_truth strong,
.evaluation_item_contexts strong {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.evaluation_item_question p,
.evaluation_item_answer p,
.evaluation_item_ground_truth p {
    margin: 0;
    font-size: 12px; /* Reduced from 13px */
    line-height: 1.5; /* Reduced from 1.6 */
    color: var(--text-primary);
    white-space: pre-wrap;
}

.evaluation_item_ground_truth {
    background: rgba(39, 174, 96, 0.08);
    padding: 8px 10px; /* More compact */
    border-radius: var(--radius-sm);
    border: 1px solid rgba(39, 174, 96, 0.2);
}

.evaluation_item_ground_truth .evaluation_field_toggle {
    font-size: 13px;
    font-weight: 600;
    color: #1a1a1a;
}

.evaluation_contexts_list {
    display: flex;
    flex-direction: column;
    gap: 6px; /* Reduced from 8px */
    margin-top: 6px; /* Reduced from 8px */
}

.evaluation_context_item {
    display: flex;
    gap: 8px;
    padding: 6px 10px; /* Reduced vertical padding */
    background: var(--bg-main);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-size: 12px; /* Reduced from 13px */
}

.evaluation_context_num {
    background: var(--primary-color);
    color: white;
    width: 18px; /* Reduced from 20px */
    height: 18px; /* Reduced from 20px */
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px; /* Reduced from 11px */
    font-weight: 600;
    flex-shrink: 0;
}

.evaluation_context_text {
    color: var(--text-secondary);
    line-height: 1.5;
}

/* Errors */
.evaluation_errors {
    background: rgba(231, 76, 60, 0.08);
    border: 1px solid rgba(231, 76, 60, 0.2);
    border-radius: var(--radius-md);
    padding: 16px;
    margin-top: 16px;
}

.evaluation_errors_header {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
    color: var(--danger-color);
    margin-bottom: 8px; /* Reduced from 12px */
    font-size: 14px; /* Slightly smaller */
}

.evaluation_errors_list {
    margin: 0;
    padding-left: 20px;
    color: var(--text-primary);
    font-size: 13px;
}

.evaluation_errors_list li {
    margin-bottom: 4px;
}

/* =============================================================================
   Estilos Adicionais para Avaliação RAG - Badges de Categoria
   ============================================================================= */

/* Caixa de informação sobre as perguntas */
.evaluation_info_box {
    display: flex;
    align-items: flex-start;
    gap: 10px; /* Reduced from 12px */
    padding: 10px 12px; /* More compact */
    background: linear-gradient(135deg, #e3f2fd 0%, #bbdefb 100%);
    border: 1px solid #90caf9;
    border-radius: var(--radius-sm); /* Smaller radius */
    margin-bottom: 12px; /* Reduced from 20px */
}

.evaluation_info_box > i {
    font-size: 20px;
    color: var(--primary-color);
    margin-top: 2px;
}

.evaluation_info_text {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    flex: 1;
}

.evaluation_info_text strong {
    width: 100%;
    color: var(--text-primary);
    font-size: 12px; /* Reduced from 13px */
    margin-bottom: 4px;
    font-weight: 600;
}

/* Badges de categoria */
.evaluation_category_badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 8px; /* More compact */
    border-radius: 10px; /* Smaller radius */
    font-size: 10px; /* Reduced from 11px */
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.evaluation_badge_technical {
    background: rgba(33, 150, 243, 0.15);
    color: #1565c0;
    border: 1px solid rgba(33, 150, 243, 0.3);
}

.evaluation_badge_legal {
    background: rgba(156, 39, 176, 0.15);
    color: #7b1fa2;
    border: 1px solid rgba(156, 39, 176, 0.3);
}

.evaluation_badge_action {
    background: rgba(255, 152, 0, 0.15);
    color: #e65100;
    border: 1px solid rgba(255, 152, 0, 0.3);
}

.evaluation_badge_general {
    background: rgba(76, 175, 80, 0.15);
    color: #2e7d32;
    border: 1px solid rgba(76, 175, 80, 0.3);
}

/* Cabeçalho da pergunta actualizado */
.evaluation_question_header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px; /* Reduced from 10px */
}

.evaluation_question_header_left {
    display: flex;
    align-items: center;
    gap: 8px; /* Reduced from 10px */
}

/* Estados de carregamento e erro */
.evaluation_loading_questions {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 30px 20px; /* Reduced from 40px */
    color: var(--text-secondary);
    gap: 12px;
}

.evaluation_loading_questions .spinner {
    width: 32px;
    height: 32px;
    border: 3px solid var(--border-color);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

.evaluation_error_loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
    color: var(--danger-color);
    gap: 12px;
    text-align: center;
}

.evaluation_error_loading i {
    font-size: 32px;
    opacity: 0.7;
}

.evaluation_error_loading .btn-secondary {
    margin-top: 8px;
    width: auto;
}

.evaluation_no_questions {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
    color: var(--text-secondary);
    gap: 12px;
    text-align: center;
}

.evaluation_no_questions i {
    font-size: 32px;
    opacity: 0.5;
}

/* Campo colapsável de ground truth */
.evaluation_field_collapsed .evaluation_field_toggle {
    cursor: pointer;
    user-select: none;
    transition: var(--transition);
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
    padding: 6px 0;
}

.evaluation_field_collapsed .evaluation_field_toggle:hover {
    color: var(--primary-color);
}

.evaluation_field_toggle {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
    padding: 6px 0;
}

.evaluation_field_toggle i {
    font-size: 10px;
    transition: transform 0.2s ease;
}

/* Textarea readonly */
.evaluation_question_input[readonly] {
    background: var(--bg-main);
    cursor: default;
}

/* Botão de reload no header em rotação */
.btn-icon.rotating i {
    animation: spin 1s linear infinite;
}

/* Responsividade para badges */
@media (max-width: 768px) {
    .evaluation_info_text {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .evaluation_category_badge {
        font-size: 10px;
        padding: 3px 8px;
    }
    
    .evaluation_question_header_left {
        flex-wrap: wrap;
    }
}

/* =============================================================================
   ESTILOS PARA PÁGINA DE HISTÓRICO
   ============================================================================= */

.history-content {
    position: relative;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    background: var(--bg-card);
    min-height: 500px;
    max-height: calc(100vh - 300px);
    overflow-y: auto;
    padding: 12px;
    font-size: 12px;
    line-height: 1.5;
}

.history-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    text-align: center;
    color: var(--text-secondary);
}

.history-placeholder h3 {
    margin: 20px 0 10px 0;
    color: var(--text-primary);
}

.history-placeholder p {
    margin: 0;
    font-size: 14px;
}

.history-groups {
    padding: 8px;
}

.history-group {
    margin-bottom: 12px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    background: var(--bg-main);
    overflow: hidden;
}

.history-group-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 12px;
    background: var(--bg-card);
    border-bottom: 1px solid var(--border-color);
    cursor: pointer;
    transition: var(--transition);
}

.history-group-header:hover {
    background: var(--bg-main);
}

.history-group-info h4 {
    margin: 0 0 4px 0;
    color: var(--text-primary);
    font-size: 13px;
    font-weight: 600;
}

.history-group-info p {
    margin: 2px 0;
    color: var(--text-secondary);
    font-size: 11px;
    line-height: 1.4;
}

.history-group-info i {
    width: 16px;
    margin-right: 8px;
    color: var(--primary-color);
}

.history-toggle {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 16px;
    cursor: pointer;
    padding: 8px;
    border-radius: 4px;
    transition: var(--transition);
}

.history-toggle:hover {
    background: var(--bg-main);
    color: var(--primary-color);
}

.history-group-content {
    padding: 0;
    max-height: 300px;
    overflow-y: auto;
}

.history-message {
    padding: 10px 12px;
    border-bottom: 1px solid var(--border-color);
    transition: var(--transition);
}

.history-message:last-child {
    border-bottom: none;
}

.history-message.user {
    background: #f8f9fa;
    border-left: 3px solid var(--success-color);
}

.history-message.assistant {
    background: #ffffff;
    border-left: 3px solid var(--primary-color);
}

.history-message.highlighted {
    background: rgba(255, 193, 7, 0.1);
}

.history-message.current-highlight {
    background: rgba(33, 150, 243, 0.15);
    box-shadow: inset 0 0 0 2px rgba(33, 150, 243, 0.3);
}

.message-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 6px;
    padding-bottom: 4px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
}

.message-role {
    font-weight: 600;
    font-size: 12px;
    color: var(--text-primary);
}

.message-role:before {
    margin-right: 6px;
}

.message-time {
    font-size: 10px;
    color: var(--text-secondary);
    font-weight: 400;
}

.message-content {
    color: var(--text-primary);
    line-height: 1.5;
    white-space: pre-wrap;
    word-wrap: break-word;
    font-size: 12px;
    padding: 2px 0;
}

/* Search functionality styles */
.codemirror-search-container {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 12px 16px;
    margin-top: 8px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.codemirror-search-box {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1;
}

.codemirror-search-icon {
    color: var(--text-secondary);
    font-size: 14px;
}

.codemirror-search-input {
    flex: 1;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    padding: 6px 8px;
    font-size: 13px;
    background: var(--bg-main);
    color: var(--text-primary);
}

.codemirror-search-input:focus {
    outline: none;
    border-color: var(--primary-color);
}

.codemirror-search-count {
    font-size: 12px;
    color: var(--text-secondary);
    min-width: 60px;
    text-align: center;
}

.codemirror-search-btn {
    background: none;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 4px 8px;
    font-size: 12px;
    transition: var(--transition);
}

.codemirror-search-btn:hover {
    background: var(--bg-main);
    border-color: var(--primary-color);
    color: var(--primary-color);
}

.codemirror-search-close {
    color: var(--danger-color);
}

.codemirror-search-close:hover {
    background: rgba(239, 68, 68, 0.1);
    border-color: var(--danger-color);
}

.codemirror-search-toggle-btn {
    background: none;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 6px 8px;
    font-size: 12px;
    transition: var(--transition);
}

.codemirror-search-toggle-btn:hover {
    background: var(--bg-main);
    border-color: var(--primary-color);
    color: var(--primary-color);
}

/* Loading modal */
.loading-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 10000;
}

.loading-modal-content {
    background: var(--bg-card);
    border-radius: var(--radius-md);
    padding: 32px;
    text-align: center;
    max-width: 400px;
    width: 90%;
    box-shadow: var(--shadow-lg);
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid var(--border-color);
    border-top: 4px solid var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 20px;
}

.loading-title {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.loading-message {
    color: var(--text-secondary);
    margin-bottom: 16px;
}

.loading-progress {
    background: var(--bg-main);
    border-radius: 4px;
    height: 8px;
    overflow: hidden;
    margin-bottom: 16px;
}

.loading-progress-bar {
    height: 100%;
    background: var(--primary-color);
    width: 0%;
    transition: width 0.3s ease;
}

.loading-steps {
    text-align: left;
    font-size: 12px;
    color: var(--text-secondary);
}

/* Estatísticas compactas */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
    margin-top: 8px;
}

.stat-card {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    background: var(--bg-main);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    transition: var(--transition);
}

.stat-card:hover {
    background: var(--bg-card);
    border-color: var(--primary-color);
}

.stat-icon {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--primary-color), var(--primary-color-dark));
    color: white;
    border-radius: 6px;
    font-size: 14px;
    flex-shrink: 0;
}

.stat-content {
    flex: 1;
    min-width: 0;
}

.stat-value {
    font-size: 16px;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.2;
    margin-bottom: 2px;
}

.stat-label {
    font-size: 10px;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 500;
}

/* Responsividade para histórico */
@media (max-width: 768px) {
    .history-group-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }

    .history-group-info h4 {
        font-size: 12px;
    }

    .history-group-info p {
        font-size: 10px;
    }

    .message-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 2px;
    }

    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}