/**
 * HumoticaOS Widget System Styles
 * ================================
 */

/* ============================================================================
   DESKTOP SWITCHER
   ============================================================================ */

.desktop-switcher-bar {
    display: flex;
    gap: 0.25rem;
    padding: 0.5rem;
    background: var(--bg-secondary);
    border-radius: 8px;
    align-items: center;
}

.desktop-switch-btn {
    width: 36px;
    height: 36px;
    border: 2px solid transparent;
    border-radius: 6px;
    background: var(--bg-card);
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    position: relative;
}

.desktop-switch-btn:hover {
    border-color: var(--primary-light);
    background: var(--bg-hover);
}

.desktop-switch-btn.active {
    border-color: var(--primary);
    background: var(--primary);
    color: white;
}

.desktop-switch-btn .desktop-icon {
    font-size: 1rem;
    line-height: 1;
}

.desktop-switch-btn .desktop-num {
    font-size: 0.6rem;
    font-weight: 700;
    opacity: 0.7;
}

.desktop-switch-btn.add-desktop {
    border-style: dashed;
    border-color: var(--border);
    font-size: 1.2rem;
    color: var(--text-secondary);
}

.desktop-switch-btn.add-desktop:hover {
    border-color: var(--primary);
    color: var(--primary);
}

/* ============================================================================
   DESKTOP CONTAINER
   ============================================================================ */

.desktop-container {
    position: relative;
    width: 100%;
    height: 100%;
    min-height: 500px;
    background: transparent;
    border-radius: 0;
    overflow: visible;
}

/* ============================================================================
   WIDGET BASE STYLES
   ============================================================================ */

.widget {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 10px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    overflow: hidden;
    transition: box-shadow 0.2s ease;
}

.widget:hover {
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.2);
}

.widget.dragging {
    opacity: 0.9;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.3);
    cursor: grabbing;
}

.widget.resizing {
    opacity: 0.95;
}

.widget.pinned {
    border-color: var(--warning);
}

.widget.collapsed {
    height: auto !important;
}

/* ============================================================================
   WIDGET HEADER
   ============================================================================ */

.widget-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 0.75rem;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    cursor: grab;
    user-select: none;
}

.widget-header:active {
    cursor: grabbing;
}

.widget-title {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 600;
    font-size: 0.85rem;
    color: var(--text);
}

.widget-icon {
    font-size: 1rem;
}

.widget-name {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 150px;
}

.widget-controls {
    display: flex;
    gap: 0.25rem;
}

.widget-btn {
    width: 24px;
    height: 24px;
    border: none;
    border-radius: 4px;
    background: transparent;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    transition: all 0.15s ease;
    color: var(--text-secondary);
}

.widget-btn:hover {
    background: var(--bg-hover);
    color: var(--text);
}

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

.widget-btn.pin-btn.active {
    color: var(--warning);
}

/* ============================================================================
   WIDGET BODY
   ============================================================================ */

.widget-body {
    padding: 0.75rem;
    overflow: auto;
    height: calc(100% - 42px);
}

/* ============================================================================
   WIDGET RESIZE HANDLE
   ============================================================================ */

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

.widget-resize-handle:hover {
    background: linear-gradient(135deg, transparent 50%, var(--primary) 50%);
}

/* ============================================================================
   DROP ZONE
   ============================================================================ */

.drop-zone {
    border: 2px dashed var(--border);
    border-radius: 12px;
    padding: 2rem;
    text-align: center;
    transition: all 0.3s ease;
    background: var(--bg-secondary);
}

.drop-zone.drag-over {
    border-color: var(--primary);
    background: rgba(106, 91, 255, 0.1);
    transform: scale(1.02);
}

.drop-zone-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
    opacity: 0.5;
}

.drop-zone-text {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.drop-zone-text strong {
    color: var(--primary);
}

/* ============================================================================
   WIDGET PICKER (Add Widget Button)
   ============================================================================ */

.widget-picker {
    position: fixed;
    bottom: 1rem;
    right: 1rem;
    z-index: 9999;
}

.widget-picker-btn {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    border: none;
    background: var(--primary);
    color: white;
    font-size: 1.5rem;
    cursor: pointer;
    box-shadow: 0 4px 20px rgba(106, 91, 255, 0.4);
    transition: all 0.2s ease;
}

.widget-picker-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 25px rgba(106, 91, 255, 0.5);
}

