/* =================================================================
   CRATE WARS 2 — Windows 95 "Dope Wars 2.1" Theme
   ================================================================= */

/* ── Reset & Base ─────────────────────────────────────────────── */
*, *::before, *::after {
  box-sizing: border-box;
  border-radius: 0 !important;
}

html, body {
  height: 100%;
  margin: 0;
  /* Win95 desktop teal background */
  background: #008080;
  color: #000000;
  font-family: 'MS Sans Serif', 'Tahoma', 'Arial', sans-serif;
  font-size: 11px;
  image-rendering: pixelated;
}

/* ── Win95 border utilities ───────────────────────────────────── */
/* Raised (outset) — buttons, panels, window borders */
.win-raised {
  border-top:    2px solid #ffffff;
  border-left:   2px solid #ffffff;
  border-bottom: 2px solid #808080;
  border-right:  2px solid #808080;
}

/* Sunken (inset) — text boxes, status displays, table wrap */
.win-sunken {
  border-top:    2px solid #808080;
  border-left:   2px solid #808080;
  border-bottom: 2px solid #ffffff;
  border-right:  2px solid #ffffff;
}

/* ── App Window — fixed size like Dope Wars 2.1 ───────────────── */
body {
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 24px;
  min-height: 100vh;
}

#app {
  /* Fixed width matching classic Dope Wars window: ~510px */
  width: 510px;
  min-width: 510px;
  max-width: 510px;
  display: flex;
  flex-direction: column;
  background: #c0c0c0;
  /* Window border — outer raised edge */
  border-top:    2px solid #ffffff;
  border-left:   2px solid #ffffff;
  border-bottom: 2px solid #404040;
  border-right:  2px solid #404040;
  box-shadow: 2px 2px 8px rgba(0,0,0,0.5);
}

/* ── Title Bar (Win95 caption style) ─────────────────────────── */
#topbar {
  background: #000080;
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 3px 6px;
  border-bottom: 2px solid #808080;
  flex-shrink: 0;
  gap: 8px;
}

#titleBlock {
  display: flex;
  align-items: baseline;
  gap: 8px;
}

#title {
  font-weight: bold;
  font-size: 11px;
  color: #ffffff;
  letter-spacing: 0.05em;
}

#subtitle {
  color: #aaaacc;
  font-size: 10px;
}

#topActions {
  display: flex;
  gap: 4px;
}

/* ── Universal Button ─────────────────────────────────────────── */
button {
  appearance: none;
  background: #c0c0c0;
  color: #000000;
  font-family: 'MS Sans Serif', 'Tahoma', 'Arial', sans-serif;
  font-size: 11px;
  padding: 2px 10px;
  cursor: pointer;
  border-top:    2px solid #ffffff;
  border-left:   2px solid #ffffff;
  border-bottom: 2px solid #808080;
  border-right:  2px solid #808080;
  white-space: nowrap;
  min-width: 75px;
  text-align: center;
  line-height: 16px;
}

button:active:not(:disabled) {
  border-top:    2px solid #808080;
  border-left:   2px solid #808080;
  border-bottom: 2px solid #ffffff;
  border-right:  2px solid #ffffff;
  padding: 3px 9px 1px 11px; /* slight shift to simulate press */
}

button:disabled {
  color: #808080;
  cursor: default;
  /* disabled buttons keep the raised border but text goes gray */
}

button:focus {
  outline: 1px dotted #000000;
  outline-offset: -4px;
}

/* Title-bar control buttons (close/min) — tiny square */
#topActions button {
  min-width: 18px;
  padding: 0 4px;
  line-height: 14px;
  font-size: 10px;
  font-weight: bold;
}

/* ── Main Layout — single-column stacked (fits 510px window) ──── */
#layout {
  display: flex;
  flex-direction: column;
  gap: 0;
  padding: 3px;
  align-items: stretch;
  flex: 1;
}

