:root {
    /* Default (Dark) */
    --bg-color: #1a1a1a;
    --taskbar-bg: rgba(20, 20, 20, 0.85);
    --window-bg: rgba(30, 30, 30, 0.9);
    --accent-color: #0078d7;
    --text-color: #ffffff;
    --border-color: rgba(255, 255, 255, 0.1);
    --hover-bg: rgba(255, 255, 255, 0.1);
    --bg-image: url('nature_wallpaper.png');
}

/* Light Theme */
[data-theme="light"] {
    --bg-color: #f0f0f0;
    --taskbar-bg: rgba(240, 240, 240, 0.85);
    --window-bg: rgba(255, 255, 255, 0.9);
    --accent-color: #0078d7;
    --text-color: #000000;
    --border-color: rgba(0, 0, 0, 0.1);
    --hover-bg: rgba(0, 0, 0, 0.05);
    --bg-image: url('light_wallpaper.png');
}

/* Blue Theme */
[data-theme="blue"] {
    --bg-color: #0f172a;
    --taskbar-bg: rgba(15, 23, 42, 0.85);
    --window-bg: rgba(30, 41, 59, 0.9);
    --accent-color: #38bdf8;
    --text-color: #e2e8f0;
    --border-color: rgba(56, 189, 248, 0.2);
    --hover-bg: rgba(56, 189, 248, 0.1);
    --bg-image: url('blue_wallpaper.png');
}

body {
    margin: 0;
    padding: 0;
    font-family: 'Segoe UI', sans-serif;
    background: var(--bg-color);
    background-image: var(--bg-image);
    background-repeat: no-repeat;
    background-position: center center;
    background-attachment: fixed;
    background-size: cover;
    overflow: hidden;
    color: var(--text-color);
    user-select: none;
    transition: color 0.3s, background 0.3s;
}

/* Theme Swatches in Settings */
.theme-section {
    padding: 10px 0;
    border-bottom: 1px solid var(--border-color);
}

.theme-grid {
    display: flex;
    gap: 15px;
    margin-top: 10px;
}

.theme-btn {
    width: 60px;
    height: 60px;
    border-radius: 8px;
    cursor: pointer;
    border: 2px solid transparent;
    position: relative;
    overflow: hidden;
    transition: transform 0.2s, border-color 0.2s;
}

.theme-btn:hover {
    transform: scale(1.05);
}

.theme-btn.active {
    border-color: var(--accent-color);
    box-shadow: 0 0 10px var(--accent-color);
}

.theme-btn.dark {
    background: #1a1a1a;
}

.theme-btn.light {
    background: #f0f0f0;
}

.theme-btn.blue {
    background: #0f172a;
}


/* =========================================================
   DESKTOP & ICONS
========================================================= */
#desktop {
    width: 100vw;
    height: calc(100vh - 48px);
    position: relative;
    padding: 10px;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    flex-wrap: wrap;
    align-content: flex-start;
    gap: 10px;
}

.desktop-icon {
    width: 80px;
    height: 90px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    border-radius: 5px;
    cursor: pointer;
    transition: background 0.2s;
}

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

.icon-img {
    font-size: 32px;
    margin-bottom: 5px;
}

.icon-label {
    font-size: 12px;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.8);
    text-align: center;
}

/* =========================================================
   WINDOWS CORE
========================================================= */
.window {
    position: absolute;
    width: 500px;
    height: 350px;
    background: var(--window-bg);
    backdrop-filter: blur(15px);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    display: none;
    flex-direction: column;
    animation: popIn 0.2s cubic-bezier(0.1, 0.9, 0.2, 1);
    overflow: visible;
}

.window.active-focus {
    box-shadow: 0 15px 40px rgba(0, 0, 0, 0.7);
    border-color: rgba(255, 255, 255, 0.3);
    z-index: 1000;
}

/* Virtual Desktop Visibility */
.window.hidden-by-workspace {
    display: none !important;
}

@keyframes popIn {
    from {
        transform: scale(0.95);
        opacity: 0;
    }

    to {
        transform: scale(1);
        opacity: 1;
    }
}

.title-bar {
    height: 32px;
    background: rgba(255, 255, 255, 0.05);
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 10px;
    cursor: move;
    transition: background 0.2s;
}

