:root { --accent: #3b82f6; }
    body { -webkit-font-smoothing: antialiased; background-color: #f8fafc; overflow: hidden; height: 100vh; height: 100dvh; display: flex; flex-direction: column; margin: 0; padding: 0; transition: background-color 0.4s ease; }
    .dark body { background-color: #020617; }
    html { font-size: 16px; transition: font-size 0.2s ease; }
    html[data-font-size="medium"] { font-size: 19px; } html[data-font-size="large"] { font-size: 22px; }

    .pip-window { position: fixed; z-index: 500; background: #000; border: 1px solid #334155; border-radius: 8px; overflow: hidden; box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6); min-width: 250px; min-height: 150px; pointer-events: auto !important; }
    .pip-window.focused { border-color: #f59e0b; z-index: 550; }
    @media (max-width: 1024px) { 
        .pip-window, .pip-btn, #pip-registry-section, button[onclick^="toggleLogDrawer"] { display: none !important; } 
    }
    .pip-header { height: 32px; background: #1e293b; color: #fff; cursor: move; display: flex; align-items: center; justify-content: space-between; padding: 0 10px; font-size: 10px; font-weight: 800; text-transform: uppercase; }
    .pip-window.focused .pip-header { background: #f59e0b; }
    .pip-content { width: 100%; height: calc(100% - 32px); position: relative; background: #111; }
    .pip-overlay { position: absolute; inset: 0; z-index: 10; display: none; background: transparent; }
    .pip-resize { position: absolute; bottom: 0; right: 0; width: 16px; height: 16px; cursor: nwse-resize; z-index: 20; background: linear-gradient(135deg, transparent 50%, #0ea5e9 50%); }

    @keyframes fluxer-dot { 0%, 100% { transform: translateY(0); opacity: 0.4; } 50% { transform: translateY(-4px); opacity: 1; } }
    .dot { animation: fluxer-dot 1.2s infinite; } .dot:nth-child(2) { animation-delay: 0.2s; } .dot:nth-child(3) { animation-delay: 0.4s; }

    .custom-scrollbar::-webkit-scrollbar { width: 4px; height: 4px; }
    .custom-scrollbar::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 4px; }
    .dark .custom-scrollbar::-webkit-scrollbar-thumb { background: #334155; }
    ::-webkit-scrollbar { width: 4px; height: 4px; }
    ::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 4px; }
    .dark ::-webkit-scrollbar-thumb { background: #334155; }

    .note-visual-wrapper * { box-sizing: border-box !important; }
    .note-visual-wrapper .vscode-container, .note-visual-wrapper .vscode-ui { display: none !important; }
    .prose .note-visual-wrapper, .prose-container .note-visual-wrapper { max-width: none !important; margin-left: 0 !important; margin-right: 0 !important; color: inherit; }
    .prose .note-visual-wrapper h2, .prose-container .note-visual-wrapper h2 { margin-top: 0 !important; margin-bottom: 0 !important; color: inherit !important; }

    /* Enhanced Prose Styles */
    .prose-container { max-width: 100% !important; overflow-wrap: anywhere; }
    .prose-container h1 { font-size: 1.55rem; font-weight: 800; margin-top: 1.5rem; margin-bottom: 0.75rem; color: #0f172a; border-bottom: 1px solid #e2e8f0; padding-bottom: 0.3em; }
    .dark .prose-container h1 { color: #f8fafc; border-bottom-color: #334155; }
    .prose-container h2 { font-size: 1.35rem; font-weight: 700; margin-top: 1.25rem; margin-bottom: 0.5rem; color: #1e293b; }
    .dark .prose-container h2 { color: #f1f5f9; }
    .prose-container h3 { font-size: 1.15rem; font-weight: 600; margin-top: 1rem; margin-bottom: 0.5rem; color: #334155; }
    .dark .prose-container h3 { color: #cbd5e1; }
    .prose-container p { font-size: 0.95rem; line-height: 1.7; margin-bottom: 1rem; margin-top: 0; }
    .prose-container ul { list-style-type: disc; padding-left: 1.5rem; margin-bottom: 1rem; margin-top: 0.5rem; }
    .prose-container ol { list-style-type: decimal; padding-left: 1.5rem; margin-bottom: 1rem; margin-top: 0.5rem; }
    .prose-container li { margin-bottom: 0.35rem; line-height: 1.6; }
    .prose-container li::marker { color: #64748b; font-weight: 600; }
    .prose-container blockquote { border-left: 4px solid #cbd5e1; padding-left: 1rem; font-style: italic; color: #64748b; margin-top: 1rem; margin-bottom: 1rem; background: rgba(241, 245, 249, 0.5); padding-top: 0.5rem; padding-bottom: 0.5rem; border-radius: 0 0.5rem 0.5rem 0; }
    .dark .prose-container blockquote { border-color: #475569; color: #94a3b8; background: rgba(30, 41, 59, 0.5); }
    .prose-container a { color: #3b82f6; text-decoration: underline; text-underline-offset: 3px; font-weight: 500; transition: color 0.2s; }
    .prose-container a:hover { color: #2563eb; }
    .dark .prose-container a:hover { color: #60a5fa; }
    .prose-container > *:first-child { margin-top: 0; }
    .prose-container > *:last-child { margin-bottom: 0; }

    .prose-container table { width: 100%; border-collapse: collapse; margin-top: 1rem; margin-bottom: 1rem; font-size: 0.9rem; text-align: left; border-radius: 0.5rem; overflow: hidden; box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06); }
    .prose-container thead { background-color: #f1f5f9; border-bottom: 2px solid #cbd5e1; }
    .dark .prose-container thead { background-color: #1e293b; border-bottom-color: #334155; }
    .prose-container th { padding: 0.75rem 1rem; font-weight: 600; color: #334155; text-transform: uppercase; font-size: 0.75rem; letter-spacing: 0.05em; }
    .dark .prose-container th { color: #cbd5e1; }
    .prose-container td { padding: 0.75rem 1rem; border-bottom: 1px solid #e2e8f0; color: #475569; }
    .dark .prose-container td { border-bottom-color: #334155; color: #94a3b8; }
    .prose-container tbody tr:hover { background-color: #f8fafc; }
    .dark .prose-container tbody tr:hover { background-color: #0f172a; }
    .prose-container tbody tr:last-child td { border-bottom: none; }

    #log-drawer { transition: transform 0.3s ease, opacity 0.3s ease; }
    #log-drawer.closed:not(.popout) { transform: translateY(100%); }
    #log-drawer.popout { position: fixed; border-radius: 8px; border: 1px solid #cbd5e1; z-index: 600; background: white; box-shadow: 0 20px 50px rgba(0, 0, 0, 0.2); }
    .dark #log-drawer.popout { border-color: #334155; background: #020617; }
    .resize-handle { position: absolute; z-index: 10; }
    .resize-top { top: -3px; left: 0; right: 0; height: 6px; cursor: ns-resize; }
    .resize-nw { top: -5px; left: -5px; width: 12px; height: 12px; cursor: nwse-resize; }
    .resize-se { bottom: -5px; right: -5px; width: 12px; height: 12px; cursor: nwse-resize; }
/* --- AGENTIC UI WIDGET STYLES --- */
.widget-container {
    animation: widget-fade-in 0.4s cubic-bezier(0.16, 1, 0.3, 1) forwards;
    transform-origin: top center;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
    position: relative;
}

@keyframes widget-fade-in {
    0% { opacity: 0; transform: translateY(15px) scale(0.98); }
    100% { opacity: 1; transform: translateY(0) scale(1); }
}

.prose .widget-container * {
    margin-top: 0 !important;
    margin-bottom: 0 !important;
}

.widget-container a {
    text-decoration: none !important;
}

/* Evitare stiluri default urate pentru liste in tabelul nostru / carduri */
.widget-container ul { list-style: none !important; padding: 0 !important; }
.widget-container li { margin: 0 !important; }

/* --- WIDGET TOOLBAR (Popup Button) --- */
.widget-toolbar {
    position: absolute;
    top: 8px;
    right: 8px;
    display: flex;
    gap: 4px;
    opacity: 0;
    transition: opacity 0.2s ease;
    z-index: 15;
    pointer-events: none;
}

.widget-container:hover .widget-toolbar {
    opacity: 1;
    pointer-events: auto;
}

.widget-toolbar-btn {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    border: 1px solid rgba(148, 163, 184, 0.3);
    background: rgba(255, 255, 255, 0.9);
    color: #475569;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.15s ease;
    backdrop-filter: blur(8px);
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

.dark .widget-toolbar-btn {
    background: rgba(15, 23, 42, 0.9);
    border-color: rgba(51, 65, 85, 0.5);
    color: #94a3b8;
}

.widget-toolbar-btn:hover {
    background: #3b82f6;
    color: white;
    border-color: #3b82f6;
    transform: scale(1.1);
}

/* Auto-refresh toggle */
.widget-refresh-toggle {
    font-size: 16px;
    transition: all 0.25s ease;
}

.widget-refresh-toggle.active {
    background: rgba(16, 185, 129, 0.15);
    color: #10b981;
    border-color: #10b981;
    box-shadow: 0 0 8px rgba(16, 185, 129, 0.25);
}

.widget-refresh-toggle.active > span {
    display: inline-block;
    animation: refresh-spin 2.5s linear infinite;
}

.dark .widget-refresh-toggle.active {
    background: rgba(16, 185, 129, 0.2);
    color: #34d399;
    border-color: rgba(16, 185, 129, 0.5);
    box-shadow: 0 0 10px rgba(16, 185, 129, 0.2);
}

/* Keep active toggle always visible */
.widget-container .widget-toolbar:has(.widget-refresh-toggle.active) {
    opacity: 1;
    pointer-events: auto;
}

@keyframes refresh-spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* --- WIDGET POPUP OVERLAY (Mobile Fullscreen) --- */
.widget-popup-overlay {
    position: fixed;
    inset: 0;
    z-index: 900;
    background: #ffffff;
    display: flex;
    flex-direction: column;
    animation: widget-popup-in 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.dark .widget-popup-overlay {
    background: #0f172a;
}

@keyframes widget-popup-in {
    0% { opacity: 0; transform: translateY(30px); }
    100% { opacity: 1; transform: translateY(0); }
}

.widget-popup-header {
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    border-bottom: 1px solid #e2e8f0;
    background: #f8fafc;
    flex-shrink: 0;
}

.dark .widget-popup-header {
    border-bottom-color: #1e293b;
    background: #020617;
}

.widget-popup-title {
    font-size: 14px;
    font-weight: 700;
    color: #0f172a;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.dark .widget-popup-title {
    color: #f1f5f9;
}

.widget-popup-close {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    font-size: 18px;
    font-weight: 700;
    color: #64748b;
    background: transparent;
    border: none;
    cursor: pointer;
    transition: all 0.15s ease;
}

.widget-popup-close:hover {
    background: #fee2e2;
    color: #ef4444;
}

.widget-popup-body {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    -webkit-overflow-scrolling: touch;
}

.widget-popup-body .widget-container {
    width: 100% !important;
    max-width: 100% !important;
    margin: 0 !important;
    animation: none;
}

/* --- MOBILE RESPONSIVE WIDGET OVERRIDES --- */
@media (max-width: 640px) {
    .widget-container {
        width: 100% !important;
        max-width: 100% !important;
        margin-left: 0 !important;
        margin-right: 0 !important;
        border-radius: 12px;
    }
    
    /* Always show toolbar on mobile (no hover) */
    .widget-toolbar {
        opacity: 1;
        pointer-events: auto;
    }
    
    .widget-toolbar-btn {
        width: 32px;
        height: 32px;
        font-size: 16px;
    }
    
    /* Ensure tables scroll horizontally on mobile */
    .widget-container table {
        min-width: 400px;
    }
    
    /* Fix chart overflow on mobile */
    .fluxer-w-chart {
        overflow-x: auto;
    }

    /* ====================================== */
    /* MOBILE CHAT LAYOUT — Maximum Width Use */
    /* ====================================== */
    
    /* Chat messages container: minimal lateral padding */
    #chat-messages {
        padding-left: 8px !important;
        padding-right: 8px !important;
        padding-top: 12px !important;
        padding-bottom: 12px !important;
    }
    
    /* Message list: tighter vertical gap between messages */
    #message-list {
        gap: 12px !important;
        padding-bottom: 8px !important;
    }

    /* Each message row: smaller avatar, less gap, less padding */
    #message-list > div {
        gap: 8px !important;
        padding: 0 !important;
        border-radius: 12px !important;
    }

    /* Avatar: shrink to 28px on mobile */
    #message-list > div > div:first-child {
        width: 28px !important;
        height: 28px !important;
        min-width: 28px !important;
    }

    /* Avatar image: match container */
    #message-list > div > div:first-child img,
    #message-list > div > div:first-child svg {
        width: 16px !important;
        height: 16px !important;
    }

    /* Content area: remove right padding to use full width */
    #message-list > div > div:nth-child(2) {
        padding-right: 2px !important;
        margin-top: 0 !important;
    }

    /* Name header in messages: slightly smaller */
    #message-list > div > div:nth-child(2) > div:first-child {
        margin-bottom: 4px !important;
    }

    #message-list > div > div:nth-child(2) > div:first-child span {
        font-size: 13px !important;
    }

    /* Prose content text: optimize for reading */
    .prose-container {
        font-size: 14px !important;
    }

    /* Input area: compact padding */
    #chat-messages + div,
    #chat-messages ~ div:last-child {
        padding-left: 8px !important;
        padding-right: 8px !important;
    }

    /* Presentation card and tech widgets: full width */
    #presentation-card,
    #technical-widgets,
    #admin-widgets {
        padding-left: 4px !important;
        padding-right: 4px !important;
    }
}

/* --- WIDGET LOADING STATE (API data-binding) --- */
.widget-loading {
    position: relative;
    pointer-events: none;
    opacity: 0.6;
    transition: opacity 0.3s ease;
}

.widget-loading {
    opacity: 0.6;
    pointer-events: none;
    filter: grayscale(0.5);
    transition: opacity 0.3s ease, filter 0.3s ease;
}

.widget-loading::after {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: inherit;
    background: linear-gradient(
        110deg,
        transparent 30%,
        rgba(59, 130, 246, 0.15) 50%,
        transparent 70%
    );
    background-size: 200% 100%;
    animation: widget-shimmer 1.5s ease-in-out infinite;
    z-index: 20;
    pointer-events: none;
}

@keyframes widget-shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* --- WIDGET CONTEXT MENU --- */
.widget-context-menu {
    position: fixed;
    z-index: 9999;
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
    min-width: 160px;
    padding: 6px;
    display: flex;
    flex-direction: column;
    gap: 2px;
    animation: context-menu-in 0.1s ease-out forwards;
}

.dark .widget-context-menu {
    background: #1e293b;
    border-color: #334155;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.5), 0 8px 10px -6px rgba(0, 0, 0, 0.5);
}

@keyframes context-menu-in {
    from { opacity: 0; transform: scale(0.95); }
    to { opacity: 1; transform: scale(1); }
}

.widget-context-item {
    display: flex;
    align-items: center;
    width: 100%;
    padding: 8px 12px;
    font-size: 13px;
    font-weight: 500;
    color: #475569;
    background: transparent;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    text-align: left;
    transition: all 0.15s ease;
}

.dark .widget-context-item {
    color: #cbd5e1;
}

.widget-context-item:hover {
    background: #f1f5f9;
    color: #0f172a;
}

.dark .widget-context-item:hover {
    background: #334155;
    color: #f8fafc;
}

/* --- SIDEBAR DESKTOP --- */
@media (min-width: 1024px) {
    body {
        --sidebar-width: 80px;
    }
    
    body.sidebar-expanded {
        --sidebar-width: 260px;
    }
    
    /* Cand este colapsat */
    body:not(.sidebar-expanded) #sidebar .sb-text {
        display: none !important;
    }
    
    body:not(.sidebar-expanded) #sidebar .sb-header-wrap {
        padding-left: 0;
        padding-right: 0;
        justify-content: center;
    }
    
    body:not(.sidebar-expanded) #sidebar .sb-logo-wrap {
        display: none !important;
    }
    
    body:not(.sidebar-expanded) #sidebar .sb-nav-wrap a {
        padding-left: 0;
        padding-right: 0;
        justify-content: center;
    }
    body:not(.sidebar-expanded) #sidebar .sb-nav-wrap a span.shrink-0 {
        margin: 0 auto;
    }
    
    body:not(.sidebar-expanded) #sidebar .sb-footer-wrap .sb-btn {
        padding-left: 0;
        padding-right: 0;
        justify-content: center;
    }
    
    body:not(.sidebar-expanded) #sidebar .sb-user-wrap {
        padding-left: 0;
        padding-right: 0;
        justify-content: center;
    }
}

/* WIDGET LAYOUT CUSToM WIDTHS */
.lyt-custom-w { width: 100% !important; flex: none !important; }
@media (min-width: 640px) {
    .lyt-custom-w { flex: 0 0 var(--cw) !important; max-width: var(--cw) !important; width: 100% !important; }
}

