/* Variables de tema por defecto (paleta Océano, modo Día). theme.js las
   sobreescribe en tiempo real via style.setProperty sobre :root — ver
   static/js/theme.js. Los colores funcionales (ok/warn/bad, badges, toasts)
   NO son variables a propósito: deben leerse igual sin importar el tema. */
:root {
  --taskbar-w: 200px;

  --wallpaper-1: #0e4a73;
  --wallpaper-2: #123b5e;
  --wallpaper-3: #0a2540;

  --accent: #0e4a73;
  --accent-strong: #123b5e;
  --accent-soft: #1a7bb5;

  --win-bg: #ffffff;
  --win-panel-bg: #f4f6f8;
  --titlebar-bg-1: #eef1f4;
  --titlebar-bg-2: #dfe3e7;
  --titlebar-bg-1-focused: #f7f9fb;
  --titlebar-bg-2-focused: #e6eaee;
  --titlebar-border: #c7ccd1;

  --text-strong: #123b5e;
  --text-body: #2b3238;
  --text-title: #33383d;
  --text-muted: #6b7684;
  --text-faint: #8a96a3;

  --card-bg: #f6f8fa;
  --row-border: #eef1f4;
  --border-soft: #e8ebee;

  --input-bg: #f8fafb;
  --input-border: #d3d9de;

  --ghost-bg: #eef1f4;
  --ghost-bg-hover: #e2e6ea;
  --ghost-text: #33383d;

  --modal-bg: #ffffff;
  --menu-bg: #ffffff;
  --menu-hover: #eef3f8;

  --taskbar-bg: rgba(20, 30, 40, 0.92);
  --taskbar-item-bg: rgba(255,255,255,0.06);
  --taskbar-item-active-bg: rgba(255,255,255,0.22);
  --taskbar-text: #dfe7ee;
  --taskbar-tray-text: #c9d6e0;

  --auth-card-bg: rgba(255,255,255,1);

  --toolbar-bg: #fafbfc;
  --row-hover-bg: #f2f6f9;
  --row-selected-bg: #dcecf8;
  --dragover-bg: #eaf3fb;
}

* { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0; width: 100%; height: 100%;
  font-family: -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  overflow: hidden; background: var(--wallpaper-3);
  color: var(--text-body);
  -webkit-font-smoothing: antialiased;
}
#desktop {
  position: absolute; inset: 0 var(--taskbar-w) 0 0;
  background: linear-gradient(160deg, var(--wallpaper-1) 0%, var(--wallpaper-2) 55%, var(--wallpaper-3) 100%);
  overflow: hidden;
}
#desktop-watermark {
  position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
  max-height: 68%; max-width: 72%; width: auto; height: auto;
  opacity: .16; pointer-events: none; user-select: none; z-index: 0;
  filter: drop-shadow(0 10px 40px rgba(0,0,0,0.35));
}
#desktop-icons {
  position: absolute; top: 14px; left: 20px; z-index: 1;
  display: flex; flex-direction: column; gap: 6px;
}
.desktop-icon {
  width: 84px; display: flex; flex-direction: column; align-items: center;
  gap: 4px; cursor: pointer; user-select: none; padding: 4px 4px; border-radius: 8px;
}
.desktop-icon:hover { background: rgba(255,255,255,0.08); }
.desktop-icon .glyph {
  width: 46px; height: 46px; border-radius: 12px; display: flex;
  align-items: center; justify-content: center; font-size: 24px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}
.desktop-icon span.label {
  color: #eaf3fb; font-size: 12px; text-align: center;
  text-shadow: 0 1px 3px rgba(0,0,0,0.6);
}

