/* Authentic Windows 98 Retro Desktop & Mobile Responsive Theme */

:root {
  --win-teal: #008080;
  --win-gray: #c0c0c0;
  --win-blue: #000080;
  --win-blue-grad: #1084d0;
  --win-dark-gray: #808080;
  --win-light: #ffffff;
  --win-black: #000000;
  --win-font: "MS Sans Serif", Tahoma, Geneva, "Segoe UI", sans-serif;
  --win-mono: "Courier New", Courier, monospace;
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  background-color: var(--win-teal);
  font-family: var(--win-font);
  font-size: 13px;
  overflow: hidden;
  user-select: none;
  -webkit-font-smoothing: none;
}

/* Authentication State & Desktop Visibility */
body.auth-pending #desktop .desktop-icons,
body.auth-pending #main-window,
body.auth-pending #taskbar,
body.auth-pending #logon-screen {
  display: none !important;
}

body.unauthenticated #desktop .desktop-icons,
body.unauthenticated #main-window,
body.unauthenticated #taskbar {
  display: none !important;
}

body.unauthenticated #logon-screen {
  display: flex !important;
}

body.authenticated #logon-screen {
  display: none !important;
}

body.authenticated #desktop .desktop-icons {
  display: flex !important;
}

body.authenticated #main-window {
  display: flex;
}

body.authenticated #taskbar {
  display: flex !important;
}

/* Authentic Windows 98 Logon Dialog */
.logon-overlay {
  position: fixed;
  inset: 0;
  background-color: var(--win-teal);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1500;
  padding: 16px;
}

.logon-dialog {
  width: 470px;
  max-width: 100%;
  box-shadow: 3px 3px 10px rgba(0, 0, 0, 0.4);
  position: relative;
}

.logon-body {
  padding: 16px 14px 14px 14px;
}

.logon-main-row {
  display: flex;
  align-items: flex-start;
  gap: 14px;
}

.logon-graphic-col {
  flex-shrink: 0;
  padding-top: 4px;
}

.logon-graphic-img {
  width: 44px;
  height: 44px;
  image-rendering: pixelated;
}

.logon-content-col {
  flex: 1;
  min-width: 0;
}

.logon-prompt {
  margin: 0 0 14px 0;
  font-size: 12px;
  line-height: 1.4;
  color: #000000;
}

.logon-field-row {
  display: flex;
  align-items: center;
  margin-bottom: 10px;
  gap: 8px;
}

.logon-field-row label {
  width: 80px;
  flex-shrink: 0;
  font-size: 12px;
  color: #000000;
}

.logon-field-row input[type="text"],
.logon-field-row input[type="password"] {
  flex: 1;
  min-width: 0;
  height: 34px;
  font-size: 16px !important; /* Prevents auto-zoom on iOS / iPhone 15 Pro */
  padding: 4px 8px;
  background-color: #ffffff;
  border: 2px inset #dfdfdf;
  box-shadow: inset 1px 1px #0a0a0a, inset -1px -1px #fff;
  border-radius: 0;
  box-sizing: border-box;
}

.logon-actions-col {
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex-shrink: 0;
}

.logon-actions-col button,
.dialog-buttons button {
  min-height: 38px !important; /* Mobile touch targets >= 38px */
  min-width: 80px !important;
  font-size: 13px !important;
  padding: 6px 14px !important;
  cursor: pointer;
}

@media (max-width: 520px) {
  .logon-dialog {
    width: 100%;
    max-width: 380px;
    margin: 0 auto;
  }

  .logon-main-row {
    flex-direction: column;
    gap: 12px;
  }

  .logon-graphic-col {
    display: flex;
    align-items: center;
    gap: 10px;
  }

  .logon-graphic-img {
    width: 36px;
    height: 36px;
  }

  .logon-field-row {
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
  }

  .logon-field-row label {
    width: 100%;
  }

  .logon-field-row input[type="text"],
  .logon-field-row input[type="password"] {
    width: 100%;
    font-size: 16px !important;
    height: 38px;
  }

  .logon-actions-col {
    flex-direction: row;
    justify-content: flex-end;
    width: 100%;
    margin-top: 8px;
    gap: 10px;
  }

  .logon-actions-col button {
    flex: 1;
    min-height: 40px !important;
  }
}

/* Desktop Canvas */
#desktop {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 36px;
  overflow: auto;
  padding: 10px;
}

