/**
 * EasyDesktop - Main Stylesheet
 * Desktop environment for Dolibarr ERP
 * 
 * @author Alberto Luque Rivas
 * @version 1.0.0
 */

/* ============================================
   CSS Variables / Theme
   ============================================ */
:root {
    /* Colors */
    --ed-primary: #0078d4;
    --ed-primary-hover: #106ebe;
    --ed-primary-active: #005a9e;
    --ed-secondary: #6c757d;
    --ed-success: #28a745;
    --ed-danger: #dc3545;
    --ed-warning: #ffc107;
    --ed-info: #17a2b8;
    
    /* Light Theme */
    --ed-bg-primary: #ffffff;
    --ed-bg-secondary: #f3f3f3;
    --ed-bg-tertiary: #e5e5e5;
    --ed-bg-hover: rgba(0, 0, 0, 0.05);
    --ed-bg-active: rgba(0, 0, 0, 0.1);
    --ed-text-primary: #1a1a1a;
    --ed-text-secondary: #5c5c5c;
    --ed-text-muted: #8c8c8c;
    --ed-border-color: #d1d1d1;
    --ed-shadow-color: rgba(0, 0, 0, 0.15);
    
    /* Taskbar */
    --ed-taskbar-height: 48px;
    --ed-taskbar-bg: rgba(243, 243, 243, 0.85);
    --ed-taskbar-blur: blur(20px);
    
    /* Window */
    --ed-window-border-radius: 8px;
    --ed-window-header-height: 36px;
    --ed-window-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
    --ed-window-shadow-focused: 0 12px 48px rgba(0, 0, 0, 0.25);
    
    /* Transitions */
    --ed-transition-fast: 0.15s ease;
    --ed-transition-normal: 0.25s ease;
    --ed-transition-slow: 0.4s ease;
    
    /* Z-Index Layers */
    --ed-z-desktop: 9000;
    --ed-z-windows: 9100;
    --ed-z-window-focused: 9200;
    --ed-z-taskbar: 9300;
    --ed-z-startmenu: 9400;
    --ed-z-spotlight: 9500;
    --ed-z-lockscreen: 9900;
    --ed-z-toggle: 9950; /* Siempre encima de todo excepto modales críticos */
}

/* Dark Theme */
[data-ed-theme="dark"],
.easydesktop-dark,
#easydesktop-wrapper.easydesktop-dark,
html[data-ed-theme="dark"] #easydesktop-wrapper {
    --ed-bg-primary: #1f1f1f;
    --ed-bg-secondary: #2d2d2d;
    --ed-bg-tertiary: #3d3d3d;
    --ed-bg-hover: rgba(255, 255, 255, 0.08);
    --ed-bg-active: rgba(255, 255, 255, 0.15);
    --ed-text-primary: #ffffff;
    --ed-text-secondary: #b3b3b3;
    --ed-text-muted: #808080;
    --ed-border-color: #404040;
    --ed-shadow-color: rgba(0, 0, 0, 0.4);
    --ed-taskbar-bg: rgba(31, 31, 31, 0.85);
}

/* Force dark theme text colors for widgets and taskbar */
#easydesktop-wrapper.easydesktop-dark .widget-header span,
#easydesktop-wrapper.easydesktop-dark #calc-display,
#easydesktop-wrapper.easydesktop-dark .calc-btn,
#easydesktop-wrapper.easydesktop-dark #notes-content,
#easydesktop-wrapper.easydesktop-dark #taskbar-clock,
#easydesktop-wrapper.easydesktop-dark #startmenu-username,
#easydesktop-wrapper.easydesktop-dark .startmenu-section h4 {
    color: var(--ed-text-primary) !important;
}

#easydesktop-wrapper.easydesktop-dark #easydesktop-calculator,
#easydesktop-wrapper.easydesktop-dark #easydesktop-notes,
#easydesktop-wrapper.easydesktop-dark #easydesktop-taskbar,
#easydesktop-wrapper.easydesktop-dark #easydesktop-startmenu {
    background: var(--ed-bg-primary);
}

#easydesktop-wrapper.easydesktop-dark #calc-display,
#easydesktop-wrapper.easydesktop-dark .widget-header,
#easydesktop-wrapper.easydesktop-dark #notes-content {
    background: var(--ed-bg-secondary);
}

/* ============================================
   Base Styles
   ============================================ */
.easydesktop-hidden {
    display: none !important;
    pointer-events: none !important;
}

#easydesktop-wrapper {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: var(--ed-z-desktop);
    pointer-events: none; /* El wrapper NUNCA bloquea - solo sus hijos específicos */
}

#easydesktop-wrapper.easydesktop-active:not(.easydesktop-hidden) {
    /* NO poner pointer-events: auto aquí - dejar que pasen los clics al ERP */
    pointer-events: none;
}

/* Solo estos elementos reciben eventos de ratón */
#easydesktop-wrapper.easydesktop-active #easydesktop-taskbar,
#easydesktop-wrapper.easydesktop-active #easydesktop-startmenu,
#easydesktop-wrapper.easydesktop-active #easydesktop-spotlight,
#easydesktop-wrapper.easydesktop-active #easydesktop-lockscreen,
#easydesktop-wrapper.easydesktop-active #easydesktop-calculator,
#easydesktop-wrapper.easydesktop-active #easydesktop-notes,
#easydesktop-wrapper.easydesktop-active .easydesktop-window,
#easydesktop-wrapper.easydesktop-active #easydesktop-dialog {
    pointer-events: auto;
}

