/* =============================================================
   Napster 2 — Web Edition
   Classic 1999 Napster 2.x aesthetic. No images required.
   ============================================================= */

:root {
  /* Classic Win chrome */
  --chrome-light: #ffffff;
  --chrome-hi:    #f6f6f6;
  --chrome-mid:   #ece9d8;
  --chrome-lo:    #d6d2c2;
  --chrome-dark:  #919b9c;
  --chrome-edge:  #404040;

  /* Napster teal */
  --teal-1: #008080;
  --teal-2: #009999;
  --teal-3: #006666;
  --teal-deep: #005757;
  --teal-tint: #b3e5e5;

  /* Blues / link */
  --link-blue: #0000ee;
  --link-blue-v: #551a8b;

  /* Status */
  --green-online: #2e7d32;
  --red-busy:     #c62828;
  --yellow-idle:  #f9a825;

  /* Surfaces */
  --bg-deep:   #3a6d6d;
  --bg-darker: #0e2f2f;
  --bg-desktop: #2c5f5f;
  --win-bg:    #f0f0e8;
  --row-alt:   #fafafa;

  /* Typography */
  --font-ui:   Tahoma, "MS Verdana", Verdana, sans-serif;
  --font-mono: "Lucida Console", "Courier New", monospace;

  /* Sizes */
  --row-h: 18px;
  --title-h: 22px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background:
    repeating-linear-gradient(
      45deg,
      #2c5f5f 0,
      #2c5f5f 2px,
      #285a5a 2px,
      #285a5a 4px
    );
  color: #222;
  font-family: var(--font-ui);
  font-size: 11px;
  user-select: none;
  -webkit-user-select: none;
  overflow: hidden;
}

button {
  font-family: inherit;
  font-size: inherit;
  cursor: pointer;
}

input, select {
  font-family: inherit;
  font-size: inherit;
}

/* =============================================================
   DESKTOP
   ============================================================= */
.desktop {
  position: relative;
  width: 100vw;
  height: 100vh;
  overflow: hidden;
}

/* =============================================================
   MENUBAR
   ============================================================= */