/* On wider screens, use a compact 2-column layout */
@media (min-width: 800px) {
  /* Keep single column — this is a windowed app, not responsive */
}

/* ── Generic Panel (raised box) ───────────────────────────────── */
.panel {
  border-top:    2px solid #ffffff;
  border-left:   2px solid #ffffff;
  border-bottom: 2px solid #808080;
  border-right:  2px solid #808080;
  background: #c0c0c0;
  padding: 4px;
  margin-bottom: 4px;
}

.panelTitle {
  background: #000080;
  color: #ffffff;
  font-size: 11px;
  font-weight: bold;
  padding: 1px 4px;
  margin-bottom: 4px;
}

/* ── Status "Black Box" ───────────────────────────────────────── */
#statusGrid {
  background: #000000;
  border-top:    2px solid #808080;
  border-left:   2px solid #808080;
  border-bottom: 2px solid #ffffff;
  border-right:  2px solid #ffffff;
  padding: 5px 8px;
  display: grid;
  gap: 2px;
  font-family: 'Courier New', 'Lucida Console', monospace;
  font-size: 11px;
}

.kv {
  display: grid;
  grid-template-columns: 60px 1fr;
  gap: 4px;
  align-items: baseline;
  line-height: 1.5;
}

.k {
  color: #00ff00;   /* lime green labels */
  font-size: 11px;
}

.v {
  color: #ffff00;   /* yellow values */
  font-weight: bold;
  text-align: right;
}

/* Special coloring for lease/debt */
#leaseVal {
  color: #ff4444;
}

/* ── Travel Buttons ───────────────────────────────────────────── */
#travelGrid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
}

.travelBtn {
  display: block;
  text-align: left;
  padding: 2px 6px;
  font-size: 10px;
  min-width: 0;
  line-height: 14px;
  white-space: normal;
}

.travelName {
  font-weight: bold;
  font-size: 10px;
}

.travelDesc {
  /* hide description to save space — classic Dope Wars doesn't show sub-text */
  display: none;
}

#travelHint {
  margin-top: 4px;
  color: #444444;
  font-size: 10px;
}

/* ── Equipment List ───────────────────────────────────────────── */
#equipList {
  display: grid;
  gap: 3px;
}

.equipRow {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 6px;
  align-items: center;
  border-bottom: 1px solid #808080;
  padding-bottom: 2px;
}

.equipName {
  font-weight: bold;
  font-size: 10px;
}

.equipDesc {
  color: #444444;
  font-size: 10px;
  line-height: 1.2;
}

/* ── Market Note Bar ──────────────────────────────────────────── */
#marketNote {
  background: #ffffff;
  border-top:    2px solid #808080;
  border-left:   2px solid #808080;
  border-bottom: 2px solid #ffffff;
  border-right:  2px solid #ffffff;
  padding: 2px 6px;
  font-size: 10px;
  color: #000080;
  margin-bottom: 4px;
  line-height: 1.4;
}

/* ── Tables (Market & Inventory) ──────────────────────────────── */
.tableWrap {
  overflow: auto;
  border-top:    2px solid #808080;
  border-left:   2px solid #808080;
  border-bottom: 2px solid #ffffff;
  border-right:  2px solid #ffffff;
  background: #ffffff;
}

table {
  width: 100%;
  border-collapse: collapse;
  background: #ffffff;
}

th, td {
  padding: 1px 4px;
  height: 19px;
  border-right: 1px solid #c0c0c0;
  border-bottom: 1px solid #c0c0c0;
  vertical-align: middle;
  white-space: nowrap;
  font-size: 11px;
}

th {
  position: sticky;
  top: 0;
  background: #c0c0c0;
  text-align: left;
  font-weight: bold;
  font-size: 11px;
  color: #000000;
  border-bottom: 2px solid #808080;
  border-right: 1px solid #808080;
}

/* Selected row — Win95 dark blue highlight */
tr.selected td,
tr:focus-within td {
  background: #000080;
  color: #ffffff;
}

