/* ==============================================================================
   DAMSDIGITAL CHAINLIT VISUAL THEME, FOLDERS & CHATGPT-STYLE SIDEBAR
   ============================================================================== */

/* 1. MARCA DE AGUA Y LOGO EN EL PIE */
.custom-brand-floating,
#custom-header-brand.custom-brand-floating {
    display: none !important;
}

/* 2. LOGO DE DAMSDIGITAL PROMINENTE Y ELEGANTE */
.chat-history-drawer > .MuiDrawer-paper > .MuiStack-root:first-child,
.MuiDrawer-paper > .MuiStack-root:first-child {
    min-height: 52px !important;
    height: 52px !important;
    padding: 6px 14px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: flex-start !important;
    background: #171717 !important;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08) !important;
}

.chat-history-drawer img[src*="/logo"],
.MuiDrawer-paper img[src*="/logo"],
.chat-history-drawer img[src*="logo_dark"],
.MuiDrawer-paper img[src*="logo_dark"],
#header img[src*="/logo"],
#header img[src*="logo_dark"],
img[src*="/logo"],
img[src*="logo_dark"],
img[alt="logo"],
img[alt="DamsDigital"],
#custom-header-brand img {
    max-height: 36px !important;
    height: 32px !important;
    width: auto !important;
    object-fit: contain !important;
    filter: drop-shadow(0 2px 8px rgba(0, 0, 0, 0.5)) !important;
    transition: transform 0.2s ease, filter 0.2s ease !important;
}

.chat-history-drawer img:hover,
#custom-header-brand img:hover,
img[src*="logo_dark"]:hover,
img[src*="/logo"]:hover {
    transform: scale(1.02) !important;
    filter: drop-shadow(0 4px 14px rgba(56, 189, 248, 0.5)) !important;
}

/* 3. SCROLLBARS ULTRA MODERNAS */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
::-webkit-scrollbar-track {
    background: transparent;
}
::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.16);
    border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.32);
}

/* ==============================================================================
   4. HEADER: DISTRIBUCIÓN RESPONSIVA DESKTOP Y MÓVIL (CERO TRASLAPES)
   ============================================================================== */
#header {
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    position: relative !important;
    padding: 6px 12px !important;
    gap: 8px !important;
    height: 52px !important;
    box-sizing: border-box !important;
    background: #0d0d0d !important;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08) !important;
}

/* 4A. Botón Hamburguesa: Siempre al extremo izquierdo */
.custom-header-sort-btn,
#header > .MuiBox-root:has(svg[data-testid="SortIcon"]),
#header svg[data-testid="SortIcon"] {
    order: 1 !important;
}

.custom-header-sort-btn,
#header > .MuiBox-root:has(svg[data-testid="SortIcon"]) {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    flex-shrink: 0 !important;
    margin: 0 4px 0 0 !important;
    z-index: 20 !important;
}

/* 4B. Marca / Logo DamsDigital: Al lado del botón hamburguesa */
#custom-header-brand {
    order: 2 !important;
    display: flex !important;
    align-items: center !important;
    text-decoration: none !important;
    margin: 0 8px 0 0 !important;
    cursor: pointer !important;
    flex-shrink: 0 !important;
    padding: 2px 4px !important;
    border-radius: 6px !important;
    z-index: 20 !important;
    transition: background 0.15s ease !important;
}

#custom-header-brand:hover {
    background: rgba(255, 255, 255, 0.05) !important;
}

/* 4C. Selector de Proyectos del Sistema: Centrado en Flexbox (Sin absolute que tape la hamburguesa) */
.custom-header-project-box,
#header > .MuiBox-root:has(#chat-profile-selector),
#header > .MuiBox-root:has(.MuiFormControl-root),
#header > .MuiBox-root:first-child {
    order: 3 !important;
    position: static !important;
    transform: none !important;
    top: auto !important;
    left: auto !important;
    flex: 1 !important;
    display: flex !important;
    justify-content: center !important;
    min-width: 0 !important;
    max-width: 250px !important;
    margin: 0 auto !important;
    z-index: 10 !important;
}

#header #chat-profile-selector,
#header .MuiSelect-select {
    padding: 5px 26px 5px 10px !important;
    font-size: 13px !important;
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    background: rgba(255, 255, 255, 0.05) !important;
    border-radius: 8px !important;
}

/* 4D. Botones del lado derecho (Nuevo chat + Perfil de usuario) */
.custom-header-right-stack,
#header > .MuiStack-root:last-child {
    order: 4 !important;
    display: flex !important;
    align-items: center !important;
    flex-shrink: 0 !important;
    gap: 4px !important;
    z-index: 20 !important;
}

/* 4E. Ajustes móviles específicos (pantallas < 660px) */
@media (max-width: 660px) {
    #header {
        padding: 4px 8px !important;
        gap: 4px !important;
        height: 48px !important;
    }

    #custom-header-brand img {
        max-height: 24px !important;
        height: 22px !important;
    }

    .custom-header-project-box,
    #header > .MuiBox-root:has(#chat-profile-selector),
    #header > .MuiBox-root:has(.MuiFormControl-root),
    #header > .MuiBox-root:first-child {
        max-width: 170px !important;
        margin: 0 4px !important;
    }

    #header #chat-profile-selector,
    #header .MuiSelect-select {
        font-size: 12px !important;
        padding: 4px 22px 4px 8px !important;
    }
}

@media (max-width: 380px) {
    .custom-header-project-box,
    #header > .MuiBox-root:has(#chat-profile-selector),
    #header > .MuiBox-root:has(.MuiFormControl-root),
    #header > .MuiBox-root:first-child {
        max-width: 130px !important;
    }
}

/* ==============================================================================
   5. BARRA DE ASIGNACIÓN DE CARPETA DENTRO DEL CHAT ACTIVO
   ============================================================================== */
#custom-chat-folder-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 16px;
    background: rgba(18, 24, 38, 0.85);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    font-size: 12px;
    color: #94a3b8;
    position: sticky;
    top: 0;
    z-index: 40;
    animation: fadeInDown 0.2s ease-out;
}

@keyframes fadeInDown {
    from { opacity: 0; transform: translateY(-6px); }
    to { opacity: 1; transform: translateY(0); }
}

.custom-folder-bar-left {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
}

.custom-folder-bar-label {
    font-weight: 600;
    color: #cbd5e1;
    font-size: 12px;
    white-space: nowrap;
}

.custom-folder-pill-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.16);
    color: #f1f5f9;
    border-radius: 16px;
    padding: 3px 12px;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    max-width: 220px;
}

