@font-face {
  font-family: "pixel";
  src: url("fonts/MotaPixel-Light.woff") format("woff");
}

@font-face {
  font-family: "pixel";
  src: url("fonts/MotaPixel-Regular.woff") format("woff");
  font-weight: bold;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}
body {
  font-family: "pixel";
  background: #008080;
  font-size: 30px;
  padding: 10px;
}
button {
  cursor: pointer;
}
#preview-image,
#preview-image-bg,
.preview-animated,
img {
  image-rendering: -moz-crisp-edges;
  image-rendering: -o-crisp-edges;
  image-rendering: -webkit-optimize-contrast;
  image-rendering: auto;
  image-rendering: crisp-edges;
  image-rendering: pixelated;
  -webkit-font-smoothing: none;
  -ms-interpolation-mode: nearest-neighbor;
}
.window {
  background: #c0c0c0;
  border: 2px solid #808080;
  width: 100%;
  height: 95vh;
  display: flex;
  flex-direction: column;
}
.title-bar {
  background: #000080;
  color: #fff;
  padding: 4px;
  display: flex;
  justify-content: space-between;
  user-select: none;
}
thead {
  background: rgb(130, 130, 130);
}
.menu-bar {
  display: flex;
  align-items: center;
  background: #c0c0c0;
  border-left: 2px solid #fff;
  border-top: 2px solid #fff;
  border-right: 2px solid #808080;
  border-bottom: 2px solid #808080;
  padding: 4px;
  gap: 12px;
}
.menu-bar .filter {
  position: relative;
}
.menu-bar .filter > label {
  display: inline-block;
  padding: 4px 8px;
  border: 2px outset #fff;
  background: #c0c0c0;
  font-size: 20px;
  user-select: none;
  cursor: pointer;
}
.menu-bar .filter.open > label {
  border: 2px inset #fff;
}
.menu-bar .filter .dropdown {
  display: none;
  position: absolute;
  top: 120%;
  left: 0;
  background: #c0c0c0;
  border: 2px solid #808080;
  padding: 6px;
  z-index: 10;
  min-width: 110px;
}
.menu-bar .filter[data-filter="author"] .dropdown {
  min-width: 150px;
}
.menu-bar .filter[data-filter="tooltype"] .dropdown {
  min-width: 150px;
}
.menu-bar .filter.open .dropdown {
  display: block;
}
.menu-bar .filter .dropdown div {
  font-size: 20px;
  margin-bottom: 4px;
}
.menu-bar button#download-selected,
.menu-bar button#clear-filters {
  padding: 4px 10px;
  font-size: 20px;
  border: 2px outset #fff;
  background: #c0c0c0;
}
.menu-bar button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}
.content {
  flex: 1;
  display: flex;
  overflow: hidden;
  background: #c0c0c0;
}
.tab-content {
  flex: 1;
  display: flex;
  overflow: hidden;
  background: #c0c0c0;
}
.sidebar {
  width: 60%;
  border-right: 2px inset #808080;
  overflow-y: auto;
  background: #c0c0c0;
}
table.file-list {
  width: 100%;
  border-collapse: collapse;
  font-size: 20px;
}
table.file-list th,
table.file-list td {
  padding: 4px;
  border-bottom: 1px solid #808080;
  text-align: left;
}
table.file-list tr.selected {
  background: #000080;
  color: #fff;
}
#scripts-content table.file-list th:first-child,
#scripts-content table.file-list td:first-child,
#tools-content table.file-list th:first-child,
#tools-content table.file-list td:first-child {
  padding-left: 16px;
}
th.sortable {
  cursor: pointer;
  text-decoration: underline;
}

.preview-panel {
  flex: 1;
  padding: 8px;
  display: flex;
  flex-direction: column;
  max-width: 40%;
}
/*
.preview-panel {
  flex: 1;
  padding: 8px;
  display: flex;
  flex-direction: column;
  max-width: 40%;
  height: 100%;
  overflow: hidden;
}
*/
.preview-window {
  border: 2px inset #fff;
  background: #e0e0e0;
  flex: 1;
  overflow: scroll;
  width: 100%;
  height: 100%;
  margin-bottom: 8px;
}
.preview-window img {
  user-select: none;
  max-width: none;
  transform-origin: center top;
  zoom: 200%;
  overflow-x: scroll;
}
.details {
  font-size: 20px;
  padding: 10px;
}
/*
.details {
  font-size: 20px;
  padding: 10px;
  overflow-y: auto;
  max-height: 200px; /* Adjust as needed
  padding-right: 8px; /* Prevents content from touching scrollbar
}
*/
button {
  font-family: pixel;
  font-weight: bold;
}
.details p {
  margin-bottom: 4px;
}
.details button {
  padding: 4px 8px;
  font-size: 20px;
  border: 2px outset #fff;
  background: #c0c0c0;
}
.title-bar-text {
  font-weight: bold;
}

