/* ═══════════════════════════════════════════════
   CYRIF OS — Desktop Environment Styles
   ═══════════════════════════════════════════════ */

:root {
    --os-bg: #262624;
    --os-panel: rgba(45, 45, 43, 0.92);
    --os-border: rgba(255,255,255,0.06);
    --os-border-hover: rgba(255,255,255,0.12);
    --os-text: #ccc;
    --os-text-dim: #555;
    --os-text-bright: #fff;
    --os-accent: #D97757;
    --os-accent-rgb: 217,119,87;
    --os-green: #00ff41;
    --os-red: #ff3c3c;
    --os-font: 'Share Tech Mono', monospace;
    --os-font-title: 'Orbitron', monospace;
    --os-taskbar-h: 38px;
    --os-titlebar-h: 30px;
    --os-win-radius: 0px;
}

/* ─── RESET ─── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body.cyrif-os {
    background: var(--os-bg);
    color: var(--os-text);
    font-family: var(--os-font);
    overflow: hidden;
    width: 100vw;
    height: 100vh;
    user-select: none;
}

/* ─── DESKTOP ─── */
#os-desktop {
    position: fixed;
    top: 0; left: 0; right: 0;
    bottom: var(--os-taskbar-h);
    overflow: hidden;
    z-index: 1;
}

#os-wallpaper {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    z-index: 0;
}

/* ─── DESKTOP ICONS ─── */
#os-icons {
    position: absolute;
    top: 20px; left: 20px;
    display: flex;
    flex-direction: column;
    flex-wrap: wrap;
    gap: 8px;
    max-height: calc(100% - 40px);
    z-index: 2;
}

.os-icon {
    width: 80px;
    padding: 10px 4px 8px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    border-radius: 4px;
    transition: background 0.15s;
}
.os-icon:hover {
    background: rgba(255,255,255,0.04);
}
.os-icon.selected {
    background: rgba(var(--os-accent-rgb), 0.1);
    outline: 1px solid rgba(var(--os-accent-rgb), 0.3);
}
.os-icon-img {
    font-size: 28px;
    line-height: 1;
    filter: drop-shadow(0 0 4px rgba(255,255,255,0.1));
}
.os-icon-label {
    font-family: var(--os-font);
    font-size: 10px;
    color: #aaa;
    text-align: center;
    text-shadow: 0 1px 3px rgba(0,0,0,0.8);
    line-height: 1.3;
    word-break: break-word;
}

/* ─── WINDOWS ─── */
.os-window {
    position: absolute;
    background: var(--os-panel);
    border: 1px solid var(--os-border);
    box-shadow: 0 8px 32px rgba(0,0,0,0.6), 0 0 1px rgba(255,255,255,0.05);
    display: flex;
    flex-direction: column;
    min-width: 240px;
    min-height: 160px;
    z-index: 10;
    transition: box-shadow 0.2s;
    border-radius: var(--os-win-radius);
    overflow: hidden;
}
.os-window.focused {
    border-color: rgba(var(--os-accent-rgb), 0.2);
    box-shadow: 0 12px 48px rgba(0,0,0,0.8), 0 0 20px rgba(var(--os-accent-rgb), 0.05);
}
.os-window.maximized {
    top: 0 !important;
    left: 0 !important;
    width: 100% !important;
    height: calc(100vh - var(--os-taskbar-h)) !important;
    border-radius: 0;
    border: none;
}
.os-window.minimized {
    display: none;
}
.os-window.snap-left {
    top: 0 !important;
    left: 0 !important;
    width: 50% !important;
    height: calc(100vh - var(--os-taskbar-h)) !important;
    border-radius: 0;
}
.os-window.snap-right {
    top: 0 !important;
    left: 50% !important;
    width: 50% !important;
    height: calc(100vh - var(--os-taskbar-h)) !important;
    border-radius: 0;
}