.custom-folder-pill-btn:hover {
    background: rgba(59, 130, 246, 0.22);
    border-color: rgba(59, 130, 246, 0.5);
    color: #93c5fd;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(37, 99, 235, 0.3);
}

.custom-folder-pill-text {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.custom-folder-pill-arrow {
    font-size: 10px;
    color: #94a3b8;
}

.custom-folder-bar-hint {
    font-size: 11px;
    color: #64748b;
    display: flex;
    align-items: center;
    gap: 4px;
}

@media (max-width: 600px) {
    #custom-chat-folder-bar {
        padding: 5px 10px;
    }
    .custom-folder-bar-hint {
        display: none;
    }
    .custom-folder-pill-btn {
        max-width: 170px;
    }
}

/* ==============================================================================
   6. MODAL INTERACTIVO DE ASIGNACIÓN A CARPETAS
   ============================================================================== */
#custom-folder-dropdown-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.55);
    backdrop-filter: blur(3px);
    z-index: 99999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    animation: fadeIn 0.15s ease-out;
}

.custom-folder-modal-card {
    background: #1e293b;
    border: 1px solid rgba(255, 255, 255, 0.14);
    border-radius: 12px;
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.7);
    width: 100%;
    max-width: 350px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.custom-folder-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    font-size: 13px;
    font-weight: 700;
    color: #f1f5f9;
}

.custom-folder-modal-close {
    background: transparent;
    border: none;
    color: #94a3b8;
    font-size: 16px;
    cursor: pointer;
    padding: 2px 6px;
    border-radius: 4px;
    transition: color 0.15s, background 0.15s;
}

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

.custom-folder-modal-list {
    max-height: 290px;
    overflow-y: auto;
    padding: 8px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.custom-folder-modal-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 13px;
    color: #cbd5e1;
    transition: background 0.15s ease, color 0.15s ease;
}

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

.custom-folder-modal-item.active {
    background: rgba(37, 99, 235, 0.25);
    color: #93c5fd;
    font-weight: 600;
    border: 1px solid rgba(59, 130, 246, 0.35);
}

.custom-folder-modal-item-left {
    display: flex;
    align-items: center;
    gap: 8px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.custom-folder-modal-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    background: rgba(15, 23, 42, 0.4);
}

.custom-folder-modal-new-btn {
    background: rgba(59, 130, 246, 0.15);
    border: 1px solid rgba(59, 130, 246, 0.35);
    color: #60a5fa;
    border-radius: 6px;
    padding: 6px 12px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    width: 100%;
}

.custom-folder-modal-new-btn:hover {
    background: #2563eb;
    color: #ffffff;
}

/* ==============================================================================
   7. SECCIÓN SUPERIOR DE CARPETAS / PROYECTOS (ESTILO TRELLO)
   ============================================================================== */
#custom-projects-container {
    padding: 6px 8px;
    margin: 4px 6px 8px 6px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.09);
    display: flex;
    flex-direction: column;
    gap: 6px;
    background: rgba(23, 23, 23, 0.7);
    border-radius: 8px;
    flex-shrink: 0;
    transition: all 0.2s ease;
}

#custom-projects-container.collapsed {
    padding: 4px 8px;
    gap: 0;
}

#custom-projects-container.collapsed #custom-projects-body {
    display: none !important;
}

.custom-projects-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 4px 6px;
    border-radius: 6px;
    cursor: pointer;
    user-select: none;
    transition: background 0.15s ease;
}

.custom-projects-header:hover {
    background: rgba(255, 255, 255, 0.05);
}

.custom-projects-title {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: #94a3b8;
    display: flex;
    align-items: center;
    gap: 6px;
}

.custom-projects-main-chevron {
    font-size: 10px;
    color: #94a3b8;
    transition: transform 0.2s ease;
    display: inline-block;
}

.custom-projects-count {
    font-size: 10px;
    color: #64748b;
    margin-left: 2px;
}

.custom-add-folder-btn {
    background: rgba(59, 130, 246, 0.15);
    color: #60a5fa;
    border: 1px solid rgba(59, 130, 246, 0.35);
    border-radius: 6px;
    padding: 3px 8px;
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 4px;
    transition: all 0.2s ease;
}

.custom-add-folder-btn:hover {
    background: #2563eb;
    color: #ffffff;
    border-color: #2563eb;
    box-shadow: 0 2px 8px rgba(37, 99, 235, 0.4);
}

/* Formulario inline para crear carpeta */
.custom-folder-form {
    background: #1e293b;
    border: 1px solid rgba(59, 130, 246, 0.4);
    border-radius: 8px;
    padding: 10px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
    animation: fadeIn 0.15s ease-out;
}

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

.custom-folder-input-row {
    display: flex;
    gap: 6px;
    align-items: center;
}

.custom-folder-icon-input {
    width: 38px;
    text-align: center;
    font-size: 16px;
    padding: 6px 4px;
    background: #0f172a;
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 6px;
    color: #ffffff;
    outline: none;
}

.custom-folder-name-input {
    flex: 1;
    padding: 6px 10px;
    background: #0f172a;
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 6px;
    color: #ffffff;
    font-size: 12px;
    outline: none;
}

.custom-folder-name-input:focus {
    border-color: #3b82f6;
}

.custom-folder-form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 6px;
}

.custom-folder-btn-submit {
    background: #2563eb;
    color: #ffffff;
    border: none;
    border-radius: 5px;
    padding: 4px 10px;
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
}

.custom-folder-btn-submit:hover {
    background: #1d4ed8;
}

.custom-folder-btn-cancel {
    background: transparent;
    color: #94a3b8;
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 5px;
    padding: 4px 8px;
    font-size: 11px;
    cursor: pointer;
}

.custom-folder-btn-cancel:hover {
    color: #ffffff;
    background: rgba(255, 255, 255, 0.08);
}

/* Tarjetas de carpetas en el sidebar */
.custom-folder-card {
    background: rgba(30, 41, 59, 0.55);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 8px;
    overflow: hidden;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.custom-folder-card:hover {
    border-color: rgba(255, 255, 255, 0.18);
    background: rgba(30, 41, 59, 0.85);
}

.custom-folder-card.drag-target-active {
    border: 2px dashed #38bdf8 !important;
    background: rgba(56, 189, 248, 0.18) !important;
    transform: scale(1.02);
    box-shadow: 0 0 16px rgba(56, 189, 248, 0.45);
}

.custom-folder-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 10px;
    cursor: pointer;
    user-select: none;
    font-size: 13px;
    font-weight: 600;
    color: #e2e8f0;
}

.custom-folder-header-left {
    display: flex;
    align-items: center;
    gap: 7px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 1;
}

.custom-folder-chevron {
    font-size: 10px;
    color: #94a3b8;
    transition: transform 0.2s ease;
    display: inline-block;
}

