/* Retro Desktop Window Styles */

.retro-window {
  position: absolute;
  background-color: var(--retro-gray);
  border-top: 3px solid #ffffff;
  border-left: 3px solid #ffffff;
  border-right: 3px solid #000000;
  border-bottom: 3px solid #000000;
  box-shadow: 4px 4px 10px rgba(0, 0, 0, 0.4);
  display: none;
  flex-direction: column;
  overflow: hidden;
  min-width: 320px;
  min-height: 200px;
  max-width: calc(100% - 16px);
  max-height: calc(100% - 16px);
}

.retro-window.inactive {
  border-top: 3px solid #dfdfdf;
  border-left: 3px solid #dfdfdf;
  border-right: 3px solid #404040;
  border-bottom: 3px solid #404040;
}

/* Titlebar */
.window-titlebar {
  height: 32px;
  background: linear-gradient(90deg, #000080, #1084d0);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 4px 0 8px;
  cursor: move;
  user-select: none;
}

.retro-window.inactive .window-titlebar {
  background: linear-gradient(90deg, #808080, #b5b5b5);
  color: #dcdcdc;
}

.window-title-left {
  display: flex;
  align-items: center;
  gap: 8px;
  overflow: hidden;
  white-space: nowrap;
}

.window-icon {
  width: 18px;
  height: 18px;
  object-fit: contain;
}

.window-title-text {
  font-family: var(--font-pixel);
  font-size: 13px;
  letter-spacing: 0.5px;
  text-overflow: ellipsis;
  overflow: hidden;
}

/* Window Control Buttons */
.window-controls {
  display: flex;
  align-items: center;
  gap: 3px;
}

.win-btn {
  width: 20px;
  height: 20px;
  background-color: var(--retro-gray);
  border-top: 1px solid #ffffff;
  border-left: 1px solid #ffffff;
  border-right: 1px solid #000000;
  border-bottom: 1px solid #000000;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
}

.win-btn:active {
  border-top: 1px solid #000000;
  border-left: 1px solid #000000;
  border-right: 1px solid #ffffff;
  border-bottom: 1px solid #ffffff;
}

.win-btn-minimize {
  background-image: url('../Assets/UI/4X/ButtonLight_Minimize_Idle.png');
}
.win-btn-minimize:active {
  background-image: url('../Assets/UI/4X/ButtonLight_Minimize_Pressed.png');
}

.win-btn-maximize {
  background-image: url('../Assets/UI/4X/ButtonLight_Fullscreen_Idle.png');
}
.win-btn-maximize:active {
  background-image: url('../Assets/UI/4X/ButtonLight_Fullscreen_Pressed.png');
}

.win-btn-close {
  background-image: url('../Assets/UI/4X/ButtonLight_Exit_Idle.png');
}
.win-btn-close:active {
  background-image: url('../Assets/UI/4X/ButtonLight_Exit_Pressed.png');
}

/* Window Body Content */
.window-body {
  flex: 1;
  overflow: auto;
  padding: 6px;
  display: flex;
  flex-direction: column;
  background-color: var(--retro-gray);
  min-height: 0;
  height: 100%;
}

.window-inner-frame {
  flex: 1;
  background: #ffffff;
  border-top: 2px solid #808080;
  border-left: 2px solid #808080;
  border-right: 2px solid #ffffff;
  border-bottom: 2px solid #ffffff;
  overflow: auto;
  position: relative;
  display: flex;
  flex-direction: column;
  min-height: 0;
  height: 100%;
}

/* Retro Custom Scrollbar */
.window-inner-frame::-webkit-scrollbar,
.window-body::-webkit-scrollbar {
  width: 16px;
  height: 16px;
}

.window-inner-frame::-webkit-scrollbar-track,
.window-body::-webkit-scrollbar-track {
  background: #dfdfdf url('../Assets/UI/4X/Scrollbar1_Track.png') repeat-y center;
}

.window-inner-frame::-webkit-scrollbar-thumb,
.window-body::-webkit-scrollbar-thumb {
  background-color: var(--retro-gray);
  border-top: 2px solid #ffffff;
  border-left: 2px solid #ffffff;
  border-right: 2px solid #000000;
  border-bottom: 2px solid #000000;
}

/* Window Status Bar */
.window-statusbar {
  height: 24px;
  background-color: var(--retro-gray);
  border-top: 1px solid #808080;
  padding: 2px 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 14px;
  color: #333;
}

/* Mobile & Touchscreen Window Adaptation */
@media (max-width: 820px), (max-height: 560px), (pointer: coarse) {
  .retro-window {
    min-width: 0 !important;
    min-height: 0 !important;
    max-width: 100% !important;
    max-height: 100% !important;
    width: 100% !important;
    height: 100% !important;
    left: 0 !important;
    top: 0 !important;
    border-radius: 0;
  }

  .window-titlebar {
    height: 28px !important;
    padding: 0 4px 0 8px !important;
  }

  .window-title-text {
    font-size: 13px !important;
  }

  .window-icon {
    width: 16px !important;
    height: 16px !important;
  }

  .window-controls {
    gap: 4px !important;
  }

  .win-btn {
    width: 22px !important;
    height: 22px !important;
    touch-action: manipulation;
  }

  .window-body {
    padding: 2px !important;
  }
}
