/* ════════════════════════════════════
   Topbar — Windows 95 Taskbar Style
   ════════════════════════════════════ */

/* ── Main taskbar ── */
#topbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 34px;
  background: #000080;
  border-bottom: 2px solid #000040;
  z-index: 1000;
  display: flex;
  align-items: stretch;
  font-family: 'Press Start 2P', monospace;
}

/* ─── OS branding (left) ─── */
#topbar-left {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  padding: 0 10px;
  gap: 7px;
}

#topbar-js-logo {
  font-family: 'Press Start 2P', monospace;
  font-size: 10px;
  font-weight: bold;
  color: #f5de19;
  display: inline-block;
  transform: scaleY(1.3);
  transform-origin: center;
  user-select: none;
  letter-spacing: 0.05em;
  text-shadow: 1px 1px 0 #000;
}

/* ── Separator line between start and taskbar ── */
#topbar-sep {
  width: 2px;
  background: #000060;
  align-self: stretch;
}

#topbar-os-icon {
  flex-shrink: 0;
  image-rendering: pixelated;
}

/* ── Taskbar buttons (center) ── */
#topbar-center {
  flex: 1;
  display: flex;
  visibility: hidden;
  align-items: center;
  gap: 3px;
  height: 100%;
  overflow: hidden;
  padding: 4px 8px;
}

.taskbar-btn {
  height: 30px;
  padding: 0 10px;
  border: 2px solid;
  border-color: #ffffff #808080 #808080 #ffffff;
  background: #c0c0c0;
  font-family: 'Press Start 2P', monospace;
  font-size: 8px;
  letter-spacing: 0.05em;
  transform: scaleY(1.3);
  transform-origin: center;
  color: #000000;
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex-shrink: 0;
  max-width: 160px;
}

.taskbar-btn:hover {
  background: #d4d0c8;
}

.taskbar-btn.active {
  border-color: #808080 #ffffff #ffffff #808080;
  background: #b8b4ac;
  box-shadow: inset 1px 1px 0 #808080;
}

/* ── System tray (right) — sunken box ── */
#topbar-right {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 6px;
  border: 2px solid;
  border-color: #000040 #4040c0 #4040c0 #000040;
  box-shadow: inset 1px 1px 0 #000060;
  margin: 5px 4px;
  padding: 0 8px;
  font-family: 'Press Start 2P', monospace;
  font-size: 8px;
  color: #ffffff;
}

#tray-clock {
  font-family: 'Press Start 2P', monospace;
  font-size: 8px;
  color: #ffffff;
  white-space: nowrap;
  padding-left: 4px;
  display: inline-block;
  flex-shrink: 0;              /* clock stays fully visible; other items give way */
  transform: scaleY(1.3);
  transform-origin: center;
}

/* ── Tray icon buttons ── */
.tray-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 20px;
  background: none;
  border: none;
  color: #ffffff;
  cursor: pointer;
  padding: 0;
  flex-shrink: 0;
}

.tray-btn:hover {
  background: rgba(255,255,255,0.2);
  color: #ffffff;
}

.tray-btn.active {
  background: rgba(255,255,255,0.2);
  color: #ffffff;
}

.tray-btn svg {
  stroke: currentColor;
}

/* ── Locale selector ── */
#topbar-locale {
  display: flex;
  align-items: center;
  position: relative;
  margin-left: 10px;
  margin-right: 10px;
}

.locale-tray-btn {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 0 6px;
  height: 20px;
  font-family: 'Press Start 2P', monospace;
  font-size: 8px;
  transform: scaleY(1.3);
  transform-origin: center;
  color: #ffffff;
  background: none;
  border: none;
  cursor: pointer;
  white-space: nowrap;
}

.locale-tray-btn:hover,
.locale-tray-btn.active {
  background: rgba(255,255,255,0.2);
  color: #ffffff;
}

.locale-chevron {
  flex-shrink: 0;
  transition: transform 0.18s;
}

.locale-tray-btn.active .locale-chevron {
  transform: rotate(180deg);
}

/* Win95 context menu */
.locale-dropdown {
  position: absolute;
  top: calc(100% + 2px);
  right: 0;
  min-width: 90px;
  background: #c0c0c0;
  border: 2px solid;
  border-color: #ffffff #808080 #808080 #ffffff;
  box-shadow: 2px 2px 0 #000000;
  list-style: none;
  margin: 0;
  padding: 2px;
  z-index: 2100;
}

.locale-dropdown[hidden] {
  display: none;
}

.locale-option {
  padding: 5px 10px;
  font-family: 'Press Start 2P', monospace;
  font-size: 8px;
  color: #000000;
  cursor: pointer;
  display: block;
  transform: scaleY(1.3);
  transform-origin: center;
}

.locale-option:hover {
  background: #000080;
  color: #ffffff;
}

.locale-option.selected {
  background: #000080;
  color: #ffffff;
}

/* ════════════════════════════════════
   Tray Popups — Win95 Dialog Style
   ════════════════════════════════════ */