.custom-folder-card.open .custom-folder-chevron {
    transform: rotate(90deg);
}

.custom-folder-icon {
    font-size: 14px;
}

.custom-folder-name {
    font-size: 12.5px;
    color: #f1f5f9;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.custom-folder-badge {
    background: rgba(255, 255, 255, 0.12);
    color: #cbd5e1;
    font-size: 10px;
    font-weight: 700;
    padding: 1px 6px;
    border-radius: 10px;
    margin-left: 4px;
}

.custom-folder-actions {
    display: flex;
    align-items: center;
    gap: 4px;
    opacity: 0;
    transition: opacity 0.15s ease;
}

.custom-folder-card:hover .custom-folder-actions {
    opacity: 1;
}

.custom-folder-action-btn {
    background: transparent;
    border: none;
    color: #94a3b8;
    cursor: pointer;
    padding: 2px 5px;
    border-radius: 4px;
    font-size: 11px;
    transition: color 0.15s, background 0.15s;
}

.custom-folder-action-btn:hover {
    color: #f87171;
    background: rgba(248, 113, 113, 0.15);
}

/* Lista de chats dentro de la carpeta */
.custom-folder-threads {
    display: none;
    flex-direction: column;
    padding: 4px 6px 8px 6px;
    gap: 3px;
    background: rgba(15, 23, 42, 0.45);
    border-top: 1px solid rgba(255, 255, 255, 0.05);
}

.custom-folder-card.open .custom-folder-threads {
    display: flex;
}

.custom-folder-empty {
    font-size: 11px;
    color: #64748b;
    text-align: center;
    padding: 8px 6px;
    border: 1px dashed rgba(255, 255, 255, 0.1);
    border-radius: 6px;
    margin: 2px;
}

/* Chat dentro de la carpeta */
.custom-thread-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 8px;
    border-radius: 6px;
    background: rgba(30, 41, 59, 0.6);
    border: 1px solid rgba(255, 255, 255, 0.05);
    cursor: pointer;
    font-size: 12px;
    color: #e2e8f0;
    text-decoration: none;
    transition: all 0.15s ease;
}

.custom-thread-item:hover {
    background: rgba(51, 65, 85, 0.95);
    border-color: rgba(255, 255, 255, 0.15);
    transform: translateX(2px);
}

.custom-thread-item.active {
    background: rgba(37, 99, 235, 0.3) !important;
    border-color: #3b82f6 !important;
    color: #ffffff;
}

.custom-thread-drag-handle {
    color: #64748b;
    font-size: 11px;
    margin-right: 6px;
    cursor: grab;
}

.custom-thread-title {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.custom-thread-unassign {
    opacity: 0;
    background: transparent;
    border: none;
    color: #94a3b8;
    cursor: pointer;
    font-size: 12px;
    padding: 0 4px;
    transition: opacity 0.15s, color 0.15s;
}

.custom-thread-item:hover .custom-thread-unassign {
    opacity: 1;
}

.custom-thread-unassign:hover {
    color: #f87171;
}

/* Zona para desasignar chat suelto al arrastrar */
.custom-unassigned-dropzone {
    margin: 6px 2px 2px 2px;
    padding: 8px 10px;
    border: 1px dashed rgba(255, 255, 255, 0.15);
    border-radius: 6px;
    font-size: 11px;
    color: #94a3b8;
    text-align: center;
    cursor: default;
    transition: all 0.2s ease;
    display: none;
}

body.is-dragging-chat .custom-unassigned-dropzone {
    display: block;
}

.custom-unassigned-dropzone.drag-target-active {
    border-color: #f59e0b !important;
    background: rgba(245, 158, 11, 0.18) !important;
    color: #fbbf24 !important;
    transform: scale(1.02);
}

.trello-dragging {
    opacity: 0.45 !important;
    transform: rotate(1.5deg) scale(0.98) !important;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.6) !important;
    border: 1px dashed #38bdf8 !important;
}

/* ==============================================================================
   8. HISTORIAL GENERAL DE CHATS: ESTILO GOOGLE GEMINI (FIJADOS + FECHAS VIVAS)
   ============================================================================== */
.chat-history-drawer .MuiDrawer-paper {
    background: #171717 !important;
    border-right: 1px solid rgba(255, 255, 255, 0.08) !important;
}

/* Ocultar suavemente el árbol nativo cuando el historial sincronizado está montado */
.custom-history-replaced > ul.MuiList-root,
.custom-history-replaced > .MuiAlert-root {
    display: none !important;
}

/* Sección dedicada de Chats Fijados (siempre arriba, nunca atrapada en fechas) */
#custom-pinned-container {
    padding: 4px 6px 8px 6px;
    margin: 0 6px 6px 6px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    display: flex;
    flex-direction: column;
    gap: 2px;
    flex-shrink: 0;
}

.custom-pinned-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 5px 8px;
    border-radius: 6px;
    cursor: pointer;
    user-select: none;
    transition: background 0.15s ease;
}

.custom-pinned-header:hover {
    background: rgba(255, 255, 255, 0.05);
}

.custom-pinned-title {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: #fbbf24;
    display: flex;
    align-items: center;
    gap: 6px;
}

.custom-pinned-chevron {
    font-size: 10px;
    color: #94a3b8;
    display: inline-block;
}

.custom-pinned-count {
    font-size: 10px;
    color: #94a3b8;
    background: rgba(251, 191, 36, 0.12);
    border: 1px solid rgba(251, 191, 36, 0.25);
    padding: 0 6px;
    border-radius: 10px;
    font-weight: 700;
}

.custom-pinned-list {
    display: flex;
    flex-direction: column;
    gap: 1px;
}

#custom-pinned-container.collapsed .custom-pinned-list {
    display: none !important;
}

.custom-pinned-empty {
    font-size: 11px;
    color: #64748b;
    padding: 6px 10px;
    font-style: italic;
}

/* Contenedor de Historial Cronológico Dinámico */
#custom-history-container {
    display: flex;
    flex-direction: column;
    padding: 0 2px 12px 2px;
    gap: 6px;
}

.custom-history-group {
    display: flex;
    flex-direction: column;
    gap: 1px;
}

.custom-history-group-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 14px 4px 14px;
    color: #8e8ea0;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    user-select: none;
}

.custom-history-group-count {
    font-size: 10px;
    color: #64748b;
    font-weight: 600;
}

.custom-history-empty {
    font-size: 12px;
    color: #64748b;
    text-align: center;
    padding: 16px 12px;
}

.custom-history-load-more {
    margin: 8px 10px 4px 10px;
    padding: 7px 12px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    color: #cbd5e1;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease;
}