/* ─── TITLE BAR ─── */
.os-titlebar {
    height: var(--os-titlebar-h);
    background: rgba(255,255,255,0.02);
    border-bottom: 1px solid var(--os-border);
    display: flex;
    align-items: center;
    padding: 0 8px;
    flex-shrink: 0;
    cursor: default;
}
.os-titlebar-icon {
    font-size: 13px;
    margin-right: 8px;
    opacity: 0.7;
}
.os-titlebar-text {
    font-family: var(--os-font-title);
    font-size: 9px;
    letter-spacing: 2px;
    color: #888;
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.os-window.focused .os-titlebar-text {
    color: #ccc;
}
.os-titlebar-btns {
    display: flex;
    gap: 1px;
    margin-left: 8px;
}
.os-titlebar-btn {
    width: 28px;
    height: 22px;
    border: none;
    background: transparent;
    color: #555;
    font-size: 11px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s;
}
.os-titlebar-btn:hover {
    background: rgba(255,255,255,0.06);
    color: #ccc;
}
.os-titlebar-btn.close:hover {
    background: rgba(255,60,60,0.3);
    color: #ff6666;
}

/* ─── WINDOW CONTENT ─── */
.os-window-content {
    flex: 1;
    overflow: hidden;
    position: relative;
}

/* ─── RESIZE HANDLES ─── */
.os-resize {
    position: absolute;
    z-index: 5;
}
.os-resize-n { top: -3px; left: 8px; right: 8px; height: 6px; cursor: n-resize; }
.os-resize-s { bottom: -3px; left: 8px; right: 8px; height: 6px; cursor: s-resize; }
.os-resize-e { top: 8px; right: -3px; bottom: 8px; width: 6px; cursor: e-resize; }
.os-resize-w { top: 8px; left: -3px; bottom: 8px; width: 6px; cursor: w-resize; }
.os-resize-ne { top: -3px; right: -3px; width: 12px; height: 12px; cursor: ne-resize; }
.os-resize-nw { top: -3px; left: -3px; width: 12px; height: 12px; cursor: nw-resize; }
.os-resize-se { bottom: -3px; right: -3px; width: 12px; height: 12px; cursor: se-resize; }
.os-resize-sw { bottom: -3px; left: -3px; width: 12px; height: 12px; cursor: sw-resize; }

/* ─── TASKBAR ─── */
#os-taskbar {
    position: fixed;
    bottom: 0; left: 0; right: 0;
    height: var(--os-taskbar-h);
    background: rgba(45, 45, 43, 0.95);
    border-top: 1px solid var(--os-border);
    display: flex;
    align-items: center;
    z-index: 9999;
    backdrop-filter: blur(10px);
}

#os-start-btn {
    width: 44px;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    border: none;
    background: transparent;
    color: var(--os-accent);
    font-size: 16px;
    transition: background 0.15s;
    border-right: 1px solid var(--os-border);
}
#os-start-btn:hover {
    background: rgba(var(--os-accent-rgb), 0.08);
}

#os-taskbar-apps {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 2px;
    padding: 0 4px;
    overflow-x: auto;
}

.os-taskbar-app {
    padding: 4px 14px;
    font-family: var(--os-font);
    font-size: 11px;
    color: #666;
    cursor: pointer;
    border: none;
    background: transparent;
    transition: all 0.15s;
    white-space: nowrap;
    border-bottom: 2px solid transparent;
    height: 100%;
    display: flex;
    align-items: center;
    gap: 6px;
}
.os-taskbar-app:hover {
    color: #aaa;
    background: rgba(255,255,255,0.02);
}
.os-taskbar-app.active {
    color: #ccc;
    border-bottom-color: var(--os-accent);
    background: rgba(var(--os-accent-rgb), 0.04);
}
.os-taskbar-app.minimized {
    color: #444;
    border-bottom-color: #333;
}
.os-taskbar-app-icon {
    font-size: 12px;
}

#os-tray {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0 12px;
    height: 100%;
    border-left: 1px solid var(--os-border);
    font-size: 11px;
    color: #555;
}
.os-tray-item {
    display: flex;
    align-items: center;
    gap: 4px;
}
.os-tray-val {
    color: #888;
}
.os-tray-dot {
    width: 6px; height: 6px;
    border-radius: 50%;
    background: var(--os-green);
    box-shadow: 0 0 4px rgba(0,255,65,0.4);
}
.os-tray-dot.offline {
    background: var(--os-red);
    box-shadow: 0 0 4px rgba(255,60,60,0.4);
}
#os-clock {
    font-family: var(--os-font);
    font-size: 12px;
    color: #888;
    letter-spacing: 1px;
}

/* ─── START MENU ─── */
#os-start-menu {
    position: fixed;
    bottom: var(--os-taskbar-h);
    left: 0;
    width: 320px;
    max-height: calc(100vh - var(--os-taskbar-h) - 20px);
    background: rgba(45, 45, 43, 0.96);
    border: 1px solid var(--os-border);
    border-bottom: none;
    display: none;
    flex-direction: column;
    z-index: 99998;
    backdrop-filter: blur(20px);
}
#os-start-menu.open {
    display: flex;
}