.tray-popup {
  position: fixed;
  top: 34px;
  right: 8px;
  width: 220px;
  background: #c0c0c0;
  border: 2px solid;
  border-color: #ffffff #808080 #808080 #ffffff;
  box-shadow:
    inset -1px -1px #404040,
    inset 1px 1px #dfdfdf,
    3px 3px 0 #000000;
  z-index: 2000;
  padding: 0;
}

#audio-popup {
  right: 170px;
  width: 220px;
}

#battery-popup {
  right: 100px;
  width: 220px;
}

.tray-popup[hidden] {
  display: none;
}

/* Win95 dialog title bar inside popup */
.tray-popup .popup-header {
  background: #000080;
  padding: 4px 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0;
}

.tray-popup .popup-title {
  font-family: 'Press Start 2P', monospace;
  font-size: 8px;
  color: #ffffff;
  font-weight: normal;
  display: inline-block;
  transform: scaleY(1.3);
  transform-origin: left center;
}

.tray-popup .popup-card .popup-title {
  color: #000000;
}

.tray-popup .popup-subtitle {
  display: none;
}

.tray-popup .popup-header-icon {
  display: none;
}

.tray-popup .popup-header svg {
  flex-shrink: 0;
  opacity: 0.9;
}

/* Dialog body */
.popup-content {
  padding: 10px;
  font-family: 'Press Start 2P', monospace;
  font-size: 8px;
  color: #000000;
  line-height: 1.8;
}

.popup-card {
  padding: 8px;
  background: #c0c0c0;
  border-radius: 0;
}

.popup-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 10px;
  font-family: 'Press Start 2P', monospace;
  font-size: 8px;
  color: #000000;
}

.popup-row:last-child {
  margin-bottom: 0;
}

.popup-grid {
  display: grid;
  gap: 8px;
  font-family: 'Press Start 2P', monospace;
  font-size: 8px;
  color: #000000;
  line-height: 1.8;
}

.popup-grid strong {
  font-weight: bold;
}

/* Wi-Fi list */
.popup-item-list {
  padding: 4px;
  display: flex;
  flex-direction: column;
  gap: 0;
}

.popup-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  cursor: pointer;
  font-family: 'Press Start 2P', monospace;
  font-size: 8px;
  color: #000000;
}

.popup-item:hover {
  background: #000080;
  color: #ffffff;
}

.popup-item:hover .popup-item-icon,
.popup-item:hover .popup-item-name,
.popup-item:hover .popup-item-status,
.popup-item:hover .popup-item-check {
  color: #ffffff;
}

.popup-item.connected {
  background: none;
}

.popup-item-icon {
  color: #000000;
  flex-shrink: 0;
}

.popup-item-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.popup-item-name {
  font-family: 'Press Start 2P', monospace;
  font-size: 8px;
  color: #000000;
  display: inline-block;
  transform: scaleY(1.3);
  transform-origin: left center;
}

.popup-item-status {
  font-family: 'Press Start 2P', monospace;
  font-size: 8px;
  color: #000080;
  display: inline-block;
  transform: scaleY(1.3);
  transform-origin: left center;
}

.popup-item-check {
  color: #000080;
  font-size: 12px;
}

.wifi-switch {
  display: none;
}

/* Volume controls */
.panel-action-btn {
  width: 22px;
  height: 20px;
  border: 2px solid;
  border-color: #ffffff #808080 #808080 #ffffff;
  background: #c0c0c0;
  font-family: 'Press Start 2P', monospace;
  font-size: 8px;
  color: #000000;
  cursor: pointer;
  transform: scaleY(1.3);
  transform-origin: center;
}

.panel-action-btn:active {
  border-color: #808080 #ffffff #ffffff #808080;
}

.panel-meter {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.volume-bar {
  height: 12px;
  border: 2px solid;
  border-color: #808080 #ffffff #ffffff #808080;
  background: #ffffff;
  overflow: hidden;
}

.volume-fill {
  width: 76%;
  height: 100%;
  background: #000080;
}

.range-slider {
  width: 100%;
  accent-color: #000080;
}

/* ════════════════════════════════════
   Mobile — compact the topbar so the (now longer) clock always fits
   ════════════════════════════════════ */
@media (max-width: 768px), (max-height: 500px) {
  /* drop the text logo (keep the little monitor icon) to free space */
  #topbar-js-logo { display: none; }
  #topbar-left { padding: 0 6px; }

  /* Give tray items breathing room and stop them from shrinking below their
     content — shrinking was making the locale button overlap the icons. */
  #topbar-right {
    margin: 4px;
    padding: 0 7px;
    gap: 8px;
  }
  .tray-btn        { flex-shrink: 0; }
  .locale-tray-btn { flex-shrink: 0; }
  #topbar-locale {
    margin-left: 8px;
    margin-right: 6px;
    flex-shrink: 0;
  }

  /* Tray popups: anchor within the viewport so they're fully visible
     (audio/battery were positioned off to the left on narrow screens). */
  .tray-popup,
  #audio-popup,
  #battery-popup {
    left: 6px;
    right: 6px;
    width: auto;
  }
}