tr:hover td {
  background: #000080;
  color: #ffffff;
}

.colGenre  { width: 38%; }
.colPrice  { width: 20%; }
.colOwned  { width: 14%; }
.colQty    { width: 12%; }
.colActions { width: 16%; }

.genreName {
  font-weight: bold;
  font-size: 11px;
}

.genreTag {
  display: inline;
  margin-left: 4px;
  font-size: 10px;
  color: #800000;
  font-weight: normal;
}

/* ── Row action buttons (inside table) ────────────────────────── */
.rowActions {
  display: flex;
  gap: 3px;
  flex-wrap: nowrap;
}

.rowActions button {
  padding: 0 5px;
  font-size: 10px;
  min-width: 30px;
  line-height: 14px;
}

/* Number input (qty) */
input[type="number"] {
  width: 36px;
  padding: 0 2px;
  font-family: 'MS Sans Serif', 'Tahoma', 'Arial', sans-serif;
  font-size: 11px;
  border-top:    2px solid #808080;
  border-left:   2px solid #808080;
  border-bottom: 2px solid #ffffff;
  border-right:  2px solid #ffffff;
  background: #ffffff;
  color: #000000;
}

/* ── Action column buttons — "primary" and "danger" ───────────── */
/* In Win95 they're all the same gray — color comes from label only */
.primary, .danger {
  /* just use context of the label, not color — classic Win95 style */
}

/* ── Tab Navigation (Win95-style) ───────────────────────────────── */
#tabNav {
  display: flex;
  gap: 0;
  padding: 4px 4px 0 4px;
  background: #c0c0c0;
}

.tab-btn {
  appearance: none;
  background: #c0c0c0;
  color: #000000;
  font-family: 'MS Sans Serif', 'Tahoma', 'Arial', sans-serif;
  font-size: 11px;
  padding: 3px 12px;
  cursor: pointer;
  border-top:    2px solid #ffffff;
  border-left:   2px solid #ffffff;
  border-bottom: 2px solid #808080;
  border-right:  2px solid #808080;
  border-bottom-left-radius: 0;
  border-bottom-right-radius: 0;
  margin-right: -1px;
  min-width: 60px;
  text-align: center;
  position: relative;
  z-index: 1;
}

.tab-btn:hover {
  background: #d0d0d0;
}

.tab-btn.active {
  background: #ffffff;
  border-bottom: 2px solid #ffffff;
  z-index: 3;
  font-weight: bold;
}

.tab-panel {
  display: none;
}

.tab-panel.active {
  display: block;
}

#tabPanels {
  background: #c0c0c0;
  padding: 4px;
  border-top: 2px solid #808080;
  position: relative;
  z-index: 2;
}

/* ── Log Window ───────────────────────────────────────────────── */
#logPanel {
  min-height: 200px;
}

#log {
  height: 200px;
  overflow-y: scroll;
  background: #ffffff;
  border-top:    2px solid #808080;
  border-left:   2px solid #808080;
  border-bottom: 2px solid #ffffff;
  border-right:  2px solid #ffffff;
  padding: 3px 5px;
  scrollbar-color: #c0c0c0 #808080;
}

.logLine {
  color: #000000;
  font-size: 11px;
  line-height: 1.35;
  white-space: normal;
}

.logFaint {
  color: #555555;
}

/* ── Inventory Section ────────────────────────────────────────── */
#invMeta {
  color: #000080;
  font-size: 10px;
  margin-bottom: 3px;
  font-weight: bold;
}

#invList {
  display: grid;
  gap: 2px;
}

.invRow {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 4px;
  align-items: baseline;
  border-bottom: 1px solid #c0c0c0;
  padding: 1px 2px;
  font-size: 11px;
}

.invRow:hover {
  background: #000080;
  color: #ffffff;
}

.invGenre {
  font-weight: bold;
}