#easydesktop-wrapper * {
    box-sizing: border-box;
}

/* ============================================
   Desktop Area
   ============================================ */
#easydesktop-desktop {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: var(--ed-taskbar-height);
    overflow: hidden;
    pointer-events: none;
}

#easydesktop-icons {
    position: absolute;
    top: 20px;
    left: 20px;
    display: grid;
    grid-template-columns: repeat(auto-fill, 80px);
    gap: 10px;
    pointer-events: auto;
}

.desktop-icon {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 80px;
    height: 80px;
    padding: 8px;
    border-radius: 6px;
    cursor: pointer;
    transition: background-color var(--ed-transition-fast);
    user-select: none;
}

.desktop-icon:hover {
    background-color: var(--ed-bg-hover);
}

.desktop-icon:active {
    background-color: var(--ed-bg-active);
}

.desktop-icon i {
    font-size: 32px;
    margin-bottom: 6px;
    color: var(--ed-text-primary);
}

.desktop-icon span {
    font-size: 11px;
    text-align: center;
    color: var(--ed-text-primary);
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
    word-break: break-word;
    line-height: 1.2;
}

/* ============================================
   Toggle Button
   ============================================ */
#easydesktop-toggle {
    position: fixed !important;
    bottom: 80px !important;
    right: 20px !important;
    left: auto !important;
    top: auto !important;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: var(--ed-primary);
    color: white;
    border: none;
    cursor: pointer;
    z-index: var(--ed-z-toggle);
    box-shadow: 0 4px 12px rgba(0, 120, 212, 0.4);
    transition: all var(--ed-transition-normal);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    pointer-events: auto !important; /* Siempre clickeable */
}

#easydesktop-toggle:hover {
    background: var(--ed-primary-hover);
    transform: scale(1.1);
    box-shadow: 0 6px 20px rgba(0, 120, 212, 0.5);
}

#easydesktop-toggle:active {
    background: var(--ed-primary-active);
    transform: scale(0.95);
}

#easydesktop-toggle.active {
    background: var(--ed-success);
}

/* Toggle en la taskbar cuando desktop activo */
#easydesktop-toggle.in-taskbar {
    position: static !important;
    bottom: auto !important;
    right: auto !important;
    width: 36px;
    height: 36px;
    border-radius: 6px;
    font-size: 16px;
    box-shadow: none;
    margin-right: 8px;
    flex-shrink: 0;
}

#easydesktop-toggle.in-taskbar:hover {
    transform: scale(1.05);
    box-shadow: none;
}

/* Hide toggle when desktop is fully active */
#easydesktop-wrapper.easydesktop-fullscreen ~ #easydesktop-toggle {
    opacity: 0;
    pointer-events: none;
}

/* ============================================
   Scrollbar Styles
   ============================================ */
#easydesktop-wrapper ::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

#easydesktop-wrapper ::-webkit-scrollbar-track {
    background: var(--ed-bg-secondary);
    border-radius: 4px;
}

#easydesktop-wrapper ::-webkit-scrollbar-thumb {
    background: var(--ed-border-color);
    border-radius: 4px;
}

#easydesktop-wrapper ::-webkit-scrollbar-thumb:hover {
    background: var(--ed-text-muted);
}

/* ============================================
   Utility Classes
   ============================================ */
.ed-flex {
    display: flex;
}

.ed-flex-center {
    display: flex;
    align-items: center;
    justify-content: center;
}

.ed-flex-between {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.ed-gap-sm {
    gap: 4px;
}

.ed-gap-md {
    gap: 8px;
}

.ed-gap-lg {
    gap: 16px;
}

/* ============================================
   Animations
   ============================================ */
@keyframes ed-fade-in {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

@keyframes ed-scale-in {
    from {
        opacity: 0;
        transform: scale(0.9);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes ed-slide-up {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes ed-slide-down {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes ed-pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}

@keyframes ed-shake {
    0%, 100% {
        transform: translateX(0);
    }
    25% {
        transform: translateX(-5px);
    }
    75% {
        transform: translateX(5px);
    }
}

.ed-animate-fade-in {
    animation: ed-fade-in var(--ed-transition-normal) forwards;
}

.ed-animate-scale-in {
    animation: ed-scale-in var(--ed-transition-normal) forwards;
}

.ed-animate-slide-up {
    animation: ed-slide-up var(--ed-transition-normal) forwards;
}

.ed-animate-shake {
    animation: ed-shake 0.3s ease;
}

/* ============================================
   Responsive
   ============================================ */
@media (max-width: 768px) {
    :root {
        --ed-taskbar-height: 56px;
    }
    
    #easydesktop-toggle {
        bottom: 70px;
        right: 15px;
        width: 45px;
        height: 45px;
    }
}

@media (max-width: 480px) {
    #easydesktop-icons {
        top: 10px;
        left: 10px;
        grid-template-columns: repeat(auto-fill, 70px);
    }
    
    .desktop-icon {
        width: 70px;
        height: 70px;
    }
    
    .desktop-icon i {
        font-size: 28px;
    }
}

/* ============================================
   Dialog / Modal
   ============================================ */
#easydesktop-dialog {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: calc(var(--ed-z-lockscreen) - 1);
    display: flex;
    align-items: center;
    justify-content: center;
    animation: ed-fade-in var(--ed-transition-fast) forwards;
}

#easydesktop-dialog.easydesktop-hidden {
    display: none !important;
}

.ed-dialog-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}

