/**
 * SIDEBAR ADAPTIVE CSS v2.0
 * Sistema de 4 niveles para sidebar redimensionable
 *
 * Niveles:
 * - Normal (>200px): Todo visible
 * - Intermediate (120-200px): Texto reducido
 * - Compact (80-120px): Solo iconos
 * - Ultra-compact (<80px): Mínimo con menú desplegable
 */

/* ================================================================
   RESIZE HANDLE
   ================================================================ */
.sidebar-resize-handle {
    position: absolute;
    top: 0;
    right: -4px;
    width: 8px;
    height: 100%;
    cursor: col-resize;
    background: transparent;
    z-index: 1000;
    transition: background 0.2s ease;
}

.sidebar-resize-handle:hover {
    background: linear-gradient(90deg, transparent, rgba(245, 166, 35, 0.3), transparent);
}

.sidebar-resize-handle.dragging {
    background: linear-gradient(90deg, transparent, rgba(245, 166, 35, 0.6), transparent);
}

/* ================================================================
   WIDTH INDICATOR
   ================================================================ */
.sidebar-width-indicator {
    position: absolute;
    top: 10px;
    right: 10px;
    background: rgba(0, 0, 0, 0.7);
    color: #F5A623;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-family: monospace;
    opacity: 0;
    transition: opacity 0.2s ease;
    z-index: 1001;
    pointer-events: none;
}

.sidebar-width-indicator.visible {
    opacity: 1;
}

/* ================================================================
   NIVEL 2: INTERMEDIATE (120-200px)
   ================================================================ */
.sidebar.intermediate .sidebar-header .app-title {
    font-size: 16px !important;
}

.sidebar.intermediate .sidebar-header .app-version {
    font-size: 14px !important;
}

.sidebar.intermediate .notification-item {
    padding: 6px 8px !important;
}

.sidebar.intermediate .notification-label,
.sidebar.intermediate .credit-amount {
    font-size: 11px !important;
}

.sidebar.intermediate .sidebar-action-btn {
    padding: 8px 10px !important;
}

.sidebar.intermediate .sidebar-action-btn span {
    font-size: 0.85em !important;
}

.sidebar.intermediate .sidebar-accordion-section .section-header {
    padding: 8px 10px !important;
    font-size: 12px !important;
}

.sidebar.intermediate .sidebar-item {
    padding: 6px 10px !important;
    font-size: 12px !important;
}

.sidebar.intermediate .sidebar-footer .section-title {
    font-size: 10px !important;
}

/* ================================================================
   NIVEL 3: COMPACT (80-120px)
   ================================================================ */

/* Header en compact */
html body .sidebar.compact .sidebar-header {
    padding: 8px !important;
    flex-direction: column !important;
    align-items: center !important;
    gap: 4px !important;
    min-height: auto !important;
    height: auto !important;
}

html body .sidebar.compact .sidebar-header .app-title {
    font-size: 0 !important;
}

html body .sidebar.compact .sidebar-header .app-title .lohmia-robot-icon {
    width: 24px !important;
    height: 24px !important;
}

html body .sidebar.compact .sidebar-header .app-title .brand,
html body .sidebar.compact .brand {
    display: none !important;
}

html body .sidebar.compact .sidebar-header .app-version,
html body .sidebar.compact .app-version,
.sidebar.compact .app-version {
    display: none !important;
    visibility: hidden !important;
    opacity: 0 !important;
    height: 0 !important;
    position: absolute !important;
}

html body .sidebar.compact .close-sidebar-btn {
    position: static !important;
    margin-bottom: 4px !important;
}

/* Notifications en compact */
html body .sidebar.compact .sidebar-notifications {
    flex-direction: column !important;
    padding: 4px !important;
    gap: 2px !important;
}

html body .sidebar.compact .notification-item {
    flex-direction: column !important;
    padding: 4px !important;
    min-height: auto !important;
    height: auto !important;
}

html body .sidebar.compact .notification-icon {
    width: 20px !important;
    height: 20px !important;
}

html body .sidebar.compact .notification-icon svg {
    width: 16px !important;
    height: 16px !important;
}

html body .sidebar.compact .notification-label {
    display: none !important;
}

html body .sidebar.compact .credit-amount {
    font-size: 10px !important;
    margin-top: 2px !important;
}

