/**
 * Windows XP - Desktop
 * Interface completa do desktop do Windows XP
 */

#xp-desktop {
    position: absolute;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: url('../images/desktop-bg.jpg') center bottom no-repeat;
    background-size: cover;
    color: #ffffff;
    display: none;
    z-index: 9997;
}

#xp-desktop.active {
    display: block;
}

/* ========================================
   DESKTOP AREA (ícones)
======================================== */

.desktop {
    position: absolute;
    padding: 8px;
    height: calc(100vh - 32px);
    width: 100vw;
    overflow: hidden;
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    flex-direction: column;
}

/* Desktop Icons */
.icon {
    width: 80px;
    display: flex;
    flex-direction: column;
    align-items: center;
    cursor: pointer;
    padding: 4px 4px 6px;
    border: 1px solid transparent;
    border-radius: 3px;
    transition: background-color 0.15s, border-color 0.15s;
    user-select: none;
    -webkit-tap-highlight-color: rgba(0,0,0,0);
    position: absolute;
    box-sizing: border-box;
}

.icon.icon-dragging {
    opacity: 0.7;
    cursor: grabbing;
    z-index: 9000 !important;
    transition: none;
}

.icon img {
    width: 48px;
    height: 48px;
    object-fit: contain;
    display: block;
    pointer-events: none;
    flex-shrink: 0;
}

.icon .icon-name {
    font-family: 'Tahoma', 'Segoe UI', sans-serif;
    font-size: 11px;
    line-height: 14px;
    max-height: 28px;
    width: 100%;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    text-align: center;
    margin-top: 3px;
    color: #fff;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.9), 0 0 4px rgba(0,0,0,0.7);
    word-break: break-word;
}

.icon:hover,
.icon.selected {
    background-color: rgba(49, 106, 197, 0.5);
    border-color: rgba(153, 209, 255, 0.8);
}

.icon::selection,
.icon::-moz-selection {
    background-color: transparent;
}

/* Recycle Bin — posição padrão inicial (sobrescrita pelo JS após drag) */
.recycle-bin-default {
    right: 8px;
    bottom: 48px;
}

/* ========================================
   WINDOWS (Janelas)
======================================== */

.window-container {
    position: relative;
    width: 100%;
    height: calc(100% - 32px);
    pointer-events: none;
}

.window {
    z-index: 100;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    max-width: 800px;
    max-height: 600px;
    width: calc(100% - 100px);
    height: calc(100% - 150px);
    box-shadow: inset -1px -1px #00138c, inset 1px 1px #0831d9, inset -2px -2px #001ea0, 
                inset 2px 2px #166aee, inset -3px -3px #003bda, inset 3px 3px #0855dd;
    border-top-left-radius: 8px;
    border-top-right-radius: 8px;
    padding: 0 0 3px;
    background: #ffffff;
    transition: all 0.1s ease;
    pointer-events: all;
    display: none;
}

.window.active {
    display: block;
}

.window.maximized {
    top: 0 !important;
    left: 0 !important;
    transform: none !important;
    width: 100vw !important;
    height: calc(100vh - 32px) !important;
    max-width: none !important;
    max-height: none !important;
    border-radius: 0 !important;
    transition: all 0.2s ease-out;
    border-top-left-radius: 0 !important;
    border-top-right-radius: 0 !important;
}

.window.minimized {
    top: 100%;
    height: 0;
    width: 0;
    opacity: 0;
    transition: all 0.2s ease-in;
}

/* Estado de arrastar - sombra mais forte */
.window.dragging {
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5), 
                inset -1px -1px #00138c, inset 1px 1px #0831d9, 
                inset -2px -2px #001ea0, inset 2px 2px #166aee;
    transition: none;
}