.ed-dialog-container {
    position: relative;
    width: 100%;
    max-width: 400px;
    margin: 20px;
    background: var(--ed-bg-primary);
    border-radius: 12px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    overflow: hidden;
    animation: ed-scale-in var(--ed-transition-normal) forwards;
}

.ed-dialog-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--ed-border-color);
    background: var(--ed-bg-secondary);
}

.ed-dialog-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--ed-text-primary);
}

.ed-dialog-close {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    border-radius: 6px;
    background: transparent;
    color: var(--ed-text-secondary);
    cursor: pointer;
    transition: all var(--ed-transition-fast);
}

.ed-dialog-close:hover {
    background: var(--ed-danger);
    color: white;
}

.ed-dialog-body {
    padding: 24px 20px;
    text-align: center;
}

.ed-dialog-icon {
    width: 64px;
    height: 64px;
    margin: 0 auto 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--ed-primary);
    border-radius: 50%;
    color: white;
    font-size: 28px;
}

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

.ed-pin-setup {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.ed-pin-setup input {
    width: 100%;
    height: 48px;
    padding: 0 16px;
    border: 2px solid var(--ed-border-color);
    border-radius: 8px;
    background: var(--ed-bg-secondary);
    color: var(--ed-text-primary);
    font-size: 18px;
    text-align: center;
    letter-spacing: 8px;
    transition: border-color var(--ed-transition-fast);
}

.ed-pin-setup input:focus {
    outline: none;
    border-color: var(--ed-primary);
}

.ed-pin-setup input::placeholder {
    letter-spacing: normal;
    color: var(--ed-text-muted);
}

.ed-pin-error {
    color: var(--ed-danger);
    font-size: 13px;
    padding: 8px;
    background: rgba(220, 53, 69, 0.1);
    border-radius: 6px;
}

.ed-dialog-footer {
    display: flex;
    gap: 12px;
    padding: 16px 20px;
    border-top: 1px solid var(--ed-border-color);
    background: var(--ed-bg-secondary);
}

.ed-btn {
    flex: 1;
    height: 42px;
    padding: 0 20px;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--ed-transition-fast);
}

.ed-btn-secondary {
    background: var(--ed-bg-tertiary);
    color: var(--ed-text-primary);
}

.ed-btn-secondary:hover {
    background: var(--ed-bg-hover);
}

.ed-btn-primary {
    background: var(--ed-primary);
    color: white;
}

.ed-btn-primary:hover {
    background: var(--ed-primary-hover);
}

/* ============================================
   Enhanced Calculator Styles
   ============================================ */
.calc-container {
    display: flex;
    flex-direction: column;
    height: 100%;
    padding: 12px;
    background: var(--ed-bg-primary);
}

.calc-display-area {
    margin-bottom: 12px;
}

.calc-history-mini {
    height: 20px;
    font-size: 12px;
    color: var(--ed-text-muted);
    text-align: right;
    padding: 0 8px;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.calc-display {
    width: 100%;
    height: 56px;
    padding: 0 16px;
    border: none;
    border-radius: 8px;
    background: var(--ed-bg-secondary);
    color: var(--ed-text-primary);
    font-size: 32px;
    font-family: 'Segoe UI', monospace;
    text-align: right;
    font-weight: 300;
}

.calc-display:focus {
    outline: 2px solid var(--ed-primary);
    outline-offset: -2px;
}

.calc-memory-bar {
    display: flex;
    gap: 4px;
    margin-bottom: 12px;
}

.calc-memory-btn {
    flex: 1;
    height: 32px;
    border: none;
    border-radius: 4px;
    background: var(--ed-bg-secondary);
    color: var(--ed-text-secondary);
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--ed-transition-fast);
}

.calc-memory-btn:hover {
    background: var(--ed-bg-tertiary);
    color: var(--ed-text-primary);
}

.calc-memory-btn.has-memory {
    color: var(--ed-primary);
    font-weight: 600;
}

.calc-memory-btn.calc-history-toggle {
    max-width: 40px;
}

.calc-buttons {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 6px;
    flex: 1;
}

.calc-btn {
    border: none;
    border-radius: 6px;
    font-size: 18px;
    font-weight: 400;
    cursor: pointer;
    transition: all var(--ed-transition-fast);
    min-height: 48px;
}

.calc-btn.calc-number {
    background: var(--ed-bg-secondary);
    color: var(--ed-text-primary);
}

.calc-btn.calc-number:hover {
    background: var(--ed-bg-tertiary);
}

.calc-btn.calc-func {
    background: var(--ed-bg-tertiary);
    color: var(--ed-text-secondary);
}

.calc-btn.calc-func:hover {
    background: var(--ed-bg-hover);
}

