/* ==============================================================================
   ABAKOS RAG — SITIOS & MARCADORES FAVORITOS (ADR-096)
   Estilos para Conmutador Naranja Sunset, Árbol Estilo Chrome y Squircles HD
   ============================================================================== */

/* --- Botón Naranja en el Rail Colapsado --- */
.sidebar-rail-btn.rail-btn-bookmarks {
    color: #f97316;
    background: rgba(249, 115, 22, 0.12);
    border: 2px solid rgba(249, 115, 22, 0.45);
    margin-bottom: 6px;
    box-shadow: 0 0 10px rgba(249, 115, 22, 0.15);
    transition: all 0.22s cubic-bezier(0.16, 1, 0.3, 1);
}

.sidebar-rail-btn.rail-btn-bookmarks:hover {
    color: #ffffff;
    background: rgba(249, 115, 22, 0.28);
    border-color: #f97316;
    transform: scale(1.12);
    box-shadow: 0 0 20px rgba(249, 115, 22, 0.6), 0 0 4px rgba(249, 115, 22, 0.8);
}

.sidebar-rail-btn.rail-btn-bookmarks.active {
    background: rgba(249, 115, 22, 0.2);
    border-color: #f97316;
    color: #fb923c;
    box-shadow: 0 0 14px rgba(249, 115, 22, 0.45);
}

/* --- Botón Naranja en la Cabecera del Sidebar (Modo Expandido) --- */
.btn-header-bookmarks {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 28px;
    padding: 0 10px;
    background: rgba(249, 115, 22, 0.08);
    border: 1px solid rgba(249, 115, 22, 0.25);
    border-radius: 8px;
    color: #f97316;
    font-size: 11.5px;
    font-weight: 600;
    cursor: pointer;
    user-select: none;
    transition: all 0.2s ease;
    margin-left: auto;
}

.btn-header-bookmarks:hover {
    color: #ffedd5;
    background: linear-gradient(135deg, rgba(249, 115, 22, 0.25), rgba(234, 88, 12, 0.35));
    border-color: rgba(249, 115, 22, 0.5);
    transform: translateY(-1px);
    box-shadow: 0 2px 10px rgba(249, 115, 22, 0.25);
}

.btn-header-bookmarks.active {
    color: #ffffff;
    background: linear-gradient(135deg, #f97316, #ea580c);
    border-color: #fb923c;
    box-shadow: 0 0 14px rgba(249, 115, 22, 0.45);
}

.app-layout.sidebar-collapsed .btn-header-bookmarks {
    display: none !important;
}

/* --- Salvaguardas Estrictas de Layout (Aislamiento de Secciones) --- */
#mainWorkspaceLayout:not(.bookmarks-mode-active) #bookmarksWorkspaceContainer {
    display: none !important;
}

#mainWorkspaceLayout.bookmarks-mode-active #splitChatSection,
#mainWorkspaceLayout.bookmarks-mode-active #documentViewerContainer,
#mainWorkspaceLayout.bookmarks-mode-active #splitGripResizer {
    display: none !important;
}

#bmModalHost .modal-overlay {
    display: flex !important;
}

/* --- Contenedor Principal del Workspace de Marcadores --- */
.bookmarks-workspace-container {
    display: flex;
    flex-direction: column;
    width: 100%;
    height: 100%;
    background: var(--bg-surface, #0f172a);
    color: var(--text-primary, #f1f5f9);
    overflow: hidden;
    position: relative;
    box-sizing: border-box;
}

/* Cabecera del Workspace */
.bookmarks-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 20px;
    border-bottom: 1px solid var(--border-color, rgba(255, 255, 255, 0.08));
    background: var(--bg-surface-elevated, rgba(15, 23, 42, 0.75));
    backdrop-filter: blur(12px);
    gap: 12px;
    flex-wrap: wrap;
    flex-shrink: 0;
}

.bookmarks-title-group {
    display: flex;
    align-items: center;
    gap: 10px;
}

.bookmarks-title-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    background: rgba(249, 115, 22, 0.12);
    border: 1px solid rgba(249, 115, 22, 0.3);
    color: #f97316;
}