html body .sidebar.compact .notification-badge {
    top: -4px !important;
    right: -4px !important;
    font-size: 9px !important;
    min-width: 14px !important;
    height: 14px !important;
}

/* Actions en compact */
html body .sidebar.compact .sidebar-actions {
    flex-direction: column !important;
    padding: 4px !important;
    gap: 4px !important;
}

html body .sidebar.compact .sidebar-action-btn {
    width: 100% !important;
    padding: 8px !important;
    justify-content: center !important;
}

html body .sidebar.compact .sidebar-action-btn span {
    display: none !important;
}

html body .sidebar.compact .sidebar-action-btn svg {
    width: 18px !important;
    height: 18px !important;
}

/* Content en compact */
html body .sidebar.compact .sidebar-content {
    padding: 4px !important;
}

html body .sidebar.compact .sidebar-accordion-section .section-header {
    padding: 6px !important;
    justify-content: center !important;
}

html body .sidebar.compact .sidebar-accordion-section .section-header span:not(.chevron) {
    display: none !important;
}

html body .sidebar.compact .sidebar-accordion-section .section-header svg:first-child {
    margin-right: 0 !important;
}

html body .sidebar.compact .sidebar-item {
    padding: 6px !important;
    justify-content: center !important;
}

html body .sidebar.compact .sidebar-item .item-icon {
    margin-right: 0 !important;
}

html body .sidebar.compact .sidebar-item .item-title,
html body .sidebar.compact .sidebar-item .item-meta {
    display: none !important;
}

/* Footer en compact */
html body .sidebar.compact .sidebar-footer {
    padding: 4px !important;
}

html body .sidebar.compact .sidebar-footer .section-title {
    display: none !important;
}

html body .sidebar.compact .sidebar-footer .sidebar-item {
    padding: 6px !important;
    justify-content: center !important;
}

html body .sidebar.compact .sidebar-footer .sidebar-item span:not(.item-icon) {
    display: none !important;
}

/* ================================================================
   ULTRA-COMPACT: SISTEMA DE ICONOS + TOOLTIPS
   Versión 2.0 - Solo iconos con tooltip al hover
   ================================================================ */

/* === CONTENEDORES BASE === */
html body .sidebar.ultra-compact .sidebar-content {
    padding: 4px 2px !important;
}

html body .sidebar.ultra-compact .sidebar-items-container {
    gap: 2px !important;
}

/* === SECTION HEADERS (Infraestructuras, Proyectos, Chats) === */
html body .sidebar.ultra-compact .sidebar-section-header {
    padding: 6px 4px !important;
    min-height: 32px !important;
    justify-content: center !important;
    position: relative !important;
}

html body .sidebar.ultra-compact .sidebar-section-header span,
html body .sidebar.ultra-compact .sidebar-section-header .section-count {
    display: none !important;
}

html body .sidebar.ultra-compact .sidebar-section-header .section-arrow {
    margin: 0 !important;
}

/* === INFRASTRUCTURE ITEMS === */
html body .sidebar.ultra-compact .infrastructure-item {
    margin-bottom: 2px !important;
}

html body .sidebar.ultra-compact .infrastructure-header {
    padding: 6px 4px !important;
    min-height: 32px !important;
    justify-content: center !important;
    gap: 0 !important;
}

html body .sidebar.ultra-compact .infrastructure-header::before {
    content: "🏢" !important;
    font-size: 14px !important;
    display: block !important;
}

html body .sidebar.ultra-compact .infrastructure-header > *:not(.expand-icon) {
    display: none !important;
}

html body .sidebar.ultra-compact .infrastructure-header .expand-icon {
    display: none !important;
}

html body .sidebar.ultra-compact .infrastructure-children {
    padding-left: 4px !important;
    border-left: 2px solid rgba(99, 179, 237, 0.3) !important;
    margin-left: 8px !important;
}

/* === PROJECT ITEMS === */
html body .sidebar.ultra-compact .project-item {
    margin-bottom: 2px !important;
}

html body .sidebar.ultra-compact .project-header {
    padding: 6px 4px !important;
    min-height: 28px !important;
    justify-content: center !important;
    gap: 0 !important;
}

html body .sidebar.ultra-compact .project-header::before {
    content: "📁" !important;
    font-size: 12px !important;
    display: block !important;
}

html body .sidebar.ultra-compact .project-header-content,
html body .sidebar.ultra-compact .project-header > *:not(.expand-icon) {
    display: none !important;
}

