/**
 * EasyDesktop - Widgets Styles
 * 
 * @author Alberto Luque Rivas
 * @version 1.0.0
 */

/* ============================================
   Widget Base
   ============================================ */
.easydesktop-widget {
    position: fixed;
    background: var(--ed-bg-primary);
    border-radius: 12px;
    box-shadow: var(--ed-window-shadow);
    border: 1px solid var(--ed-border-color);
    overflow: hidden;
    z-index: var(--ed-z-startmenu);
    pointer-events: auto;
    animation: ed-scale-in var(--ed-transition-normal) forwards;
    transition: box-shadow var(--ed-transition-fast);
}

.easydesktop-widget.dragging {
    box-shadow: var(--ed-window-shadow-focused);
    opacity: 0.95;
    z-index: calc(var(--ed-z-startmenu) + 10);
}

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

.widget-header span {
    font-size: 14px;
    font-weight: 600;
    color: var(--ed-text-primary);
}

.widget-close {
    width: 28px;
    height: 28px;
    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);
}

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

.widget-body {
    padding: 12px;
}

/* ============================================
   Calculator Widget
   ============================================ */
#easydesktop-calculator {
    width: 360px;
    height: auto;
    min-height: 520px;
    max-height: calc(100vh - var(--ed-taskbar-height) - 24px);
    bottom: calc(var(--ed-taskbar-height) + 12px);
    right: 12px;
    left: auto;
    top: auto;
}

#easydesktop-calculator .widget-body {
    padding: 0;
    overflow: visible;
    position: relative;
}

.calc-container {
    display: flex;
    flex-direction: column;
    height: 100%;
    padding: 12px;
}

.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,
.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;
    outline: none;
}

.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,
.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);
}

/* ============================================
   Notes Widget
   ============================================ */
#easydesktop-notes {
    width: 400px;
    height: 500px;
    max-height: calc(100vh - var(--ed-taskbar-height) - 24px);
    bottom: calc(var(--ed-taskbar-height) + 12px);
    right: 384px;
    left: auto;
    top: auto;
    display: flex;
    flex-direction: column;
}

#easydesktop-notes .widget-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 0;
    overflow: hidden;
}

.notes-manager {
    display: flex;
    flex-direction: column;
    height: 100%;
}

.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: 120px;
    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-list {
    flex: 1;
    overflow-y: auto;
    padding: 12px;
}

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

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

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

.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;
    pointer-events: auto;
}

.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);
}

/* Legacy notes support */
#notes-content {
    flex: 1;
    width: 100%;
    padding: 16px;
    border: none;
    resize: none;
    background: var(--ed-bg-primary);
    color: var(--ed-text-primary);
    font-size: 14px;
    line-height: 1.6;
    font-family: inherit;
    outline: none;
}

#notes-content::placeholder {
    color: var(--ed-text-muted);
}

#notes-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
    border-top: 1px solid var(--ed-border-color);
    background: var(--ed-bg-secondary);
}

#notes-saved {
    font-size: 12px;
    color: var(--ed-text-muted);
    opacity: 0;
    transition: opacity var(--ed-transition-fast);
}

#notes-saved.visible {
    opacity: 1;
}

#notes-copy {
    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);
}

#notes-copy:hover {
    background: var(--ed-bg-hover);
    color: var(--ed-primary);
}

/* ============================================
   Spotlight Search
   ============================================ */
#easydesktop-spotlight {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    display: flex;
    justify-content: center;
    padding-top: 15vh;
    z-index: var(--ed-z-spotlight);
    pointer-events: auto;
    animation: ed-fade-in var(--ed-transition-fast) forwards;
}

#spotlight-container {
    width: 100%;
    max-width: 680px;
    padding: 0 20px;
    animation: ed-slide-down var(--ed-transition-normal) forwards;
}

#spotlight-input-wrapper {
    display: flex;
    align-items: center;
    background: var(--ed-bg-primary);
    border-radius: 12px;
    padding: 0 20px;
    box-shadow: var(--ed-window-shadow-focused);
    border: 1px solid var(--ed-border-color);
}

#spotlight-input-wrapper i {
    font-size: 20px;
    color: var(--ed-text-muted);
    margin-right: 16px;
}

#spotlight-input {
    flex: 1;
    height: 64px;
    border: none;
    background: transparent;
    color: var(--ed-text-primary);
    font-size: 20px;
    outline: none;
}

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

#spotlight-shortcut {
    padding: 4px 10px;
    background: var(--ed-bg-secondary);
    border-radius: 6px;
    font-size: 12px;
    font-weight: 500;
    color: var(--ed-text-muted);
    border: 1px solid var(--ed-border-color);
}

#spotlight-results {
    margin-top: 12px;
    background: var(--ed-bg-primary);
    border-radius: 12px;
    box-shadow: var(--ed-window-shadow);
    border: 1px solid var(--ed-border-color);
    max-height: 50vh;
    overflow-y: auto;
}