.custom-history-load-more:hover {
    background: rgba(255, 255, 255, 0.11);
    color: #ffffff;
}

/* Filas de chats estilo Google Gemini: cápsula horizontal, sin recuadro pesado */
.custom-history-row,
[id^="thread-"]:not(#thread-info),
a[href*="/thread/"] {
    display: flex !important;
    flex-direction: row !important;
    align-items: center !important;
    justify-content: space-between !important;
    height: 34px !important;
    min-height: 34px !important;
    max-height: 34px !important;
    padding: 0 10px 0 12px !important;
    margin: 1px 6px !important;
    border-radius: 17px !important;
    box-sizing: border-box !important;
    background: transparent !important;
    color: #e3e3e3 !important;
    text-decoration: none !important;
    transition: background 0.12s ease, color 0.12s ease !important;
    position: relative !important;
    cursor: pointer !important;
    border: none !important;
    box-shadow: none !important;
}

/* Hover estilo Google Gemini */
.custom-history-row:hover,
[id^="thread-"]:not(#thread-info):hover,
a[href*="/thread/"]:hover {
    background: rgba(255, 255, 255, 0.08) !important;
    color: #ffffff !important;
}

/* Chat actualmente seleccionado / activo */
.custom-history-row.active-chat,
[id^="thread-"]:not(#thread-info).active-chat,
a[href*="/thread/"].active-chat {
    background: rgba(255, 255, 255, 0.14) !important;
    color: #ffffff !important;
    font-weight: 500 !important;
}

/* Chat fijado dentro de la sección Fijados */
.custom-history-row.is-pinned-thread {
    background: rgba(251, 191, 36, 0.06) !important;
}

.custom-history-row.is-pinned-thread:hover {
    background: rgba(251, 191, 36, 0.13) !important;
}

.custom-history-row.is-pinned-thread.active-chat {
    background: rgba(251, 191, 36, 0.2) !important;
}

.custom-history-row-title {
    flex: 1 1 auto !important;
    min-width: 0 !important;
    font-size: 13px !important;
    color: inherit !important;
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    text-align: left !important;
    line-height: 34px !important;
    font-weight: inherit !important;
}

.custom-history-folder-dot {
    flex-shrink: 0;
    font-size: 11px;
    margin-right: 5px;
    opacity: 0.78;
}

.custom-thread-pin-badge {
    font-size: 10px;
    margin-right: 4px;
    flex-shrink: 0;
    opacity: 0.85;
}

/* Resetear TODOS los contenedores intermedios de MUI dentro de cada enlace */
a[href*="/thread/"] .MuiStack-root,
[id^="thread-"] .MuiStack-root {
    display: flex !important;
    flex-direction: row !important;
    align-items: center !important;
    min-width: 0 !important;
    flex: 1 1 auto !important;
    width: 100% !important;
    height: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
    min-height: unset !important;
    max-height: 34px !important;
    overflow: hidden !important;
    background: transparent !important;
}

/* Ocultar el icono de burbuja nativo para lograr la pureza visual de Google Gemini */
a[href*="/thread/"] svg[data-testid="ChatBubbleOutlineIcon"],
[id^="thread-"] svg[data-testid="ChatBubbleOutlineIcon"] {
    display: none !important;
}

/* Texto del título en una sola línea limpia con puntos suspensivos */
a[href*="/thread/"] p,
[id^="thread-"] p,
a[href*="/thread/"] span,
[id^="thread-"] span {
    flex: 1 1 auto !important;
    min-width: 0 !important;
    width: auto !important;
    max-width: 100% !important;
    margin: 0 !important;
    font-size: 13px !important;
    color: inherit !important;
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    text-align: left !important;
    line-height: 34px !important;
    font-weight: normal !important;
    text-transform: none !important;
}

/* Contenedor de acciones estilo Gemini (Fijar 📌, Renombrar ✏️, Carpeta 📁, Eliminar 🗑️) */
.gemini-chat-actions {
    display: inline-flex !important;
    align-items: center !important;
    gap: 1px !important;
    flex-shrink: 0 !important;
    margin-left: 4px !important;
    z-index: 5 !important;
}

.btn-chat-action {
    background: transparent !important;
    border: none !important;
    cursor: pointer !important;
    font-size: 11px !important;
    padding: 3px 4px !important;
    border-radius: 4px !important;
    line-height: 1 !important;
    display: none !important;
    opacity: 0.65 !important;
    transition: opacity 0.12s ease, transform 0.12s ease, background 0.12s ease !important;
    color: #94a3b8 !important;
}

/* Si el chat está fijado, el pin siempre es visible exactamente como en Gemini */
.btn-chat-action.btn-chat-pin.pinned {
    display: inline-flex !important;
    opacity: 0.95 !important;
    font-size: 12px !important;
}

/* Al pasar el cursor sobre la fila, mostrar todas las acciones */
.custom-history-row:hover .btn-chat-action,
a[href*="/thread/"]:hover .btn-chat-action,
[id^="thread-"]:hover .btn-chat-action {
    display: inline-flex !important;
}

.btn-chat-action:hover {
    opacity: 1 !important;
    background: rgba(255, 255, 255, 0.15) !important;
    transform: scale(1.15) !important;
}

.btn-chat-action.btn-chat-delete:hover {
    background: rgba(239, 68, 68, 0.25) !important;
    color: #f87171 !important;
}

/* Encabezados de fecha (Hoy, Ayer, etc.) estilo Gemini */
.chat-history-drawer ul > li > ul > div:first-child p,
.chat-history-drawer .MuiListSubheader-root,
.chat-history-drawer .MuiListSubheader-root p {
    background: transparent !important;
    background-color: transparent !important;
    color: #8e8ea0 !important;
    font-size: 11px !important;
    font-weight: 600 !important;
    letter-spacing: 0.05em !important;
    text-transform: uppercase !important;
    padding: 10px 14px 4px 14px !important;
    line-height: normal !important;
    height: auto !important;
    min-height: unset !important;
}

@media (hover: none) {
    .btn-chat-action {
        display: inline-flex !important;
        opacity: 0.8 !important;
    }
}

/* 9. NOTIFICACIÓN TOAST FLOTANTE */
#custom-toast {
    position: fixed;
    bottom: 24px;
    right: 24px;
    background: #1e293b;
    color: #ffffff;
    border: 1px solid rgba(59, 130, 246, 0.4);
    border-radius: 8px;
    padding: 10px 16px;
    font-size: 12px;
    font-weight: 600;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
    z-index: 999999;
    opacity: 0;
    transform: translateY(10px);
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    pointer-events: none;
}

#custom-toast.show {
    opacity: 1;
    transform: translateY(0);
}

/* ==============================================================================
   OVERRIDE: HEADER ORDENADO, LOGO GRANDE EN SIDEBAR, LOGO EN EL PIE JUNTO A CHAINLIT
   ============================================================================== */
#header {
    justify-content: flex-start !important;
}
#header > .custom-header-sort-btn {
    order: 1 !important;
    margin: 0 4px 0 0 !important;
}
#header > .custom-header-project-box {
    order: 2 !important;
    margin: 0 auto !important;
}
#header > .custom-header-right-stack {
    order: 3 !important;
    margin-left: auto !important;
}
#header img[alt="logo"],
#header img[src*="/logo"],
#header #custom-header-brand {
    display: none !important;
}

