/* ── Fluent Change AI Desktop Shell ──────────────────────── */

:root {
  --bg-desktop:   #080c12;
  --bg-taskbar:   rgba(12,20,30,.85);
  --bg-window:    #111b24;
  --bg-titlebar:  #0d1720;
  --accent:       #2250fc;
  --accent-dim:   #2250fc40;
  --text-primary: #e1e8ed;
  --text-secondary: #8696a0;
  --text-dim:     #4a5f6e;
  --border:       #1a2a36;
  --shadow:       0 8px 32px rgba(0,0,0,.5);
  --radius:       12px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: 'Outfit', -apple-system, sans-serif;
  background: var(--bg-desktop);
  color: var(--text-primary);
  height: 100vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  user-select: none;
}

/* ── Desktop Wallpaper ────────────────────────────────── */

#desktop {
  flex: 1;
  position: relative;
  overflow: hidden;
  background: #060d18 url('wallpaper.svg') center / cover no-repeat;
}

/* ── Desktop Logo ─────────────────────────────────────── */

.desktop-logo {
  position: absolute;
  top: 32px;
  left: 40px;
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -.02em;
  color: rgba(255,255,255,.75);
  text-shadow: 0 2px 20px rgba(34,80,252,.25), 0 0 40px rgba(0,0,0,.5);
  z-index: 1;
  pointer-events: none;
}

.desktop-logo span {
  font-weight: 300;
  color: rgba(255,255,255,.45);
}

.desktop-version {
  font-size: 11px;
  font-weight: 400;
  color: rgba(255,255,255,.3);
  text-align: right;
  margin-top: 2px;
  letter-spacing: .02em;
}

.desktop-grid {
  position: absolute;
  inset: 0;
  z-index: 1;
}

/* ── App Icon ─────────────────────────────────────────── */

.app-icon {
  position: absolute;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  padding: 16px 8px;
  border-radius: var(--radius);
  transition: background .2s ease, box-shadow .2s ease;
  touch-action: none;
  width: 100px;
}

.app-icon:hover {
  background: rgba(255,255,255,.06);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.app-icon.dragging {
  opacity: .85;
  z-index: 10;
  cursor: grabbing;
  transition: none;
  box-shadow: 0 8px 30px rgba(0,0,0,.4);
}

.app-icon-img {
  width: 64px;
  height: 64px;
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  box-shadow: 0 4px 16px rgba(0,0,0,.3);
  transition: box-shadow .2s ease;
}

.app-icon:hover .app-icon-img {
  box-shadow: 0 6px 24px rgba(0,0,0,.4);
}

.app-icon-label {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-primary);
  text-align: center;
  text-shadow: 0 1px 4px rgba(0,0,0,.8);
  max-width: 100px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ── Window Layer ─────────────────────────────────────── */

#windowLayer {
  position: fixed;
  inset: 0;
  z-index: 100;
  pointer-events: none;
}

/* ── App Window ───────────────────────────────────────── */

.app-window {
  position: absolute;
  display: flex;
  flex-direction: column;
  background: var(--bg-window);
  border: 1px solid rgba(255,255,255,.08);
  border-radius: 12px;
  box-shadow: 0 8px 40px rgba(0,0,0,.45), 0 0 0 1px rgba(0,0,0,.3);
  overflow: hidden;
  animation: windowOpen .2s ease;
  pointer-events: auto;
  transition: box-shadow .2s;
}

.app-window.focused {
  box-shadow: 0 16px 60px rgba(0,0,0,.55), 0 0 0 1px rgba(0,212,161,.12);
}

.app-window.minimized {
  pointer-events: none;
  opacity: 0;
  transform: scale(.4) translateY(100px);
  transition: all .3s ease;
}