.invFlags {
  margin-top: 1px;
  color: #555555;
  font-size: 10px;
}

.money {
  font-weight: bold;
  text-align: right;
}

/* ── Record Cards (Bag / Expedit) ─────────────────────────────── */
.recordCard {
  border-top:    2px solid #ffffff;
  border-left:   2px solid #ffffff;
  border-bottom: 2px solid #808080;
  border-right:  2px solid #808080;
  background: #c0c0c0;
  padding: 4px 6px;
  display: grid;
  gap: 2px;
}

.recordTitle {
  font-weight: bold;
  font-size: 11px;
  line-height: 1.2;
}

.recordMeta {
  color: #444444;
  font-size: 10px;
  line-height: 1.2;
}

.recordActions {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  margin-top: 2px;
}

.shiny {
  border-color: #ffcc00;
  background: #fffbe6;
}

/* No animation on Win95 theme — static is the aesthetic */
.shiny::after {
  display: none;
}

/* ── Muted text ───────────────────────────────────────────────── */
.muted {
  color: #555555;
  font-size: 10px;
}

/* ── Pill labels ──────────────────────────────────────────────── */
.pill {
  display: inline;
  border: 1px solid #808080;
  background: #e0e0e0;
  padding: 0 3px;
  font-size: 10px;
  color: #000000;
}

.danger-pill {
  display: inline;
  border: 1px solid #800000;
  background: #ffd0d0;
  padding: 0 3px;
  font-size: 10px;
  color: #800000;
}

/* ── Divider ──────────────────────────────────────────────────── */
.divider {
  height: 2px;
  background: #808080;
  margin: 4px 0;
}

/* ── Gig Panel ────────────────────────────────────────────────── */
#gigBox {
  display: grid;
  gap: 4px;
}

.gigTitle {
  font-weight: bold;
  font-size: 11px;
  color: #000080;
}

.gigReq {
  color: #000000;
  font-size: 10px;
  line-height: 1.4;
}

/* ── Modal (Win95 dialog box) ─────────────────────────────────── */
#modalRoot {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  place-items: center;
  z-index: 50;
  padding: 18px;
}

#modalRoot:not(.hidden) {
  display: grid;
}

#modalCard {
  width: min(480px, 100%);
  max-height: calc(100vh - 36px);
  display: flex;
  flex-direction: column;
  background: #c0c0c0;
  border-top:    2px solid #ffffff;
  border-left:   2px solid #ffffff;
  border-bottom: 2px solid #808080;
  border-right:  2px solid #808080;
  padding: 0;
}

#modalTitle {
  background: #000080;
  color: #ffffff;
  font-weight: bold;
  font-size: 11px;
  padding: 3px 6px;
  display: flex;
  align-items: center;
}

#modalBody {
  color: #000000;
  font-size: 11px;
  line-height: 1.45;
  padding: 10px 12px;
  overflow-y: auto;
  flex: 1;
  min-height: 0;
}

#modalActions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  padding: 8px 12px;
  border-top: 1px solid #808080;
  flex-wrap: wrap;
}

.hidden {
  display: none !important;
}

/* ── Bottom Nav Bar ───────────────────────────────────────────── */
#bottomNav {
  display: flex;
  gap: 2px;
  padding: 3px 4px;
  background: #c0c0c0;
  border-top: 2px solid #808080;
  flex-shrink: 0;
}

.nav-btn {
  font-size: 10px;
  padding: 2px 8px;
  min-width: 60px;
}

.nav-btn.active {
  border-top:    2px solid #808080;
  border-left:   2px solid #808080;
  border-bottom: 2px solid #ffffff;
  border-right:  2px solid #ffffff;
  background: #e0e0e0;
}

/* ── Section labels ───────────────────────────────────────────── */
#left, #center, #right {
  /* stack panels vertically within each column */
}

/* Status area label bar */
#left > .panel:first-child .panelTitle {
  /* Already styled via .panelTitle */
}
