:root {
  --os-bg: url('wallpaper3.webp');
  --taskbar-bg: rgba(15, 23, 42, 0.85);
  --taskbar-border: rgba(255, 255, 255, 0.1);
  --text: #f8fafc;
  --muted: #94a3b8;
  --accent: #8b5cf6;
  --win-bg: #1e293b;
  --win-header: #0f172a;
  --desktop-card-bg: rgba(15, 23, 42, 0.28);
  --desktop-card-border: rgba(255, 255, 255, 0.14);
  --desktop-title-shadow: 0 1px 3px rgba(0, 0, 0, 0.45);
}

[data-theme="light"] {
  --taskbar-bg: rgba(255, 255, 255, 0.85);
  --taskbar-border: rgba(0, 0, 0, 0.1);
  --text: #0f172a;
  --muted: #64748b;
  --win-bg: #ffffff;
  --win-header: #f1f5f9;
  --desktop-card-bg: rgba(255, 255, 255, 0.55);
  --desktop-card-border: rgba(15, 23, 42, 0.12);
  --desktop-title-shadow: none;
}

body {
  margin: 0;
  padding: 0;
  font-family: 'Inter', sans-serif;
  color: var(--text);
  overflow: hidden; /* No scrolling on the main window */
  user-select: none;
}

/* Desktop */
#desktop {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 48px; /* taskbar height */
  background: var(--os-bg) center top/cover no-repeat;
  z-index: 1;
}

.desktop-groups {
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  width: min(630px, calc(50%));
  height: 100%;
  overflow-y: auto;
  box-sizing: border-box;
}

.desktop-group-card {
  background: var(--desktop-card-bg);
  border: 1px solid var(--desktop-card-border);
  border-radius: 20px;
  padding: 10px 18px 8px;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  box-shadow: 0 16px 36px rgba(0, 0, 0, 0.22);
}

.desktop-group-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}

.desktop-group-title {
  font-size: 12px;
  font-weight: 700;
  color: var(--text);
  text-shadow: var(--desktop-title-shadow);
}

.desktop-group-icons {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 10px;
}

.desktop-icon {
  width: 51px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  cursor: pointer;
  text-align: center;
  flex: 0 0 51px;
}

.desktop-icon:hover .icon-img {
  transform: scale(1.05);
  box-shadow: 0 4px 15px rgba(0,0,0,0.4);
}

.desktop-icon.is-disabled {
  cursor: default;
}

.desktop-icon.is-disabled .icon-img {
  opacity: 0.6;
  box-shadow: 0 2px 8px rgba(0,0,0,0.18);
}

.desktop-icon.is-disabled span {
  opacity: 0.78;
}

.desktop-icon span {
  font-size: 8.5px;
  font-weight: 500;
  color: #fff;
  text-shadow: 0 1px 3px rgba(0,0,0,0.8);
  background: rgba(0,0,0,0.3);
  padding: 1px 4px;
  border-radius: 4px;
}

.icon-img {
  width: 30.6px;
  height: 30.6px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  transition: all 0.2s ease;
  box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}
.icon-img [data-lucide] { width: 15.3px; height: 15.3px; }

@media (max-width: 980px) {
  .desktop-groups {
    width: calc(100% - 32px);
    padding: 16px;
  }
}

/* Taskbar */
#taskbar {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 48px;
  background: var(--taskbar-bg);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-top: 1px solid var(--taskbar-border);
  display: flex;
  align-items: center;
  padding: 0 10px;
  z-index: 1000;
}

#start-btn {
  width: 40px;
  height: 40px;
  background: transparent;
  border: none;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.2s;
  margin-right: 10px;
}
#start-btn:hover { background: rgba(255,255,255,0.1); }
.bsf-logo-icon {
  width: 28px;
  height: 28px;
  background: linear-gradient(135deg, #f97316, #8b5cf6);
  color: white;
  border-radius: 6px;
  font-weight: 900;
  font-size: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
}

#taskbar-apps {
  flex: 1;
  display: flex;
  gap: 5px;
  overflow-x: auto;
}

.taskbar-app {
  padding: 0 12px;
  height: 36px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 6px;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  transition: all 0.2s;
  max-width: 160px;
}
.taskbar-app [data-lucide] { width: 16px; height: 16px; color: var(--accent); }
.taskbar-app:hover { background: rgba(255,255,255,0.05); }
.taskbar-app.active {
  background: rgba(255,255,255,0.1);
  border-bottom: 2px solid var(--accent);
  border-bottom-left-radius: 0;
  border-bottom-right-radius: 0;
}

#taskbar-tray {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 10px;
  font-size: 13px;
  font-weight: 500;
}

/* Start Menu */
#start-menu {
  position: absolute;
  bottom: 56px;
  left: 10px;
  width: 320px;
  background: var(--taskbar-bg);
  backdrop-filter: blur(15px);
  -webkit-backdrop-filter: blur(15px);
  border: 1px solid var(--taskbar-border);
  border-radius: 12px;
  box-shadow: 0 10px 40px rgba(0,0,0,0.5);
  display: none;
  flex-direction: column;
  z-index: 1001;
  overflow: hidden;
  transform-origin: bottom left;
  animation: popIn 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes popIn {
  0% { transform: scale(0.95); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}

.start-header {
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 15px;
  border-bottom: 1px solid var(--taskbar-border);
}
.start-avatar {
  width: 48px; height: 48px; border-radius: 50%;
  background: var(--accent); color: white;
  display: flex; align-items: center; justify-content: center;
  font-weight: bold; font-size: 18px;
}
.start-body { padding: 10px; }
.start-item {
  padding: 12px 15px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  transition: background 0.2s;
  color: var(--text);
}
.start-item:hover { background: rgba(255,255,255,0.1); }
.start-item [data-lucide] { width: 18px; height: 18px; color: var(--muted); }
.start-body hr { border: none; border-top: 1px solid var(--taskbar-border); margin: 10px 0; }

/* Window System */
#window-container {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 48px;
  z-index: 10;
  pointer-events: none; /* Let clicks pass through to desktop if no window */
}

.os-window {
  position: absolute;
  width: 800px;
  height: 600px;
  background: var(--win-bg);
  border: 1px solid var(--taskbar-border);
  border-radius: 8px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.4);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  pointer-events: auto; /* Catch clicks */
  transition: transform 0.1s;
}

.os-window.maximized {
  top: 0 !important;
  left: 0 !important;
  width: 100% !important;
  height: 100% !important;
  border-radius: 0;
}

.win-header {
  height: 40px;
  background: var(--win-header);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 10px;
  cursor: grab;
  border-bottom: 1px solid var(--taskbar-border);
}
.win-header:active { cursor: grabbing; }

.win-title {
  font-size: 13px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
}
.win-title [data-lucide] { width: 14px; height: 14px; color: var(--accent); }

.win-controls {
  display: flex;
  gap: 8px;
}
.win-btn {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.win-btn.close { background: #ff5f56; }
.win-btn.maximize { background: #27c93f; }
.win-btn.minimize { background: #ffbd2e; }

.win-content {
  flex: 1;
  background: #fff; /* Most iframes expect white bg */
  position: relative;
}
.win-content iframe {
  width: 100%;
  height: 100%;
  border: none;
  display: block;
}

/* Glass panel to prevent iframe eating drag events */
.win-glass {
  position: absolute;
  top:0; left:0; right:0; bottom:0;
  z-index: 100;
  display: none;
}
.os-window.dragging .win-glass { display: block; }