/* Logo del sidebar: grande casi de lado a lado */
.chat-history-drawer > .MuiDrawer-paper > .MuiStack-root:first-child,
.MuiDrawer-paper > .MuiStack-root:first-child {
    height: auto !important;
    min-height: 80px !important;
    padding: 10px 12px !important;
    justify-content: center !important;
}
.chat-history-drawer img[src*="logo"],
.MuiDrawer-paper img[src*="logo"],
.chat-history-drawer img[alt="DamsDigital"],
.MuiDrawer-paper img[alt="DamsDigital"],
.chat-history-drawer img[alt="logo"],
.MuiDrawer-paper img[alt="logo"] {
    width: 100% !important;
    height: auto !important;
    max-height: 85px !important;
    max-width: 100% !important;
    object-fit: contain !important;
}

/* Watermark en el pie: David Sierra al lado exactamente de Chainlit (sin sobreponer) */
.watermark,
.custom-watermark-row {
    display: flex !important;
    flex-direction: row !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 16px !important;
    padding: 6px 0 8px 0 !important;
    margin: 4px auto 0 auto !important;
    position: static !important;
    width: auto !important;
}

.custom-footer-brand-link {
    display: inline-flex !important;
    align-items: center !important;
    text-decoration: none !important;
    cursor: pointer !important;
    flex-shrink: 0 !important;
    transition: transform 0.2s ease, opacity 0.2s ease !important;
}

.custom-footer-brand-link:hover {
    transform: scale(1.05) !important;
}

.custom-footer-brand-link img {
    height: 30px !important;
    max-height: 32px !important;
    width: auto !important;
    object-fit: contain !important;
    filter: drop-shadow(0 2px 6px rgba(0, 0, 0, 0.5)) !important;
}

.watermark a[href*="chainlit"],
.watermark a[href*="Chainlit"],
.watermark a {
    display: inline-flex !important;
    align-items: center !important;
    text-decoration: none !important;
    opacity: 0.8 !important;
    transition: opacity 0.2s ease !important;
}

.watermark a[href*="chainlit"]:hover,
.watermark a[href*="Chainlit"]:hover,
.watermark a:hover {
    opacity: 1 !important;
}

.watermark p {
    margin: 0 !important;
    color: #94a3b8 !important;
    font-size: 12px !important;
}

/* ==============================================================================
   PANTALLA DIVIDIDA (SPLIT SCREEN VIEW) & DROPZONE DE ARRASTRE
   ============================================================================== */

body.split-active #root {
    position: fixed !important;
    top: 0; left: 0; bottom: 0;
    width: calc(100vw - var(--split-w, 50vw)) !important;
    max-width: calc(100vw - var(--split-w, 50vw)) !important;
    overflow: hidden !important;
}
/* Chainlit fija 100vw en los contenedores internos: forzarlos a seguir el ancho de #root */
body.split-active #root > div,
body.split-active #root > div > div,
body.split-active #root > div > div > div {
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
}
@media (max-width: 800px) {
    body.split-active #root { width: 100vw !important; max-width: 100vw !important; }
    #custom-split-view-container { width: 100vw !important; }
}

#custom-split-view-container {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: var(--split-w, 50vw);
    background: #0b0f19;
    border-left: 1px solid rgba(255, 255, 255, 0.12);
    z-index: 1300;
    display: flex;
    flex-direction: column;
    animation: splitSlideIn 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes splitSlideIn {
    from {
        transform: translateX(100%);
    }
    to {
        transform: translateX(0);
    }
}

.split-view-header {
    height: 48px;
    background: #111827;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 14px;
    color: #f1f5f9;
    font-size: 13px;
    font-weight: 600;
    user-select: none;
}

.split-view-header-title {
    display: flex;
    align-items: center;
    gap: 8px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 65%;
}

.split-view-header-title span.badge {
    background: rgba(255, 255, 255, 0.08);
    color: #cbd5e1;
    border: 1px solid rgba(255, 255, 255, 0.15);
    font-size: 10px;
    padding: 2px 6px;
    border-radius: 4px;
    font-weight: 700;
    text-transform: uppercase;
}

.split-view-actions {
    display: flex;
    align-items: center;
    gap: 6px;
}

.split-view-btn {
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.12);
    color: #cbd5e1;
    border-radius: 6px;
    padding: 4px 9px;
    font-size: 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 4px;
    transition: all 0.15s ease;
}

.split-view-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    color: #ffffff;
}

.split-view-btn.close:hover {
    background: rgba(239, 68, 68, 0.25);
    border-color: #ef4444;
    color: #fca5a5;
}

.split-view-iframe {
    flex: 1;
    width: 100%;
    min-height: 0;
    border: none;
    background: #0f172a;
}

/* ZONA DE SOLTAR (INVISIBLE, sin cuadro azul): mitad derecha de la pantalla mientras se arrastra un chat */
#custom-split-screen-dropzone {
    display: none;
    position: fixed;
    top: 0; right: 0; bottom: 0;
    width: 40%;
    background: transparent;
    border: none;
    z-index: 2000;
}
#custom-split-screen-dropzone > * { display: none !important; }
body.is-dragging-chat #custom-split-screen-dropzone { display: block; }
#custom-split-screen-dropzone.drag-hover { background: rgba(255,255,255,0.03); }

/* ESTILOS PARA CUANDO UN CHAT SE CARGA DENTRO DEL IFRAME DE SPLIT VIEW */
body.is-split-frame .chat-history-drawer {
    display: none !important;
}

body.is-split-frame #custom-chat-folder-bar {
    display: none !important;
}

body.is-split-frame #header {
    padding-left: 14px !important;
}

/* ==============================================================================
   DESPLEGABLES DE COMANDOS ("Used 🛠️ ..."): estilo consola con altura máxima
   (los pasos de herramienta tienen un id "step-🛠️ <nombre>" en su cabecera)
   ============================================================================== */