/* Desktop Icons */
.desktop-icons {
  display: flex;
  flex-direction: column;
  flex-wrap: wrap;
  align-content: flex-start;
  gap: 16px;
  width: 90px;
  z-index: 1;
}

.desktop-icon {
  width: 76px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  cursor: pointer;
  padding: 4px;
}

.desktop-icon img, .desktop-icon svg {
  width: 32px;
  height: 32px;
  margin-bottom: 4px;
  image-rendering: pixelated;
}

.desktop-icon-label {
  color: #ffffff;
  font-size: 11px;
  text-shadow: 1px 1px 1px #000000;
  line-height: 1.2;
  padding: 2px 4px;
  word-break: break-word;
}

.desktop-icon.selected .desktop-icon-label {
  background-color: var(--win-blue);
  outline: 1px dotted #ffff00;
}

/* Main Windows 98 Window */
.window {
  position: absolute;
  top: 20px;
  left: 100px;
  width: 960px;
  max-width: calc(100vw - 120px);
  max-height: calc(100vh - 64px);
  display: flex;
  flex-direction: column;
  box-shadow: 3px 3px 10px rgba(0, 0, 0, 0.4);
  z-index: 10;
}

.window.active-window {
  z-index: 20;
}

.title-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 3px 4px 3px 4px;
  background: linear-gradient(90deg, var(--win-blue), var(--win-blue-grad));
  color: white;
  cursor: move;
}

.title-bar.inactive {
  background: linear-gradient(90deg, #808080, #b5b5b5);
}

.title-bar-text {
  font-weight: bold;
  letter-spacing: 0;
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
}

.title-bar-text img {
  width: 16px;
  height: 16px;
}

.title-bar-controls {
  display: flex;
  gap: 2px;
}

/* Menu Bar */
.window-menu-bar {
  display: flex;
  background-color: var(--win-gray);
  border-bottom: 1px solid var(--win-dark-gray);
  padding: 2px 6px;
  gap: 2px;
  font-size: 12px;
  position: relative;
}

.menu-item {
  padding: 2px 8px;
  cursor: pointer;
  position: relative;
}

.menu-item:hover, .menu-item.active {
  background-color: var(--win-blue);
  color: white;
}

.menu-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  background-color: var(--win-gray);
  border-top: 2px solid #fff;
  border-left: 2px solid #fff;
  border-right: 2px solid #000;
  border-bottom: 2px solid #000;
  box-shadow: 2px 2px 4px rgba(0,0,0,0.3);
  min-width: 170px;
  display: none;
  z-index: 100;
  padding: 2px;
  color: #000;
}

.menu-dropdown.show {
  display: block;
}

.menu-dropdown-item {
  padding: 4px 14px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
}

.menu-dropdown-item:hover {
  background-color: var(--win-blue);
  color: white;
}

.menu-divider {
  height: 1px;
  background-color: var(--win-dark-gray);
  border-bottom: 1px solid #fff;
  margin: 3px 2px;
}

/* Toolbar */
.window-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 8px;
  background-color: var(--win-gray);
  border-bottom: 2px groove #fff;
  flex-wrap: wrap;
}

.toolbar-wallet-select {
  font-weight: bold;
  font-size: 12px;
  padding: 2px 4px;
}

.toolbar-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  padding: 3px 8px;
}

.toolbar-btn img {
  width: 16px;
  height: 16px;
}

.status-badge {
  display: inline-block;
  padding: 2px 6px;
  font-size: 11px;
  font-weight: bold;
  border: 1px solid #000;
}

.status-badge.connected {
  background-color: #008000;
  color: #fff;
}

.status-badge.disconnected {
  background-color: #c00000;
  color: #fff;
}

.status-badge.unconnected {
  background-color: #e68a00;
  color: #fff;
}

/* Window Content Body */
.window-body {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
  margin: 0;
  background-color: var(--win-gray);
}

/* Tabs */
menu[role="tablist"] {
  display: flex;
  margin: 0 0 -2px 0;
  padding: 0 0 0 4px;
  list-style: none;
  gap: 2px;
  flex-wrap: wrap;
  z-index: 2;
  position: relative;
}

button[role="tab"] {
  font-size: 12px;
  padding: 4px 10px;
  cursor: pointer;
  background: var(--win-gray);
  border-top: 2px solid #fff;
  border-left: 2px solid #fff;
  border-right: 2px solid #000;
  border-bottom: none;
  outline: none;
}

