/**
 * Universal Desktop v2.0.0 - Styles
 * 1:1 Port from React/Tailwind to Vanilla CSS
 */

/* ========================================
   RESET & BASE
   ======================================== */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ========================================
   THEME VARIABLES
   ======================================== */

:root {
    --background: #ffffff;
    --foreground: #000000;
    --card: #ffffff;
    --border: rgba(0, 0, 0, 0.1);
    --muted: #f3f4f6;
    --muted-foreground: #6b7280;
    --accent: #f3f4f6;
    --ring: #3b82f6;
    --radius: 0.5rem;
}

.dark {
    --background: #0a0a0a;
    --foreground: #ffffff;
    --card: #171717;
    --border: rgba(255, 255, 255, 0.1);
    --muted: #262626;
    --muted-foreground: #a1a1aa;
    --accent: #262626;
    --ring: #60a5fa;
}

/* ========================================
   APP CONTAINER
   ======================================== */

#app {
    width: 100%;
    height: 100vh;
    overflow: hidden;
    position: relative;
}

/* ========================================
   DESKTOP BACKGROUND
   ======================================== */

.desktop-background {
    position: absolute;
    inset: 0;
    z-index: 0;
    transition: background 0.3s ease;
}

/* ========================================
   DESKTOP INDICATOR (Dots at top)
   ======================================== */

.desktop-indicator {
    position: absolute;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 10;
    display: flex;
    align-items: center;
    gap: 12px;
    background: rgba(0, 0, 0, 0.3);
    backdrop-filter: blur(10px);
    padding: 8px 16px;
    border-radius: 20px;
}

.desktop-dots {
    display: flex;
    gap: 8px;
    align-items: center;
}

.desktop-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.4);
    border: none;
    cursor: pointer;
    transition: all 0.2s ease;
    padding: 0;
}

.desktop-dot:hover {
    background: rgba(255, 255, 255, 0.6);
    transform: scale(1.2);
}

.desktop-dot.active {
    background: rgba(255, 255, 255, 1);
    width: 24px;
    border-radius: 4px;
}

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

.desktop-container {
    position: absolute;
    inset: 0;
    top: 60px;
    bottom: 60px;
    z-index: 1;
    overflow: hidden;
    touch-action: pan-x pan-y;
}

/* ========================================
   DESKTOP GRID
   ======================================== */

.desktop-grid {
    display: grid;
    width: 100%;
    height: 100%;
    padding: 20px;
    gap: 12px;
    position: relative;
}

.grid-slot {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 12px;
    transition: background 0.15s ease;
}

.grid-slot.drop-target {
    background: rgba(255, 255, 255, 0.1);
    border: 2px dashed rgba(255, 255, 255, 0.5);
}

/* ========================================
   DESKTOP ICON
   ======================================== */

.desktop-icon {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 8px;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.15s ease;
    user-select: none;
    -webkit-user-select: none;
    touch-action: none;
}

.desktop-icon:hover {
    background: rgba(255, 255, 255, 0.1);
    transform: translateY(-2px);
}

.desktop-icon:active {
    transform: scale(0.95);
}

.desktop-icon.dragging {
    opacity: 0.5;
}

.icon-image {
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 12px;
    backdrop-filter: blur(8px);
    overflow: hidden;
}

.icon-image img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.icon-label {
    color: white;
    text-align: center;
    font-size: 12px;
    max-width: 60px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
}

/* ========================================
   EDGE INDICATORS
   ======================================== */

.edge-indicator {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 100px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(59, 130, 246, 0.3);
    backdrop-filter: blur(8px);
    pointer-events: none;
    z-index: 100;
}

.edge-indicator.left {
    left: 0;
    border-right: 3px solid rgba(59, 130, 246, 0.8);
}

.edge-indicator.right {
    right: 0;
    border-left: 3px solid rgba(59, 130, 246, 0.8);
}

.edge-indicator span {
    font-size: 32px;
    color: white;
    animation: pulse 1s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 0.6; transform: scale(1); }
    50% { opacity: 1; transform: scale(1.1); }
}

/* ========================================
   WINDOWS CONTAINER
   ======================================== */

.windows-container {
    position: absolute;
    inset: 0;
    top: 60px;
    bottom: 60px;
    z-index: 50;
    pointer-events: none;
}

/* ========================================
   APPLICATION WINDOW
   ======================================== */

.app-window {
    position: absolute;
    width: 600px;
    max-width: 90vw;
    height: 400px;
    max-height: 70vh;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    pointer-events: auto;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
}

.window-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: var(--muted);
    border-bottom: 1px solid var(--border);
    cursor: move;
    user-select: none;
}

.window-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 500;
    color: var(--foreground);
}

.window-title img {
    width: 20px;
    height: 20px;
    object-fit: contain;
}

.window-controls {
    display: flex;
    gap: 8px;
}

.window-control {
    width: 32px;
    height: 32px;
    border: none;
    border-radius: 6px;
    background: transparent;
    color: var(--foreground);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    transition: background 0.15s ease;
}

.window-control:hover {
    background: var(--accent);
}

.window-control.minimize:hover {
    background: #fbbf24;
    color: white;
}

.window-control.close:hover {
    background: #ef4444;
    color: white;
}

.window-content {
    flex: 1;
    overflow: auto;
    background: var(--background);
}

.app-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    padding: 40px;
    text-align: center;
    color: var(--muted-foreground);
}

.app-placeholder img {
    width: 80px;
    height: 80px;
    margin-bottom: 20px;
    opacity: 0.5;
}

.app-placeholder h3 {
    margin-bottom: 12px;
    color: var(--foreground);
}

.app-placeholder p {
    max-width: 400px;
    line-height: 1.6;
}