@keyframes windowOpen {
  from { opacity: 0; transform: scale(.92) translateY(10px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}

.window-titlebar {
  display: flex;
  align-items: center;
  height: 42px;
  padding: 0 14px;
  background: var(--bg-titlebar);
  border-bottom: 1px solid rgba(255,255,255,.04);
  flex-shrink: 0;
  cursor: grab;
  user-select: none;
}

.window-titlebar:active { cursor: grabbing; }

/* macOS-style traffic light buttons — left side */
.window-controls {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-right: 14px;
}

.traffic-btn {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  position: relative;
  transition: filter .15s;
  pointer-events: auto;
}

.traffic-btn svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  transition: opacity .1s;
}

.window-controls:hover .traffic-btn svg {
  opacity: 1;
}

.traffic-close  { background: #ff5f57; }
.traffic-minimize { background: #ffbd2e; }
.traffic-maximize { background: #28c840; }

.traffic-close:hover  { filter: brightness(1.2); }
.traffic-minimize:hover { filter: brightness(1.2); }
.traffic-maximize:hover { filter: brightness(1.2); }

/* Unfocused: muted dots */
.app-window:not(.focused) .traffic-btn {
  background: rgba(255,255,255,.12);
}
.app-window:not(.focused):hover .traffic-btn {
  background: revert;
}
.app-window:not(.focused) .traffic-close { background: rgba(255,255,255,.12); }
.app-window:not(.focused) .traffic-minimize { background: rgba(255,255,255,.12); }
.app-window:not(.focused) .traffic-maximize { background: rgba(255,255,255,.12); }
.app-window:not(.focused):hover .traffic-close { background: #ff5f57; }
.app-window:not(.focused):hover .traffic-minimize { background: #ffbd2e; }
.app-window:not(.focused):hover .traffic-maximize { background: #28c840; }

.window-title {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  pointer-events: none;
}

.window-icon {
  font-size: 15px;
}

.app-window.maximized {
  inset: 0 !important;
  width: 100% !important;
  height: 100% !important;
  border-radius: 0;
}

.window-frame {
  flex: 1;
  border: none;
  background: var(--bg-desktop);
  width: 100%;
}

.window-drag-overlay {
  position: absolute;
  inset: 0;
  z-index: 999;
  display: none;
}

/* ── Window Resize Handles ───────────────────────────── */

.resize-handle {
  position: absolute;
  z-index: 10;
}

.resize-n  { top: -3px; left: 10px; right: 10px; height: 6px; cursor: n-resize; }
.resize-s  { bottom: -3px; left: 10px; right: 10px; height: 6px; cursor: s-resize; }
.resize-e  { right: -3px; top: 10px; bottom: 10px; width: 6px; cursor: e-resize; }
.resize-w  { left: -3px; top: 10px; bottom: 10px; width: 6px; cursor: w-resize; }
.resize-nw { top: -4px; left: -4px; width: 14px; height: 14px; cursor: nw-resize; }
.resize-ne { top: -4px; right: -4px; width: 14px; height: 14px; cursor: ne-resize; }
.resize-sw { bottom: -4px; left: -4px; width: 14px; height: 14px; cursor: sw-resize; }
.resize-se { bottom: -4px; right: -4px; width: 14px; height: 14px; cursor: se-resize; }

.app-window.maximized .resize-handle { display: none; }

/* ── Dock (macOS-style taskbar) ──────────────────────── */

#taskbar {
  position: fixed;
  bottom: 8px;
  left: 50%;
  transform: translateX(-50%);
  height: auto;
  min-height: 52px;
  background: rgba(18,28,38,.70);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border: 1px solid rgba(255,255,255,.08);
  border-radius: 16px;
  display: flex;
  align-items: center;
  padding: 6px 12px;
  gap: 4px;
  z-index: 200;
  flex-shrink: 0;
}

.taskbar-apps {
  display: flex;
  gap: 2px;
  align-items: center;
}

/* Separator between apps and clock */
.dock-separator {
  width: 1px;
  height: 28px;
  background: rgba(255,255,255,.1);
  margin: 0 8px;
  flex-shrink: 0;
}

.taskbar-app {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 6px 10px;
  border-radius: 12px;
  font-size: 10px;
  font-weight: 500;
  color: var(--text-dim);
  cursor: pointer;
  transition: all .2s ease;
  position: relative;
}

.taskbar-app:hover {
  background: rgba(255,255,255,.08);
  color: var(--text-secondary);
  transform: translateY(-2px);
}

.taskbar-app.active {
  color: var(--text-primary);
}

/* Active dot indicator under icon */
.taskbar-app.active::after {
  content: '';
  position: absolute;
  bottom: 2px;
  left: 50%;
  transform: translateX(-50%);
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--accent);
}

/* Minimized: dimmer dot */
.taskbar-app.minimized::after {
  content: '';
  position: absolute;
  bottom: 2px;
  left: 50%;
  transform: translateX(-50%);
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--text-dim);
}

.taskbar-app-icon {
  font-size: 24px;
  line-height: 1;
}

.taskbar-app-label {
  font-size: 10px;
  max-width: 70px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.taskbar-clock {
  font-family: 'IBM Plex Mono', monospace;
  text-align: right;
  padding: 0 6px;
  line-height: 1.3;
}

.clock-time {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
}

.clock-date {
  font-size: 10px;
  color: var(--text-dim);
}

/* ── Home Button ─────────────────────────────────────── */

.home-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  cursor: pointer;
  flex-shrink: 0;
  position: relative;
  background: transparent;
  border: none;
  transition: transform .2s ease, filter .2s ease;
}

/* Gradient ring via conic-gradient on pseudo-element */
.home-btn::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 50%;
  padding: 4px;
  background: conic-gradient(from 180deg, #2250fc, #00d4a1, #2250fc, #1a1a2e, #2250fc);
  -webkit-mask: radial-gradient(farthest-side, transparent calc(100% - 4px), #000 calc(100% - 4px));
          mask: radial-gradient(farthest-side, transparent calc(100% - 4px), #000 calc(100% - 4px));
  transition: all .25s ease;
}

.home-btn:hover {
  transform: translateY(-2px);
  filter: drop-shadow(0 0 8px rgba(34,80,252,.5));
}

.home-btn:active {
  transform: translateY(0) scale(.9);
}

/* ── Launchpad Overlay ───────────────────────────────── */

.launchpad {
  position: fixed;
  inset: 0;
  z-index: 500;
  background: rgba(6,13,24,.85);
  backdrop-filter: blur(30px);
  -webkit-backdrop-filter: blur(30px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 40px;
  opacity: 0;
  pointer-events: none;
  transition: opacity .25s ease;
}

.launchpad.open {
  opacity: 1;
  pointer-events: auto;
}

.launchpad-title {
  font-size: 15px;
  font-weight: 500;
  color: var(--text-secondary);
  letter-spacing: .06em;
  text-transform: uppercase;
}

.launchpad-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, 140px);
  gap: 20px;
  justify-content: center;
  max-width: 700px;
  padding: 0 40px;
}

.launchpad-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 24px 16px;
  border-radius: 16px;
  cursor: pointer;
  transition: all .2s ease;
  position: relative;
}

.launchpad-card:hover {
  background: rgba(255,255,255,.06);
}

.launchpad-card:active {
  transform: scale(.95);
}

.launchpad-card-icon {
  width: 72px;
  height: 72px;
  border-radius: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 32px;
  box-shadow: 0 6px 24px rgba(0,0,0,.4);
  transition: box-shadow .2s ease, transform .2s ease;
}

.launchpad-card:hover .launchpad-card-icon {
  transform: translateY(-3px);
  box-shadow: 0 10px 32px rgba(0,0,0,.5);
}

.launchpad-card-name {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
}

.launchpad-card-desc {
  font-size: 11px;
  color: var(--text-dim);
  text-align: center;
  line-height: 1.3;
}

/* Status badge on card */
.launchpad-card-badge {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.launchpad-card-badge.running {
  background: #28c840;
  box-shadow: 0 0 6px rgba(40,200,64,.5);
}

.launchpad-card-badge.minimized-badge {
  background: #ffbd2e;
  box-shadow: 0 0 6px rgba(255,189,46,.4);
}

/* Pin/unpin button on launchpad cards */
.launchpad-pin {
  position: absolute;
  bottom: 8px;
  right: 8px;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: none;
  background: rgba(255,255,255,.06);
  color: var(--text-dim);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  opacity: 0;
  transition: all .2s ease;
}

.launchpad-card:hover .launchpad-pin {
  opacity: 1;
}

.launchpad-pin.pinned {
  opacity: .7;
  color: var(--accent);
}

.launchpad-pin:hover {
  background: rgba(255,255,255,.12);
  opacity: 1 !important;
}

.launchpad-pin svg {
  width: 14px;
  height: 14px;
}

.launchpad-hint {
  font-size: 12px;
  color: var(--text-dim);
  opacity: .6;
}

/* ── Welcome Wrap (holds welcome + storage tiles) ───── */

.welcome-wrap {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  display: flex;
  gap: 20px;
  z-index: 50;
  animation: welcomeIn 0.4s ease;
  cursor: grab;
  touch-action: none;
}

.welcome-wrap.dragging {
  cursor: grabbing;
  user-select: none;
}

.welcome-wrap.closing {
  opacity: 0;
  transform: scale(0.95);
  transition: all 0.3s ease;
  pointer-events: none;
}

@keyframes welcomeIn {
  from { opacity: 0; transform: translate(-50%, -48%) scale(0.95); }
  to   { opacity: 1; transform: translate(-50%, -50%) scale(1); }
}

/* ── Welcome Tile ────────────────────────────────────── */

.welcome-tile {
  width: 360px;
  max-width: calc(50vw - 30px);
  background: rgba(14, 22, 32, 0.92);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 20px;
  padding: 32px 28px 24px;
  box-shadow: 0 12px 48px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(34, 80, 252, 0.08);
  position: relative;
}

/* ── Storage Info Tile ───────────────────────────────── */

.storage-tile {
  width: 360px;
  max-width: calc(50vw - 30px);
  background: rgba(14, 22, 32, 0.92);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 20px;
  padding: 32px 28px 24px;
  box-shadow: 0 12px 48px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(0, 212, 161, 0.08);
  position: relative;
}

.storage-tile .welcome-grid {
  margin-bottom: 16px;
}

.storage-tile .welcome-item {
  border-color: rgba(0, 212, 161, 0.06);
}

.storage-tile .welcome-item:hover {
  background: rgba(0, 212, 161, 0.06);
}

.storage-disclaimer {
  font-size: 10px;
  color: var(--text-dim);
  text-align: center;
  line-height: 1.5;
  opacity: 0.7;
  padding-top: 4px;
  border-top: 1px solid rgba(255, 255, 255, 0.04);
}

.welcome-close {
  position: absolute;
  top: 12px;
  right: 14px;
  width: 28px;
  height: 28px;
  border: none;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-dim);
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.welcome-close:hover {
  background: rgba(255, 95, 87, 0.2);
  color: #ff5f57;
}

.welcome-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 24px;
}

.welcome-wave {
  font-size: 28px;
}

.welcome-header h2 {
  font-size: 17px;
  font-weight: 600;
  color: var(--text-primary);
  letter-spacing: -0.01em;
}

.welcome-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 20px;
}

.welcome-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.04);
  transition: background 0.2s;
}

.welcome-item:hover {
  background: rgba(255, 255, 255, 0.06);
}

.welcome-item-icon {
  font-size: 22px;
  flex-shrink: 0;
}

.welcome-item-text {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-primary);
  line-height: 1.3;
}