.menubar {
  display: flex;
  align-items: center;
  height: 28px;
  background: linear-gradient(180deg, #f6f6f6, #d8d8d8);
  border-bottom: 1px solid #888;
  padding: 0 6px;
  gap: 8px;
}
.menubar-brand {
  font-weight: bold;
  font-size: 14px;
  letter-spacing: 0.5px;
  padding: 0 8px;
  display: inline-flex;
  align-items: baseline;
}
.menubar-brand .brand-mark {
  color: var(--teal-1);
  font-size: 16px;
  font-weight: bold;
}
.menubar-brand .brand-rest {
  color: #222;
}
.menubar-menu {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  gap: 2px;
}
.menubar-item {
  background: transparent;
  border: 1px solid transparent;
  padding: 3px 8px;
  font-size: 11px;
  border-radius: 0;
}
.menubar-item:hover {
  background: var(--teal-1);
  color: #fff;
  border-color: var(--teal-deep);
}
.menubar-status {
  margin-left: auto;
  font-size: 11px;
  color: #444;
  padding-right: 4px;
}

/* =============================================================
   TOOLBAR
   ============================================================= */
.toolbar {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px 6px;
  background: linear-gradient(180deg, #e8e8e8, #c8c8c8);
  border-bottom: 1px solid #888;
}
.tool {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: linear-gradient(180deg, #fafafa, #d4d4d4);
  border: 1px solid #888;
  padding: 3px 8px;
  border-radius: 2px;
  font-size: 11px;
  min-width: 70px;
  justify-content: flex-start;
}
.tool:hover { background: linear-gradient(180deg, #fff, #e0e0e0); }
.tool.active {
  background: linear-gradient(180deg, var(--teal-2), var(--teal-3));
  color: #fff;
  border-color: var(--teal-deep);
}
.tool-icon { font-size: 12px; }
.toolbar-spacer { flex: 1; }
.toolbar-online {
  font-size: 11px;
  color: #333;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding-right: 6px;
}
.toolbar-online .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--red-busy);
  display: inline-block;
}
.toolbar-online .dot.online { background: var(--green-online); }

/* =============================================================
   WINDOWS
   ============================================================= */
.win {
  position: absolute;
  background: var(--chrome-mid);
  border: 1px solid var(--chrome-edge);
  box-shadow:
    1px 1px 0 var(--chrome-dark),
    inset 1px 1px 0 var(--chrome-light);
  display: flex;
  flex-direction: column;
  min-width: 360px;
  min-height: 200px;
}
.win.minimized { display: none; }
.win.maximized {
  top: 60px !important;
  left: 0 !important;
  width: 100vw !important;
  height: calc(100vh - 92px) !important;
}
.win.active { z-index: 50; }

/* Titlebar */
.titlebar {
  height: var(--title-h);
  background: linear-gradient(180deg, var(--teal-1), var(--teal-3));
  color: #fff;
  font-weight: bold;
  display: flex;
  align-items: center;
  padding: 0 4px 0 6px;
  cursor: move;
  user-select: none;
  border-bottom: 1px solid var(--teal-deep);
}
.win:not(.active) .titlebar {
  background: linear-gradient(180deg, #7a9a9a, #5a7a7a);
}
.title-icon { margin-right: 4px; }
.title-text { flex: 1; font-size: 12px; letter-spacing: 0.3px; }
.title-buttons { display: flex; gap: 2px; }
.btn-title {
  width: 18px; height: 16px;
  background: linear-gradient(180deg, #f6f6f6, #c0c0c0);
  border: 1px solid #444;
  color: #000;
  font-size: 11px;
  line-height: 1;
  padding: 0;
  border-radius: 0;
}
.btn-title:hover { background: linear-gradient(180deg, #fff, #d8d8d8); }
.btn-title:active { background: linear-gradient(180deg, #c0c0c0, #f6f6f6); }

/* Per-window placement */
.win-search    { top: 70px;  left: 24px;   width: 640px; height: 360px; }
.win-library   { top: 70px;  left: 700px;  width: 480px; height: 320px; }
.win-transfers { top: 450px; left: 24px;   width: 640px; height: 240px; }
.win-hotlist   { top: 450px; left: 700px;  width: 280px; height: 240px; }
.win-users     { top: 70px;  left: 700px;  width: 460px; height: 320px; }
.win-chat      { top: 250px; left: 320px;  width: 520px; height: 360px; }
.win-player    { top: 70px;  left: 860px; width: 360px; height: 200px; }

@media (max-width: 1100px) {
  .win-library { left: 24px; top: 460px; }
  .win-hotlist { left: 24px; top: 800px; }
  .win-users   { left: 24px; }
}

/* Window toolbar (between title and table) */
.win-toolbar {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 6px;
  background: var(--chrome-mid);
  border-bottom: 1px solid var(--chrome-dark);
}
.win-toolbar .search-input,
.win-toolbar .search-filter,
.win-toolbar select,
.win-toolbar input[type="number"] {
  height: 20px;
  padding: 1px 4px;
  border: 1px solid #7f7f7f;
  background: #fff;
  font-size: 11px;
}
.search-input { flex: 1; min-width: 100px; }
.search-bitrate, .search-max {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
}
.muted { color: #666; font-size: 11px; }

/* =============================================================
   BUTTONS
   ============================================================= */
.btn {
  background: linear-gradient(180deg, #fafafa, #d4d4d4);
  border: 1px solid #7f7f7f;
  padding: 3px 10px;
  font-size: 11px;
  border-radius: 2px;
  box-shadow: inset 1px 1px 0 #fff, inset -1px -1px 0 #888;
}
.btn:hover { background: linear-gradient(180deg, #fff, #e0e0e0); }
.btn:active { box-shadow: inset 1px 1px 0 #888, inset -1px -1px 0 #fff; }
.btn.primary {
  background: linear-gradient(180deg, var(--teal-2), var(--teal-1));
  color: #fff;
  border-color: var(--teal-deep);
  font-weight: bold;
}
.btn.primary:hover {
  background: linear-gradient(180deg, var(--teal-1), var(--teal-3));
}

/* =============================================================
   TABLES
   ============================================================= */
.table-wrap {
  flex: 1;
  overflow: auto;
  background: #fff;
  border: 1px solid #7f7f7f;
  margin: 4px;
  position: relative;
}
.results-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 11px;
  table-layout: fixed;
}
.results-table thead {
  position: sticky;
  top: 0;
  z-index: 2;
}
.results-table thead th {
  background: linear-gradient(180deg, #e8e8e8, #c8c8c8);
  border: 1px solid #888;
  border-left: none;
  border-right: none;
  padding: 2px 6px;
  text-align: left;
  font-weight: bold;
  white-space: nowrap;
}
.results-table tbody td {
  padding: 2px 6px;
  height: var(--row-h);
  border-bottom: 1px solid #e0e0e0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.results-table tbody tr:nth-child(even) td { background: var(--row-alt); }
.results-table tbody tr:hover td { background: #fff8c4; }
.results-table tbody tr.selected td {
  background: #316ac5;
  color: #fff;
}
.results-table tbody tr.empty td {
  text-align: center;
  color: #888;
  font-style: italic;
  padding: 10px;
}

.col-filename { width: 42%; }
.col-user     { width: 18%; }
.col-bitrate  { width: 10%; }
.col-length   { width: 10%; }
.col-size     { width: 10%; }
.col-status   { width: 10%; }
.col-speed    { width: 18%; }
.col-count    { width: 12%; }
.col-progress { width: 26%; }
.col-play     { width: 28px; }

a.play-link {
  display: inline-block;
  width: 18px;
  height: 16px;
  line-height: 14px;
  text-align: center;
  text-decoration: none;
  color: var(--teal-deep);
  border: 1px solid #888;
  background: linear-gradient(180deg, #fafafa, #d4d4d4);
  font-size: 10px;
  border-radius: 1px;
  cursor: pointer;
}
a.play-link:hover {
  background: linear-gradient(180deg, var(--teal-2), var(--teal-3));
  color: #fff;
  border-color: var(--teal-deep);
}
a.play-link.playing {
  background: linear-gradient(180deg, var(--teal-2), var(--teal-1));
  color: #fff;
  border-color: var(--teal-deep);
}

a.filelink {
  color: var(--link-blue);
  text-decoration: underline;
  cursor: pointer;
}
a.filelink:hover { color: var(--link-blue-v); }
a.userlink {
  color: var(--link-blue);
  text-decoration: underline;
  cursor: pointer;
}
a.userlink:hover { color: var(--link-blue-v); }

/* Progress bar in transfers */
.progress {
  position: relative;
  height: 12px;
  background: #fff;
  border: 1px solid #888;
  border-radius: 1px;
  overflow: hidden;
  width: 100%;
}
.progress-bar {
  height: 100%;
  background: linear-gradient(180deg, var(--teal-2), var(--teal-3));
  transition: width 0.2s linear;
}
.progress-text {
  position: absolute;
  inset: 0;
  text-align: center;
  font-size: 10px;
  line-height: 12px;
  color: #000;
  mix-blend-mode: difference;
}

/* =============================================================
   STATUSBAR
   ============================================================= */
.statusbar {
  background: var(--chrome-mid);
  border-top: 1px solid var(--chrome-dark);
  padding: 3px 8px;
  font-size: 11px;
  color: #333;
  display: flex;
  align-items: center;
  gap: 6px;
}

/* =============================================================
   LOGIN OVERLAY
   ============================================================= */
.login-overlay {
  position: fixed;
  inset: 0;
  background: rgba(20, 40, 40, 0.65);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}
.login-overlay.hidden { display: none; }

.login-window {
  width: 340px;
  background: var(--chrome-mid);
  border: 1px solid var(--chrome-edge);
  box-shadow: 2px 2px 0 var(--chrome-dark);
}
.login-titlebar {
  background: linear-gradient(180deg, var(--teal-1), var(--teal-3));
  color: #fff;
  font-weight: bold;
  height: 22px;
  display: flex;
  align-items: center;
  padding: 0 4px 0 6px;
}
.login-title-icon {
  display: inline-block;
  width: 14px; height: 14px;
  background: var(--teal-1);
  color: #fff;
  font-weight: bold;
  font-size: 10px;
  text-align: center;
  line-height: 14px;
  margin-right: 4px;
  border: 1px solid #fff;
}
.login-title-text { flex: 1; font-size: 12px; }
.login-close {
  background: linear-gradient(180deg, #f6f6f6, #c0c0c0);
  border: 1px solid #444;
  width: 18px; height: 16px;
  font-size: 11px;
  line-height: 1;
  padding: 0;
}
.login-body { padding: 12px; }
.login-logo {
  text-align: center;
  font-size: 28px;
  font-weight: bold;
  margin-bottom: 12px;
  letter-spacing: -1px;
}
.login-logo .napster-n {
  color: var(--teal-1);
  font-size: 32px;
}
.login-logo .napster-rest {
  color: #222;
}
.login-form {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.login-form label {
  display: grid;
  grid-template-columns: 90px 1fr;
  align-items: center;
  font-size: 11px;
}
.login-form input,
.login-form select {
  height: 20px;
  padding: 1px 4px;
  border: 1px solid #7f7f7f;
  background: #fff;
  font-size: 11px;
}
.login-checkbox {
  display: flex !important;
  grid-template-columns: none !important;
  gap: 4px;
  margin-top: 4px;
  align-items: center;
}
.login-actions {
  display: flex;
  gap: 6px;
  justify-content: flex-end;
  margin-top: 12px;
}
.login-status {
  margin-top: 10px;
  padding: 4px 6px;
  border: 1px solid var(--chrome-dark);
  background: var(--win-bg);
  font-size: 11px;
  color: #444;
  min-height: 18px;
}
.login-status.connecting { color: var(--teal-deep); font-weight: bold; }
.login-status.connected  { color: var(--green-online); font-weight: bold; }
.login-status.error      { color: var(--red-busy); font-weight: bold; }

/* =============================================================
   CONTEXT MENU
   ============================================================= */
.ctx-menu {
  position: absolute;
  background: var(--chrome-mid);
  border: 1px solid var(--chrome-edge);
  box-shadow: 2px 2px 0 var(--chrome-dark);
  list-style: none;
  margin: 0;
  padding: 2px;
  min-width: 160px;
  z-index: 2000;
  font-size: 11px;
}
.ctx-menu li {
  padding: 3px 16px;
  cursor: pointer;
}
.ctx-menu li:hover {
  background: var(--teal-1);
  color: #fff;
}
.ctx-menu li.sep {
  border-top: 1px solid var(--chrome-dark);
  margin: 2px 4px;
  padding: 0;
  pointer-events: none;
}

/* =============================================================
   DIALOGS
   ============================================================= */
.dialog {
  position: fixed;
  inset: 0;
  background: rgba(20, 40, 40, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1500;
}
.dialog[hidden] { display: none; }
.dialog-window {
  background: var(--chrome-mid);
  border: 1px solid var(--chrome-edge);
  box-shadow: 2px 2px 0 var(--chrome-dark);
  width: 380px;
  display: flex;
  flex-direction: column;
  max-height: 80vh;
}
.dialog-window.wide { width: 560px; }
.dialog-body {
  padding: 8px;
  overflow: auto;
  flex: 1;
  background: var(--win-bg);
}
.dialog-body .results-table { background: #fff; }
.dialog-actions {
  display: flex;
  justify-content: flex-end;
  padding: 6px 8px;
  background: var(--chrome-mid);
  border-top: 1px solid var(--chrome-dark);
}

/* Info dialog key/value list */
.info-grid {
  display: grid;
  grid-template-columns: 110px 1fr;
  gap: 4px 8px;
  font-size: 11px;
}
.info-grid dt {
  color: var(--teal-deep);
  font-weight: bold;
  text-align: right;
}
.info-grid dd { margin: 0; }

/* =============================================================
   CHAT
   ============================================================= */
.chat-log {
  flex: 1;
  margin: 4px;
  padding: 6px 8px;
  background: #fff;
  border: 1px solid #7f7f7f;
  overflow-y: auto;
  font-family: var(--font-mono);
  font-size: 11px;
  line-height: 1.4;
}
.chat-msg { margin: 0 0 2px 0; }
.chat-msg .chat-who { color: var(--teal-deep); font-weight: bold; }
.chat-msg.system   { color: #888; font-style: italic; }
.chat-msg.self .chat-who { color: var(--link-blue); }
.chat-input-row {
  display: flex;
  gap: 6px;
  padding: 4px 6px 6px;
  background: var(--chrome-mid);
  border-top: 1px solid var(--chrome-dark);
}
.chat-input-row input {
  flex: 1;
  height: 22px;
  padding: 2px 4px;
  border: 1px solid #7f7f7f;
  background: #fff;
}

/* =============================================================
   NOW PLAYING WINDOW
   ============================================================= */
.player-now {
  padding: 10px 8px 6px;
  background: linear-gradient(180deg, #fff, #ece9d8);
  border-bottom: 1px solid var(--chrome-dark);
}
.player-track {
  font-size: 12px;
  font-weight: bold;
  color: #222;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-family: var(--font-mono);
}
.player-from {
  font-size: 10px;
  color: var(--teal-deep);
  margin-top: 2px;
}
.player-progress-row {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 8px 2px;
  background: var(--win-bg);
}
.player-progress {
  flex: 1;
  height: 12px;
  background: #fff;
  border: 1px solid #888;
  border-radius: 1px;
  overflow: hidden;
  cursor: pointer;
  position: relative;
}
.player-progress-fill {
  height: 100%;
  background: linear-gradient(180deg, var(--teal-2), var(--teal-3));
  width: 0;
  transition: width 0.15s linear;
}
.player-time {
  font-family: var(--font-mono);
  font-size: 10px;
  color: #333;
  min-width: 80px;
  text-align: right;
}
.player-controls {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 6px 8px;
  background: var(--win-bg);
  border-top: 1px solid var(--chrome-dark);
}
.player-controls .btn {
  min-width: 36px;
}
.player-vol {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  margin-left: 6px;
}
.player-vol input[type=range] {
  width: 80px;
  height: 14px;
}
.player-controls select {
  height: 20px;
  border: 1px solid #7f7f7f;
  background: #fff;
  margin-left: 4px;
  font-size: 10px;
}
.player-statusbar {
  padding: 4px 8px;
  font-size: 10px;
  color: #555;
  background: var(--chrome-mid);
  border-top: 1px solid var(--chrome-dark);
}
.player-statusbar.playing {
  color: var(--green-online);
  font-weight: bold;
}

/* =============================================================
   FOOTER
   ============================================================= */
.footer {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  height: 22px;
  background: linear-gradient(180deg, var(--teal-1), var(--teal-3));
  color: #fff;
  display: flex;
  align-items: center;
  padding: 0 10px;
  gap: 6px;
  font-size: 11px;
  border-top: 1px solid var(--teal-deep);
}
.footer .sep { opacity: 0.6; }

/* =============================================================
   SCROLLBARS
   ============================================================= */
.table-wrap::-webkit-scrollbar,
.chat-log::-webkit-scrollbar,
.dialog-body::-webkit-scrollbar {
  width: 14px;
  height: 14px;
}
.table-wrap::-webkit-scrollbar-thumb,
.chat-log::-webkit-scrollbar-thumb,
.dialog-body::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, #e8e8e8, #c0c0c0);
  border: 1px solid #888;
}
.table-wrap::-webkit-scrollbar-track,
.chat-log::-webkit-scrollbar-track,
.dialog-body::-webkit-scrollbar-track {
  background: #d8d8d8;
}
/* Fix: each window is its own stacking context, so sticky table headers stay inside it */
.win { isolation: isolate; }