.window.active-focus .title-bar {
    background: rgba(255, 255, 255, 0.15);
}

.title-text {
    font-size: 12px;
    font-weight: 600;
}

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

.control-btn {
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
}

.control-btn:hover {
    background: rgba(255, 255, 255, 0.1);
}

.control-btn.close:hover {
    background: #e81123;
}

.window-content {
    flex: 1;
    padding: 10px;
    overflow: auto;
}

/* Resize Handles */
.resize-handle {
    position: absolute;
    z-index: 100;
}

.resize-handle-right {
    top: 0;
    right: 0;
    width: 6px;
    height: 100%;
    cursor: e-resize;
}

.resize-handle-bottom {
    bottom: 0;
    left: 0;
    width: 100%;
    height: 6px;
    cursor: s-resize;
}

.resize-handle-corner {
    bottom: 0;
    right: 0;
    width: 15px;
    height: 15px;
    cursor: se-resize;
    z-index: 101;
}

/* =========================================================
   APP SPECIFIC STYLES
========================================================= */
/* Notepad */
textarea {
    width: 100%;
    height: 100%;
    background: transparent;
    border: none;
    color: white;
    resize: none;
    outline: none;
    font-family: monospace;
}

/* Calculator */
.calc-content {
    display: flex;
    flex-direction: column;
    padding: 15px;
}

.calc-display {
    background: rgba(0, 0, 0, 0.3);
    color: white;
    font-size: 32px;
    text-align: right;
    padding: 10px;
    border-radius: 6px;
    margin-bottom: 10px;
}

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

.calc-grid button {
    background: rgba(255, 255, 255, 0.1);
    border: none;
    color: white;
    border-radius: 4px;
    font-size: 16px;
    cursor: pointer;
}

.calc-grid button:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* Settings */
.setting-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 0;
    border-bottom: 1px solid var(--border-color);
}

#voice-setting-row {
    cursor: pointer;
}

#voice-setting-row:hover {
    background: var(--hover-bg);
}

.toggle {
    width: 40px;
    height: 20px;
    background: #444;
    border-radius: 10px;
    position: relative;
}

.toggle.active {
    background: var(--accent-color);
}

.toggle::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 16px;
    height: 16px;
    background: white;
    border-radius: 50%;
    transition: 0.2s;
}

.toggle.active::after {
    left: 22px;
}

/* =========================================================
   TASKBAR
========================================================= */
#taskbar {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 48px;
    background: var(--taskbar-bg);
    backdrop-filter: blur(20px);
    border-top: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    padding: 0 10px;
    z-index: 10000;
}

.taskbar-icon {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    border-radius: 4px;
    cursor: pointer;
    margin: 0 2px;
    transition: background 0.2s;
}

.taskbar-icon:hover {
    background: rgba(255, 255, 255, 0.1);
}

#start-btn {
    font-size: 24px;
    color: var(--accent-color);
}

#task-view-btn {
    width: 40px;
    height: 40px;
    display: flex;
    justify-content: center;
    align-items: center;
    border-radius: 5px;
    cursor: pointer;
    font-size: 20px;
    color: white;
    transition: background 0.2s;
    margin-right: 5px;
}

#task-view-btn:hover {
    background: rgba(255, 255, 255, 0.1);
}

.taskbar-divider {
    width: 1px;
    height: 24px;
    background: var(--border-color);
    margin: 0 10px;
}

.taskbar-spacer {
    flex: 1;
}

.taskbar-clock {
    font-size: 12px;
    padding: 0 10px;
}

/* =========================================================
   START MENU
========================================================= */
#start-menu {
    position: fixed;
    bottom: 58px;
    left: 10px;
    width: 320px;
    height: 400px;
    background: var(--window-bg);
    backdrop-filter: blur(20px);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    display: none;
    flex-direction: column;
    z-index: 9999;
    animation: slideUp 0.2s ease;
}

@keyframes slideUp {
    from {
        transform: translateY(20px);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

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

.pinned-apps {
    padding: 15px;
}

.app-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    margin-top: 10px;
}

.start-app {
    padding: 10px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 4px;
    cursor: pointer;
}

.start-app:hover {
    background: rgba(255, 255, 255, 0.1);
}

/* =========================================================
   GESTURE OVERLAY & CAMERA
========================================================= */
#gesture-overlay {
    position: fixed;
    bottom: 60px;
    left: 10px;
    z-index: 9998;
    pointer-events: none;
}