/* New styles for search and tabs */
.search-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px;
  background: #c0c0c0;
  border-left: 2px solid #fff;
  border-top: 2px solid #fff;
  border-right: 2px solid #808080;
  border-bottom: 2px solid #808080;
}
.search-bar input {
  flex: 1;
  min-width: 0;
  padding: 4px;
  font-family: "pixel";
  font-size: 20px;
  border: 2px inset #fff;
}
.tabs {
  display: flex;
  background: #c0c0c0;
  border-left: 2px solid #fff;
  border-top: 2px solid #fff;
  border-right: 2px solid #808080;
  border-bottom: 2px solid #808080;
}
.tab {
  padding: 8px 16px;
  cursor: pointer;
  border-right: 1px solid #808080;
}
.tab.active {
  background: #000080;
  color: #fff;
}
.tab-menu-mobile {
  display: none;
  position: relative;
  background: #c0c0c0;
  border-left: 2px solid #fff;
  border-top: 2px solid #fff;
  border-right: 2px solid #808080;
  border-bottom: 2px solid #808080;
  padding: 0;
  width: 150px;
}
#tab-menu-button {
  width: 100%;
  font-family: "pixel";
  font-size: 18px;
  background: #c0c0c0;
  border: 2px outset #fff;
  padding: 6px 8px;
  text-align: left;
  cursor: pointer;
}
#tab-menu-button:active {
  border: 2px inset #fff;
}
.tab-menu-list {
  display: none;
  position: absolute;
  top: calc(100% + 2px);
  left: 0;
  width: 100%;
  background: #c0c0c0;
  border-left: 2px solid #fff;
  border-top: 2px solid #fff;
  border-right: 2px solid #808080;
  border-bottom: 2px solid #808080;
  box-shadow: 2px 2px 0 rgba(0, 0, 0, 0.25);
  z-index: 10;
}
.tab-menu-list.open {
  display: block;
}
.tab-menu-item {
  padding: 6px 10px;
  font-family: "pixel";
  font-size: 18px;
  cursor: pointer;
}
.tab-menu-item:hover {
  background: #000080;
  color: #fff;
}
.tab-menu-item.active {
  background: #000080;
  color: #fff;
}
.tab-content {
  display: none;
}
.tab-content.active {
  display: flex;
  flex: 1;
}
/* Audio player styles */
/*
.audio-player {
  width: 100%;
  margin-top: 10px;
}
*/
.audio-player {
  margin-top: 10px;
  margin-bottom: 10px;
}
.audio-controls {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}
.audio-timeline {
  flex-grow: 1;
}
#play-btn {
  width: 30px;
  height: 30px;
  cursor: pointer;
}
.music-play-btn {
  cursor: pointer;
  padding: 2px 6px;
  font-size: 16px;
}
.menu-bar .filter[data-filter="type"].hidden,
.menu-bar .filter[data-filter="game"].hidden,
.menu-bar .filter[data-filter="tooltype"].hidden {
  display: none;
}

/* CSS for Background Animation */
#preview-image-bg {
  position: relative;
  zoom: 200%;
  max-height: 200px;
  height: 70%;
  overflow: hidden;
  image-rendering: -moz-crisp-edges;
  image-rendering: -o-crisp-edges;
  image-rendering: -webkit-optimize-contrast;
  -ms-interpolation-mode: nearest-neighbor;
}
#preview-image-npc {
  position: relative;
  zoom: 200%;
  max-height: 200px;
  height: 70%;
  image-rendering: -moz-crisp-edges;
  image-rendering: -o-crisp-edges;
  image-rendering: -webkit-optimize-contrast;
  -ms-interpolation-mode: nearest-neighbor;
}

.npc-frames-container {
  display: flex;
  gap: 10px;
  animation: scrollFrames 10s linear infinite;
}

.npc-frame {
  flex-shrink: 0;
  image-rendering: pixelated;
}

.tile {
  position: absolute;
  background-repeat: no-repeat;
  background-image: var(--sprite-sheet);
  background-position: var(--sprite-pos);
  width: var(--sprite-w);
  height: var(--sprite-h);
}

/* Styles for Scripts and Tools tabs */
.info-panel {
  flex: 1;
  padding: 20px;
  overflow-y: auto;
}
.info-item {
  margin-bottom: 20px;
  padding: 15px;
  background: #e0e0e0;
  border: 2px inset #fff;
}
.info-item h3 {
  margin-bottom: 10px;
  color: #000080;
}
.info-item p {
  margin-bottom: 8px;
}
.info-item a {
  color: #0000ff;
  text-decoration: underline;
}
/* ======= Modal overlay (dimmed background) ======= */
#modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  display: none;
  z-index: 1000;
}

