/* === WebOS — Estilos del Gestor de Ventanas ===
 * Estructura ventana, titlebar, controles, body, drag/resize, animaciones
 */

/* === Área del Escritorio === */
#desktop-area {
    position: fixed;
    inset: 0;
    padding-bottom: 48px;
    z-index: 1;
}

/* === Estructura de Ventana === */
.window {
    position: absolute;
    min-width: 320px;
    min-height: 200px;
    display: flex;
    flex-direction: column;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-window);
    overflow: hidden;
    display: none;
    transition: transform var(--transition-normal), opacity var(--transition-normal);
}

.window.open {
    display: flex;
    animation: windowOpen 0.25s ease forwards;
}

.window.closing {
    animation: windowClose 0.2s ease forwards;
}

.window.minimized {
    animation: windowMinimize 0.3s ease forwards;
}

@keyframes windowOpen {
    from { opacity: 0; transform: scale(0.9); }
    to { opacity: 1; transform: scale(1); }
}

@keyframes windowClose {
    from { opacity: 1; transform: scale(1); }
    to { opacity: 0; transform: scale(0.9); }
}

@keyframes windowMinimize {
    from { opacity: 1; transform: scale(1) translateY(0); }
    to { opacity: 0; transform: scale(0.5) translateY(100px); }
}

/* === Barra de Título === */
.window-titlebar {
    height: 36px;
    min-height: 36px;
    background: var(--bg-titlebar);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    padding: 0 8px;
    cursor: default;
    flex-shrink: 0;
}

.window-controls {
    display: flex;
    gap: 0;
    flex-shrink: 0;
    margin-left: auto;
    position: absolute;
    right: 0;
    top: 0;
    bottom: 0;
    padding: 0 4px;
}

.window-controls button {
    width: 46px;
    height: 36px;
    border: none;
    background: transparent;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-titlebar);
    transition: background 0.15s, color 0.15s;
    padding: 0;
    margin: 0;
    font-size: 0;
    overflow: hidden;
}

.window-controls button:hover {
    background: rgba(255, 255, 255, 0.1);
}

.window.focused .window-controls button:hover {
    background: rgba(255, 255, 255, 0.15);
}

.btn-close:hover {
    background: #e81123 !important;
    color: #fff !important;
}

.window-title {
    flex: 1;
    text-align: center;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-titlebar);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-right: 160px;
}

.window.minimized .window-title {
    opacity: 0;
}

/* === Cuerpo de Ventana === */
.window-body {
    flex: 1;
    overflow: auto;
    background: var(--bg-surface);
    color: var(--text-primary);
}

/* === Resize Handle (esquina inferior derecha) === */
.resize-handle {
    position: absolute;
    z-index: 10;
    border-radius: 0;
}
.resize-corner {
    bottom: 0;
    right: 0;
    width: 20px;
    height: 20px;
    cursor: nwse-resize;
    border-bottom-right-radius: var(--radius-md);
}

/* === Ventana maximizada === */
.window.maximized {
    top: 0 !important;
    left: 0 !important;
    width: 100% !important;
    height: calc(100% - 48px) !important;
    border-radius: 0;
    transform: none !important;
}

/* === Foco de ventana === */
.window.focused .window-titlebar {
    background: var(--bg-surface-hover);
    border-bottom-color: var(--border-active);
}
.window.focused .window-title {
    color: var(--text-primary);
    font-weight: 600;
}

/* === Estado de la tarea (minimizada en taskbar) === */
.taskbar-item.active .taskbar-dot {
    display: block;
}

.taskbar-dot {
    display: none;
    width: 3px;
    height: 3px;
    background: var(--text-secondary);
    border-radius: 50%;
    position: absolute;
    bottom: 2px;
    left: 50%;
    transform: translateX(-50%);
    transition: background var(--transition-fast);
}

.taskbar-item.active .taskbar-dot {
    background: var(--color-primary);
}

/* === Panel del sistema de archivos === */
.files-panel {
    display: flex;
    height: 100%;
}

.files-sidebar {
    width: 180px;
    min-width: 180px;
    border-right: 1px solid var(--border-color);
    padding: 8px;
    overflow-y: auto;
    background: rgba(0, 0, 0, 0.15);
}

.files-sidebar-item {
    padding: 6px 10px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 13px;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: background var(--transition-fast);
    color: var(--text-primary);
}
.files-sidebar-item:hover {
    background: var(--glass-bg);
}
.files-sidebar-item.selected {
    background: rgba(0, 120, 212, 0.3);
}