.calc-btn.calc-operator {
    background: var(--ed-bg-tertiary);
    color: var(--ed-primary);
    font-weight: 500;
}

.calc-btn.calc-operator:hover {
    background: var(--ed-primary);
    color: white;
}

.calc-btn.calc-equals {
    background: var(--ed-primary);
    color: white;
    font-size: 24px;
}

.calc-btn.calc-equals:hover {
    background: var(--ed-primary-hover);
}

.calc-btn:active {
    transform: scale(0.95);
}

/* Calculator History Panel */
.calc-history-panel {
    position: absolute;
    top: 0;
    right: 0;
    width: 280px;
    height: 100%;
    background: var(--ed-bg-primary);
    border-left: 1px solid var(--ed-border-color);
    transform: translateX(100%);
    transition: transform var(--ed-transition-normal);
    display: flex;
    flex-direction: column;
    z-index: 10;
}

.calc-history-panel.visible {
    transform: translateX(0);
}

.calc-history-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    border-bottom: 1px solid var(--ed-border-color);
    font-weight: 600;
    color: var(--ed-text-primary);
}

.calc-history-clear {
    border: none;
    background: none;
    color: var(--ed-text-muted);
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 4px;
}

.calc-history-clear:hover {
    background: var(--ed-danger);
    color: white;
}

.calc-history-list {
    flex: 1;
    overflow-y: auto;
    padding: 8px;
}

.calc-history-item {
    padding: 12px;
    border-radius: 6px;
    cursor: pointer;
    margin-bottom: 4px;
    transition: background var(--ed-transition-fast);
}

.calc-history-item:hover {
    background: var(--ed-bg-hover);
}

.calc-history-expression {
    font-size: 13px;
    color: var(--ed-text-muted);
    margin-bottom: 4px;
}

.calc-history-result {
    font-size: 18px;
    font-weight: 500;
    color: var(--ed-text-primary);
}

.calc-history-empty {
    text-align: center;
    padding: 40px 20px;
    color: var(--ed-text-muted);
}

/* ============================================
   Enhanced Notes Styles
   ============================================ */
.notes-manager {
    display: flex;
    flex-direction: column;
    height: 100%;
    background: var(--ed-bg-primary);
}

.notes-toolbar {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border-bottom: 1px solid var(--ed-border-color);
    flex-wrap: wrap;
}

.notes-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border: none;
    border-radius: 6px;
    background: var(--ed-primary);
    color: white;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--ed-transition-fast);
}

.notes-btn:hover {
    background: var(--ed-primary-hover);
}

.notes-btn-new i {
    font-size: 12px;
}

.notes-search {
    flex: 1;
    min-width: 150px;
    position: relative;
}

.notes-search i {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--ed-text-muted);
    font-size: 13px;
}

.notes-search-input {
    width: 100%;
    height: 36px;
    padding: 0 12px 0 36px;
    border: 1px solid var(--ed-border-color);
    border-radius: 6px;
    background: var(--ed-bg-secondary);
    color: var(--ed-text-primary);
    font-size: 13px;
}

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

.notes-sort-select {
    height: 36px;
    padding: 0 12px;
    border: 1px solid var(--ed-border-color);
    border-radius: 6px;
    background: var(--ed-bg-secondary);
    color: var(--ed-text-primary);
    font-size: 13px;
    cursor: pointer;
}

.notes-list {
    flex: 1;
    overflow-y: auto;
    padding: 12px;
}

.notes-empty {
    text-align: center;
    padding: 60px 20px;
    color: var(--ed-text-muted);
}

.notes-empty i {
    font-size: 48px;
    margin-bottom: 16px;
    opacity: 0.5;
}

.notes-empty p {
    margin-bottom: 20px;
}

.notes-list-item {
    display: flex;
    flex-direction: column;
    padding: 12px 16px;
    margin-bottom: 8px;
    background: var(--ed-bg-secondary);
    border-radius: 8px;
    cursor: pointer;
    transition: all var(--ed-transition-fast);
    position: relative;
}

.notes-list-item:hover {
    background: var(--ed-bg-tertiary);
}

.notes-list-item.pinned {
    background: var(--ed-bg-tertiary);
}

.notes-list-item.pinned::before {
    content: '\f08d';
    font-family: 'Font Awesome 5 Free';
    font-weight: 900;
    position: absolute;
    top: 8px;
    right: 8px;
    font-size: 10px;
    color: var(--ed-primary);
}

.notes-list-item-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 4px;
}

.notes-list-item-title {
    font-weight: 600;
    color: var(--ed-text-primary);
    font-size: 14px;
}

.notes-list-item-date {
    font-size: 11px;
    color: var(--ed-text-muted);
}

.notes-list-item-preview {
    font-size: 12px;
    color: var(--ed-text-secondary);
    line-height: 1.4;
    overflow: hidden;
    max-height: 36px;
}

.notes-list-item-actions {
    display: flex;
    gap: 4px;
    margin-top: 8px;
    opacity: 0;
    transition: opacity var(--ed-transition-fast);
}

.notes-list-item:hover .notes-list-item-actions {
    opacity: 1;
}