.bookmarks-title-text {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.bookmarks-main-title {
    font-size: 15px;
    font-weight: 700;
    letter-spacing: -0.01em;
    display: flex;
    align-items: center;
    gap: 8px;
}

.bookmarks-count-pill {
    font-size: 11px;
    font-weight: 600;
    padding: 1px 7px;
    border-radius: 12px;
    background: rgba(249, 115, 22, 0.15);
    color: #fb923c;
    border: 1px solid rgba(249, 115, 22, 0.25);
}

.bookmarks-subtitle {
    font-size: 11.5px;
    color: var(--text-muted, #94a3b8);
}

/* Barra de Búsqueda y Botones de Acción */
.bookmarks-header-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

.bookmarks-search-wrapper {
    position: relative;
    display: flex;
    align-items: center;
    width: 260px;
    max-width: 100%;
}

.bookmarks-search-icon {
    position: absolute;
    left: 10px;
    color: var(--text-muted, #94a3b8);
    pointer-events: none;
}

.bookmarks-search-input {
    width: 100%;
    height: 32px;
    padding: 0 28px 0 32px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--border-color, rgba(255, 255, 255, 0.1));
    border-radius: 8px;
    color: var(--text-primary, #f1f5f9);
    font-size: 12px;
    outline: none;
    transition: all 0.2s ease;
}

.bookmarks-search-input:focus {
    border-color: #f97316;
    background: rgba(249, 115, 22, 0.04);
    box-shadow: 0 0 0 2px rgba(249, 115, 22, 0.2);
}

.bookmarks-search-clear {
    position: absolute;
    right: 8px;
    background: transparent;
    border: none;
    color: var(--text-muted, #94a3b8);
    cursor: pointer;
    font-size: 12px;
    display: none;
}

.btn-bm-head {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 32px;
    padding: 0 12px;
    border-radius: 8px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    border: 1px solid transparent;
}

.btn-bm-head.primary {
    background: linear-gradient(135deg, #f97316, #ea580c);
    color: #ffffff;
    border-color: #fb923c;
    box-shadow: 0 2px 8px rgba(249, 115, 22, 0.3);
}

.btn-bm-head.primary:hover {
    background: linear-gradient(135deg, #fb923c, #f97316);
    box-shadow: 0 4px 12px rgba(249, 115, 22, 0.45);
    transform: translateY(-1px);
}

.btn-bm-head.secondary {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-primary, #f1f5f9);
    border-color: var(--border-color, rgba(255, 255, 255, 0.12));
}

.btn-bm-head.secondary:hover {
    background: rgba(255, 255, 255, 0.09);
    border-color: rgba(255, 255, 255, 0.2);
    transform: translateY(-1px);
}

.btn-bm-head.return {
    background: rgba(255, 255, 255, 0.03);
    color: var(--text-muted, #94a3b8);
    border-color: var(--border-color, rgba(255, 255, 255, 0.08));
}

.btn-bm-head.return:hover {
    background: rgba(239, 68, 68, 0.12);
    color: #f87171;
    border-color: rgba(239, 68, 68, 0.3);
}

/* --- Cuerpo y Árbol de Marcadores (Chrome Style) --- */
.bookmarks-body {
    flex: 1;
    overflow-y: auto;
    padding: 16px 24px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    box-sizing: border-box;
}

/* Nodo Carpeta */
.bm-folder-block {
    display: flex;
    flex-direction: column;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--border-color, rgba(255, 255, 255, 0.06));
    overflow: hidden;
    transition: border-color 0.2s ease;
}

.bm-folder-block:hover {
    border-color: rgba(249, 115, 22, 0.25);
}

.bm-folder-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
    cursor: pointer;
    user-select: none;
    background: rgba(255, 255, 255, 0.02);
    transition: background 0.15s ease;
}

.bm-folder-header:hover {
    background: rgba(249, 115, 22, 0.06);
}

.bm-folder-title-left {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    font-weight: 600;
}

.bm-folder-chevron {
    width: 14px;
    height: 14px;
    color: var(--text-muted, #94a3b8);
    transition: transform 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.bm-folder-block.is-collapsed .bm-folder-chevron {
    transform: rotate(-90deg);
}

.bm-folder-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    border-radius: 6px;
    background: rgba(59, 130, 246, 0.15);
    color: #60a5fa;
    border: 1px solid rgba(59, 130, 246, 0.3);
}

.bm-folder-count {
    font-size: 11px;
    font-weight: 500;
    color: var(--text-muted, #94a3b8);
}

.bm-folder-actions {
    display: flex;
    align-items: center;
    gap: 4px;
    opacity: 0;
    transition: opacity 0.15s ease;
}

.bm-folder-header:hover .bm-folder-actions {
    opacity: 1;
}

.btn-bm-mini-opt {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    border-radius: 6px;
    border: none;
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-muted, #94a3b8);
    cursor: pointer;
    transition: all 0.15s ease;
}

.btn-bm-mini-opt:hover {
    background: rgba(255, 255, 255, 0.12);
    color: var(--text-primary, #f1f5f9);
}

/* Contenedor de Items dentro de la Carpeta */
.bm-folder-content {
    display: flex;
    flex-direction: column;
    padding: 4px 8px 8px 24px;
    gap: 4px;
    border-top: 1px solid var(--border-color, rgba(255, 255, 255, 0.04));
}

.bm-folder-block.is-collapsed .bm-folder-content {
    display: none;
}

/* Fila de Marcador / Sitio */
.bm-item-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid transparent;
    transition: all 0.18s cubic-bezier(0.16, 1, 0.3, 1);
    cursor: pointer;
}

.bm-item-row:hover {
    background: rgba(255, 255, 255, 0.05);
    border-color: rgba(249, 115, 22, 0.3);
    transform: translateX(2px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
}

.bm-item-left {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
    flex: 1;
}

/* Squircle de Favicon en Alta Resolución (32x32px) */
.bm-squircle-icon {
    width: 32px;
    height: 32px;
    min-width: 32px;
    min-height: 32px;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.15);
    transition: transform 0.2s ease, border-color 0.2s ease;
}

.bm-item-row:hover .bm-squircle-icon {
    transform: scale(1.05);
    border-color: rgba(249, 115, 22, 0.4);
}

.bm-squircle-icon img {
    width: 20px;
    height: 20px;
    object-fit: contain;
}

.bm-squircle-fallback {
    font-size: 12px;
    font-weight: 700;
    color: #fb923c;
    text-transform: uppercase;
}

/* Información del Marcador */
.bm-item-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.bm-item-title-row {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
}

.bm-item-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary, #f1f5f9);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.bm-item-domain {
    font-size: 11.5px;
    color: var(--text-muted, #94a3b8);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.bm-item-notes {
    font-size: 11.5px;
    color: #cbd5e1;
    opacity: 0.9;
    white-space: normal !important;
    overflow: visible !important;
    text-overflow: clip !important;
    display: block !important;
    line-height: 1.45 !important;
    word-break: break-word !important;
    max-width: 100% !important;
    margin-top: 3px;
    margin-bottom: 2px;
}

/* Botonera de Acciones en la Fila */
.bm-item-actions {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-left: 12px;
    flex-shrink: 0;
}

.btn-bm-action {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    height: 26px;
    padding: 0 8px;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    border: 1px solid transparent;
    transition: all 0.15s ease;
}

/* Abrir Enlace */
.btn-bm-action.btn-bm-open {
    background: rgba(59, 130, 246, 0.1);
    color: #60a5fa;
    border-color: rgba(59, 130, 246, 0.25);
}

.btn-bm-action.btn-bm-open:hover {
    background: rgba(59, 130, 246, 0.2);
    border-color: rgba(59, 130, 246, 0.5);
    color: #93c5fd;
}

/* Botón Convertir a Wiki (Scraping a Demanda) */
.btn-bm-action.btn-bm-wiki {
    background: rgba(129, 140, 248, 0.12);
    color: #a5b4fc;
    border-color: rgba(129, 140, 248, 0.3);
}

.btn-bm-action.btn-bm-wiki:hover {
    background: linear-gradient(135deg, rgba(129, 140, 248, 0.25), rgba(99, 102, 241, 0.35));
    border-color: rgba(129, 140, 248, 0.6);
    color: #e0e7ff;
    box-shadow: 0 0 10px rgba(129, 140, 248, 0.3);
}

@keyframes bmSpin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.bm-action-spinner {
    animation: bmSpin 0.75s linear infinite !important;
    display: inline-block !important;
    vertical-align: middle;
}

/* Si ya fue convertido a Wiki: Ver en Wiki */
.btn-bm-action.btn-bm-wiki.is-converted {
    background: rgba(16, 185, 129, 0.12);
    color: #34d399;
    border-color: rgba(16, 185, 129, 0.3);
}

.btn-bm-action.btn-bm-wiki.is-converted:hover {
    background: rgba(16, 185, 129, 0.22);
    border-color: rgba(16, 185, 129, 0.6);
    color: #a7f3d0;
    box-shadow: 0 0 10px rgba(16, 185, 129, 0.3);
}

/* Copiar URL */
.btn-bm-action.btn-bm-copy {
    background: rgba(255, 255, 255, 0.04);
    color: var(--text-muted, #94a3b8);
    border-color: var(--border-color, rgba(255, 255, 255, 0.08));
}

.btn-bm-action.btn-bm-copy:hover {
    background: rgba(255, 255, 255, 0.09);
    color: var(--text-primary, #f1f5f9);
}

/* Menú Contextual ⋮ */
.btn-bm-action.btn-bm-more {
    padding: 0 6px;
    background: transparent;
    color: var(--text-muted, #94a3b8);
}

.btn-bm-action.btn-bm-more:hover {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-primary, #f1f5f9);
}

/* Empty State / Sin Marcadores */
.bookmarks-empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 48px 24px;
    text-align: center;
    gap: 12px;
    margin: auto 0;
}

.bookmarks-empty-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    background: rgba(249, 115, 22, 0.1);
    border: 1px solid rgba(249, 115, 22, 0.25);
    color: #f97316;
    display: flex;
    align-items: center;
    justify-content: center;
}

.bookmarks-empty-title {
    font-size: 16px;
    font-weight: 700;
}

.bookmarks-empty-desc {
    font-size: 13px;
    color: var(--text-muted, #94a3b8);
    max-width: 380px;
    line-height: 1.5;
}

/* --- Modo Claro Adaptativo --- */
[data-theme="light"] .bookmarks-workspace-container {
    background: #faf7f2;
    color: #1e293b;
}

[data-theme="light"] .bookmarks-header {
    background: rgba(255, 255, 255, 0.85);
    border-color: rgba(0, 0, 0, 0.08);
}

[data-theme="light"] .bookmarks-search-input {
    background: #ffffff;
    border-color: rgba(0, 0, 0, 0.12);
    color: #0f172a;
}

[data-theme="light"] .bm-folder-block {
    background: #ffffff;
    border-color: rgba(0, 0, 0, 0.06);
}

[data-theme="light"] .bm-folder-header {
    background: rgba(0, 0, 0, 0.02);
}

[data-theme="light"] .bm-item-row {
    background: #ffffff;
    border-color: rgba(0, 0, 0, 0.04);
}

[data-theme="light"] .bm-item-row:hover {
    background: #fff7ed;
    border-color: rgba(249, 115, 22, 0.4);
}

[data-theme="light"] .bm-squircle-icon {
    background: #f8fafc;
    border-color: rgba(0, 0, 0, 0.08);
}

/* Modal Moderno Post-Conversión a Wiki */
.bm-wiki-success-card {
    background: #0f172a !important;
}

[data-theme="light"] .bm-wiki-success-card {
    background: #ffffff !important;
    border: 1px solid rgba(99, 102, 241, 0.25) !important;
    box-shadow: 0 20px 50px rgba(15, 23, 42, 0.25), 0 0 35px rgba(99, 102, 241, 0.1) !important;
}

[data-theme="light"] .bm-wiki-success-preview {
    background: #f8fafc !important;
    border: 1px solid rgba(0, 0, 0, 0.08) !important;
}

#btnOpenInWikiNow:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 22px rgba(99, 102, 241, 0.55) !important;
    filter: brightness(1.08);
}
#btnOpenInWikiNow:active {
    transform: translateY(0);
}

/* ==============================================================================
   RESPONSIVE M?VIL Y TABLETS: OPTIMIZACI?N QUIR?RGICA FAVORITOS (< 900px)
   ============================================================================== */
.bm-mobile-sidebar-toggle {
    display: none;
}
.bm-title-text-compact {
    display: none;
}

@media (max-width: 899px) {
    .bm-mobile-sidebar-toggle {
        display: inline-flex !important;
        margin-right: 4px;
        flex-shrink: 0;
    }
    .bookmarks-header {
        padding: 8px 10px;
        gap: 8px;
        flex-wrap: nowrap;
        min-height: 44px;
    }
    .bookmarks-title-group {
        gap: 6px;
        min-width: 0;
        flex-shrink: 1;
    }
    .bookmarks-subtitle {
        display: none !important;
    }
    .bookmarks-main-title {
        font-size: 13px;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }
    .bookmarks-title-icon {
        display: none;
    }
    .bookmarks-header-actions {
        display: flex;
        align-items: center;
        gap: 6px;
        flex-shrink: 0;
        margin-left: auto;
    }
    .bookmarks-search-wrapper {
        width: 120px;
        min-width: 70px;
    }
    .bookmarks-search-input {
        padding: 4px 8px 4px 26px;
        font-size: 11px;
        height: 28px;
    }
    .btn-bm-head {
        height: 28px;
        padding: 0 8px;
        font-size: 11px;
    }
    .btn-bm-head span {
        display: none !important;
    }
    .btn-bm-head svg {
        width: 13px;
        height: 13px;
    }
    .bookmarks-body {
        padding: 10px 8px !important;
        gap: 8px !important;
    }
    .bm-folder-block {
        border-radius: 8px;
    }
    .bm-folder-header {
        padding: 7px 8px !important;
    }
    .bm-folder-actions {
        opacity: 1 !important;
    }
    .bm-folder-content {
        padding: 4px 6px 6px 10px !important;
        gap: 6px !important;
    }
}

@media (max-width: 640px) {
    .bm-title-text-full {
        display: none !important;
    }
    .bm-title-text-compact {
        display: inline !important;
        font-weight: 700;
    }
    .bookmarks-search-wrapper {
        width: 95px;
    }
    .bookmarks-search-input {
        font-size: 10.5px;
        padding-left: 24px;
    }
    .bookmarks-search-icon {
        left: 6px;
        width: 12px;
        height: 12px;
    }
    .btn-bm-head {
        width: 28px;
        height: 28px;
        padding: 0;
        justify-content: center;
    }
    
    /* Layout Vertical en 2 niveles para Fila de Marcador: Icono+Texto arriba, Botones abajo */
    .bm-item-row {
        flex-direction: column !important;
        align-items: stretch !important;
        gap: 8px !important;
        padding: 9px 10px !important;
    }
    .bm-item-left {
        width: 100% !important;
        min-width: 0 !important;
        gap: 10px !important;
        align-items: flex-start !important;
    }
    .bm-squircle-icon {
        width: 32px !important;
        height: 32px !important;
        min-width: 32px !important;
        min-height: 32px !important;
        flex-shrink: 0 !important;
        margin-top: 1px !important;
    }
    .bm-item-info {
        flex: 1 !important;
        min-width: 0 !important;
        gap: 3px !important;
    }
    .bm-item-title-row {
        width: 100% !important;
    }
    .bm-item-title {
        font-size: 13px !important;
        white-space: normal !important;
        display: -webkit-box !important;
        -webkit-line-clamp: 2 !important;
        -webkit-box-orient: vertical !important;
        overflow: hidden !important;
        line-height: 1.35 !important;
        word-break: break-word !important;
    }
    .bm-item-domain {
        font-size: 11px !important;
        color: var(--text-muted, #94a3b8) !important;
        line-height: 1.2 !important;
    }
    .bm-item-notes {
        font-size: 11.5px !important;
        white-space: normal !important;
        overflow: visible !important;
        text-overflow: clip !important;
        display: block !important;
        line-height: 1.45 !important;
        word-break: break-word !important;
        -webkit-line-clamp: unset !important;
        margin-top: 3px !important;
        margin-bottom: 3px !important;
    }
    .bm-item-actions {
        width: 100% !important;
        margin-left: 0 !important;
        display: flex !important;
        align-items: center !important;
        justify-content: flex-end !important;
        gap: 6px !important;
        padding-top: 6px !important;
        border-top: 1px solid rgba(255, 255, 255, 0.05) !important;
        flex-wrap: wrap !important;
    }
    .btn-bm-action {
        height: 27px !important;
        padding: 0 8px !important;
        font-size: 11px !important;
    }
    .btn-bm-action.btn-bm-wiki {
        padding: 0 9px !important;
    }
    [data-theme="light"] .bm-item-actions {
        border-top-color: rgba(0, 0, 0, 0.06) !important;
    }
}

@media (max-width: 380px) {
    .bookmarks-header {
        padding: 6px 6px;
        gap: 4px;
    }
    .bookmarks-search-wrapper {
        width: 80px;
    }
    .bookmarks-search-input {
        font-size: 10px;
        padding-left: 20px;
    }
    .bookmarks-search-icon {
        left: 4px;
        width: 11px;
        height: 11px;
    }
    .bookmarks-main-title {
        font-size: 12px;
    }
    .bookmarks-count-pill {
        padding: 1px 4px;
        font-size: 9.5px;
    }
}


/* --- Integración RAG: Archivos Adjuntos a Favoritos (ADR-100) --- */
.bm-attached-file-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-top: 4px;
    padding: 3px 8px;
    border-radius: 6px;
    background: rgba(249, 115, 22, 0.1);
    border: 1px solid rgba(249, 115, 22, 0.25);
    color: #fb923c;
    font-size: 11px;
    font-weight: 500;
    cursor: pointer;
    max-width: fit-content;
    transition: all 0.16s ease;
}

.bm-attached-file-chip:hover {
    background: rgba(249, 115, 22, 0.18);
    border-color: rgba(249, 115, 22, 0.45);
    color: #fdba74;
    transform: translateY(-1px);
}

.bm-file-name {
    max-width: 220px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-weight: 600;
}

.bm-file-view-tag {
    font-size: 10px;
    opacity: 0.85;
    margin-left: 4px;
}

/* Botón Ver Archivo en la fila de marcadores */
.btn-bm-action.btn-bm-doc {
    background: rgba(249, 115, 22, 0.12);
    color: #fb923c;
    border-color: rgba(249, 115, 22, 0.3);
}

.btn-bm-action.btn-bm-doc:hover {
    background: rgba(249, 115, 22, 0.22);
    border-color: rgba(249, 115, 22, 0.6);
    color: #fdba74;
    box-shadow: 0 0 10px rgba(249, 115, 22, 0.3);
}

/* Modo claro para chip y botón doc */
[data-theme="light"] .bm-attached-file-chip {
    background: #fff7ed;
    border-color: #fdba74;
    color: #c2410c;
}
[data-theme="light"] .bm-attached-file-chip:hover {
    background: #ffedd5;
    color: #9a3412;
}
[data-theme="light"] .btn-bm-action.btn-bm-doc {
    background: #fff7ed;
    border-color: #fdba74;
    color: #c2410c;
}
[data-theme="light"] .btn-bm-action.btn-bm-doc:hover {
    background: #ea580c;
    color: #ffffff;
    border-color: #ea580c;
}

/* Árbol de Archivos: Carpeta e Items de Favoritos */
.tree-folder.is-bm-folder .tree-folder-name {
    color: var(--text-primary);
}
[data-theme="light"] .tree-folder.is-bm-folder .tree-folder-name {
    color: var(--text-primary);
}

.tree-file-item.is-bm-doc:hover {
    background: rgba(249, 115, 22, 0.08);
}


/* --- Modales de Marcadores: Footer, Botones y Spinner --- */
.bm-modal-footer {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 12px;
    margin-top: 22px;
    padding-top: 14px;
    border-top: 1px solid var(--border-color, rgba(255, 255, 255, 0.08));
}
.btn-bm-modal {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    height: 38px;
    min-width: 95px;
    padding: 0 18px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    box-sizing: border-box;
    transition: all 0.2s ease;
    border: 1px solid transparent;
}
.btn-bm-modal.secondary {
    background: rgba(255, 255, 255, 0.06);
    color: var(--text-primary, #f1f5f9);
    border-color: var(--border-color, rgba(255, 255, 255, 0.12));
}
.btn-bm-modal.secondary:hover {
    background: rgba(255, 255, 255, 0.11);
    border-color: rgba(255, 255, 255, 0.22);
}
.btn-bm-modal.primary {
    background: linear-gradient(135deg, #f97316, #ea580c);
    color: #ffffff;
    border-color: #fb923c;
    box-shadow: 0 2px 8px rgba(249, 115, 22, 0.3);
}
.btn-bm-modal.primary:hover {
    background: linear-gradient(135deg, #fb923c, #f97316);
    box-shadow: 0 4px 12px rgba(249, 115, 22, 0.45);
    transform: translateY(-1px);
}
.btn-bm-modal:disabled {
    opacity: 0.65;
    cursor: not-allowed;
    transform: none !important;
}

/* Botón Explorar de archivos */
.btn-bm-file-browse {
    height: 28px;
    padding: 0 12px;
    font-size: 11px;
    font-weight: 600;
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.06);
    color: var(--text-primary, #f1f5f9);
    border: 1px solid var(--border-color, rgba(255, 255, 255, 0.14));
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    white-space: nowrap;
    width: auto !important;
    pointer-events: none;
}

/* Spinner animado */
.bm-spinner {
    display: inline-block;
    width: 13px;
    height: 13px;
    border: 2px solid rgba(255, 255, 255, 0.35);
    border-radius: 50%;
    border-top-color: #ffffff;
    animation: bm-spin 0.65s linear infinite;
    vertical-align: middle;
}
@keyframes bm-spin {
    to { transform: rotate(360deg); }
}

/* Lista de Archivos Adjuntos en el Modal */
.bm-attached-files-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 8px;
    max-height: 160px;
    overflow-y: auto;
}
.bm-attached-file-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: rgba(249, 115, 22, 0.08);
    border: 1px solid rgba(249, 115, 22, 0.22);
    border-radius: 8px;
    padding: 6px 10px;
    gap: 8px;
}
.bm-attached-file-info {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 11.5px;
    color: #fb923c;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 1;
}
.bm-attached-file-actions {
    display: flex;
    align-items: center;
    gap: 5px;
    flex-shrink: 0;
}
.btn-bm-file-view {
    background: rgba(249, 115, 22, 0.15);
    color: #fb923c;
    border: 1px solid rgba(249, 115, 22, 0.35);
    border-radius: 5px;
    padding: 2px 7px;
    font-size: 10.5px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s ease;
}
.btn-bm-file-view:hover {
    background: #f97316;
    color: #ffffff;
}
.btn-bm-file-delete {
    background: rgba(239, 68, 68, 0.12);
    color: #ef4444;
    border: 1px solid rgba(239, 68, 68, 0.3);
    border-radius: 5px;
    padding: 2px 7px;
    font-size: 10.5px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s ease;
}
.btn-bm-file-delete:hover {
    background: #ef4444;
    color: #ffffff;
}

/* Modo Claro para modales de marcadores */
[data-theme="light"] .btn-bm-modal.secondary {
    background: #f1f5f9;
    color: #334155;
    border-color: #cbd5e1;
}
[data-theme="light"] .btn-bm-modal.secondary:hover {
    background: #e2e8f0;
    color: #0f172a;
    border-color: #94a3b8;
}
[data-theme="light"] .bm-attached-file-item {
    background: #fff7ed;
    border-color: #fdba74;
}
[data-theme="light"] .bm-attached-file-info {
    color: #c2410c;
}
[data-theme="light"] .bm-item-notes {
    color: #334155 !important;
}

/* Reglas móviles para modal */
@media (max-width: 640px) {
    .bm-modal-footer {
        display: flex !important;
        flex-direction: row !important;
        width: 100% !important;
        gap: 10px !important;
        margin-top: 18px !important;
        padding-top: 12px !important;
    }
    .btn-bm-modal {
        flex: 1 !important;
        height: 42px !important;
        min-width: 0 !important;
        width: auto !important;
        font-size: 13px !important;
        padding: 0 10px !important;
        border-radius: 8px !important;
    }
}
