/* ==========================================================================
   Windows XP Luna Visual Component System
   Complete reusable UI library: windows, buttons, menus, taskbar,
   scrollbars, cursors, selection, resize handles, placeholder icons.
   All values reference tokens.css via var().
   ========================================================================== */


/* ==========================================================================
   1. Window Chrome
   ========================================================================== */

.win95-window {
  position: absolute;
  min-width: 300px;
  min-height: 200px;
  background: var(--win95-window-bg);
  border-radius: 8px 8px 0 0;
  box-shadow: var(--xp-window-shadow), 0 0 0 1px rgba(0,0,0,0.2);
  padding: 0;
  display: flex;
  flex-direction: column;
  z-index: var(--z-windows);
  overflow: hidden;
}

.win95-window.maximized {
  top: 0 !important;
  left: 0 !important;
  width: 100% !important;
  height: calc(100vh - var(--win95-taskbar-height)) !important;
  border-radius: 0;
}

.win95-titlebar {
  height: var(--win95-titlebar-height);
  background: linear-gradient(180deg, #0997ff 0%, var(--xp-titlebar-start) 8%, var(--xp-titlebar-end) 90%, #6db8f2 100%);
  display: flex;
  align-items: center;
  padding: 0 4px 0 6px;
  gap: 4px;
  cursor: default;
  flex-shrink: 0;
  border-radius: 8px 8px 0 0;
}

.win95-titlebar.inactive {
  background: linear-gradient(180deg, #b4c6e7 0%, var(--xp-titlebar-inactive-start) 8%, var(--xp-titlebar-inactive-end) 90%, #cdd8ef 100%);
}

.win95-titlebar-icon {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  image-rendering: auto;
}

.win95-titlebar-text {
  font-family: var(--font-content);
  font-size: var(--font-size-md);
  color: var(--win95-window-title-text);
  font-weight: bold;
  text-shadow: 1px 1px 2px rgba(0,0,0,0.5);
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  user-select: none;
}

.win95-titlebar-buttons {
  display: flex;
  gap: 2px;
  flex-shrink: 0;
}

/* XP-style title bar buttons: minimize, maximize, close */
.win95-titlebar-btn {
  width: 22px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-family: var(--font-content);
  font-weight: bold;
  padding: 0;
  border: 1px solid rgba(0,0,0,0.25);
  border-radius: 3px;
  cursor: pointer;
  color: #ffffff;
  line-height: 1;
  background: var(--xp-minmax-btn);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.4), inset 0 -1px 0 rgba(0,0,0,0.15);
  text-shadow: 1px 1px 1px rgba(0,0,0,0.3);
}

.win95-titlebar-btn:hover {
  background: var(--xp-minmax-btn-hover);
}

.win95-titlebar-btn:active {
  background: #2a5db0;
  box-shadow: inset 0 1px 2px rgba(0,0,0,0.3);
  padding-top: 1px;
}

/* Close button — red */
.win95-titlebar-btn:last-child {
  background: var(--xp-close-btn);
  border-color: rgba(120,20,20,0.4);
  margin-left: 2px;
}

.win95-titlebar-btn:last-child:hover {
  background: var(--xp-close-btn-hover);
}

.win95-titlebar-btn:last-child:active {
  background: #a03030;
  box-shadow: inset 0 1px 2px rgba(0,0,0,0.3);
}

.win95-titlebar-btn:focus-visible {
  outline: 1px dotted #ffffff;
  outline-offset: -3px;
}


/* ==========================================================================
   2. Window Menu Bar
   ========================================================================== */

.win95-menubar {
  height: var(--win95-menubar-height);
  background: var(--win95-window-bg);
  display: flex;
  align-items: center;
  padding: 0 4px;
  border-bottom: 1px solid var(--win95-border-dark);
  flex-shrink: 0;
}

.win95-menubar-item {
  font-family: var(--font-content);
  font-size: var(--font-size-base);
  padding: 3px 8px;
  cursor: default;
  user-select: none;
  color: var(--win95-button-text);
  border-radius: 2px;
}

.win95-menubar-item:hover {
  background: var(--win95-menu-hover);
  color: var(--win95-menu-hover-text);
}


/* ==========================================================================
   3. Window Content Area
   ========================================================================== */

.win95-window-body {
  background: var(--xp-window-body-bg);
  border: 1px solid var(--win95-border-dark);
  margin: 2px 3px;
  padding: 6px;
  overflow: auto;
  flex: 1;
  font-family: var(--font-content);
  font-size: var(--font-size-base);
  color: #333333;
}

/* XP-style scrollbars (Chromium browsers) */
.win95-window-body::-webkit-scrollbar {
  width: 17px;
  height: 17px;
}

.win95-window-body::-webkit-scrollbar-track {
  background: var(--win95-scrollbar-track);
  border-left: 1px solid var(--win95-border-dark);
}

.win95-window-body::-webkit-scrollbar-thumb {
  background: linear-gradient(90deg, #ece9d8 0%, #d6d2c2 100%);
  border: 1px solid var(--win95-border-dark);
  border-radius: 2px;
}

.win95-window-body::-webkit-scrollbar-thumb:hover {
  background: linear-gradient(90deg, #ddd9cb 0%, #c8c4b4 100%);
}

.win95-window-body::-webkit-scrollbar-button {
  background: var(--win95-button-face);
  border: 1px solid var(--win95-border-dark);
  width: 17px;
  height: 17px;
  border-radius: 1px;
}

.win95-window-body::-webkit-scrollbar-button:hover {
  background: #e0ddd0;
}

.win95-window-body::-webkit-scrollbar-button:active {
  background: #c8c4b4;
}

.win95-window-body::-webkit-scrollbar-corner {
  background: var(--win95-window-bg);
}


/* ==========================================================================
   4. Status Bar
   ========================================================================== */

.win95-statusbar {
  height: var(--win95-statusbar-height);
  background: var(--win95-window-bg);
  display: flex;
  align-items: center;
  padding: 0 4px;
  gap: 2px;
  flex-shrink: 0;
}

.win95-statusbar-section {
  border: 1px solid var(--win95-border-dark);
  border-top-color: var(--win95-border-dark);
  padding: 2px 6px;
  font-size: var(--font-size-sm);
  font-family: var(--font-content);
  color: var(--win95-button-text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  background: #f1efe3;
}

.win95-statusbar-section:first-child {
  flex: 1;
}


/* ==========================================================================
   5. XP Buttons
   ========================================================================== */

.win95-btn {
  background: linear-gradient(180deg, #ffffff 0%, #ece9d8 50%, #d6d2c2 100%);
  border: 1px solid var(--win95-border-dark);
  border-radius: 3px;
  font-family: var(--font-content);
  font-size: var(--font-size-base);
  color: var(--win95-button-text);
  padding: 4px 16px;
  cursor: pointer;
  min-width: 75px;
  text-align: center;
  user-select: none;
  box-shadow: 0 1px 1px rgba(0,0,0,0.1);
}

.win95-btn:hover {
  background: linear-gradient(180deg, #ffffff 0%, #f0eddf 50%, #e0ddd0 100%);
  border-color: #316ac5;
}

.win95-btn:active,
.win95-btn.pressed {
  background: linear-gradient(180deg, #d6d2c2 0%, #ece9d8 100%);
  box-shadow: inset 0 1px 2px rgba(0,0,0,0.15);
  padding: 5px 15px 3px 17px;
}

.win95-btn:focus-visible {
  outline: 1px dotted var(--win95-button-text);
  outline-offset: -4px;
}

.win95-btn.default {
  border: 2px solid #003c74;
  box-shadow: 0 0 0 1px #316ac5;
}

.win95-btn:disabled {
  color: var(--win95-border-dark);
  background: var(--win95-button-face);
  cursor: default;
}


/* ==========================================================================
   6. Dropdown Menus (Start menu + context menu)
   ========================================================================== */

.win95-menu {
  position: absolute;
  background: var(--win95-menu-bg);
  border: 1px solid var(--win95-border-dark);
  border-radius: 4px;
  box-shadow: 3px 3px 8px rgba(0,0,0,0.3);
  padding: 2px;
  min-width: 180px;
  display: none;
  z-index: var(--z-context-menu);
}

.win95-menu.visible {
  display: block;
}

.win95-menu-item {
  padding: 6px 24px 6px 32px;
  font-family: var(--font-content);
  font-size: var(--font-size-base);
  cursor: default;
  white-space: nowrap;
  position: relative;
  display: flex;
  align-items: center;
  color: var(--win95-button-text);
  user-select: none;
  border-radius: 2px;
}

.win95-menu-item:hover {
  background: var(--win95-menu-hover);
  color: var(--win95-menu-hover-text);
}

.win95-menu-item.has-submenu::after {
  content: "\25BA";
  position: absolute;
  right: 8px;
  font-size: var(--font-size-xs);
}

.win95-menu-item.disabled {
  color: var(--win95-border-dark);
  pointer-events: none;
}

.win95-menu-item.disabled:hover {
  background: transparent;
}

.win95-menu-separator {
  height: 1px;
  margin: 3px 4px;
  border-top: 1px solid #d6d2c2;
  border-bottom: none;
}

.win95-menu-item-icon {
  width: 16px;
  height: 16px;
  margin-right: 6px;
  flex-shrink: 0;
  image-rendering: auto;
}

/* Start menu sidebar (vertical "Windows XP" text band) */
.win95-menu-sidebar {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 26px;
  background: linear-gradient(to top, var(--xp-titlebar-start), var(--xp-titlebar-end));
  border-radius: 4px 0 0 4px;
}

.win95-menu-sidebar-text {
  writing-mode: vertical-rl;
  transform: rotate(180deg);
  font-family: var(--font-content);
  font-size: var(--font-size-sm);
  font-weight: bold;
  color: var(--win95-window-title-text);
  text-shadow: 1px 1px 2px rgba(0,0,0,0.4);
  padding: var(--space-3);
  user-select: none;
}


/* ==========================================================================
   7. Taskbar Base Styles
   ========================================================================== */

.taskbar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: var(--win95-taskbar-height);
  background: linear-gradient(180deg, var(--xp-taskbar-end) 0%, var(--xp-taskbar-start) 100%);
  box-shadow: 0 -1px 3px rgba(0,0,0,0.3);
  display: flex;
  align-items: center;
  padding: 2px 4px;
  z-index: var(--z-taskbar);
  gap: 2px;
}

.start-btn {
  display: flex;
  align-items: center;
  gap: 4px;
  font-family: var(--font-content);
  font-size: var(--font-size-md);
  padding: 3px 10px 3px 6px;
  background: linear-gradient(180deg, #5db85d 0%, var(--xp-start-btn-start) 10%, var(--xp-start-btn-end) 90%, #1e5e1e 100%);
  border: 1px solid #1a5e1a;
  border-radius: 0 8px 8px 0;
  cursor: pointer;
  font-weight: bold;
  font-style: italic;
  color: #ffffff;
  text-shadow: 1px 1px 2px rgba(0,0,0,0.5);
  flex-shrink: 0;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.25), 0 1px 2px rgba(0,0,0,0.2);
}

.start-btn:hover {
  background: linear-gradient(180deg, #6ec86e 0%, #44a844 10%, #358535 90%, #245e24 100%);
}

.start-btn:active,
.start-btn.pressed {
  background: linear-gradient(180deg, #266d26 0%, #2d7b2d 50%, #3c9a3c 100%);
  box-shadow: inset 0 1px 3px rgba(0,0,0,0.3);
}

.start-btn-icon {
  width: 20px;
  height: 20px;
  image-rendering: auto;
}

.taskbar-windows {
  display: flex;
  flex: 1;
  gap: 2px;
  overflow: hidden;
}

.taskbar-window-btn {
  background: linear-gradient(180deg, #3e6db5 0%, #2f5799 50%, #24508f 100%);
  border: 1px solid rgba(0,0,0,0.2);
  border-radius: 3px;
  font-family: var(--font-content);
  font-size: var(--font-size-sm);
  padding: 3px 10px;
  cursor: pointer;
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-align: left;
  color: #ffffff;
  text-shadow: 1px 1px 1px rgba(0,0,0,0.3);
  flex-shrink: 0;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.15);
}

.taskbar-window-btn:hover {
  background: linear-gradient(180deg, #4a7dc5 0%, #3967a9 50%, #2e5a9f 100%);
}

.taskbar-window-btn.active {
  background: linear-gradient(180deg, #1e448b 0%, #16356f 50%, #1a3d7a 100%);
  box-shadow: inset 0 1px 3px rgba(0,0,0,0.4);
  font-weight: bold;
}

.taskbar-clock {
  font-family: var(--font-content);
  font-size: var(--font-size-sm);
  padding: 3px 10px;
  background: rgba(0,0,0,0.15);
  border: 1px solid rgba(0,0,0,0.15);
  border-radius: 2px;
  min-width: 70px;
  text-align: center;
  color: #ffffff;
  text-shadow: 1px 1px 1px rgba(0,0,0,0.3);
  flex-shrink: 0;
}


/* ==========================================================================
   8. Cursor Classes
   ========================================================================== */

body {
  cursor: var(--cursor-default);
}

a,
button,
[role="button"],
.clickable {
  cursor: var(--cursor-pointer);
}

.cursor-wait,
.loading {
  cursor: var(--cursor-wait);
}

.cursor-move,
.dragging {
  cursor: var(--cursor-move);
}


/* ==========================================================================
   9. Selection Rectangle (drag-select)
   ========================================================================== */

.drag-select-rect {
  position: fixed;
  border: 1px solid var(--win95-selection-bg);
  background: rgba(49, 106, 197, 0.2);
  pointer-events: none;
  display: none;
  z-index: var(--z-selection);
}

.drag-select-rect.active {
  display: block;
}


/* ==========================================================================
   10. Pixel Icon Placeholders
   Using CSS gradients to suggest shapes.
   These are PLACEHOLDERS until Diego provides real .png assets.
   NOTE: Hex colors used here are intentional for icon artwork only.
   ========================================================================== */

.icon-placeholder {
  width: var(--win95-icon-size);
  height: var(--win95-icon-size);
  image-rendering: auto;
  display: block;
}

/* Yellow folder icon */
.icon-folder {
  width: var(--win95-icon-size);
  height: var(--win95-icon-size);
  background:
    linear-gradient(135deg, #FFD700 0%, #FFD700 40%, transparent 40%) no-repeat 0 4px / 20px 8px,
    linear-gradient(to bottom, #FFC107 0%, #FFA000 100%) no-repeat 0 10px / 30px 20px;
  border-radius: 2px;
  image-rendering: auto;
}

/* Gray monitor / computer icon */
.icon-computer {
  width: var(--win95-icon-size);
  height: var(--win95-icon-size);
  background:
    linear-gradient(to bottom, #E0E0E0 0%, #B0B0B0 100%) no-repeat 4px 2px / 24px 18px,
    linear-gradient(to bottom, #4040A0 0%, #2020A0 100%) no-repeat 6px 4px / 20px 12px,
    linear-gradient(to bottom, #C0C0C0 0%, #A0A0A0 100%) no-repeat 10px 22px / 12px 4px,
    linear-gradient(to bottom, #D0D0D0 0%, #B0B0B0 100%) no-repeat 6px 26px / 20px 3px;
  image-rendering: auto;
}

/* Blue/green globe icon */
.icon-globe {
  width: var(--win95-icon-size);
  height: var(--win95-icon-size);
  background: radial-gradient(circle at 40% 40%, #4488FF 0%, #2266CC 40%, #116633 60%, #228844 80%, #2266CC 100%);
  border-radius: 50%;
  image-rendering: auto;
}

/* Envelope / mail icon */
.icon-mail {
  width: var(--win95-icon-size);
  height: var(--win95-icon-size);
  background:
    linear-gradient(135deg, #F0F0F0 25%, transparent 25%) no-repeat 0 6px / 16px 10px,
    linear-gradient(225deg, #F0F0F0 25%, transparent 25%) no-repeat 16px 6px / 16px 10px,
    linear-gradient(to bottom, #E8E8E8 0%, #D0D0D0 100%) no-repeat 0 6px / 32px 20px;
  image-rendering: auto;
}

/* Play button / media icon */
.icon-media {
  width: var(--win95-icon-size);
  height: var(--win95-icon-size);
  background:
    linear-gradient(to bottom, #333333 0%, #1A1A1A 100%) no-repeat 2px 2px / 28px 28px;
  position: relative;
  image-rendering: auto;
}

.icon-media::after {
  content: "";
  position: absolute;
  top: 8px;
  left: 12px;
  width: 0;
  height: 0;
  border-style: solid;
  border-width: 8px 0 8px 14px;
  border-color: transparent transparent transparent #FFFFFF;
}


/* ==========================================================================
   11. Window Resize Handles
   ========================================================================== */

.win95-resize-handle {
  position: absolute;
  z-index: 1;
}

.win95-resize-n {
  top: -3px;
  left: 0;
  right: 0;
  height: 6px;
  cursor: n-resize;
}

.win95-resize-s {
  bottom: -3px;
  left: 0;
  right: 0;
  height: 6px;
  cursor: s-resize;
}

.win95-resize-e {
  right: -3px;
  top: 0;
  bottom: 0;
  width: 6px;
  cursor: e-resize;
}

.win95-resize-w {
  left: -3px;
  top: 0;
  bottom: 0;
  width: 6px;
  cursor: w-resize;
}

.win95-resize-ne {
  top: -3px;
  right: -3px;
  width: 10px;
  height: 10px;
  cursor: ne-resize;
}

.win95-resize-nw {
  top: -3px;
  left: -3px;
  width: 10px;
  height: 10px;
  cursor: nw-resize;
}

.win95-resize-se {
  bottom: -3px;
  right: -3px;
  width: 10px;
  height: 10px;
  cursor: se-resize;
}

.win95-resize-sw {
  bottom: -3px;
  left: -3px;
  width: 10px;
  height: 10px;
  cursor: sw-resize;
}

/* Grip indicator in bottom-right corner */
.win95-resize-grip {
  position: absolute;
  bottom: 2px;
  right: 2px;
  width: 12px;
  height: 12px;
  background:
    linear-gradient(135deg,
      transparent 30%,
      var(--win95-border-dark) 30%, var(--win95-border-dark) 35%,
      transparent 35%, transparent 45%,
      var(--win95-border-dark) 45%, var(--win95-border-dark) 50%,
      transparent 50%, transparent 60%,
      var(--win95-border-dark) 60%, var(--win95-border-dark) 65%,
      transparent 65%
    );
  cursor: se-resize;
  z-index: 1;
}


/* ==========================================================================
   12. Utility & State Classes
   ========================================================================== */

.hidden {
  display: none !important;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Focus visible for keyboard navigation */
.win95-window:focus-visible {
  outline: 2px solid var(--win95-accent-cyan);
  outline-offset: 1px;
}

/* Text selection */
::selection {
  background: var(--win95-selection-bg);
  color: var(--win95-selection-text);
}