.welcome-item-text small {
  font-weight: 400;
  color: var(--text-dim);
  font-size: 10px;
}

.welcome-hint {
  font-size: 11px;
  color: var(--text-dim);
  text-align: center;
  line-height: 1.4;
}

/* ── Cat Widget ──────────────────────────────────────── */

.cat-widget {
  position: absolute;
  bottom: 80px;
  right: 24px;
  width: 240px;
  z-index: 40;
  background: rgba(14, 22, 32, 0.92);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 18px;
  overflow: hidden;
  box-shadow: 0 8px 36px rgba(0, 0, 0, 0.45);
  cursor: grab;
  touch-action: none;
  animation: catIn 0.5s ease 0.8s both;
}

@keyframes catIn {
  from { opacity: 0; transform: translateY(16px) scale(0.96); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.cat-widget.dragging {
  cursor: grabbing;
  user-select: none;
}

.cat-widget-img {
  width: 100%;
  height: 180px;
  object-fit: cover;
  display: block;
  background: rgba(255, 255, 255, 0.03);
  transition: opacity 0.3s;
}

.cat-widget-img.loading {
  opacity: 0.3;
}

.cat-widget-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
}

.cat-widget-label {
  font-size: 11px;
  color: var(--text-dim);
  display: flex;
  align-items: center;
  gap: 6px;
}

.cat-widget-label span {
  font-size: 14px;
}

.cat-widget-btn {
  width: 28px;
  height: 28px;
  border: none;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-dim);
  font-size: 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.cat-widget-btn:hover {
  background: rgba(255, 255, 255, 0.12);
  color: var(--text-secondary);
}

.cat-widget-actions {
  display: flex;
  gap: 6px;
}

.cat-widget-btn.spinning {
  animation: spin 0.6s ease;
}

.cat-play-btn.cat-playing {
  background: rgba(255, 150, 50, 0.2);
  color: #ffaa44;
  animation: catPulse 0.6s ease infinite alternate;
}

@keyframes catPulse {
  from { transform: scale(1); }
  to   { transform: scale(1.15); }
}

@keyframes spin {
  from { transform: rotate(0deg); }
  to   { transform: rotate(360deg); }
}

/* ── Mobile ──────────────────────────────────────────── */

@media (max-width: 768px) {
  .desktop-logo {
    top: 16px;
    left: 20px;
    font-size: 18px;
  }

  .desktop-version { font-size: 9px; }

  /* Taskbar: full width at bottom */
  #taskbar {
    left: 0;
    right: 0;
    bottom: 0;
    transform: none;
    border-radius: 0;
    padding: 4px 8px;
    min-height: 46px;
    gap: 2px;
    justify-content: center;
  }

  .taskbar-app {
    padding: 4px 8px;
  }

  .taskbar-app-label { display: none; }
  .taskbar-app-icon { font-size: 22px; }

  .taskbar-clock {
    padding: 0 4px;
  }

  .clock-time { font-size: 11px; }
  .clock-date { display: none; }

  .home-btn {
    width: 30px;
    height: 30px;
  }

  .dock-separator {
    height: 22px;
    margin: 0 4px;
  }

  /* Windows: always fullscreen on mobile */
  .app-window {
    border-radius: 0 !important;
  }

  .app-window.maximized {
    border-radius: 0;
  }

  .resize-handle { display: none !important; }

  .window-titlebar {
    height: 38px;
    padding: 0 10px;
  }

  /* Launchpad: scrollable, tighter grid */
  .launchpad {
    justify-content: flex-start;
    padding-top: 60px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    gap: 24px;
  }

  .launchpad-grid {
    grid-template-columns: repeat(2, 140px);
    gap: 12px;
    padding: 0 20px;
    max-width: 100%;
  }

  .launchpad-card {
    padding: 18px 12px;
  }

  .launchpad-card-icon {
    width: 56px;
    height: 56px;
    border-radius: 14px;
    font-size: 26px;
  }

  .launchpad-title { font-size: 13px; }
  .launchpad-hint { font-size: 11px; }

  /* Welcome wrap: stack vertically on mobile */
  .welcome-wrap {
    flex-direction: column;
    align-items: center;
    gap: 12px;
    max-height: calc(100vh - 80px);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  .welcome-tile,
  .storage-tile {
    max-width: calc(100vw - 40px);
    width: 360px;
  }

  .cat-widget {
    width: 180px;
    bottom: 60px;
    right: 12px;
  }

  .cat-widget-img {
    height: 130px;
  }
}