.step:has([id^="step-🛠"]) .message-content {
    max-height: 320px;
    overflow-y: auto;
    background: #0b0f19;
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 8px;
    margin: 6px 0 4px 0;
    padding: 6px 12px;
    box-sizing: border-box;
    max-width: 100%;
}
.step:has([id^="step-🛠"]) .message-content pre,
.step:has([id^="step-🛠"]) .message-content code {
    font-family: "JetBrains Mono", "Fira Code", Consolas, monospace !important;
    font-size: 12px !important;
    line-height: 1.5 !important;
    color: #cbd5e1 !important;
    background: transparent !important;
    white-space: pre-wrap !important;
    word-break: break-word !important;
}
.step:has([id^="step-🛠"]) .message-content::-webkit-scrollbar { width: 6px; }
.step:has([id^="step-🛠"]) .message-content::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 4px;
}

/* ==============================================================================
   SELECTOR DE MODO DE TRABAJO (Acción / Plan / Preguntar / Seguro)
   Sin tonos azules: rosa-coral, ámbar, verde azulado (teal) y esmeralda
   ============================================================================== */
.custom-mode-selector-wrapper {
    position: relative;
    display: inline-flex;
    align-items: center;
    flex-shrink: 0;
    margin-left: 2px;
}

.custom-mode-btn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    height: 32px;
    padding: 0 10px;
    border-radius: 9999px;
    font-size: 12.5px;
    font-weight: 600;
    line-height: 1;
    color: #f1f5f9;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.14);
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.15s ease, border-color 0.15s ease, transform 0.12s ease;
}

.custom-mode-btn:hover {
    background: rgba(255, 255, 255, 0.11);
}

.custom-mode-btn:active {
    transform: scale(0.97);
}

.custom-mode-btn.mode-action {
    color: #fecdd3;
    background: rgba(244, 63, 94, 0.14);
    border-color: rgba(251, 113, 133, 0.42);
}

.custom-mode-btn.mode-plan {
    color: #fde68a;
    background: rgba(245, 158, 11, 0.14);
    border-color: rgba(251, 191, 36, 0.42);
}

.custom-mode-btn.mode-ask {
    color: #99f6e4;
    background: rgba(20, 184, 166, 0.14);
    border-color: rgba(45, 212, 191, 0.42);
}

.custom-mode-btn.mode-safe {
    color: #a7f3d0;
    background: rgba(16, 185, 129, 0.14);
    border-color: rgba(52, 211, 153, 0.42);
}

.custom-mode-icon {
    font-size: 13px;
    line-height: 1;
}

.custom-mode-caret {
    font-size: 10px;
    opacity: 0.78;
    margin-left: 1px;
}

.custom-mode-popover {
    position: absolute;
    left: 0;
    width: 258px;
    z-index: 9999;
    background: #14171f;
    border: 1px solid rgba(255, 255, 255, 0.14);
    border-radius: 12px;
    padding: 6px;
    box-shadow: 0 14px 34px rgba(0, 0, 0, 0.55);
    display: none;
    flex-direction: column;
    gap: 4px;
}

.custom-mode-popover.open {
    display: flex;
}

.custom-mode-popover.open-up {
    bottom: calc(100% + 8px);
    top: auto;
}

.custom-mode-popover.open-down {
    top: calc(100% + 8px);
    bottom: auto;
}

.custom-mode-popover.align-right {
    left: auto;
    right: 0;
}

.custom-mode-option {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    border-radius: 8px;
    border: 1px solid transparent;
    background: transparent;
    color: #e2e8f0;
    text-align: left;
    cursor: pointer;
    transition: background 0.12s ease, border-color 0.12s ease;
}

.custom-mode-option:hover {
    background: rgba(255, 255, 255, 0.06);
}

.custom-mode-option.opt-action.active {
    background: rgba(244, 63, 94, 0.14);
    border-color: rgba(251, 113, 133, 0.35);
}

.custom-mode-option.opt-plan.active {
    background: rgba(245, 158, 11, 0.14);
    border-color: rgba(251, 191, 36, 0.35);
}

.custom-mode-option.opt-ask.active {
    background: rgba(20, 184, 166, 0.14);
    border-color: rgba(45, 212, 191, 0.35);
}

.custom-mode-option.opt-safe.active {
    background: rgba(16, 185, 129, 0.14);
    border-color: rgba(52, 211, 153, 0.35);
}

.custom-mode-opt-icon {
    font-size: 16px;
    line-height: 1;
    flex-shrink: 0;
}

.custom-mode-opt-text {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
    flex: 1;
}

.custom-mode-opt-title {
    font-size: 13px;
    font-weight: 600;
    color: #f8fafc;
    line-height: 1.2;
}

.custom-mode-opt-desc {
    font-size: 11px;
    color: #94a3b8;
    line-height: 1.25;
}

.custom-mode-opt-check {
    font-size: 12px;
    font-weight: 700;
    opacity: 0;
    color: #f8fafc;
    flex-shrink: 0;
}

.custom-mode-option.active .custom-mode-opt-check {
    opacity: 1;
}

/* ==============================================================================
   ACELERACIÓN DE RENDERIZADO, AISLAMIENTO DE REFLOW Y OPTIMIZACIÓN MÓVIL
   ============================================================================== */

/* Virtualización nativa de mensajes fuera de pantalla y aislamiento de layout */
.step {
    content-visibility: auto;
    contain-intrinsic-size: auto 110px;
    contain: layout style;
}

/* Aislar el cuadro de texto para que TextareaAutosize al escribir no recalcule mensajes previos */
.MuiBox-root:has(> #chat-input),
.MuiInputBase-root:has(#chat-input),
.MuiFormControl-root:has(#chat-input) {
    contain: layout style;
}

/* Eliminar transition: all costosas sustituyéndolas por propiedades específicas */
.custom-folder-pill-btn {
    transition: background-color 0.16s ease, border-color 0.16s ease, color 0.16s ease, transform 0.16s ease !important;
}
.custom-folder-modal-new-btn,
.custom-add-folder-btn,
.custom-folder-card,
.custom-thread-item,
.custom-unassigned-dropzone,
.split-view-btn,
#custom-toast {
    transition: background-color 0.16s ease, border-color 0.16s ease, color 0.16s ease, opacity 0.16s ease, transform 0.16s ease !important;
}
#custom-projects-container {
    transition: padding 0.16s ease !important;
}