/* ======= Modal window itself ======= */
#feedback-modal {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 50%;
  max-width: 500px;
  background: #c0c0c0;
  border: 2px solid #808080;
  display: none;
  z-index: 1001;
  font-family: "pixel";
}

/* Title bar inside modal (Win95 style) */
#feedback-modal .modal-title-bar {
  background: #000080;
  color: #fff;
  padding: 4px;
  display: flex;
  justify-content: space-between;
  user-select: none;
}

/* Close button “X” in top-right */
#feedback-modal .close-btn {
  cursor: pointer;
  font-size: 20px;
  line-height: 1;
  padding: 0 8px;
  font-weight: bold;
}

/* Content area inside modal */
#feedback-modal .modal-content {
  padding: 8px;
  font-size: 20px;
  color: #000;
}

/* Ensure textarea also looks “pixel” and Win95-ish */
#feedback-modal textarea {
  border: 2px inset #fff;
  background: #fff;
  color: #000;
  outline: none;
}

/* Ensure the Submit button has Win95 borders */
#feedback-modal button {
  cursor: pointer;
  border: 2px outset #fff;
  background: #c0c0c0;
  font-family: "pixel";
  font-weight: bold;
}
@keyframes spin {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

.spinning {
  animation: spin 3s linear infinite;
  animation-direction: reverse;
  animation-play-state: paused;
}
#disc-image {
  image-rendering: auto;
  image-rendering: auto;
  -ms-interpolation-mode: bicubic;
}

.game-image-slideshow {
  position: relative;
  width: 120px;
  height: 80px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.game-image-slideshow img {
  position: absolute;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  opacity: 0;
  transition: opacity 0.5s ease-in-out;
}

.game-image-slideshow img.active {
  opacity: 1;
}

.music-preview-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}

.music-title-info {
  flex: 1;
  min-width: 0; /* Allows text truncation */
}

.music-title-info p {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin: 0;
}

.disc-preview {
  text-align: center;
  margin-bottom: 10px;
}

/* Unified preview panel styles */
.tab-content .preview-panel {
  flex: 1;
  padding: 8px;
  display: flex;
  flex-direction: column;
  max-width: 40%;
  height: 100%;
  overflow: hidden;
}

/* Specific styles for scripts/tools tabs */
#scripts-content .preview-panel,
#tools-content .preview-panel {
  max-width: 100%;
  width: 100%;
  padding: 0;
}

/* Scrollable content container */
.preview-scrollable {
  height: 100%;
  overflow-y: auto;
  padding: 8px;
}

/* Music tab specific styles */
#music-content .preview-panel {
  padding: 0;
}

.music-preview-container {
  height: 100%;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.music-preview-content {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
}

/* Audio player additional controls */
.audio-extra-controls {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 5px;
}

.volume-control {
  display: flex;
  align-items: center;
  gap: 5px;
}

#volume-slider {
  -webkit-appearance: none;
  height: 4px;
  background: #808080;
  border: 1px solid #000;
}

#volume-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 12px;
  height: 12px;
  background: #c0c0c0;
  border: 2px outset #fff;
  cursor: pointer;
}

#volume-slider::-moz-range-thumb {
  width: 12px;
  height: 12px;
  background: #c0c0c0;
  border: 2px outset #fff;
  cursor: pointer;
}

@media (max-width: 800px) {
  .tabs {
    display: none;
  }
  .tab-menu-mobile {
    display: flex;
  }
  .content {
    flex-direction: column;
    overflow: visible;
  }
  .tab-content {
    flex-direction: column;
    overflow: visible;
  }
  .sidebar {
    width: 100%;
    flex: 1;
    border-right: none;
    border-bottom: 2px inset #808080;
    background: #c0c0c0;
  }
  .tab-content .preview-panel {
    position: sticky;
    bottom: 0;
    width: 100%;
    max-width: none;
    flex: none;
    height: 33vh;
    border-top: 2px inset #808080;
    background: #c0c0c0;
    overflow: auto;
  }
  .preview-window {
    width: 100%;
    max-height: 100%;
  }
  .preview-scrollable {
    max-height: 100%;
  }
  #feedback-modal {
    width: 90%;
    max-width: 90%;
  }
  .menu-bar button,
  .menu-bar .filter > label {
    font-size: 16px !important;
    padding: 4px 8px !important;
  }
  /* Hide metadata blocks for compact view */
  #tiles-content .details p {
    display: none;
  }
  #backgrounds-content .details p {
    display: none;
  }
  #music-content .disc-preview {
    display: none;
  }
}