button[role="tab"][aria-selected="true"] {
  font-weight: bold;
  margin-top: -2px;
  padding-top: 6px;
  padding-bottom: 5px;
  background: var(--win-gray);
  border-bottom: 2px solid var(--win-gray);
  z-index: 3;
}

article[role="tabpanel"] {
  display: none;
  border: 2px solid;
  border-color: #fff #000 #000 #fff;
  background: var(--win-gray);
  padding: 12px;
  position: relative;
  z-index: 1;
}

article[role="tabpanel"].active {
  display: block;
}

/* Cards & Panels inside tab */
.panel-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 12px;
  margin-bottom: 12px;
}

.win-card {
  border: 2px groove #fff;
  padding: 10px;
  background: var(--win-gray);
}

.win-card-title {
  font-weight: bold;
  font-size: 12px;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 6px;
  border-bottom: 1px solid var(--win-dark-gray);
  padding-bottom: 4px;
}

/* Address Box */
.address-row {
  margin-bottom: 8px;
  background: #fff;
  padding: 6px;
  border: 2px inset #fff;
}

.address-label {
  font-size: 11px;
  color: #404040;
  font-weight: bold;
  margin-bottom: 2px;
  display: flex;
  justify-content: space-between;
}

.address-val {
  font-family: var(--win-mono);
  font-size: 11px;
  word-break: break-all;
  user-select: all;
  color: #000;
}

.btn-inline {
  padding: 2px 6px;
  font-size: 11px;
  cursor: pointer;
  margin-left: 4px;
}

/* Tables */
.table-container {
  max-height: 320px;
  overflow-y: auto;
  border: 2px inset #fff;
  background: #fff;
  margin-bottom: 8px;
}

table.win-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
  text-align: left;
}

table.win-table th {
  background: var(--win-gray);
  position: sticky;
  top: 0;
  padding: 4px 8px;
  font-size: 11px;
  border-top: 1px solid #fff;
  border-left: 1px solid #fff;
  border-right: 1px solid var(--win-dark-gray);
  border-bottom: 1px solid var(--win-dark-gray);
  white-space: nowrap;
}

table.win-table td {
  padding: 4px 8px;
  border-bottom: 1px solid #e0e0e0;
  border-right: 1px solid #f0f0f0;
  white-space: nowrap;
}

table.win-table tr:hover {
  background-color: #000080;
  color: #fff;
}

table.win-table tr:hover a {
  color: #ffff00;
}

.mono {
  font-family: var(--win-mono);
}

/* Forms */
.form-group {
  margin-bottom: 10px;
}

.form-group label {
  display: block;
  font-weight: bold;
  margin-bottom: 3px;
  font-size: 12px;
}

.form-control {
  width: 100%;
  padding: 4px 6px;
  font-family: var(--win-font);
  font-size: 13px;
  border: 2px inset #fff;
  background: #fff;
}

.form-control:focus {
  outline: 1px dotted #000;
}

/* Status Bar */
.status-bar {
  display: flex;
  background-color: var(--win-gray);
  border-top: 1px solid var(--win-dark-gray);
  padding: 2px 4px;
  gap: 4px;
  font-size: 11px;
}

.status-bar-field {
  padding: 2px 6px;
  border: 2px inset #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.status-bar-field.flex-grow {
  flex-grow: 1;
}

/* Windows 98 Taskbar */
#taskbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  height: 36px;
  background-color: var(--win-gray);
  border-top: 2px solid #fff;
  border-bottom: 1px solid #000;
  display: flex;
  align-items: center;
  padding: 2px 4px;
  gap: 4px;
  z-index: 1000;
}

#start-button {
  font-weight: bold;
  font-size: 12px;
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  height: 28px;
  cursor: pointer;
}

#start-button.active {
  border-top: 2px solid #000;
  border-left: 2px solid #000;
  border-right: 2px solid #fff;
  border-bottom: 2px solid #fff;
  background-color: #d4d0c8;
}

#start-button img {
  width: 16px;
  height: 16px;
}

.taskbar-divider {
  width: 2px;
  height: 24px;
  border-left: 1px solid var(--win-dark-gray);
  border-right: 1px solid #fff;
  margin: 0 2px;
}

.taskbar-items {
  flex: 1;
  display: flex;
  gap: 4px;
  overflow-x: auto;
}

.taskbar-btn {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 3px 8px;
  height: 28px;
  font-size: 12px;
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  cursor: pointer;
  background-color: var(--win-gray);
}