/* Title Bar */
.title-bar {
    background: linear-gradient(180deg, #0997ff, #0053ee 8%, #0050ee 40%, #06f 88%, 
                #06f 93%, #005bff 95%, #003dd7 96%, #003dd7);
    padding: 3px 5px;
    border-top: 1px solid #0831d9;
    border-left: 1px solid #0831d9;
    border-right: 1px solid #001ea0;
    border-top-left-radius: 8px;
    border-top-right-radius: 7px;
    font-size: 14px;
    color: #fff;
    text-shadow: 1px 1px #0f1089;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: grab;
    user-select: none;
}

.title-bar:active {
    cursor: grabbing;
}

.window.dragging .title-bar {
    cursor: grabbing !important;
}

.title-bar .window-title {
    display: flex;
    align-items: center;
    gap: 5px;
}

.title-bar img {
    height: 18px;
    transform: translateY(3px);
}

.title-bar .controls {
    display: flex;
    gap: 2px;
}

.title-bar button {
    width: 21px;
    height: 21px;
    min-width: 21px;
    min-height: 21px;
    margin-left: 2px;
    background-repeat: no-repeat;
    background-position: center;
    background-color: #0050ee;
    transition: background 0.1s;
    border: 1px solid rgba(255, 255, 255, 0.3);
    padding: 0;
    cursor: pointer;
    border-radius: 2px;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}

.title-bar button:hover {
    background-color: #1060ff;
    border-color: rgba(255, 255, 255, 0.5);
}

.title-bar button:active {
    background-color: #0040cc;
    border-color: rgba(0, 0, 0, 0.3);
}

/* Minimize Button - Linha horizontal */
.btn-minimize {
    background-image: url('data:image/svg+xml;charset=utf-8,%3Csvg xmlns="http://www.w3.org/2000/svg" width="10" height="10"%3E%3Crect x="0" y="7" width="10" height="2" fill="white"/%3E%3C/svg%3E');
    background-size: 10px 10px;
}

.btn-minimize::after {
    content: "";
    position: absolute;
    bottom: 6px;
    left: 3px;
    right: 3px;
    height: 2px;
    background-color: white;
    box-shadow: 0 1px 1px rgba(0, 0, 0, 0.3);
}

/* Maximize Button - Quadrado */
.btn-maximize {
    background-image: url('data:image/svg+xml;charset=utf-8,%3Csvg xmlns="http://www.w3.org/2000/svg" width="10" height="10"%3E%3Crect x="1" y="1" width="8" height="8" fill="none" stroke="white" stroke-width="2"/%3E%3C/svg%3E');
    background-size: 10px 10px;
}

.btn-maximize::after {
    content: "";
    position: absolute;
    top: 4px;
    left: 4px;
    width: 10px;
    height: 10px;
    border: 2px solid white;
    box-sizing: border-box;
    box-shadow: 0 1px 1px rgba(0, 0, 0, 0.3);
}

.window.maximized .btn-maximize::after {
    width: 8px;
    height: 8px;
    top: 5px;
    left: 5px;
}

/* Close Button - X */
.btn-close {
    background-color: #ee5050;
    background-image: url('data:image/svg+xml;charset=utf-8,%3Csvg xmlns="http://www.w3.org/2000/svg" width="10" height="10"%3E%3Cline x1="2" y1="2" x2="8" y2="8" stroke="white" stroke-width="2" stroke-linecap="round"/%3E%3Cline x1="8" y1="2" x2="2" y2="8" stroke="white" stroke-width="2" stroke-linecap="round"/%3E%3C/svg%3E');
    background-size: 10px 10px;
}

.btn-close::before,
.btn-close::after {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    width: 2px;
    height: 12px;
    background-color: white;
    box-shadow: 0 1px 1px rgba(0, 0, 0, 0.3);
}

.btn-close::before {
    transform: translate(-50%, -50%) rotate(45deg);
}

.btn-close::after {
    transform: translate(-50%, -50%) rotate(-45deg);
}

.btn-close:hover {
    background-color: #ff6060;
}

.btn-close:active {
    background-color: #cc4040;
}

/* Window Content */
.menu-bar {
    height: 21px;
    font-size: 14px;
    line-height: 20px;
    color: black;
    background-color: #E9EADA;
    border-bottom: 1px solid #939498;
    width: calc(100% - 4px);
    margin: 0 2px;
}

.menu-bar span {
    display: inline-block;
    padding: 0 6px;
    cursor: pointer;
    border: 1px solid transparent;
}

.menu-bar span:hover {
    background-color: rgba(153, 209, 255, 0.47);
    border-color: #99D1FF;
}

.window-content {
    outline: none;
    width: calc(100% - 4px);
    height: calc(100% - 50px);
    margin: 0 2px;
    border: none;
    overflow: auto;
    resize: none;
    padding: 15px;
    font-family: 'Segoe UI', Tahoma, sans-serif;
    font-size: 14px;
    line-height: 1.6;
    color: #000;
}

.window-content h1,
.window-content h2,
.window-content h3 {
    margin-bottom: 10px;
    color: #003c74;
}

.window-content p {
    margin-bottom: 12px;
}

/* ========================================
   TASKBAR (Barra de tarefas)
======================================== */

.taskbar {
    background-color: #245EDC;
    background: linear-gradient(to bottom, #245EDC 0%, #3f8cf3 9%, #245EDC 18%, 
                #245EDC 92%, #1941A5 100%) center/cover no-repeat;
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 32px;
    display: flex;
    align-items: center;
    z-index: 200;
}

/* Start Button */
.start-button {
    height: 100%;
    font-size: 22px;
    line-height: 22px;
    font-weight: bold;
    font-style: italic;
    background: radial-gradient(circle, #5eac56 0%, #3c873c 100%) center/cover no-repeat;
    box-shadow: 0px 5px 10px #79ce71 inset, 4px 0 8px #3f8cf3;
    padding: 2px 25px 6px 10px;
    text-shadow: 1px 1px 3px #222;
    border-radius: 0px 8px 8px 0px;
    margin-right: 16px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    user-select: none;
}

.start-button:hover {
    filter: brightness(1.1);
}

.start-button:active {
    filter: brightness(0.95);
}

.start-button img {
    height: 20px;
    filter: drop-shadow(1px 1px 1px #222);
    transform: translateY(2px);
}

/* Opened Tabs */
.opened-tabs {
    flex: 1;
    display: flex;
    gap: 4px;
    overflow-x: auto;
    overflow-y: hidden;
    padding: 0 8px;
}

.opened-tabs::-webkit-scrollbar {
    height: 4px;
}

.opened-tabs::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.3);
    border-radius: 2px;
}

.open-tab {
    min-width: 150px;
    max-width: 200px;
    height: 26px;
    background-color: #4892F7;
    background-image: linear-gradient(to bottom, #4892F7, #3080E0);
    border: 1px solid #306FD9;
    border-radius: 2px;
    font-family: 'Calibri', 'Segoe UI', monospace;
    font-size: 14px;
    line-height: 14px;
    padding: 6px 8px;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 5px;
    user-select: none;
    transition: all 0.2s;
}

.open-tab:hover {
    background-image: linear-gradient(to bottom, #5BA3FF, #4090F0);
}

.open-tab.active {
    background-image: linear-gradient(to bottom, #3060C0, #2050B0);
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.3);
}

.open-tab img {
    height: 18px;
    width: 18px;
    flex-shrink: 0;
}

/* Time/Clock */
.time {
    height: 100%;
    font-family: 'Calibri', 'Segoe UI', monospace;
    font-size: 14px;
    line-height: 14px;
    background: linear-gradient(to bottom, #1290E9 0%, #19B9F3 9%, #1290E9 18%, 
                #1290E9 92%, #1941A5 100%) center/cover no-repeat;
    box-shadow: 0px 5px 10px #14A5F0 inset, 0px 5px 10px #333333;
    padding: 9px 15px 9px 25px;
    border-left: 1px solid #092E51;
    text-shadow: 1px 1px 2px #222;
    cursor: pointer;
    text-transform: uppercase;
    display: flex;
    align-items: center;
    user-select: none;
}

.time:hover {
    filter: brightness(1.1);
}

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

@media (orientation: portrait) {
    #xp-desktop {
        background-image: url('../images/desktop-bg-portrait.jpg');
    }
}

@media screen and (max-width: 768px) {
    .desktop {
        flex-direction: row;
        justify-content: flex-start;
        align-content: flex-start;
    }
    
    .icon {
        margin: 4px;
    }
    
    .window {
        width: calc(100% - 20px);
        height: calc(100% - 70px);
        max-width: unset;
    }
    
    .start-button {
        font-size: 18px;
        padding: 2px 15px 6px 8px;
    }
    
    .open-tab {
        min-width: 100px;
        max-width: 150px;
    }
}

@media screen and (max-width: 480px) {
    .desktop {
        padding: 4px;
    }
    
    .icon {
        width: 80px;
        margin: 2px;
    }
    
    .icon img {
        width: 40px;
    }
    
    .icon .icon-name {
        font-size: 12px;
    }
    
    .taskbar {
        height: 28px;
    }
    
    .start-button {
        font-size: 16px;
    }
    
    .time {
        padding: 6px 10px;
        font-size: 12px;
    }
}

/* ========================================
   ANIMATIONS
======================================== */

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

@keyframes fadeOut {
    from {
        opacity: 1;
    }
    to {
        opacity: 0;
        visibility: hidden;
    }
}

.fade-in {
    animation: fadeIn 0.5s forwards;
}

.fade-out {
    animation: fadeOut 0.5s forwards;
}

/* ========================================
   WEBAMP — reset de classes do tema que conflitam com o player.
   O tema tem .window { display:none } e .title-bar { gradient azul XP }
   mas o Webamp reutiliza essas classes nos seus componentes internos.
======================================== */

/* 1. Janelas ocultas pelo .window { display:none } do tema */
#webamp .window,
#webamp #main-window,
#webamp #equalizer-window {
    display: block !important;
    top: auto !important;
    left: auto !important;
    transform: none !important;
    max-width: none !important;
    max-height: none !important;
    box-shadow: none !important;
    border-top-left-radius: 0 !important;
    border-top-right-radius: 0 !important;
    padding: 0 !important;
    pointer-events: auto !important;
    /* Não sobrescrever background/width/height — CSS do Webamp cuida */
}

/* 2. Barra do equalizador usa class="title-bar" e recebia o gradiente azul XP */
#webamp .title-bar {
    background: none !important;
    background-image: none !important;
    border: none !important;
    border-top-left-radius: 0 !important;
    border-top-right-radius: 0 !important;
    padding: 0 !important;
    font-size: inherit !important;
    color: inherit !important;
    cursor: default !important;
    user-select: none !important;
}

/* ========================================
   LIXEIRA — Demos
======================================== */

.recyclebin-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    height: 100%;
    color: #999;
    font-family: Tahoma, sans-serif;
    font-size: 13px;
}

.recyclebin-demos {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 10px;
    align-content: flex-start;
    overflow-y: auto;
    height: 100%;
    background: #fff;
}

.demo-icon {
    width: 80px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    padding: 4px 2px;
    border: 1px solid transparent;
    border-radius: 2px;
    cursor: pointer;
    user-select: none;
}

.demo-icon:hover  { background: rgba(49,106,197,.15); border-color: #316ac5; }
.demo-icon:active { background: rgba(49,106,197,.30); border-color: #316ac5; }

.demo-icon img {
    width: 48px;
    display: block;
    pointer-events: none;
}

.demo-icon-name {
    font-family: Tahoma, 'Segoe UI', sans-serif;
    font-size: 11px;
    text-align: center;
    word-break: break-word;
    line-height: 1.3;
    color: #000;
    max-height: 32px;
    overflow: hidden;
    width: 76px;
}

/* ========================================
   DEMO PLAYER — estilo Windows Media Player
======================================== */

.xp-demo-player {
    display: flex;
    flex-direction: column;
    gap: 14px;
    padding: 16px;
    background: #1a1a2e;
    height: 100%;
    box-sizing: border-box;
}

.xp-demo-player-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.xp-demo-title {
    font-family: Tahoma, sans-serif;
    font-size: 14px;
    font-weight: bold;
    color: #fff;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 300px;
}

.xp-demo-label {
    font-family: Tahoma, sans-serif;
    font-size: 11px;
    color: #888;
    margin-top: 2px;
}

.xp-demo-audio {
    width: 100%;
    outline: none;
}

/* ========================================
   WALLPAPER — Toast de confirmação
======================================== */

#wxp-wallpaper-toast {
    position: absolute;
    bottom: 48px;
    right: 12px;
    display: flex;
    align-items: center;
    gap: 10px;
    background: #fffbe6;
    border: 1px solid #c8a800;
    border-radius: 6px;
    padding: 8px 14px 8px 10px;
    box-shadow: 2px 2px 8px rgba(0,0,0,.35);
    font-family: Tahoma, sans-serif;
    font-size: 12px;
    color: #333;
    z-index: 9999;
    opacity: 0;
    transform: translateY(10px);
    transition: opacity .3s ease, transform .3s ease;
    pointer-events: none;
}

#wxp-wallpaper-toast img {
    width: 28px;
    flex-shrink: 0;
}

#wxp-wallpaper-toast strong {
    display: block;
    font-size: 12px;
    color: #000;
}

