/* ==========================================================================
   RaspiNAS – Desktop-Shell im WINDOWS-11-STIL
   Wallpaper, Desktop-Icons, Fenster mit Windows-Titelleisten-Knöpfen,
   zentrierte Taskleiste mit Start-Logo, Windows-Startmenü, System-Tray.
   ========================================================================== */

:root {
  --taskbar-h: 48px;
  --accent-wall1: rgba(59, 130, 246, 0.5);
  --accent-wall2: rgba(59, 130, 246, 0.2);
  --win-radius: 9px;
  --win-blur: saturate(180%) blur(22px);
}

/* ---- Wallpaper (angelehnt an Windows 11 „Bloom") ---- */
.desktop {
  position: fixed; inset: 0; overflow: hidden;
  background:
    radial-gradient(1100px 820px at 50% 44%, var(--accent-wall1), transparent 55%),
    radial-gradient(760px 620px at 30% 74%, rgba(126, 87, 224, 0.34), transparent 60%),
    radial-gradient(900px 720px at 74% 26%, rgba(37, 176, 214, 0.32), transparent 60%),
    linear-gradient(140deg, #0b1a3d 0%, #0a1330 55%, #0b1024 100%);
}
[data-theme="light"] .desktop {
  background:
    radial-gradient(1100px 820px at 50% 44%, rgba(120, 170, 240, 0.7), transparent 55%),
    radial-gradient(760px 620px at 28% 74%, rgba(150, 130, 235, 0.4), transparent 60%),
    radial-gradient(900px 720px at 74% 26%, rgba(120, 200, 225, 0.45), transparent 60%),
    linear-gradient(140deg, #9ab8e6 0%, #aec8ee 55%, #c6d8f2 100%);
}

/* ---- Desktop-Icons ---- */
.desktop-icons {
  position: absolute; top: 12px; left: 10px; bottom: calc(var(--taskbar-h) + 10px);
  display: flex; flex-direction: column; flex-wrap: wrap; gap: 2px; align-content: flex-start;
  z-index: 1;
}
.desktop-icon {
  width: 84px; height: 86px; border: 1px solid transparent; background: transparent; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 9px 4px 6px;
  border-radius: 6px; color: #fff; transition: background .1s, border-color .1s;
}
.desktop-icon:hover { background: rgba(255, 255, 255, 0.14); border-color: rgba(255, 255, 255, 0.16); }
.desktop-icon:focus-visible { outline: 1px solid rgba(255, 255, 255, 0.7); }
.di-tile {
  width: 40px; height: 40px; border-radius: 9px; display: flex; align-items: center; justify-content: center;
  background: rgba(255, 255, 255, 0.16); color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.2); box-shadow: 0 5px 14px rgba(0, 0, 0, .28);
}
.di-label { font-size: 12px; font-weight: 500; text-align: center; text-shadow: 0 1px 4px rgba(0, 0, 0, .6); line-height: 1.2; }
[data-theme="light"] .desktop-icon { color: #15233f; }
[data-theme="light"] .di-tile { background: rgba(255, 255, 255, 0.82); color: var(--accent); border-color: rgba(255, 255, 255, .95); }
[data-theme="light"] .di-label { text-shadow: 0 1px 3px rgba(255, 255, 255, .7); }

/* ---- Fensterfläche ----
   pointer-events:none, damit die leere Ebene KEINE Klicks abfängt – sonst wären
   die Desktop-Symbole darunter nicht anklickbar. Die Fenster selbst schalten
   pointer-events wieder ein. */
.wm-windows { position: absolute; left: 0; right: 0; top: 0; bottom: var(--taskbar-h); z-index: 2; pointer-events: none; }
.wm-windows .window { pointer-events: auto; }

/* ==========================================================================
   Fenster – Windows-11-Look
   ========================================================================== */
.window {
  position: absolute; display: flex; flex-direction: column; overflow: hidden;
  background: var(--panel); border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--win-radius); box-shadow: 0 22px 64px rgba(0, 0, 0, .55), 0 0 0 1px rgba(0, 0, 0, .3);
  min-width: 380px; min-height: 240px;
}
[data-theme="light"] .window { border-color: rgba(0, 0, 0, .08); box-shadow: 0 22px 60px rgba(20, 40, 80, .3), 0 0 0 1px rgba(0, 0, 0, .06); }
.window.active { box-shadow: 0 30px 90px rgba(0, 0, 0, .62), 0 0 0 1px var(--accent); }
[data-theme="light"] .window.active { box-shadow: 0 30px 80px rgba(20, 40, 80, .34), 0 0 0 1px var(--accent); }
.window.maximized { border-radius: 0; border: none; }
.window.opening { animation: winopen .16s cubic-bezier(.2, .9, .3, 1); }
.window.closing { animation: winclose .12s ease forwards; }
@keyframes winopen { from { opacity: 0; transform: scale(.96) translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes winclose { to { opacity: 0; transform: scale(.97); } }

/* Titelleiste (Mica-artig) */
.win-titlebar {
  height: 40px; flex: none; display: flex; align-items: stretch; justify-content: space-between;
  padding-left: 12px; background: var(--bg-elev); border-bottom: 1px solid var(--border-soft);
  user-select: none; touch-action: none;
}
.win-title { display: flex; align-items: center; gap: 9px; font-size: 12.5px; font-weight: 600; color: var(--text); overflow: hidden; cursor: grab; flex: 1; }
.win-title:active { cursor: grabbing; }
.win-title svg { color: var(--accent); flex: none; }
.win-title span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Windows-Caption-Buttons: minimieren / maximieren / schließen */
.win-controls { display: flex; align-items: stretch; }
.win-btn {
  width: 46px; height: 40px; border: none; background: transparent; color: var(--text);
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  transition: background .1s, color .1s; padding: 0;
}
.win-btn:hover { background: rgba(255, 255, 255, 0.08); }
[data-theme="light"] .win-btn:hover { background: rgba(0, 0, 0, 0.06); }
.win-close:hover { background: #c42b1c; color: #fff; }
.window:not(.maximized) .win-close { border-top-right-radius: var(--win-radius); }

.win-body { flex: 1; overflow: auto; padding: 18px; background: var(--panel); }
.win-body > .page-head:first-child { margin-top: 2px; }
.win-resize { position: absolute; right: 0; bottom: 0; width: 16px; height: 16px; cursor: nwse-resize; z-index: 3; touch-action: none; }

/* ==========================================================================
   Taskleiste – Windows 11 (zentriert + Tray rechts)
   ========================================================================== */
.taskbar {
  position: absolute; left: 0; right: 0; bottom: 0; height: var(--taskbar-h); z-index: 10;
  display: flex; align-items: center; justify-content: center;
  background: rgba(32, 34, 42, 0.78); border-top: 1px solid rgba(255, 255, 255, 0.06);
  backdrop-filter: var(--win-blur); -webkit-backdrop-filter: var(--win-blur);
}
[data-theme="light"] .taskbar { background: rgba(243, 246, 251, 0.82); border-top-color: rgba(0, 0, 0, .06); }

.task-center { display: flex; align-items: center; gap: 4px; }

.start-btn {
  width: 42px; height: 40px; border: none; border-radius: 7px; background: transparent; cursor: pointer;
  display: flex; align-items: center; justify-content: center; transition: background .1s;
}
.start-btn:hover { background: rgba(255, 255, 255, 0.09); }
[data-theme="light"] .start-btn:hover { background: rgba(0, 0, 0, 0.06); }
.win-logo { display: flex; color: var(--accent); }

/* Such-Pille neben dem Start-Knopf (wie bei Windows 11) */
.search-btn {
  display: flex; align-items: center; gap: 7px; height: 32px; padding: 0 13px 0 11px;
  margin: 0 3px; border: 1px solid rgba(255, 255, 255, 0.10); border-radius: 16px;
  background: rgba(255, 255, 255, 0.07); color: var(--text-muted); cursor: pointer;
  font-size: 12.5px; font-family: inherit; transition: background .12s, border-color .12s, color .12s;
}
.search-btn:hover { background: rgba(255, 255, 255, 0.12); color: var(--text); border-color: rgba(255, 255, 255, 0.16); }
[data-theme="light"] .search-btn { background: rgba(255, 255, 255, 0.75); border-color: rgba(0, 0, 0, 0.08); }
[data-theme="light"] .search-btn:hover { background: #fff; border-color: rgba(0, 0, 0, 0.14); }
.search-btn .sb-lbl { line-height: 1; }
@media (max-width: 640px) { .search-btn .sb-lbl { display: none; } .search-btn { padding: 0 9px; } }

.task-apps { display: flex; align-items: center; gap: 3px; }
.task-btn {
  width: 42px; height: 40px; border: none; border-radius: 7px; background: transparent; color: var(--text-muted);
  cursor: pointer; display: flex; align-items: center; justify-content: center; position: relative;
  transition: background .1s, color .1s;
}
.task-btn:hover { background: rgba(255, 255, 255, 0.09); color: var(--text); }
[data-theme="light"] .task-btn:hover { background: rgba(0, 0, 0, 0.05); }
.task-btn.active { background: rgba(255, 255, 255, 0.11); color: var(--accent); }
[data-theme="light"] .task-btn.active { background: rgba(0, 0, 0, 0.06); }
/* Windows-„Running/Active"-Strich unter dem Icon */
.task-btn::after {
  content: ""; position: absolute; bottom: 2px; left: 50%; transform: translateX(-50%);
  width: 6px; height: 3px; border-radius: 3px; background: var(--text-dim); transition: width .15s, background .15s;
}
.task-btn.active::after { width: 17px; background: var(--accent); }
.task-btn.minimized::after { width: 7px; }

/* System-Tray rechts */
.task-tray { position: absolute; right: 6px; top: 0; bottom: 0; display: flex; align-items: center; gap: 2px; padding-right: 2px; }
.tray-icons { display: flex; align-items: center; gap: 8px; padding: 0 8px; height: 34px; border-radius: 6px; color: var(--text-muted); }
.tray-icons:hover { background: rgba(255, 255, 255, 0.09); }
[data-theme="light"] .tray-icons:hover { background: rgba(0, 0, 0, 0.05); }
.tray-btn { width: 34px; height: 34px; border: none; background: transparent; color: var(--text-muted); border-radius: 6px; cursor: pointer; display: flex; align-items: center; justify-content: center; transition: background .1s, color .1s; }
.tray-btn:hover { background: rgba(255, 255, 255, 0.09); color: var(--text); }
[data-theme="light"] .tray-btn:hover { background: rgba(0, 0, 0, 0.05); }
.tray-clock {
  display: flex; flex-direction: column; align-items: flex-end; justify-content: center; line-height: 1.2;
  height: 40px; padding: 0 10px; border: none; background: transparent; color: var(--text); cursor: default;
  border-radius: 6px; font-variant-numeric: tabular-nums;
}
.tray-clock:hover { background: rgba(255, 255, 255, 0.09); }
[data-theme="light"] .tray-clock:hover { background: rgba(0, 0, 0, 0.05); }
.tray-clock .t { font-size: 12px; font-weight: 500; }
.tray-clock .d { font-size: 11px; color: var(--text-muted); }
.tray-avatar { border: none; background: transparent; padding: 4px; border-radius: 50%; cursor: pointer; display: flex; }
.tray-avatar:hover { background: rgba(255, 255, 255, 0.12); }

/* ==========================================================================
   Startmenü – Windows 11 (mittig, Acryl)
   ========================================================================== */
.startmenu {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(var(--taskbar-h) + 10px); z-index: 400;
  width: 540px; max-width: calc(100vw - 20px); padding: 22px 22px 12px;
  background: rgba(43, 45, 54, 0.94); border: 1px solid rgba(255, 255, 255, 0.09);
  border-radius: 12px; box-shadow: 0 30px 80px rgba(0, 0, 0, .55);
  backdrop-filter: var(--win-blur); -webkit-backdrop-filter: var(--win-blur);
  animation: smin .16s cubic-bezier(.2, .9, .3, 1);
}
[data-theme="light"] .startmenu { background: rgba(249, 250, 253, 0.96); border-color: rgba(0, 0, 0, .08); box-shadow: 0 30px 80px rgba(20, 40, 80, .3); }
@keyframes smin { from { opacity: 0; transform: translate(-50%, 12px); } to { opacity: 1; transform: translate(-50%, 0); } }

.sm-search {
  display: flex; align-items: center; gap: 9px; padding: 0 13px; height: 38px; margin-bottom: 18px;
  background: var(--bg-elev); border: 1px solid var(--border); border-radius: 20px; color: var(--text-muted);
}
.sm-search input,
.sm-search input:focus {
  flex: 1; border: none; background: transparent; outline: none; box-shadow: none;
  color: var(--text); font-size: 13.5px; padding: 0; border-radius: 0;
}
.sm-search:focus-within { border-color: var(--accent); }
.sm-section { font-size: 12.5px; font-weight: 700; color: var(--text); margin: 0 4px 12px; }
.sm-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; min-height: 150px; align-content: start; }
.sm-app {
  display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 15px 6px 12px;
  border: none; background: transparent; color: var(--text); cursor: pointer; border-radius: 9px;
  font-size: 11.5px; font-weight: 500; transition: background .1s;
}
.sm-app:hover { background: rgba(255, 255, 255, 0.07); }
[data-theme="light"] .sm-app:hover { background: rgba(0, 0, 0, 0.045); }
.sm-ico { width: 34px; height: 34px; display: flex; align-items: center; justify-content: center; color: var(--accent); }
.sm-lbl { text-align: center; line-height: 1.2; }

.sm-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--border-soft); }
.sm-user { display: flex; align-items: center; gap: 10px; padding: 6px 10px; border-radius: 8px; }
.sm-user .avatar { color: #fff; font-weight: 700; }
.sm-user-name { font-size: 13.5px; font-weight: 600; }
.sm-power { width: 38px; height: 38px; border: none; background: transparent; color: var(--text-muted); border-radius: 8px; cursor: pointer; display: flex; align-items: center; justify-content: center; transition: background .1s, color .1s; }
.sm-power:hover { background: rgba(239, 68, 68, .12); color: var(--danger); }

/* ==========================================================================
   Medien-Viewer (Lightbox)
   ========================================================================== */
.lightbox { position: fixed; inset: 0; z-index: 700; background: rgba(4, 7, 16, 0.94); display: flex; flex-direction: column; animation: fadein .16s ease; backdrop-filter: blur(4px); }
.lb-bar { display: flex; align-items: center; gap: 12px; padding: 12px 16px; color: #eaf0fb; }
.lb-title { font-weight: 600; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lb-count { font-size: 12.5px; color: #9fb0cd; }
.lb-bar .spacer { flex: 1; }
.lb-btn { width: 40px; height: 40px; border: none; background: rgba(255, 255, 255, 0.1); color: #fff; border-radius: 8px; cursor: pointer; display: flex; align-items: center; justify-content: center; transition: background .12s; }
.lb-btn:hover { background: rgba(255, 255, 255, 0.22); }
.lb-stage { flex: 1; display: flex; align-items: center; justify-content: center; position: relative; overflow: hidden; padding: 0 8px 14px; }
/* Hinweis, wenn ein Videoformat nicht abspielbar ist */
.lb-error { display: flex; flex-direction: column; align-items: center; gap: 10px; text-align: center; color: #eaf0fb; max-width: 420px; padding: 20px; }
.lb-error-ico { color: #93c5fd; opacity: .9; }
.lb-error-title { font-weight: 700; font-size: 15px; }
.lb-error-hint { font-size: 13px; color: rgba(234, 240, 251, .65); margin-bottom: 6px; }
.lb-stage img { max-width: 100%; max-height: 100%; object-fit: contain; border-radius: 8px; transition: transform .15s; cursor: zoom-in; }
.lb-stage img.zoomed { cursor: zoom-out; max-width: none; max-height: none; }
.lb-stage video { max-width: 100%; max-height: 100%; border-radius: 8px; background: #000; }
.lb-nav { position: absolute; top: 50%; transform: translateY(-50%); width: 50px; height: 50px; border-radius: 50%; border: none; background: rgba(255, 255, 255, 0.12); color: #fff; cursor: pointer; display: flex; align-items: center; justify-content: center; transition: background .12s; }
.lb-nav:hover { background: rgba(255, 255, 255, 0.26); }
.lb-prev { left: 16px; } .lb-next { right: 16px; }

/* ---- Galerie ---- */
.gallery-section-title { font-size: 14px; font-weight: 700; margin: 6px 0 12px; display: flex; align-items: center; gap: 8px; }
.gallery-section-title svg { color: var(--accent); }
.gallery-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(128px, 1fr)); gap: 10px; }
.g-thumb { position: relative; aspect-ratio: 1; border-radius: 9px; overflow: hidden; cursor: pointer; border: 1px solid var(--border-soft); background: var(--panel-2); padding: 0; }
.g-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform .2s; }
.g-thumb:hover img { transform: scale(1.06); }
.g-thumb .g-play { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; background: rgba(0, 0, 0, .28); color: #fff; }
.g-thumb .g-name { position: absolute; left: 0; right: 0; bottom: 0; padding: 14px 8px 6px; font-size: 11px; color: #fff; background: linear-gradient(transparent, rgba(0, 0, 0, .65)); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Auswahl-/Upload-Leisten über der Taskleiste */
.bulkbar { bottom: calc(var(--taskbar-h) + 14px); }
.uploads { bottom: calc(var(--taskbar-h) + 14px); }

@media (max-width: 880px) {
  .desktop-icons { flex-direction: row; width: calc(100% - 24px); }
  .win-title { cursor: default; }
  .win-resize { display: none; }
  .tray-clock .d { display: none; }
  .tray-icons { display: none; }
  .startmenu { width: calc(100vw - 16px); }
  .sm-grid { grid-template-columns: repeat(3, 1fr); }
}

/* ==========================================================================
   Admin-Bereich – Navigation links, Inhalt rechts (wie Windows-Einstellungen)
   ========================================================================== */
.win-body.admin-mount { padding: 0; overflow: hidden; display: flex; }
.admin-wrap { display: flex; flex: 1; min-height: 0; width: 100%; }

.admin-nav {
  width: 208px; flex-shrink: 0; display: flex; flex-direction: column; gap: 2px;
  padding: 14px 10px; border-right: 1px solid var(--border-soft); background: var(--panel-2);
  overflow-y: auto;
}
.admin-nav-head { display: flex; align-items: center; gap: 10px; padding: 6px 8px 14px; }
.admin-nav-ico {
  display: flex; align-items: center; justify-content: center; width: 34px; height: 34px;
  border-radius: 9px; color: #fff; flex-shrink: 0;
  background: linear-gradient(135deg, var(--accent), color-mix(in srgb, var(--accent) 55%, #7c3aed));
}
.admin-nav-head .t { font-weight: 700; font-size: 14px; line-height: 1.25; }
.admin-nav-head .d { font-size: 11.5px; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 128px; }

.admin-nav-btn {
  display: flex; align-items: center; gap: 10px; padding: 9px 11px; border: none; border-radius: 8px;
  background: transparent; color: var(--text-muted); cursor: pointer; font-size: 13.5px; font-weight: 600;
  font-family: inherit; text-align: left; transition: background .1s, color .1s; position: relative;
}
.admin-nav-btn:hover { background: rgba(255, 255, 255, 0.06); color: var(--text); }
[data-theme="light"] .admin-nav-btn:hover { background: rgba(0, 0, 0, 0.045); }
.admin-nav-btn.active { background: var(--accent-soft); color: var(--text); }
.admin-nav-btn.active::before {
  content: ""; position: absolute; left: 0; top: 50%; transform: translateY(-50%);
  width: 3px; height: 16px; border-radius: 2px; background: var(--accent);
}
.admin-nav-btn.active svg { color: var(--accent); }

.admin-content { flex: 1; min-width: 0; overflow: auto; padding: 18px; }

@media (max-width: 880px) {
  .admin-wrap { flex-direction: column; }
  .admin-nav { width: 100%; flex-direction: row; align-items: center; padding: 8px; border-right: none; border-bottom: 1px solid var(--border-soft); overflow-x: auto; }
  .admin-nav-head { display: none; }
  .admin-nav-btn { flex-shrink: 0; }
}