#spotlight-results:empty {
    display: none;
}

.spotlight-category {
    padding: 12px 16px 8px;
    border-bottom: 1px solid var(--ed-border-color);
}

.spotlight-category:last-child {
    border-bottom: none;
}

.spotlight-category-title {
    font-size: 12px;
    font-weight: 600;
    color: var(--ed-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 8px;
}

.spotlight-result {
    display: flex;
    align-items: center;
    padding: 12px;
    border-radius: 8px;
    cursor: pointer;
    transition: background-color var(--ed-transition-fast);
}

.spotlight-result:hover,
.spotlight-result.selected {
    background: var(--ed-bg-hover);
}

.spotlight-result-icon {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    margin-right: 12px;
    font-size: 18px;
    color: white;
}

.spotlight-result-content {
    flex: 1;
    min-width: 0;
}

.spotlight-result-title {
    font-size: 15px;
    font-weight: 500;
    color: var(--ed-text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.spotlight-result-subtitle {
    font-size: 13px;
    color: var(--ed-text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.spotlight-result-action {
    padding: 4px 10px;
    background: var(--ed-bg-secondary);
    border-radius: 6px;
    font-size: 12px;
    color: var(--ed-text-muted);
    opacity: 0;
    transition: opacity var(--ed-transition-fast);
}

.spotlight-result:hover .spotlight-result-action,
.spotlight-result.selected .spotlight-result-action {
    opacity: 1;
}

.spotlight-no-results {
    padding: 40px 20px;
    text-align: center;
    color: var(--ed-text-muted);
}

.spotlight-no-results i {
    font-size: 48px;
    margin-bottom: 16px;
    opacity: 0.5;
}

.spotlight-no-results p {
    font-size: 16px;
    margin: 0;
}

/* ============================================
   Desktop Widgets Area
   ============================================ */
#easydesktop-widgets {
    position: absolute;
    top: 20px;
    right: 20px;
    width: 320px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    pointer-events: auto;
}

.dashboard-widget {
    background: var(--ed-bg-primary);
    border-radius: 12px;
    box-shadow: 0 2px 8px var(--ed-shadow-color);
    border: 1px solid var(--ed-border-color);
    overflow: hidden;
}

.dashboard-widget-header {
    padding: 12px 16px;
    background: var(--ed-bg-secondary);
    border-bottom: 1px solid var(--ed-border-color);
    font-size: 14px;
    font-weight: 600;
    color: var(--ed-text-primary);
    display: flex;
    align-items: center;
    gap: 8px;
}

.dashboard-widget-header i {
    color: var(--ed-primary);
}

.dashboard-widget-body {
    padding: 16px;
}

/* ============================================
   Stats Widget
   ============================================ */
#easydesktop-stats {
    right: 320px;
    bottom: 60px;
    width: 320px;
}

#stats-content {
    padding: 12px;
    max-height: 400px;
    overflow-y: auto;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    padding: 4px;
}

.stat-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 16px 12px;
    border-radius: 12px;
    background: var(--ed-bg-secondary);
    cursor: pointer;
    transition: all var(--ed-transition-fast);
    text-align: center;
    min-height: 100px;
    justify-content: center;
}

.stat-item:hover {
    background: var(--ed-bg-hover);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    color: white;
    flex-shrink: 0;
    margin-bottom: 4px;
}

.stat-info {
    width: 100%;
}

.stat-value {
    font-size: 28px;
    font-weight: 700;
    color: var(--ed-text-primary);
    line-height: 1;
    margin-bottom: 4px;
}

.stat-label {
    font-size: 11px;
    color: var(--ed-text-secondary);
    margin-top: 4px;
    font-weight: 500;
}

.stat-amount {
    font-size: 12px;
    font-weight: 600;
    color: var(--ed-primary);
    margin-top: 4px;
}

.stats-loading,
.stats-error {
    padding: 32px;
    text-align: center;
    color: var(--ed-text-muted);
}

.stats-loading i,
.stats-error i {
    font-size: 24px;
    margin-bottom: 8px;
    display: block;
}

.stats-error {
    color: var(--ed-danger);
}

/* ============================================
   Responsive
   ============================================ */
@media (max-width: 768px) {
    #easydesktop-calculator,
    #easydesktop-notes {
        width: calc(100% - 24px);
        left: 12px;
        right: 12px;
    }
    
    #easydesktop-notes {
        right: 12px;
    }
    
    #spotlight-container {
        padding: 0 12px;
    }
    
    #spotlight-input {
        height: 56px;
        font-size: 18px;
    }
    
    #easydesktop-widgets {
        position: static;
        width: 100%;
        padding: 12px;
    }
}

@media (max-width: 480px) {
    .calc-btn {
        height: 48px;
        font-size: 18px;
    }
    
    #calc-display {
        height: 50px;
        font-size: 28px;
    }
}