.camera-container {
    position: relative;
    width: 200px;
    height: 150px;
    border-radius: 10px;
    overflow: hidden;
    border: 2px solid var(--accent-color);
    background: black;
}

#camera,
#output_canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    transform: scaleX(-1);
}

#gesture-status {
    position: absolute;
    bottom: 5px;
    left: 0;
    width: 100%;
    text-align: center;
    color: #0f0;
    font-weight: bold;
    text-shadow: 0 1px 2px black;
    font-size: 14px;
    background: rgba(0, 0, 0, 0.5);
}

/* Camera Nav */
.camera-nav {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 30px;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    justify-content: flex-end;
    align-items: center;
    padding: 0 5px;
    box-sizing: border-box;
    z-index: 100;
    opacity: 0;
    transition: opacity 0.2s;
    pointer-events: auto;
    /* Enable clicking buttons */
}

.camera-container:hover .camera-nav {
    opacity: 1;
}

.cam-btn {
    width: 24px;
    height: 24px;
    color: white;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    font-size: 14px;
    border-radius: 4px;
    margin-left: 2px;
}

.cam-btn:hover {
    background: rgba(255, 255, 255, 0.3);
}

.cam-btn.active {
    color: var(--accent-color);
}

/* Camera States */
#gesture-overlay.large .camera-container {
    width: 320px;
    height: 240px;
}

#gesture-overlay.transparent .camera-container {
    opacity: 0.4;
}

#gesture-overlay.locked .camera-container {
    border-color: red;
}

#gesture-overlay.minimized .camera-container {
    height: 30px;
    overflow: hidden;
}

#gesture-overlay.minimized video,
#gesture-overlay.minimized canvas {
    display: none;
}

/* =========================================================
   CUSTOM CURSOR
========================================================= */
#custom-cursor {
    position: fixed;
    top: 0;
    left: 0;
    width: 20px;
    height: 20px;
    background: rgba(255, 255, 255, 0.8);
    border: 2px solid var(--accent-color);
    border-radius: 50%;
    pointer-events: none;
    z-index: 999999;
    /* Transform will be set via JS for performance */
    transition: width 0.1s, height 0.1s, background 0.1s;
    box-shadow: 0 0 10px var(--accent-color);
    /* Offset to center the cursor on the point */
    margin-left: -10px;
    margin-top: -10px;
}

#custom-cursor.active {
    background: #0f0;
    width: 15px;
    height: 15px;
    margin-left: -7.5px;
    margin-top: -7.5px;
}

#custom-cursor.fist {
    background: cyan;
    border-color: cyan;
    width: 25px;
    height: 25px;
    border-radius: 4px;
    margin-left: -12.5px;
    margin-top: -12.5px;
}

/* =========================================================
   BOOT SCREEN
========================================================= */
#pine-boot-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: #1a1a1a;
    background: radial-gradient(circle at center, #2a2a2a 0%, #111 100%);
    z-index: 999999;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: white;
    font-family: 'Segoe UI', sans-serif;
    transition: opacity 0.3s ease;
    user-select: none;
}

#pine-boot-screen.fade-out {
    opacity: 0;
    pointer-events: none;
}

.pine-boot-content {
    text-align: center;
    animation: pineScaleIn 0.8s cubic-bezier(0.2, 0.8, 0.2, 1) forwards;
}

.pine-boot-logo {
    font-size: 64px;
    margin-bottom: 20px;
    display: block;
}

.pine-boot-title {
    font-size: 24px;
    font-weight: 300;
    letter-spacing: 4px;
    margin-bottom: 40px;
    text-transform: uppercase;
}

.pine-boot-bar-container {
    width: 200px;
    height: 4px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 2px;
    overflow: hidden;
    margin: 0 auto;
}

.pine-boot-bar {
    width: 0%;
    height: 100%;
    background: var(--accent-color);
    border-radius: 2px;
    animation: pineProgress 2s ease-in-out forwards;
}