.os-menu-header {
    padding: 16px;
    border-bottom: 1px solid var(--os-border);
    display: flex;
    align-items: center;
    gap: 12px;
}
.os-menu-logo {
    font-family: var(--os-font-title);
    font-size: 20px;
    font-weight: 900;
    letter-spacing: 6px;
    color: #fff;
}
.os-menu-logo .i { color: var(--os-accent); }
.os-menu-version {
    font-size: 9px;
    color: #333;
    letter-spacing: 2px;
}

.os-menu-section {
    padding: 6px 0;
}
.os-menu-section-title {
    font-family: var(--os-font-title);
    font-size: 8px;
    letter-spacing: 3px;
    color: #333;
    padding: 6px 16px 4px;
    text-transform: uppercase;
}

.os-menu-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 16px;
    cursor: pointer;
    transition: background 0.1s;
    border: none;
    background: none;
    width: 100%;
    text-align: left;
    color: var(--os-text);
    font-family: var(--os-font);
    font-size: 12px;
}
.os-menu-item:hover {
    background: rgba(var(--os-accent-rgb), 0.06);
}
.os-menu-item-icon {
    font-size: 16px;
    width: 24px;
    text-align: center;
}
.os-menu-item-name {
    flex: 1;
}
.os-menu-item.locked {
    opacity: 0.3;
    cursor: not-allowed;
}
.os-menu-item.locked::after {
    content: '🔒';
    font-size: 10px;
}

.os-menu-footer {
    padding: 12px 16px;
    border-top: 1px solid var(--os-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.os-menu-user {
    font-size: 12px;
    color: #ECECEC;
}
.os-menu-user-tier {
    font-family: var(--os-font-title);
    font-size: 9px;
    letter-spacing: 2px;
    padding: 3px 10px;
    border: 1px solid rgba(217, 119, 87, 0.4);
    color: #D97757;
    border-radius: 4px;
    background: rgba(217, 119, 87, 0.08);
}
.os-menu-logout {
    font-size: 12px;
    color: #B0B0AE;
    cursor: pointer;
    background: none;
    border: none;
    font-family: var(--os-font);
    transition: color 0.15s;
}
.os-menu-logout:hover {
    color: #D97757;
}

/* ─── CONTEXT MENU ─── */
.os-context-menu {
    position: fixed;
    background: rgba(45, 45, 43, 0.96);
    border: 1px solid var(--os-border);
    min-width: 180px;
    z-index: 99999;
    display: none;
    backdrop-filter: blur(10px);
}
.os-context-menu.open {
    display: block;
}
.os-context-item {
    display: block;
    width: 100%;
    padding: 8px 14px;
    font-family: var(--os-font);
    font-size: 11px;
    color: #888;
    border: none;
    background: none;
    text-align: left;
    cursor: pointer;
}
.os-context-item:hover {
    background: rgba(var(--os-accent-rgb), 0.06);
    color: #ccc;
}
.os-context-sep {
    height: 1px;
    background: var(--os-border);
    margin: 2px 8px;
}

/* ─── SNAP PREVIEW ─── */
.os-snap-preview {
    position: fixed;
    background: rgba(var(--os-accent-rgb), 0.06);
    border: 2px solid rgba(var(--os-accent-rgb), 0.2);
    z-index: 8;
    display: none;
    pointer-events: none;
    transition: all 0.15s ease;
}

/* ─── WINDOW OPEN/CLOSE ANIMATIONS ─── */
@keyframes osWinOpen {
    from { opacity: 0; transform: scale(0.92); }
    to { opacity: 1; transform: scale(1); }
}
@keyframes osWinClose {
    from { opacity: 1; transform: scale(1); }
    to { opacity: 0; transform: scale(0.95); }
}
.os-window.opening {
    animation: osWinOpen 0.2s ease-out forwards;
}
.os-window.closing {
    animation: osWinClose 0.15s ease-in forwards;
    pointer-events: none;
}

/* ─── SCANLINES (OS-level) ─── */
#os-scanlines {
    position: fixed;
    top: 0; left: 0;
    width: 100vw; height: 100vh;
    background: repeating-linear-gradient(
        0deg,
        transparent, transparent 2px,
        rgba(0,0,0,0.06) 2px, rgba(0,0,0,0.06) 4px
    );
    pointer-events: none;
    z-index: 99997;
    opacity: 0.4;
}