#wxp-wallpaper-toast span {
    color: #555;
}

#wxp-wallpaper-toast.wxp-toast-show {
    opacity: 1;
    transform: translateY(0);
}

/* ========================================
   MY DOCUMENTS — Galeria de Fotos
======================================== */

.mydocs-gallery {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 10px;
    align-content: flex-start;
    overflow-y: auto;
    height: 100%;
    background: #fff;
}

.mydocs-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    height: 100%;
    color: #999;
    font-family: Tahoma, sans-serif;
    font-size: 13px;
}

/* Cada ícone de foto */
.foto-icon {
    width: 80px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    padding: 4px 2px;
    border: 1px solid transparent;
    border-radius: 2px;
    cursor: pointer;
    user-select: none;
}

.foto-icon:hover {
    background: rgba(49, 106, 197, 0.15);
    border-color: #316ac5;
}

.foto-icon:active,
.foto-icon.selected {
    background: rgba(49, 106, 197, 0.3);
    border-color: #316ac5;
}

.foto-icon-img {
    width: 48px;
    display: block;
    pointer-events: none;
    position: relative;
    z-index: 1;
}

.foto-icon-name {
    font-family: Tahoma, 'Segoe UI', sans-serif;
    font-size: 11px;
    text-align: center;
    word-break: break-word;
    line-height: 1.3;
    color: #000;
    max-height: 32px;
    overflow: hidden;
    width: 76px;
}