html body .sidebar.ultra-compact .project-header .expand-icon {
    display: none !important;
}

html body .sidebar.ultra-compact .project-children {
    padding-left: 4px !important;
    border-left: 2px solid rgba(99, 179, 237, 0.2) !important;
    margin-left: 6px !important;
}

/* === CHAT ITEMS === */
html body .sidebar.ultra-compact .chat-item {
    padding: 6px 4px !important;
    min-height: 28px !important;
    justify-content: center !important;
    gap: 0 !important;
    position: relative !important;
}

html body .sidebar.ultra-compact .chat-item::before {
    content: "💬" !important;
    font-size: 12px !important;
    display: block !important;
}

html body .sidebar.ultra-compact .chat-item > * {
    display: none !important;
}

html body .sidebar.ultra-compact .chat-item.active {
    background: rgba(99, 179, 237, 0.2) !important;
    border-radius: 4px !important;
}

/* === ORPHAN CONTAINERS === */
html body .sidebar.ultra-compact .orphan-projects-container,
html body .sidebar.ultra-compact .orphan-chats-container {
    padding: 2px !important;
    gap: 2px !important;
}

/* === SIDEBAR ACTIONS (Botones Nuevo Chat, etc) === */
html body .sidebar.ultra-compact .sidebar-actions {
    padding: 4px 2px !important;
    gap: 4px !important;
    flex-direction: column !important;
}

html body .sidebar.ultra-compact .sidebar-action-btn {
    padding: 8px 4px !important;
    min-height: 32px !important;
    justify-content: center !important;
    width: 100% !important;
}

html body .sidebar.ultra-compact .sidebar-action-btn span {
    display: none !important;
}

html body .sidebar.ultra-compact .sidebar-action-btn svg {
    margin: 0 !important;
    width: 16px !important;
    height: 16px !important;
}

/* === SIDEBAR FOOTER === */
html body .sidebar.ultra-compact .sidebar-footer {
    padding: 4px 2px !important;
    border-top: 1px solid rgba(99, 179, 237, 0.2) !important;
}

html body .sidebar.ultra-compact .sidebar-footer .sidebar-section {
    padding: 2px !important;
}

html body .sidebar.ultra-compact .sidebar-footer .section-title {
    display: none !important;
}

html body .sidebar.ultra-compact .sidebar-footer .sidebar-item {
    padding: 8px 4px !important;
    min-height: 32px !important;
    justify-content: center !important;
    gap: 0 !important;
}

html body .sidebar.ultra-compact .sidebar-footer .sidebar-item span {
    display: none !important;
}

html body .sidebar.ultra-compact .sidebar-footer .sidebar-item svg {
    margin: 0 !important;
    width: 18px !important;
    height: 18px !important;
}

/* === SIDEBAR HEADER === */
html body .sidebar.ultra-compact .sidebar-header {
    padding: 8px 4px !important;
    min-height: 40px !important;
    justify-content: center !important;
}

html body .sidebar.ultra-compact .sidebar-header .sidebar-logo span,
html body .sidebar.ultra-compact .sidebar-header .sidebar-title {
    display: none !important;
}

/* === SIDEBAR NOTIFICATIONS === */
html body .sidebar.ultra-compact .sidebar-notifications {
    padding: 4px 2px !important;
    flex-direction: column !important;
    gap: 4px !important;
}

html body .sidebar.ultra-compact .sidebar-notifications .notification-item {
    padding: 4px !important;
    justify-content: center !important;
}

html body .sidebar.ultra-compact .sidebar-notifications .notification-item span {
    display: none !important;
}

/* === TOOLTIPS NATIVOS - Añadir via JavaScript === */
/* Los tooltips se añaden con el atributo title="" */

/* === HOVER EFFECTS === */
html body .sidebar.ultra-compact .chat-item:hover,
html body .sidebar.ultra-compact .project-header:hover,
html body .sidebar.ultra-compact .infrastructure-header:hover,
html body .sidebar.ultra-compact .sidebar-item:hover,
html body .sidebar.ultra-compact .sidebar-action-btn:hover {
    background: rgba(99, 179, 237, 0.15) !important;
    border-radius: 4px !important;
}

/* === WIDTH INDICATOR === */
html body .sidebar.ultra-compact .sidebar-width-indicator {
    font-size: 10px !important;
    padding: 2px 4px !important;
}