.notes-action-btn {
    width: 28px;
    height: 28px;
    border: none;
    border-radius: 4px;
    background: var(--ed-bg-hover);
    color: var(--ed-text-secondary);
    cursor: pointer;
    transition: all var(--ed-transition-fast);
}

.notes-action-btn:hover {
    background: var(--ed-primary);
    color: white;
}

.notes-action-btn.active {
    color: var(--ed-primary);
}

.notes-action-delete:hover {
    background: var(--ed-danger);
}

/* ============================================
   Sticky Notes (floating on desktop)
   ============================================ */
.sticky-note {
    display: flex;
    flex-direction: column;
    border-radius: 4px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    overflow: hidden;
    font-family: 'Segoe UI', sans-serif;
}

.sticky-note-pinned {
    z-index: 999 !important;
}

.sticky-note-header {
    display: flex;
    align-items: center;
    padding: 6px 8px;
    gap: 8px;
    cursor: move;
    min-height: 36px;
}

.sticky-note-title {
    flex: 1;
    border: none;
    background: transparent;
    font-size: 13px;
    font-weight: 600;
    color: rgba(0, 0, 0, 0.8);
    outline: none;
}

.sticky-note-title::placeholder {
    color: rgba(0, 0, 0, 0.4);
    font-weight: 400;
}

.sticky-note-actions {
    display: flex;
    gap: 4px;
}

.sticky-note-btn {
    width: 24px;
    height: 24px;
    border: none;
    border-radius: 4px;
    background: rgba(0, 0, 0, 0.1);
    color: rgba(0, 0, 0, 0.6);
    cursor: pointer;
    transition: all var(--ed-transition-fast);
    font-size: 12px;
}

.sticky-note-btn:hover {
    background: rgba(0, 0, 0, 0.2);
}

.sticky-note-btn.active {
    color: var(--ed-primary);
}

.sticky-note-close:hover {
    background: var(--ed-danger);
    color: white;
}

.sticky-note-content {
    flex: 1;
    padding: 12px;
    border: none;
    background: transparent;
    color: rgba(0, 0, 0, 0.8);
    font-size: 14px;
    line-height: 1.5;
    resize: none;
    outline: none;
    font-family: inherit;
}

.sticky-note-content::placeholder {
    color: rgba(0, 0, 0, 0.4);
}

.sticky-note-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 4px 12px;
    font-size: 10px;
    color: rgba(0, 0, 0, 0.4);
}

.sticky-note-resize {
    width: 16px;
    height: 16px;
    cursor: se-resize;
    background: linear-gradient(135deg, transparent 50%, rgba(0, 0, 0, 0.2) 50%);
}

.sticky-note-color-picker {
    position: absolute;
    top: 36px;
    right: 8px;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 8px;
    background: white;
    border-radius: 8px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
    z-index: 10;
    width: 140px;
}

.color-option {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    cursor: pointer;
    transition: transform var(--ed-transition-fast);
}

.color-option:hover {
    transform: scale(1.15);
}

.color-option.active {
    box-shadow: 0 0 0 3px var(--ed-primary);
}

/* ============================================
   Widget Manager Styles
   ============================================ */
.widget-window {
    position: fixed;
    display: flex;
    flex-direction: column;
    background: var(--ed-bg-primary);
    border-radius: var(--ed-window-border-radius);
    box-shadow: var(--ed-window-shadow);
    overflow: hidden;
    z-index: var(--ed-z-windows);
}

.widget-window.widget-focused {
    z-index: var(--ed-z-window-focused);
    box-shadow: var(--ed-window-shadow-focused);
}

.widget-window.widget-minimized {
    display: none;
}

.widget-window .widget-header {
    display: flex;
    align-items: center;
    height: var(--ed-window-header-height);
    padding: 0 12px;
    background: var(--ed-bg-secondary);
    border-bottom: 1px solid var(--ed-border-color);
    cursor: move;
    user-select: none;
}

.widget-window .widget-header-icon {
    margin-right: 8px;
    color: var(--ed-text-secondary);
    font-size: 14px;
}