/* Optimización estricta para celulares y pantallas táctiles */
@media (max-width: 768px), (hover: none), (pointer: coarse) {
    #custom-chat-folder-bar {
        backdrop-filter: none !important;
        -webkit-backdrop-filter: none !important;
        background: #121826 !important;
    }

    #custom-folder-dropdown-modal {
        backdrop-filter: none !important;
        -webkit-backdrop-filter: none !important;
        background: rgba(0, 0, 0, 0.72) !important;
    }

    .chat-history-drawer img[src*="logo"],
    .MuiDrawer-paper img[src*="logo"],
    .custom-footer-brand-link img {
        filter: none !important;
    }

    /* Evitar zoom automático y congelamiento de teclado virtual en iOS Safari / Android */
    #chat-input,
    #chat-input textarea,
    textarea#chat-input,
    #edit-chat-input,
    #edit-chat-input textarea {
        font-size: 16px !important;
    }

    /* Respuesta táctil inmediata sin retardo de 300ms y scroll fluido en sidebar */
    .custom-history-row,
    .custom-thread-item,
    .custom-folder-header,
    .custom-mode-btn,
    .btn-chat-action,
    .custom-folder-pill-btn,
    button {
        touch-action: manipulation;
    }

    .chat-history-drawer .MuiDrawer-paper,
    .chat-history-drawer .MuiBox-root {
        -webkit-overflow-scrolling: touch;
        overscroll-behavior: contain;
    }

    .btn-chat-action:hover,
    .custom-thread-item:hover {
        transform: none !important;
    }
}

@media (prefers-reduced-motion: reduce) {
    *, ::before, ::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

@media (max-width: 480px) {
    .custom-mode-btn {
        padding: 0 8px;
    }
    .custom-mode-label {
        display: none;
    }
}

/* ==============================================================================
   BOTÓN COMPACTAR EN BARRA DE CHAT & SECCIÓN COLAPSABLE DE ARCHIVADOS
   ============================================================================== */
.custom-folder-bar-right {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}

.custom-compact-btn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    background: rgba(16, 185, 129, 0.14);
    border: 1px solid rgba(52, 211, 153, 0.35);
    color: #a7f3d0;
    border-radius: 16px;
    padding: 3px 10px;
    font-size: 11.5px;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.custom-compact-btn:hover:not(:disabled) {
    background: rgba(16, 185, 129, 0.25);
    border-color: rgba(52, 211, 153, 0.65);
    color: #ffffff;
}

.custom-compact-btn:disabled {
    opacity: 0.65;
    cursor: wait;
}

#custom-archived-container {
    margin: 8px 6px 14px 6px;
    padding: 4px 6px;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.custom-archived-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 8px;
    border-radius: 6px;
    cursor: pointer;
    user-select: none;
    transition: background-color 0.15s ease;
}

.custom-archived-header:hover {
    background: rgba(255, 255, 255, 0.05);
}

.custom-archived-title {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #94a3b8;
    display: flex;
    align-items: center;
    gap: 6px;
}

.custom-archived-chevron {
    font-size: 10px;
    color: #64748b;
}

.custom-archived-count {
    font-size: 10px;
    color: #94a3b8;
    background: rgba(255, 255, 255, 0.08);
    padding: 0 6px;
    border-radius: 10px;
}

.custom-archived-list {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.custom-archived-row {
    opacity: 0.78;
}

.custom-archived-row:hover {
    opacity: 1;
}

.btn-chat-unarchive {
    display: inline-flex !important;
    opacity: 0.8 !important;
}

/* ==============================================================================
   ALERTAS VISUALES POR CANTIDAD DE CAJITAS (🛠️) Y TAMAÑO DEL CHAT
   ============================================================================== */
.custom-compact-badge {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    flex-shrink: 0;
    font-size: 10px;
    font-weight: 700;
    line-height: 1;
    padding: 2px 5px;
    border-radius: 9999px;
    margin-left: 4px;
    font-variant-numeric: tabular-nums;
}

.custom-compact-badge.critical {
    background: rgba(239, 68, 68, 0.22);
    color: #fca5a5;
    border: 1px solid rgba(248, 113, 113, 0.45);
}

.custom-compact-badge.warn {
    background: rgba(245, 158, 11, 0.16);
    color: #fcd34d;
    border: 1px solid rgba(251, 191, 36, 0.35);
}

.custom-history-row.is-compact-critical {
    box-shadow: inset 3px 0 0 #ef4444 !important;
}

.custom-thread-item.is-compact-critical {
    border-left: 3px solid #ef4444 !important;
}

#custom-chat-folder-bar.alert-critical {
    background: rgba(69, 10, 10, 0.88) !important;
    border-bottom: 1px solid rgba(248, 113, 113, 0.45) !important;
}

#custom-chat-folder-bar.alert-warn {
    border-bottom: 1px solid rgba(251, 191, 36, 0.35) !important;
}

.custom-bar-alert-pill {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    border-radius: 9999px;
    font-size: 11px;
    font-weight: 600;
    color: #fecaca;
    background: rgba(220, 38, 38, 0.28);
    border: 1px solid rgba(248, 113, 113, 0.48);
    white-space: nowrap;
}

.custom-compact-btn.critical {
    background: rgba(220, 38, 38, 0.28);
    border-color: rgba(248, 113, 113, 0.7);
    color: #fee2e2;
}

.custom-compact-btn.critical:hover:not(:disabled) {
    background: #dc2626;
    border-color: #ef4444;
    color: #ffffff;
}

.custom-compact-btn.warn {
    background: rgba(245, 158, 11, 0.2);
    border-color: rgba(251, 191, 36, 0.55);
    color: #fef3c7;
}

@media (max-width: 660px) {
    .custom-bar-alert-pill {
        display: none;
    }
    .custom-compact-btn {
        font-size: 11px;
        padding: 3px 8px;
    }
}

/* Botón flotante para ir al último mensaje del chat */
#custom-scroll-bottom-btn {
    position: fixed;
    right: 18px;
    bottom: 92px;
    z-index: 900;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 7px 12px;
    border-radius: 9999px;
    background: #1e293b;
    color: #f1f5f9;
    border: 1px solid rgba(148, 163, 184, 0.35);
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.45);
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    opacity: 0;
    pointer-events: none;
    transform: translateY(8px);
    transition: opacity 0.16s ease, transform 0.16s ease, background-color 0.16s ease;
    touch-action: manipulation;
}

#custom-scroll-bottom-btn.visible {
    opacity: 0.94;
    pointer-events: auto;
    transform: translateY(0);
}

#custom-scroll-bottom-btn:hover {
    background: #334155;
    opacity: 1;
}

@media (max-width: 660px) {
    #custom-scroll-bottom-btn {
        right: 12px;
        bottom: 84px;
        padding: 7px 10px;
    }
}

/* ==============================================================================
   AJUSTE DE LÍNEA EN BLOQUES DE TEXTO (```text, ```markdown, ```log, etc.)
   Evita scroll horizontal infinito y mantiene todo visible dentro de la pantalla
   ============================================================================== */