.widget-picker-menu {
    position: absolute;
    top: calc(100% + 0.5rem);
    right: 0;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 0.75rem;
    min-width: 280px;
    max-height: 70vh;
    overflow-y: auto;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.3);
    display: none;
    z-index: 10001 !important;
}

.widget-picker-menu.open {
    display: block;
    animation: slideDown 0.2s ease;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.widget-picker-category {
    font-size: 0.7rem;
    font-weight: 700;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 0.5rem 0.5rem 0.25rem;
    margin-top: 0.5rem;
}

.widget-picker-category:first-child {
    margin-top: 0;
}

.widget-picker-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.6rem 0.75rem;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.15s ease;
}

.widget-picker-item:hover {
    background: var(--bg-hover);
}

.widget-picker-item-icon {
    font-size: 1.25rem;
}

.widget-picker-item-info {
    flex: 1;
}

.widget-picker-item-name {
    font-weight: 600;
    font-size: 0.85rem;
    color: var(--text);
}

.widget-picker-item-desc {
    font-size: 0.7rem;
    color: var(--text-secondary);
}

/* ============================================================================
   WIDGET-SPECIFIC STYLES
   ============================================================================ */

/* Notes Widget */
.widget-notes textarea {
    width: 100%;
    height: calc(100% - 10px);
    resize: none;
    border: none;
    background: transparent;
    color: var(--text);
    font-family: inherit;
    font-size: 0.9rem;
    line-height: 1.6;
}

.widget-notes textarea:focus {
    outline: none;
}

/* PDF Widget */
.widget-pdf-viewer {
    width: 100%;
    height: 100%;
    border: none;
}

/* Vision Widget */
.widget-vision-preview {
    max-width: 100%;
    max-height: 200px;
    border-radius: 8px;
    margin-bottom: 0.75rem;
}

.widget-vision-analysis {
    background: var(--bg-secondary);
    padding: 0.75rem;
    border-radius: 8px;
    font-size: 0.85rem;
    line-height: 1.5;
}

/* YouTube Widget */
.widget-youtube-embed {
    width: 100%;
    aspect-ratio: 16/9;
    border-radius: 8px;
    border: none;
}

.widget-youtube-transcript {
    margin-top: 0.75rem;
    max-height: 150px;
    overflow-y: auto;
    font-size: 0.8rem;
    color: var(--text-secondary);
    line-height: 1.5;
}

/* Quick Ask Widget */
.widget-quick-ask-input {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
}

.widget-quick-ask-input input {
    flex: 1;
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--bg-secondary);
    color: var(--text);
    font-size: 0.85rem;
}

.widget-quick-ask-input button {
    padding: 0.5rem 1rem;
    border: none;
    border-radius: 6px;
    background: var(--primary);
    color: white;
    cursor: pointer;
    font-weight: 600;
}

.widget-quick-ask-response {
    background: var(--bg-secondary);
    padding: 0.75rem;
    border-radius: 8px;
    font-size: 0.85rem;
    line-height: 1.5;
    max-height: 200px;
    overflow-y: auto;
}

/* TODO Widget */
.widget-todo-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem;
    border-radius: 6px;
    transition: background 0.15s ease;
}

.widget-todo-item:hover {
    background: var(--bg-secondary);
}

.widget-todo-item input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--primary);
}

.widget-todo-item.completed {
    opacity: 0.5;
    text-decoration: line-through;
}

.widget-todo-add {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.75rem;
    padding-top: 0.75rem;
    border-top: 1px solid var(--border);
}

.widget-todo-add input {
    flex: 1;
    padding: 0.4rem 0.6rem;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: var(--bg-secondary);
    color: var(--text);
    font-size: 0.8rem;
}

/* ============================================================================
   RESPONSIVE
   ============================================================================ */

@media (max-width: 768px) {
    .desktop-container {
        height: calc(100vh - 150px);
    }

    .widget {
        min-width: 280px;
    }

    .widget-picker-btn {
        width: 48px;
        height: 48px;
        font-size: 1.2rem;
    }

    .widget-picker-menu {
        min-width: 240px;
        right: -10px;
    }
}