.widget-window .widget-header-title {
    flex: 1;
    font-size: 13px;
    font-weight: 500;
    color: var(--ed-text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.widget-window .widget-header-actions {
    display: flex;
    gap: 4px;
}

.widget-window .widget-header-actions button {
    width: 28px;
    height: 28px;
    border: none;
    border-radius: 4px;
    background: transparent;
    color: var(--ed-text-secondary);
    cursor: pointer;
    transition: all var(--ed-transition-fast);
    font-size: 12px;
}

.widget-window .widget-header-actions button:hover {
    background: var(--ed-bg-hover);
}

.widget-window .widget-header-actions .widget-close:hover {
    background: var(--ed-danger);
    color: white;
}

.widget-window .widget-content {
    flex: 1;
    overflow: auto;
    position: relative;
}

.widget-window .widget-resize-handle {
    position: absolute;
    right: 0;
    bottom: 0;
    width: 16px;
    height: 16px;
    cursor: se-resize;
    background: linear-gradient(135deg, transparent 50%, var(--ed-border-color) 50%);
}

/* ============================================
   New Widget System Styles
   ============================================ */
.easydesktop-widget {
    position: fixed;
    display: flex;
    flex-direction: column;
    background: var(--ed-bg-primary);
    border-radius: var(--ed-window-border-radius);
    box-shadow: var(--ed-window-shadow);
    overflow: hidden;
    z-index: var(--ed-z-windows);
}

.easydesktop-widget.easydesktop-hidden {
    display: none !important;
}

.easydesktop-widget .widget-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: var(--ed-window-header-height);
    padding: 0 12px;
    background: var(--ed-bg-secondary);
    border-bottom: 1px solid var(--ed-border-color);
    cursor: move;
    user-select: none;
}

.easydesktop-widget .widget-header > span {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    font-weight: 500;
    color: var(--ed-text-primary);
}

.easydesktop-widget .widget-header > span i {
    color: var(--ed-text-secondary);
    font-size: 14px;
}

.easydesktop-widget .widget-header-actions {
    display: flex;
    gap: 2px;
}

.easydesktop-widget .widget-header-actions .widget-btn {
    width: 28px;
    height: 28px;
    border: none;
    border-radius: 4px;
    background: transparent;
    color: var(--ed-text-secondary);
    cursor: pointer;
    transition: all var(--ed-transition-fast);
    font-size: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.easydesktop-widget .widget-header-actions .widget-btn:hover {
    background: var(--ed-bg-hover);
    color: var(--ed-text-primary);
}

.easydesktop-widget .widget-header-actions .widget-close:hover {
    background: var(--ed-danger);
    color: white;
}

.easydesktop-widget .widget-header-actions .widget-pin.pinned {
    color: var(--ed-primary);
}

.easydesktop-widget .widget-header-actions .widget-pin.pinned i {
    transform: rotate(45deg);
}

.easydesktop-widget .widget-body {
    flex: 1;
    overflow: auto;
    position: relative;
}

/* ============================================
   Web Search Widget (Popup/Tab mode)
   ============================================ */
#easydesktop-websearch {
    position: fixed;
    z-index: 100005;
    width: 380px;
    background: var(--ed-bg-secondary);
    border-radius: 12px;
    box-shadow: var(--ed-shadow-heavy);
    border: 1px solid var(--ed-border-color);
    overflow: hidden;
    pointer-events: auto !important;
}

#easydesktop-websearch * {
    pointer-events: auto;
}

/* Header */
#websearch-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    background: var(--ed-bg-tertiary);
    border-bottom: 1px solid var(--ed-border-color);
}

#websearch-title {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--ed-text-primary);
    font-size: 14px;
    font-weight: 600;
}

#websearch-title i {
    color: var(--ed-primary);
}

#websearch-close {
    width: 28px;
    height: 28px;
    border: none;
    border-radius: 6px;
    background: transparent;
    color: var(--ed-text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    transition: all var(--ed-transition-fast);
}

#websearch-close:hover {
    background: var(--ed-danger);
    color: white;
}

/* Body */
#websearch-body {
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

/* Engine selector */
#websearch-engine-selector {
    display: flex;
    justify-content: center;
    gap: 8px;
}

.websearch-engine {
    width: 40px;
    height: 40px;
    border: 2px solid transparent;
    border-radius: 10px;
    background: var(--ed-bg-hover);
    color: var(--ed-text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    font-weight: 700;
    transition: all var(--ed-transition-fast);
}

.websearch-engine:hover {
    transform: scale(1.1);
    border-color: var(--ed-border-color);
}

.websearch-engine.active {
    color: white;
    transform: scale(1.1);
}

.websearch-engine[data-engine="google"].active { background: #4285f4; border-color: #4285f4; }
.websearch-engine[data-engine="bing"].active { background: #00809d; border-color: #00809d; }
.websearch-engine[data-engine="duckduckgo"].active { background: #de5833; border-color: #de5833; }
.websearch-engine[data-engine="youtube"].active { background: #ff0000; border-color: #ff0000; }
.websearch-engine[data-engine="wikipedia"].active { background: #000000; border-color: #000000; }

/* Input wrapper */
#websearch-input-wrapper {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--ed-bg-primary);
    border: 2px solid var(--ed-border-color);
    border-radius: 25px;
    padding: 4px 4px 4px 16px;
    transition: border-color var(--ed-transition-fast);
}

#websearch-input-wrapper:focus-within {
    border-color: var(--ed-primary);
}

#websearch-input {
    flex: 1;
    border: none;
    background: transparent;
    font-size: 14px;
    color: var(--ed-text-primary);
    outline: none;
    padding: 8px 0;
}

#websearch-input::placeholder {
    color: var(--ed-text-muted);
}

#websearch-go {
    width: 36px;
    height: 36px;
    border: none;
    border-radius: 50%;
    background: var(--ed-primary);
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    transition: all var(--ed-transition-fast);
}

#websearch-go:hover {
    background: var(--ed-primary-hover);
    transform: scale(1.05);
}

/* Options */
#websearch-options {
    display: flex;
    justify-content: center;
    gap: 16px;
}

.websearch-option {
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    color: var(--ed-text-secondary);
    font-size: 12px;
    transition: color var(--ed-transition-fast);
}

.websearch-option:hover {
    color: var(--ed-text-primary);
}

.websearch-option input[type="radio"] {
    display: none;
}