.files-main {
    flex: 1;
    padding: 12px;
    overflow-y: auto;
}

.files-toolbar {
    display: flex;
    gap: 8px;
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border-color);
    flex-wrap: wrap;
}

.files-toolbar button {
    padding: 4px 12px;
    border: 1px solid var(--border-color);
    background: var(--glass-bg);
    color: var(--text-primary);
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 12px;
    transition: background var(--transition-fast);
}
.files-toolbar button:hover {
    background: var(--bg-surface-hover);
}
.files-toolbar .btn-danger {
    background: rgba(231, 76, 60, 0.2) !important;
    color: var(--color-danger) !important;
    border-color: rgba(231, 76, 60, 0.4) !important;
}
.files-toolbar .btn-danger:hover {
    background: rgba(231, 76, 60, 0.35) !important;
}
}

/* Vista grid (tabla) */
.files-grid {
    display: table;
    width: auto;
    table-layout: auto;
}

.files-grid .file-item {
    display: table-cell;
    text-align: center;
    vertical-align: middle;
    padding: 12px 8px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background var(--transition-fast);
}

/* Vista lista */
.files-list {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

/* Ítem de archivo/carpeta */
.file-item {
    padding: 12px 8px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background var(--transition-fast);
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-width: 0;
}
.file-item:hover {
    background: var(--glass-bg);
}
.file-item.selected {
    background: rgba(0, 120, 212, 0.25);
    outline: 1px solid var(--color-primary);
}
.file-item-icon {
    font-size: 32px;
    line-height: 1;
    margin-bottom: 4px;
}
.file-item-name {
    font-size: 12px;
    word-break: break-all;
    color: var(--text-primary);
    line-height: 1.3;
    max-width: 90px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Cuando es table-cell (grid view), resetear flex */
.files-grid .file-item {
    display: table-cell;
    vertical-align: middle;
    flex-direction: column;
    align-items: center;
}
.files-grid .file-item-icon {
    margin-bottom: 4px;
}

/* Vista lista */
.files-list {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.files-list .file-item {
    display: flex;
    flex-direction: row;
    padding: 8px 12px;
    gap: 10px;
    justify-content: flex-start;
    align-items: center;
}
.files-list .file-item-icon {
    font-size: 20px;
    margin-bottom: 0;
}
.files-list .file-item-name {
    text-align: left;
    max-width: none;
    font-size: 13px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Vista lista ítems */
.files-list .file-item {
    flex-direction: row;
    padding: 8px 12px;
    gap: 10px;
}
.files-list .file-item-name {
    text-align: left;
    max-width: none;
    font-size: 13px;
}
.files-list .file-item-icon {
    font-size: 20px;
}

/* Breadcrumb */
.files-breadcrumb {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-bottom: 8px;
    font-size: 12px;
    color: var(--text-secondary);
    flex-wrap: wrap;
}
.breadcrumb-item {
    cursor: pointer;
    padding: 2px 6px;
    border-radius: 3px;
    transition: background var(--transition-fast);
}
.breadcrumb-item:hover {
    background: var(--glass-bg);
    color: var(--text-primary);
}
.breadcrumb-sep {
    color: var(--text-secondary);
    opacity: 0.5;
}

/* === Terminal === */
.terminal-body {
    background: #0a0a0a;
    color: #33ff33;
    font-family: var(--font-mono);
    font-size: 13px;
    padding: 10px;
    height: 100%;
    overflow-y: auto;
    line-height: 1.6;
}

.terminal-line {
    white-space: pre-wrap;
    word-break: break-all;
}
.terminal-line.error { color: #ff5555; }
.terminal-line.info { color: #55ffff; }
.terminal-line.success { color: #33ff33; }

.terminal-input-line {
    display: flex;
    align-items: center;
    margin-top: 4px;
}
.terminal-prompt {
    color: #33ff33;
    margin-right: 6px;
    white-space: nowrap;
}
.terminal-input {
    flex: 1;
    background: transparent;
    border: none;
    color: #33ff33;
    font-family: var(--font-mono);
    font-size: 13px;
    outline: none;
    caret-color: #33ff33;
}

/* === Snake === */
.snake-canvas {
    display: block;
    margin: 0 auto;
    background: #111;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-sm);
}

.snake-controls {
    display: grid;
    grid-template-columns: repeat(3, 50px);
    grid-template-rows: repeat(3, 50px);
    gap: 4px;
    margin: 12px auto 0;
    justify-content: center;
}
.snake-controls button {
    width: 50px;
    height: 50px;
    border: 1px solid var(--border-color);
    background: var(--glass-bg);
    color: var(--text-primary);
    border-radius: var(--radius-sm);
    font-size: 20px;
    cursor: pointer;
    transition: background var(--transition-fast);
}
.snake-controls button:hover {
    background: var(--bg-surface-hover);
}
.snake-controls .empty { visibility: hidden; }

.snake-scoreboard {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    background: rgba(0, 0, 0, 0.2);
    border-bottom: 1px solid var(--border-color);
    font-size: 13px;
}

/* === Calculadora === */
.calc-display {
    padding: 16px;
    text-align: right;
    background: rgba(0, 0, 0, 0.2);
    border-bottom: 1px solid var(--border-color);
}
.calc-expression {
    font-size: 14px;
    color: var(--text-secondary);
    min-height: 20px;
    margin-bottom: 4px;
}
.calc-result {
    font-size: 32px;
    font-weight: 300;
    color: var(--text-primary);
    overflow: hidden;
    text-overflow: ellipsis;
}

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

.calc-btn {
    padding: 18px;
    border: none;
    font-size: 18px;
    cursor: pointer;
    transition: background var(--transition-fast);
    background: var(--glass-bg);
    color: var(--text-primary);
}
.calc-btn:hover {
    background: var(--bg-surface-hover);
}
.calc-btn.operator {
    background: rgba(0, 120, 212, 0.3);
    color: #7ac4ff;
}
.calc-btn.operator:hover {
    background: rgba(0, 120, 212, 0.5);
}
.calc-btn.equals {
    background: var(--color-primary);
    color: var(--text-on-primary);
    font-weight: 600;
}
.calc-btn.equals:hover {
    background: var(--color-primary-hover);
}
.calc-btn.wide {
    grid-column: span 2;
}

/* Historial calculadora */
.calc-history-panel {
    max-height: 150px;
    overflow-y: auto;
    padding: 8px 12px;
    border-top: 1px solid var(--border-color);
    font-size: 12px;
}
.calc-history-item {
    padding: 4px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    color: var(--text-secondary);
}
.calc-history-item span:last-child {
    color: var(--text-primary);
    float: right;
}

/* === Notas === */
.notes-layout {
    display: flex;
    height: 100%;
}

.notes-list-panel {
    width: 220px;
    min-width: 220px;
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    background: rgba(0, 0, 0, 0.1);
}

.notes-list-header {
    padding: 10px 12px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 6px;
}
.notes-list-header h3 {
    font-size: 13px;
    font-weight: 600;
}
.notes-list-header button {
    width: 24px;
    height: 24px;
    border: 1px solid var(--border-color);
    background: var(--glass-bg);
    color: var(--text-primary);
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background var(--transition-fast);
}
.notes-list-header button:hover {
    background: var(--bg-surface-hover);
}

.notes-list {
    flex: 1;
    overflow-y: auto;
}

.note-item {
    padding: 12px 12px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    cursor: pointer;
    transition: background var(--transition-fast);
    gap: 4px;
}
.note-item:hover {
    background: var(--glass-bg);
}
.note-item.selected {
    background: rgba(0, 120, 212, 0.25);
    border-left: 3px solid var(--color-primary);
}
.note-item-title {
    font-size: 13px;
    font-weight: 500;
    margin-bottom: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.note-item-date {
    font-size: 11px;
    color: var(--text-secondary);
}

.notes-editor-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.notes-editor-header {
    padding: 10px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
}

.notes-title-input {
    flex: 1;
    padding: 4px 8px;
    border: 1px solid var(--border-color);
    background: var(--glass-bg);
    color: var(--text-primary);
    font-size: 15px;
    font-weight: 500;
    border-radius: var(--radius-sm);
    outline: none;
    font-family: var(--font-family);
}
.notes-title-input:focus {
    border-color: var(--color-primary);
}

.notes-delete-btn {
    padding: 4px 10px;
    border: 1px solid rgba(231, 76, 60, 0.4);
    background: rgba(231, 76, 60, 0.15);
    color: var(--color-danger);
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 12px;
    transition: background var(--transition-fast);
}
.notes-delete-btn:hover {
    background: rgba(231, 76, 60, 0.3);
}

.notes-save-btn {
    padding: 4px 10px;
    border: 1px solid rgba(40, 200, 64, 0.4);
    background: rgba(40, 200, 64, 0.15);
    color: #28c840;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 12px;
    transition: background var(--transition-fast);
}
.notes-save-btn:hover {
    background: rgba(40, 200, 64, 0.3);
}

.notes-content {
    flex: 1;
}
.notes-content textarea {
    width: 100%;
    height: 100%;
    border: none;
    background: transparent;
    color: var(--text-primary);
    font-size: 14px;
    font-family: var(--font-family);
    padding: 12px;
    resize: none;
    outline: none;
    line-height: 1.6;
}
.notes-content textarea::placeholder {
    color: var(--text-secondary);
}

.notes-status {
    padding: 4px 10px;
    font-size: 11px;
    color: var(--text-secondary);
    border-top: 1px solid var(--border-color);
    background: rgba(0, 0, 0, 0.1);
}

/* === Configuración === */
.settings-layout {
    display: flex;
    height: 100%;
}

.settings-nav {
    width: 160px;
    min-width: 160px;
    border-right: 1px solid var(--border-color);
    padding: 8px 0;
    background: rgba(0, 0, 0, 0.1);
}

.settings-nav-item {
    padding: 8px 14px;
    cursor: pointer;
    font-size: 13px;
    color: var(--text-primary);
    transition: background var(--transition-fast);
    border-left: 3px solid transparent;
}
.settings-nav-item:hover {
    background: var(--glass-bg);
}
.settings-nav-item.active {
    border-left-color: var(--color-primary);
    background: rgba(0, 120, 212, 0.15);
    font-weight: 500;
}

.settings-content {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
}

.settings-section {
    display: none;
}
.settings-section.active {
    display: block;
}

.settings-section h2 {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 16px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border-color);
}

.settings-group {
    margin-bottom: 20px;
}
.settings-group h3 {
    font-size: 14px;
    font-weight: 500;
    margin-bottom: 10px;
    color: var(--text-secondary);
}

.settings-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 0;
}
.settings-row label {
    font-size: 13px;
}

/* Toggle switch */
.toggle-switch {
    position: relative;
    width: 44px;
    height: 24px;
    cursor: pointer;
}
.toggle-switch input {
    display: none;
}
.toggle-slider {
    position: absolute;
    inset: 0;
    background: rgba(255, 255, 255, 0.15);
    border-radius: 12px;
    transition: background var(--transition-fast);
}
.toggle-slider::before {
    content: '';
    position: absolute;
    width: 18px;
    height: 18px;
    left: 3px;
    top: 3px;
    background: #fff;
    border-radius: 50%;
    transition: transform var(--transition-fast);
}
.toggle-switch input:checked + .toggle-slider {
    background: var(--color-primary);
}
.toggle-switch input:checked + .toggle-slider::before {
    transform: translateX(20px);
}

/* Wallpaper selector */
.wallpaper-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap: 10px;
}
.wallpaper-option {
    height: 60px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    border: 2px solid transparent;
    transition: border-color var(--transition-fast);
}
.wallpaper-option:hover {
    border-color: var(--text-secondary);
}
.wallpaper-option.selected {
    border-color: var(--color-primary);
}

/* Input styles */
.settings-input {
    padding: 6px 10px;
    border: 1px solid var(--border-color);
    background: var(--glass-bg);
    color: var(--text-primary);
    border-radius: var(--radius-sm);
    font-size: 13px;
    outline: none;
    font-family: var(--font-family);
    transition: border-color var(--transition-fast);
}
.settings-input:focus {
    border-color: var(--color-primary);
}

/* Select */
.settings-select {
    padding: 6px 10px;
    border: 1px solid var(--border-color);
    background: var(--glass-bg);
    color: var(--text-primary);
    border-radius: var(--radius-sm);
    font-size: 13px;
    outline: none;
    font-family: var(--font-family);
    cursor: pointer;
}

/* Scores table */
.scores-table, .history-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}
.scores-table th, .history-table th {
    text-align: left;
    padding: 8px 10px;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-secondary);
    font-weight: 500;
}
.scores-table td, .history-table td {
    padding: 6px 10px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}

/* About */
.about-info {
    text-align: center;
    padding: 20px;
}
.about-info h1 {
    font-size: 2rem;
    margin-bottom: 8px;
}
.about-info p {
    color: var(--text-secondary);
    margin: 4px 0;
}