.pine-boot-subtext {
    margin-top: 15px;
    font-size: 12px;
    opacity: 0.5;
    font-weight: 300;
}

@keyframes pineScaleIn {
    from {
        transform: scale(0.9);
        opacity: 0;
    }

    to {
        transform: scale(1);
        opacity: 1;
    }
}

@keyframes pineProgress {
    0% {
        width: 0%;
    }

    50% {
        width: 70%;
    }

    100% {
        width: 100%;
    }
}

/* =========================================================
   WIDGETS (DESKTOP)
========================================================= */
#desktop-widgets-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 10;
}

.pine-widget {
    position: absolute;
    background: rgba(30, 30, 30, 0.6);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
    color: white;
    overflow: hidden;
    pointer-events: auto;
    display: flex;
    flex-direction: column;
    transition: box-shadow 0.2s;
}

.pine-widget:hover {
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.4);
    border-color: rgba(255, 255, 255, 0.2);
}

.pine-widget-header {
    height: 12px;
    width: 100%;
    cursor: grab;
    background: rgba(255, 255, 255, 0.05);
}

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

/* Clock */
#widget-clock {
    width: 140px;
    height: 80px;
    align-items: center;
    justify-content: center;
}

.clock-time {
    font-size: 32px;
    font-weight: 300;
    line-height: 1;
}

.clock-date {
    font-size: 12px;
    opacity: 0.7;
    margin-top: 4px;
}

/* =========================================================
   VOICE TOAST
   ========================================================= */
#voice-toast {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.7);
    color: white;
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 12px;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    z-index: 10000;
    opacity: 0;
    transition: opacity 0.3s, transform 0.3s;
    pointer-events: none;
    transform: translateX(-50%) translateY(-20px);
    max-width: 50px;
    text-align: center;
}

#voice-toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* Calendar */
#widget-calendar {
    width: 200px;
    padding-bottom: 10px;
}

.calendar-header {
    text-align: center;
    padding: 8px 0;
    font-size: 14px;
    font-weight: 600;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 2px;
    padding: 5px;
    text-align: center;
    font-size: 10px;
}

.cal-day-name {
    opacity: 0.5;
    margin-bottom: 4px;
}

.cal-day {
    padding: 4px;
    border-radius: 4px;
    cursor: pointer;
}

.cal-day:hover {
    background: rgba(255, 255, 255, 0.1);
}

.cal-day.today {
    background: var(--accent-color);
    color: white;
    font-weight: bold;
}

.cal-day.empty {
    pointer-events: none;
}

/* =========================================================
   TASK VIEW & SNAP OVERLAYS
========================================================= */
#task-view-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(15px);
    z-index: 999950;
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.3s ease;
}

#task-view-overlay.visible {
    opacity: 1;
}

.tv-title {
    color: white;
    font-size: 24px;
    margin-bottom: 30px;
    font-weight: 300;
    letter-spacing: 2px;
}

.desktop-list {
    display: flex;
    gap: 20px;
    padding: 20px;
    overflow-x: auto;
    max-width: 90%;
}

.desktop-thumbnail {
    width: 200px;
    height: 120px;
    background: rgba(255, 255, 255, 0.05);
    border: 2px solid rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
}

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

/* Snap Preview */
#pine-snap-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 999900;
    display: none;
}

#pine-snap-overlay.active {
    display: block;
}

.snap-preview {
    position: absolute;
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 12px;
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.2);
    opacity: 0;
    transition: all 0.2s cubic-bezier(0.2, 0.8, 0.2, 1);
    transform: scale(0.95);
}

/* Voice Toast */
#voice-toast {
    position: fixed;
    bottom: 80px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(10px);
    padding: 8px 16px;
    border-radius: 20px;
    color: white;
    font-size: 14px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    z-index: 999990;
    display: none;
    align-items: center;
    gap: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

#voice-toast.show {
    display: flex;
    animation: fadeToast 2s ease forwards;
}

@keyframes fadeToast {
    0% {
        opacity: 0;
        transform: translate(-50%, 10px);
    }

    10% {
        opacity: 1;
        transform: translate(-50%, 0);
    }

    80% {
        opacity: 1;
        transform: translate(-50%, 0);
    }

    100% {
        opacity: 0;
        transform: translate(-50%, -10px);
    }
}