/* ---------------------------------------------------------- Ventanas -- */
.window {
  position: absolute; min-width: 360px; min-height: 260px;
  background: var(--win-panel-bg); border-radius: 10px; overflow: hidden;
  box-shadow: 0 18px 50px rgba(0,0,0,0.45), 0 0 0 1px rgba(0,0,0,0.08);
  display: flex; flex-direction: column;
}
.window.focused { box-shadow: 0 22px 60px rgba(0,0,0,0.55), 0 0 0 1px rgba(20,110,180,0.5); }
.window.minimized { display: none; }
.window.maximized { border-radius: 0; }
.win-titlebar {
  height: 38px; flex: 0 0 auto; background: linear-gradient(var(--titlebar-bg-1), var(--titlebar-bg-2));
  border-bottom: 1px solid var(--titlebar-border); display: flex; align-items: center;
  padding: 0 10px; cursor: default; user-select: none; gap: 8px;
}
.window.focused .win-titlebar { background: linear-gradient(var(--titlebar-bg-1-focused), var(--titlebar-bg-2-focused)); }
.win-titlebar .win-icon { font-size: 15px; }
.win-titlebar .win-title { font-size: 13px; font-weight: 600; color: var(--text-title); flex: 1;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.win-controls { display: flex; gap: 6px; }
.win-btn {
  width: 15px; height: 15px; border-radius: 50%; border: none; cursor: pointer;
  display: flex; align-items: center; justify-content: center; font-size: 9px; color: transparent;
}
.win-btn:hover { color: rgba(0,0,0,0.55); }
.win-btn.close { background: #ff5f57; }
.win-btn.min { background: #febc2e; }
.win-btn.max { background: #28c840; }
.win-body { flex: 1; overflow: auto; position: relative; background: var(--win-bg); color: var(--text-body); }
.win-resize {
  position: absolute; right: 0; bottom: 0; width: 16px; height: 16px; cursor: nwse-resize;
}

/* ------------------------------------------------------------ Taskbar -- */
/* Barra vertical pegada al borde derecho: botón TitanNAS arriba, ventanas
   abiertas apilándose debajo (con scroll si no caben), y el reloj/estado
   de salud empujado al fondo de la columna por el flex:1 de #taskbar-items. */
/* Barra auto-oculta: vive fuera de pantalla (translateX) salvo que tenga
   la clase .visible, que le agrega initTaskbarAutoHide() en shell.js al
   detectar el mouse sobre #taskbar-edge (la franja del borde) o sobre la
   barra misma. Sigue reservando su espacio en el layout de #desktop (no
   cambia su `width`/`inset`), solo se desliza visualmente. */
#taskbar {
  position: absolute; top: 0; right: 0; bottom: 0; width: var(--taskbar-w);
  background: var(--taskbar-bg); backdrop-filter: blur(10px);
  display: flex; flex-direction: column; align-items: stretch; padding: 10px 8px; gap: 8px;
  border-left: 1px solid rgba(255,255,255,0.08); z-index: 10000;
  transform: translateX(100%); transition: transform 0.2s ease;
}
#taskbar.visible { transform: translateX(0); }
#taskbar-edge {
  position: absolute; top: 0; right: 0; bottom: 0; width: 10px; z-index: 9999;
}
#start-btn, .taskbar-item {
  display: flex; align-items: center; gap: 6px; color: var(--taskbar-text); background: var(--taskbar-item-bg);
  border: none; border-radius: 6px; padding: 6px 12px; cursor: pointer; font-size: 12.5px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; width: 100%; text-align: left; flex-shrink: 0;
}
#start-btn:hover { background: var(--taskbar-item-active-bg); }
#taskbar-items { display: flex; flex-direction: column; gap: 6px; flex: 1; overflow-y: auto; overflow-x: hidden; min-height: 0; }
.taskbar-item.active { background: var(--taskbar-item-active-bg); color: #fff; }
#tray {
  display: flex; flex-direction: column; align-items: flex-start; gap: 6px; color: var(--taskbar-tray-text);
  font-size: 12.5px; padding-top: 8px; border-top: 1px solid rgba(255,255,255,0.08); flex-shrink: 0;
}
#tray .clock { min-width: auto; text-align: left; }
#tray .health-dot { width: 8px; height: 8px; border-radius: 50%; background: #2ecc71; display: inline-block; }
#tray .health-dot.warn { background: #f1c40f; }
#tray .health-dot.bad { background: #e74c3c; }

/* -------------------------------------------------------------- Menú -- */
#start-menu {
  position: absolute; right: calc(var(--taskbar-w) + 8px); top: 10px; width: 260px;
  background: var(--menu-bg); border-radius: 10px; box-shadow: 0 12px 40px rgba(0,0,0,0.35);
  padding: 8px; display: none; z-index: 10001;
}
#start-menu.open { display: block; }
#start-menu .menu-item {
  display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 6px;
  cursor: pointer; font-size: 13px; color: var(--text-title);
}
#start-menu .menu-item:hover { background: var(--menu-hover); }
#start-menu hr { border: none; border-top: 1px solid var(--border-soft); margin: 6px 0; }

/* -------------------------------------------------------------- Login -- */
#auth-screen {
  position: fixed; inset: 0; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(160deg, var(--wallpaper-1) 0%, var(--wallpaper-2) 55%, var(--wallpaper-3) 100%);
  overflow: hidden;
}
.auth-watermark {
  position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
  max-height: 78%; max-width: 80%; width: auto; height: auto;
  opacity: .16; pointer-events: none; user-select: none; z-index: 0;
  filter: drop-shadow(0 10px 40px rgba(0,0,0,0.35));
}
.auth-card {
  position: relative; z-index: 1;
  width: 360px; background: var(--auth-card-bg); border-radius: 14px; padding: 32px 28px;
  box-shadow: 0 25px 60px rgba(0,0,0,0.4); text-align: center;
}
.auth-card h1 { font-size: 20px; margin: 4px 0 2px; color: var(--text-strong); }
.auth-card p.sub { color: var(--text-muted); font-size: 13px; margin: 0 0 20px; }
.auth-card .logo { font-size: 40px; margin-bottom: 6px; }
.auth-card input {
  width: 100%; padding: 11px 12px; margin-bottom: 12px; border: 1px solid var(--input-border);
  border-radius: 8px; font-size: 14px; background: var(--input-bg); color: var(--text-body);
}
.auth-card input:focus { outline: none; border-color: var(--accent-soft); background: var(--win-bg); }
.auth-card button {
  width: 100%; padding: 11px; border: none; border-radius: 8px; background: var(--accent);
  color: #fff; font-size: 14px; font-weight: 600; cursor: pointer; margin-top: 4px;
}
.auth-card button:hover { background: var(--accent-strong); }
.auth-card .error { color: #d64545; font-size: 12.5px; min-height: 18px; margin-top: 10px; }
.remember-row {
  display: flex; align-items: center; gap: 8px; margin: 2px 0 14px;
  font-size: 12.5px; color: var(--text-muted); cursor: pointer; user-select: none;
}
.remember-row input[type="checkbox"] { width: 14px; height: 14px; cursor: pointer; accent-color: var(--accent); }
.auth-card .hint { color: var(--text-faint); font-size: 11.5px; margin-top: 14px; }

/* ---------------------------------------------------------- Utilidades -- */
.hidden { display: none !important; }
.toast-stack { position: fixed; top: 16px; right: 16px; display: flex; flex-direction: column; gap: 8px; z-index: 20000; }
.toast {
  background: #24292e; color: #fff; padding: 10px 16px; border-radius: 8px; font-size: 13px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.3); max-width: 320px;
}
.toast.error { background: #a02c2c; }
.toast.success { background: #1f7a3f; }