/* ========================================
   TASKBAR
   ======================================== */

.taskbar {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 60px;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(20px);
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    align-items: center;
    padding: 0 16px;
    gap: 12px;
    z-index: 100;
}

.taskbar-btn {
    width: 44px;
    height: 44px;
    border: none;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.1);
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s ease;
    font-size: 18px;
}

.taskbar-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: scale(1.05);
}

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

.taskbar-icon {
    font-size: 20px;
}

.taskbar-windows {
    flex: 1;
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding: 4px 0;
}

.taskbar-windows::-webkit-scrollbar {
    height: 4px;
}

.taskbar-windows::-webkit-scrollbar-track {
    background: transparent;
}

.taskbar-windows::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 2px;
}

.taskbar-window-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    border: none;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.1);
    color: white;
    cursor: pointer;
    font-size: 14px;
    white-space: nowrap;
    transition: all 0.15s ease;
    max-width: 200px;
}

.taskbar-window-btn:hover {
    background: rgba(255, 255, 255, 0.2);
}

.taskbar-window-btn.minimized {
    opacity: 0.6;
}

.taskbar-window-btn img {
    width: 20px;
    height: 20px;
    object-fit: contain;
}

.taskbar-window-btn span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.taskbar-right {
    display: flex;
    align-items: center;
    gap: 8px;
}

.taskbar-clock {
    color: white;
    font-size: 14px;
    padding: 8px 12px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    font-variant-numeric: tabular-nums;
}

/* ========================================
   DIALOGS
   ======================================== */

.dialog-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.dialog-overlay.hidden {
    display: none;
}

.dialog-content {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    width: 100%;
    max-width: 600px;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
}

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

.dialog-header h2 {
    font-size: 20px;
    font-weight: 600;
    color: var(--foreground);
}

.dialog-close {
    width: 32px;
    height: 32px;
    border: none;
    border-radius: 6px;
    background: transparent;
    color: var(--muted-foreground);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    transition: all 0.15s ease;
}

.dialog-close:hover {
    background: var(--accent);
    color: var(--foreground);
}

.dialog-body {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
}

.dialog-description {
    color: var(--muted-foreground);
    font-size: 14px;
    margin-bottom: 20px;
    line-height: 1.5;
}

/* ========================================
   APPLICATION LIST
   ======================================== */

.app-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.app-list-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--card);
    transition: all 0.15s ease;
}

.app-list-item:hover {
    background: var(--accent);
}

.app-list-icon {
    width: 48px;
    height: 48px;
    object-fit: contain;
    flex-shrink: 0;
}

.app-list-info {
    flex: 1;
    min-width: 0;
}

.app-list-name {
    font-weight: 500;
    color: var(--foreground);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.app-list-category {
    font-size: 12px;
    color: var(--muted-foreground);
    margin-top: 4px;
    padding: 2px 8px;
    background: var(--muted);
    border-radius: 4px;
    display: inline-block;
}

.app-list-btn {
    padding: 8px 16px;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s ease;
    white-space: nowrap;
}

.app-list-btn.install {
    background: #3b82f6;
    color: white;
}

.app-list-btn.install:hover {
    background: #2563eb;
}

.app-list-btn.installed {
    background: var(--muted);
    color: var(--muted-foreground);
    cursor: default;
}

/* ========================================
   SETTINGS DIALOG
   ======================================== */

.settings-form {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.setting-item {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.setting-item label {
    font-weight: 500;
    color: var(--foreground);
}

.setting-item select,
.setting-item input[type="color"],
.setting-item input[type="text"] {
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--background);
    color: var(--foreground);
    font-size: 14px;
}

.setting-item select:focus,
.setting-item input:focus {
    outline: 2px solid var(--ring);
    outline-offset: 2px;
}

.setting-value {
    padding: 8px 12px;
    background: var(--muted);
    border-radius: 6px;
    color: var(--foreground);
    font-size: 14px;
}

/* ========================================
   ACTIVE APPS DIALOG
   ======================================== */

.active-apps-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.active-app-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--card);
}

.active-app-item img {
    width: 40px;
    height: 40px;
    object-fit: contain;
}

.active-app-item span {
    flex: 1;
    font-weight: 500;
    color: var(--foreground);
}

.active-app-controls {
    display: flex;
    gap: 8px;
}

.active-app-controls button {
    padding: 6px 12px;
    border: none;
    border-radius: 6px;
    background: var(--muted);
    color: var(--foreground);
    font-size: 13px;
    cursor: pointer;
    transition: background 0.15s ease;
}

.active-app-controls button:hover {
    background: var(--accent);
}

.no-apps {
    text-align: center;
    color: var(--muted-foreground);
    padding: 40px 20px;
}

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

@media (max-width: 768px) {
    .desktop-indicator {
        top: 10px;
        padding: 6px 12px;
    }
    
    .desktop-container {
        top: 50px;
        bottom: 70px;
    }
    
    .windows-container {
        top: 50px;
        bottom: 70px;
    }
    
    .taskbar {
        height: 70px;
    }
    
    .taskbar-btn {
        width: 40px;
        height: 40px;
    }
    
    .app-window {
        width: 95vw;
        height: 70vh;
    }
    
    .dialog-content {
        max-width: 95vw;
    }
}

/* ========================================
   UTILITIES
   ======================================== */

.hidden {
    display: none !important;
}

/* Disable text selection on interactive elements */
.desktop-icon,
.taskbar-btn,
.window-header,
button {
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}

/* Smooth transitions */
* {
    transition-property: background-color, border-color, color, fill, stroke;
    transition-duration: 150ms;
    transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
}

/* Remove transition from transform/opacity for better drag performance */
.desktop-icon,
.grid-slot {
    transition-property: background-color, transform;
}