.websearch-option input[type="radio"]:checked + span {
    color: var(--ed-primary);
    font-weight: 600;
}

.websearch-option span {
    display: flex;
    align-items: center;
    gap: 4px;
}

.websearch-option i {
    font-size: 11px;
}

/* Recent searches */
#websearch-recent {
    border-top: 1px solid var(--ed-border-color);
    padding-top: 12px;
}

.websearch-recent-title {
    display: block;
    font-size: 11px;
    color: var(--ed-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 8px;
}

#websearch-recent-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
    max-height: 150px;
    overflow-y: auto;
}

.websearch-recent-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    border-radius: 8px;
    cursor: pointer;
    transition: background var(--ed-transition-fast);
}

.websearch-recent-item:hover {
    background: var(--ed-bg-hover);
}

.websearch-recent-engine {
    width: 22px;
    height: 22px;
    border-radius: 5px;
    color: white;
    font-size: 10px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.websearch-recent-query {
    flex: 1;
    font-size: 13px;
    color: var(--ed-text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.websearch-recent-remove {
    width: 24px;
    height: 24px;
    border: none;
    border-radius: 4px;
    background: transparent;
    color: var(--ed-text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    opacity: 0;
    transition: all var(--ed-transition-fast);
}

.websearch-recent-item:hover .websearch-recent-remove {
    opacity: 1;
}

.websearch-recent-remove:hover {
    background: var(--ed-danger);
    color: white;
}

.websearch-no-recent {
    font-size: 12px;
    color: var(--ed-text-muted);
    text-align: center;
    padding: 8px;
}

/* Taskbar web search button */
#taskbar-websearch {
    display: flex;
    align-items: center;
}

#taskbar-websearch-btn {
    width: 40px;
    height: 40px;
    border: none;
    border-radius: 8px;
    background: transparent;
    color: var(--ed-text-primary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--ed-transition-fast);
    font-size: 16px;
}

#taskbar-websearch-btn:hover {
    background: var(--ed-bg-hover);
}

#taskbar-websearch-btn.active {
    background: var(--ed-primary);
    color: white;
}

/* Taskbar file manager button (elFinder) */
#taskbar-filemanager {
    display: flex;
    align-items: center;
}

#taskbar-filemanager-btn {
    width: 40px;
    height: 40px;
    border: none;
    border-radius: 8px;
    background: transparent;
    color: #f39c12;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--ed-transition-fast);
    font-size: 16px;
}

#taskbar-filemanager-btn:hover {
    background: var(--ed-bg-hover);
}

#taskbar-filemanager-btn.active {
    background: var(--ed-primary);
    color: white;
}

#taskbar-dbmanager-btn {
    width: 40px;
    height: 40px;
    border: none;
    border-radius: 8px;
    background: transparent;
    color: #3498db;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--ed-transition-fast);
    font-size: 16px;
}

#taskbar-dbmanager-btn:hover {
    background: var(--ed-bg-hover);
}

#taskbar-dbmanager-btn.active {
    background: var(--ed-primary);
    color: white;
}

#taskbar-websearch-btn {
    width: 40px;
    height: 40px;
    border: none;
    border-radius: 8px;
    background: transparent;
    color: #2ecc71;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--ed-transition-fast);
    font-size: 16px;
}

#taskbar-websearch-btn:hover {
    background: var(--ed-bg-hover);
}

#taskbar-websearch-btn.active {
    background: var(--ed-primary);
    color: white;
}

/* ============================================
   elFinder Integration Styles
   ============================================ */

/* Window content must be relative for absolute positioning of elFinder */
.ed-window-content:has(#elfinder-container) {
    position: relative;
    overflow: hidden;
}

#elfinder-container {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    height: 100%;
}

/* Ensure elFinder fills its container */
#elfinder-container .elfinder {
    border: none !important;
    border-radius: 0 !important;
}

#elfinder-container .elfinder-workzone {
    height: calc(100% - 64px) !important; /* toolbar + statusbar height */
}

/* ============================================
   elFinder Light Theme - Simple & Clean
   ============================================ */
.elfinder-easydesktop {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif !important;
    background: #ffffff !important;
}

.elfinder-easydesktop .elfinder-toolbar {
    background: #f5f5f5 !important;
    border-bottom: 1px solid #ddd !important;
}

.elfinder-easydesktop .elfinder-buttonset {
    background: transparent !important;
    border: none !important;
}

.elfinder-easydesktop .elfinder-button {
    background: transparent !important;
    border: none !important;
    color: #333 !important;
    border-radius: 4px !important;
}

.elfinder-easydesktop .elfinder-button:hover {
    background: #e0e0e0 !important;
}

.elfinder-easydesktop .elfinder-button.ui-state-active,
.elfinder-easydesktop .elfinder-button.ui-state-hover {
    background: #d0d0d0 !important;
}

.elfinder-easydesktop .elfinder-navbar {
    background: #fafafa !important;
    border-right: 1px solid #ddd !important;
}

.elfinder-easydesktop .elfinder-navbar .elfinder-tree {
    background: transparent !important;
}

.elfinder-easydesktop .elfinder-navbar .elfinder-navbar-dir {
    color: #333 !important;
}