.step .ai-message,
.step .ai-message > .MuiStack-root,
.step .ai-message .MuiTypography-root,
.step .ai-message .MuiBox-root {
    min-width: 0 !important;
    max-width: 100% !important;
}

.step .MuiTypography-root p,
.step .MuiTypography-root li,
.step .MuiTypography-root a {
    overflow-wrap: anywhere;
}

.step pre {
    max-width: 100% !important;
    box-sizing: border-box !important;
}

.step pre code.language-text,
.step pre code.language-txt,
.step pre code.language-plaintext,
.step pre code.language-markdown,
.step pre code.language-md,
.step pre code.language-log,
.step pre code.language-csv,
.step pre code.language-ini,
.step pre code.language-json,
.step pre code.hljs.language-text,
.step pre code.hljs.language-txt,
.step pre code.hljs.language-plaintext,
.step pre code.hljs.language-markdown,
.step pre code.hljs.language-md,
.step pre code.hljs.language-log,
.step pre code.hljs.language-csv,
.step pre code.hljs.language-ini,
.step pre code.hljs.language-json {
    white-space: pre-wrap !important;
    overflow-wrap: anywhere !important;
    word-break: break-word !important;
    overflow-x: hidden !important;
}

@media (max-width: 768px), (hover: none), (pointer: coarse) {
    .step pre code,
    .step pre code.hljs {
        white-space: pre-wrap !important;
        overflow-wrap: anywhere !important;
        word-break: break-word !important;
        overflow-x: hidden !important;
    }
}

/* ==============================================================================
   AJUSTES DINÁMICOS DE MODELO Y RAZONAMIENTO EN CHAT SETTINGS
   ============================================================================== */
#chat-settings-dialog .custom-effort-locked #mui-component-select-effort {
    pointer-events: none;
    opacity: 0.68;
    cursor: not-allowed;
}

#chat-settings-dialog .custom-effort-locked .MuiOutlinedInput-root,
#chat-settings-dialog .custom-effort-locked .MuiInputBase-root {
    pointer-events: none;
    opacity: 0.68;
    cursor: not-allowed;
}

.custom-effort-model-hint {
    margin-top: 6px;
    padding: 6px 10px;
    border-radius: 8px;
    font-size: 12px;
    line-height: 1.35;
    color: #93c5fd;
    background: rgba(59, 130, 246, 0.12);
    border: 1px solid rgba(59, 130, 246, 0.28);
}

.custom-effort-model-hint.is-locked {
    color: #fcd34d;
    background: rgba(245, 158, 11, 0.12);
    border-color: rgba(245, 158, 11, 0.34);
}

/* ==============================================================================
   VAULT SEGURO WOLKVOX (BOTON + MODAL ZERO-LEAK)
   ============================================================================== */
.custom-vault-btn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 5px 10px;
    margin-left: 6px;
    border-radius: 10px;
    border: 1px solid rgba(16, 185, 129, 0.35);
    background: rgba(16, 185, 129, 0.12);
    color: #6ee7b7;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.18s ease;
    white-space: nowrap;
}

.custom-vault-btn:hover {
    background: rgba(16, 185, 129, 0.24);
    border-color: rgba(16, 185, 129, 0.65);
}

@media (max-width: 600px) {
    .custom-vault-label {
        display: none;
    }
}

#custom-wolkvox-vault-modal {
    position: fixed;
    inset: 0;
    z-index: 99999;
    background: rgba(2, 6, 23, 0.72);
    backdrop-filter: blur(6px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
}

.custom-vault-card {
    width: 100%;
    max-width: 560px;
    max-height: 90vh;
    overflow-y: auto;
    background: #0f172a;
    color: #f8fafc;
    border: 1px solid rgba(148, 163, 184, 0.25);
    border-radius: 16px;
    padding: 18px 20px;
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.55);
}

.custom-vault-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    padding-bottom: 12px;
    border-bottom: 1px solid rgba(148, 163, 184, 0.18);
    margin-bottom: 12px;
}

.custom-vault-title {
    font-size: 15px;
    font-weight: 700;
    color: #f1f5f9;
}

.custom-vault-sub {
    font-size: 12px;
    color: #94a3b8;
    margin-top: 3px;
}

.custom-vault-section-title {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #94a3b8;
    margin-bottom: 8px;
}

.custom-vault-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 180px;
    overflow-y: auto;
}

.custom-vault-empty {
    font-size: 12px;
    color: #94a3b8;
    padding: 10px 12px;
    border-radius: 10px;
    background: rgba(30, 41, 59, 0.6);
}

.custom-vault-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 9px 12px;
    border-radius: 10px;
    background: rgba(30, 41, 59, 0.78);
    border: 1px solid rgba(148, 163, 184, 0.16);
}

.custom-vault-row-alias {
    font-size: 13px;
    font-weight: 700;
    color: #e2e8f0;
}

.custom-vault-row-desc {
    font-weight: 400;
    font-size: 12px;
    color: #94a3b8;
}

.custom-vault-row-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    font-size: 11px;
    color: #cbd5e1;
    margin-top: 3px;
}

.custom-vault-del-btn {
    background: rgba(239, 68, 68, 0.14);
    border: 1px solid rgba(239, 68, 68, 0.35);
    color: #fca5a5;
    border-radius: 8px;
    padding: 5px 8px;
    cursor: pointer;
    font-size: 12px;
}

.custom-vault-del-btn:hover {
    background: rgba(239, 68, 68, 0.28);
}

.custom-vault-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.custom-vault-grid label {
    display: flex;
    flex-direction: column;
    gap: 4px;
    font-size: 11px;
    color: #cbd5e1;
}

.custom-vault-grid label.full-col {
    grid-column: 1 / -1;
}

.custom-vault-grid input {
    background: #020617;
    color: #f8fafc;
    border: 1px solid rgba(148, 163, 184, 0.28);
    border-radius: 8px;
    padding: 7px 10px;
    font-size: 12px;
    outline: none;
}

.custom-vault-grid input:focus {
    border-color: #10b981;
}

.custom-vault-msg {
    font-size: 12px;
    margin-top: 10px;
    min-height: 16px;
}

.custom-vault-msg.is-ok { color: #34d399; }
.custom-vault-msg.is-err { color: #f87171; }

.custom-vault-actions {
    display: flex;
    justify-content: flex-end;
    margin-top: 10px;
}

.custom-vault-save-btn {
    background: linear-gradient(135deg, #10b981, #059669);
    color: #ffffff;
    border: none;
    border-radius: 10px;
    padding: 8px 16px;
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
}

.custom-vault-save-btn:hover {
    filter: brightness(1.08);
}