.taskbar-btn.active {
  font-weight: bold;
  background-color: #e0e0e0;
  border-top: 2px solid #000;
  border-left: 2px solid #000;
  border-right: 2px solid #fff;
  border-bottom: 2px solid #fff;
}

.taskbar-btn img {
  width: 16px;
  height: 16px;
}

/* System Tray */
.system-tray {
  display: flex;
  align-items: center;
  gap: 6px;
  border: 2px inset #fff;
  padding: 2px 8px;
  height: 26px;
  background-color: var(--win-gray);
  font-size: 11px;
}

.tray-icon {
  width: 16px;
  height: 16px;
  cursor: pointer;
}

#tray-clock {
  font-family: var(--win-font);
  font-size: 11px;
  padding-left: 4px;
}

/* Start Menu Popup */
#start-menu {
  position: fixed;
  bottom: 36px;
  left: 2px;
  width: 230px;
  background-color: var(--win-gray);
  border-top: 2px solid #fff;
  border-left: 2px solid #fff;
  border-right: 2px solid #000;
  border-bottom: 2px solid #000;
  box-shadow: 3px 3px 6px rgba(0,0,0,0.4);
  display: none;
  z-index: 1001;
}

#start-menu.show {
  display: flex;
}

.start-menu-banner {
  width: 32px;
  background: linear-gradient(180deg, var(--win-blue), #1084d0);
  writing-mode: vertical-rl;
  transform: rotate(180deg);
  color: #fff;
  font-weight: bold;
  font-size: 16px;
  letter-spacing: 2px;
  padding: 10px 4px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
}

.start-menu-items {
  flex: 1;
  padding: 4px 2px;
}

.start-menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 12px;
  cursor: pointer;
  font-size: 12px;
}

.start-menu-item:hover {
  background-color: var(--win-blue);
  color: white;
}

.start-menu-item img {
  width: 24px;
  height: 24px;
}

/* Dialog Modals */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.3);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 2000;
}

.modal-overlay.show {
  display: flex;
}

.modal-dialog {
  width: 440px;
  max-width: 90vw;
  box-shadow: 4px 4px 12px rgba(0,0,0,0.5);
}

.dialog-content {
  display: flex;
  gap: 16px;
  padding: 16px;
}

.dialog-icon {
  width: 32px;
  height: 32px;
  flex-shrink: 0;
}

.dialog-text {
  flex: 1;
  font-size: 12px;
  line-height: 1.4;
}

.dialog-buttons {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 10px 16px 14px 16px;
}

/* QR Code Display */
.qr-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 10px;
  background: #fff;
  border: 2px inset #fff;
  margin: 10px 0;
}

#qrcode-view img, #qrcode-view canvas {
  margin: auto;
  display: block;
}

/* Responsive / iPhone 15 Pro Optimization */
@media (max-width: 768px) {
  html, body {
    overflow: auto;
  }

  #desktop {
    padding: 0;
    bottom: 42px;
  }

  .desktop-icons {
    display: none; /* Hide desktop icons on mobile to prioritize app window */
  }

  .window {
    position: static;
    top: 0;
    left: 0;
    width: 100% !important;
    max-width: 100% !important;
    height: calc(100vh - 42px) !important;
    max-height: calc(100vh - 42px) !important;
    border: none;
    box-shadow: none;
  }

  .window-body {
    padding: 6px;
  }

  .title-bar {
    padding: 6px 8px;
    font-size: 14px;
  }

  .window-toolbar {
    padding: 6px;
    gap: 6px;
  }

  .toolbar-btn {
    padding: 6px 10px;
    font-size: 12px;
  }

  menu[role="tablist"] {
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 2px;
  }

  button[role="tab"] {
    padding: 6px 12px;
    font-size: 13px;
    white-space: nowrap;
    min-height: 36px;
  }

  article[role="tabpanel"] {
    padding: 8px;
  }

  .panel-grid {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  table.win-table {
    font-size: 11px;
  }

  table.win-table th, table.win-table td {
    padding: 6px 6px;
  }

  .form-control {
    font-size: 16px; /* Prevents auto-zoom on iOS */
    padding: 8px 6px;
  }

  button {
    min-height: 36px;
  }

  #taskbar {
    height: 42px;
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }

  #start-button {
    height: 32px;
    padding: 4px 10px;
  }

  .taskbar-btn {
    height: 32px;
  }

  .status-bar {
    display: none; /* Save vertical screen space on mobile */
  }
}