.elfinder-easydesktop .elfinder-navbar .elfinder-navbar-dir:hover {
    background: #f0f0f0 !important;
}

.elfinder-easydesktop .elfinder-navbar .elfinder-navbar-dir.ui-state-active {
    background: #e3f2fd !important;
    color: #1976d2 !important;
}

.elfinder-easydesktop .elfinder-workzone {
    background: #ffffff !important;
}

.elfinder-easydesktop .elfinder-cwd {
    background: #ffffff !important;
}

.elfinder-easydesktop .elfinder-cwd-view-icons .elfinder-cwd-file .elfinder-cwd-filename {
    color: #333 !important;
}

.elfinder-easydesktop .elfinder-cwd-file.ui-selected {
    background: #e3f2fd !important;
}

.elfinder-easydesktop .elfinder-cwd-file.ui-selected .elfinder-cwd-filename {
    color: #1976d2 !important;
}

.elfinder-easydesktop .elfinder-statusbar {
    background: #f5f5f5 !important;
    border-top: 1px solid #ddd !important;
    color: #666 !important;
}

.elfinder-easydesktop .elfinder-path {
    background: transparent !important;
    color: #666 !important;
}

/* ============================================
   elFinder Dark Theme - Simple & Clean
   ============================================ */
[data-theme="dark"] .elfinder-easydesktop {
    background: #1e1e1e !important;
}

[data-theme="dark"] .elfinder-easydesktop .elfinder-toolbar {
    background: #2d2d2d !important;
    border-bottom: 1px solid #444 !important;
}

[data-theme="dark"] .elfinder-easydesktop .elfinder-button {
    color: #ccc !important;
}

[data-theme="dark"] .elfinder-easydesktop .elfinder-button:hover {
    background: #444 !important;
}

[data-theme="dark"] .elfinder-easydesktop .elfinder-button.ui-state-active,
[data-theme="dark"] .elfinder-easydesktop .elfinder-button.ui-state-hover {
    background: #555 !important;
}

[data-theme="dark"] .elfinder-easydesktop .elfinder-navbar {
    background: #252525 !important;
    border-right: 1px solid #444 !important;
}

[data-theme="dark"] .elfinder-easydesktop .elfinder-navbar .elfinder-navbar-dir {
    color: #ccc !important;
}

[data-theme="dark"] .elfinder-easydesktop .elfinder-navbar .elfinder-navbar-dir:hover {
    background: #333 !important;
}

[data-theme="dark"] .elfinder-easydesktop .elfinder-navbar .elfinder-navbar-dir.ui-state-active {
    background: #0d47a1 !important;
    color: #fff !important;
}

[data-theme="dark"] .elfinder-easydesktop .elfinder-workzone,
[data-theme="dark"] .elfinder-easydesktop .elfinder-cwd {
    background: #1e1e1e !important;
}

[data-theme="dark"] .elfinder-easydesktop .elfinder-cwd-view-icons .elfinder-cwd-file .elfinder-cwd-filename {
    color: #ccc !important;
}

[data-theme="dark"] .elfinder-easydesktop .elfinder-cwd-file.ui-selected {
    background: #1565c0 !important;
}

[data-theme="dark"] .elfinder-easydesktop .elfinder-cwd-file.ui-selected .elfinder-cwd-filename {
    color: #fff !important;
}

[data-theme="dark"] .elfinder-easydesktop .elfinder-statusbar {
    background: #2d2d2d !important;
    border-top: 1px solid #444 !important;
    color: #999 !important;
}

[data-theme="dark"] .elfinder-easydesktop .elfinder-path {
    color: #999 !important;
}

[data-theme="dark"] .elfinder-easydesktop .elfinder-contextmenu {
    background: #2d2d2d !important;
    border: 1px solid #444 !important;
    color: #ccc !important;
}

[data-theme="dark"] .elfinder-easydesktop .elfinder-contextmenu .ui-state-hover {
    background: #444 !important;
}

[data-theme="dark"] .elfinder-easydesktop .elfinder-dialog,
[data-theme="dark"] .elfinder-easydesktop .ui-dialog {
    background: #2d2d2d !important;
    border: 1px solid #444 !important;
}

[data-theme="dark"] .elfinder-easydesktop .ui-dialog-titlebar {
    background: #0d47a1 !important;
    border-bottom: none !important;
    color: #fff !important;
}

[data-theme="dark"] .elfinder-easydesktop .ui-dialog-content {
    color: #ccc !important;
    background: #252525 !important;
}

[data-theme="dark"] .elfinder-easydesktop .elfinder-contextmenu-item:hover {
    background: var(--ed-bg-hover, #333);
}

[data-theme="dark"] .elfinder-easydesktop .elfinder-dialog {
    background: var(--ed-bg-secondary, #1e1e1e);
    color: var(--ed-text-primary, #e0e0e0);
}

[data-theme="dark"] .elfinder-easydesktop .ui-widget-header {
    background: var(--ed-bg-secondary, #1e1e1e);
    border-color: var(--ed-border-color, #333);
}

[data-theme="dark"] .elfinder-easydesktop .ui-widget-content {
    background: var(--ed-bg-primary, #121212);
    color: var(--ed-text-primary, #e0e0e0);
}