/* ========================================
   VISUALIZADOR DE IMAGENS — XP Picture Viewer
======================================== */

.xp-image-viewer {
    display: flex;
    flex-direction: column;
    height: 100%;
    background: #1a1a2e;
    font-family: Tahoma, sans-serif;
}

.xp-image-viewer-toolbar {
    display: flex;
    align-items: center;
    gap: 2px;
    background: linear-gradient(to bottom, #ece9d8, #d4d0c8);
    border-bottom: 1px solid #a0a0a0;
    padding: 4px 8px;
    flex-shrink: 0;
}

.xp-imgbtn {
    background: linear-gradient(to bottom, #fff, #ddd);
    border: 1px solid #999;
    border-radius: 2px;
    padding: 3px 10px;
    font-size: 12px;
    cursor: pointer;
    text-decoration: none;
    color: #000;
    line-height: 1.4;
}

.xp-imgbtn:hover {
    background: linear-gradient(to bottom, #d4eaff, #a8d4ff);
    border-color: #316ac5;
}

.xp-imgbtn-sep {
    width: 1px;
    height: 20px;
    background: #aaa;
    margin: 0 4px;
}

.xp-image-viewer-body {
    flex: 1;
    overflow: auto;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #1a1a2e;
    padding: 10px;
}

.xp-image-main {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    display: block;
    box-shadow: 0 4px 20px rgba(0,0,0,.6);
    transform-origin: center;
    transition: transform 0.15s ease;
    cursor: zoom-in;
}

.xp-image-viewer-footer {
    background: linear-gradient(to bottom, #ece9d8, #d4d0c8);
    border-top: 1px solid #a0a0a0;
    padding: 3px 10px;
    font-size: 11px;
    color: #444;
    flex-shrink: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ========================================
   NOTEPAD — Bloco de Notas Windows XP
======================================== */

.notepad-window {
    display: flex;
    flex-direction: column;
    height: 100%;
    background: #fff;
    font-family: 'Lucida Console', 'Courier New', monospace;
    font-size: 13px;
}

.notepad-menubar {
    display: flex;
    gap: 0;
    background: #f0f0f0;
    border-bottom: 1px solid #bbb;
    padding: 2px 4px;
    flex-shrink: 0;
}

.notepad-menubar span {
    padding: 2px 8px;
    cursor: default;
    font-size: 12px;
    font-family: Tahoma, sans-serif;
    color: #000;
    border-radius: 2px;
}

.notepad-menubar span:hover {
    background: #316ac5;
    color: #fff;
}

.notepad-body {
    flex: 1;
    overflow-y: auto;
    padding: 8px 10px;
    white-space: pre-wrap;
    word-wrap: break-word;
    line-height: 1.6;
    background: #fff;
    color: #000;
}

/* parágrafos e títulos dentro da letra */
.notepad-body p   { margin: 0 0 8px; }
.notepad-body h1,
.notepad-body h2,
.notepad-body h3  { font-size: 14px; font-weight: bold; margin: 8px 0 4px; }
.notepad-body br  { display: block; }

/* scrollbar estilo XP */
.notepad-body::-webkit-scrollbar { width: 16px; }
.notepad-body::-webkit-scrollbar-track { background: #f0f0f0; border-left: 1px solid #bbb; }
.notepad-body::-webkit-scrollbar-thumb { background: #c0c0c0; border: 1px solid #888; }
.notepad-body::-webkit-scrollbar-thumb:hover { background: #a0a0a0; }
