/* BCNM — Dark FFXI theme */

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  background: #1a1a2e;
  color: #e0e0e0;
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding-top: env(safe-area-inset-top);
}

/* Header */
#header {
  display: flex;
  flex-direction: column;
  background: #16213e;
  border-bottom: 1px solid #0f3460;
  flex-shrink: 0;
}

#header-row1 {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 10px 2px;
}

#header-row2 {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 2px 10px 5px;
}

#header h1 {
  font-size: 16px;
  color: #e94560;
  white-space: nowrap;
}

.nav-icon { height: 20px; vertical-align: middle; margin-right: 4px; image-rendering: pixelated; }

#nav { display: flex; gap: 4px; }
#nav a {
  color: #aaa;
  text-decoration: none;
  font-size: 12px;
  padding: 2px 6px;
  border-radius: 3px;
}
#nav a:hover { color: #fff; }
#nav a.nav-active { color: #e94560; font-weight: bold; }

/* Search */
#search-wrap {
  position: relative;
  flex: 1;
  max-width: 400px;
  min-width: 120px;
}

#bcnm-search {
  width: 100%;
  padding: 4px 8px;
  border: 1px solid #0f3460;
  border-radius: 4px;
  background: #1a1a2e;
  color: #e0e0e0;
  font-size: 16px;
  outline: none;
}
#bcnm-search:focus { border-color: #e94560; }

/* Suggestions */
#suggestions {
  position: absolute;
  top: 100%;
  left: 0; right: 0;
  background: #16213e;
  border: 1px solid #0f3460;
  border-top: none;
  border-radius: 0 0 4px 4px;
  max-height: 280px;
  overflow-y: auto;
  z-index: 100;
}
#suggestions.hidden { display: none; }
.suggestion {
  padding: 5px 8px;
  font-size: 12px;
  color: #ccc;
  cursor: pointer;
}
.suggestion:hover { background: #0f3460; color: #fff; }
.sug-type {
  display: inline-block;
  font-size: 9px;
  padding: 1px 4px;
  border-radius: 2px;
  margin-right: 4px;
  font-weight: bold;
  background: #1a1a2e;
  color: #888;
}

/* Item Summary */
.item-summary {
  background: #16213e;
  border: 1px solid #0f3460;
  border-radius: 4px;
  margin-bottom: 10px;
  padding: 8px 12px;
}

.item-summary-title {
  font-size: 14px;
  font-weight: bold;
  color: #f0c040;
  margin-bottom: 6px;
  border-bottom: 1px solid #0f346044;
  padding-bottom: 4px;
}

.item-summary-rows {
  display: grid;
  grid-template-columns: auto auto auto auto;
  column-gap: 8px;
  row-gap: 2px;
  width: fit-content;
  font-size: 12px;
}

.isr-bcnm { color: #ccc; }
.isr-zone { color: #888; font-size: 11px; }
.isr-cap { color: #888; font-size: 11px; }
.isr-pct {
  color: #e94560;
  font-weight: bold;
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.type-heading {
  font-size: 13px;
  font-weight: bold;
  color: #8ab4f8;
  padding: 10px 0 4px;
  border-bottom: 1px solid #8ab4f830;
  margin-bottom: 4px;
}
.type-heading:first-child { padding-top: 0; }

/* Results */
#results-wrap {
  flex: 1;
  overflow-y: auto;
  padding: 8px 12px;
}

#loading, .no-results {
  text-align: center;
  color: #888;
  padding: 40px;
  font-size: 14px;
}
.no-results { color: #555; }

/* ============================================================
   BCNM Card — Collapsible
   ============================================================ */
.bcnm-card {
  margin-bottom: 2px;
}

/* Header row (always visible, clickable) */
.bcnm-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 10px;
  background: #16213e;
  border: 1px solid #0f3460;
  border-radius: 4px;
  cursor: pointer;
  user-select: none;
}
.bcnm-header:hover { border-color: #1a4a80; }
.bcnm-card.open .bcnm-header { border-radius: 4px 4px 0 0; }

.bcnm-expand {
  font-size: 10px;
  color: #555;
  flex-shrink: 0;
  width: 12px;
  text-align: center;
}

.bcnm-name {
  font-size: 13px;
  font-weight: bold;
  color: #f0c040;
  white-space: nowrap;
}

.bcnm-cap {
  font-size: 11px;
  font-weight: bold;
  padding: 0 5px;
  border-radius: 3px;
  white-space: nowrap;
  flex-shrink: 0;
}

/* Level cap colors */
.cap-uncap .bcnm-cap { color: #aaa; background: #2a2a3a; }
.cap-20 .bcnm-cap    { color: #a8d8ea; background: #1a3040; }
.cap-30 .bcnm-cap    { color: #8fd694; background: #1a3520; }
.cap-40 .bcnm-cap    { color: #c8e0a0; background: #2a3510; }
.cap-50 .bcnm-cap    { color: #e0c080; background: #3a2a10; }
.cap-60 .bcnm-cap    { color: #e08060; background: #3a1a15; }
.cap-75 .bcnm-cap    { color: #d070d0; background: #301530; }

/* Party size badge */
.bcnm-size {
  font-size: 10px;
  padding: 0 4px;
  border-radius: 3px;
  white-space: nowrap;
  flex-shrink: 0;
}
.size-3  { color: #8ab4f8; background: #0f2440; }
.size-6  { color: #a8d8ea; background: #0f2440; }
.size-18 { color: #d4a0f0; background: #201030; }

.bcnm-zone {
  font-size: 11px;
  color: #666;
  white-space: nowrap;
}

/* Body (hidden by default) */
.bcnm-body {
  display: none;
  background: #13192e;
  border: 1px solid #0f3460;
  border-top: none;
  border-radius: 0 0 4px 4px;
  padding: 6px 0;
}
.bcnm-card.open .bcnm-body { display: block; columns: 2; column-gap: 0; }

.bcnm-info {
  padding: 4px 12px 6px;
  font-size: 11px;
  color: #888;
  column-span: all;
}

/* Loot Pools */
.loot-pool {
  padding: 4px 12px;
  border-bottom: 1px solid #0f346018;
  break-inside: avoid;
}
.loot-pool:last-child { border-bottom: none; }

.pool-label {
  font-size: 10px;
  color: #e94560;
  font-weight: bold;
  margin-bottom: 2px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.loot-rows {
  display: grid;
  grid-template-columns: auto auto;
  column-gap: 8px;
  width: fit-content;
  padding-left: 8px;
  font-size: 12px;
}

.loot-name { color: #ccc; text-decoration: none; border-bottom: 1px solid #0f346040; padding: 1px 0; }
a.loot-name { color: #f0c040; }
a.loot-name:hover { text-decoration: underline; }
.loot-gil { color: #f0c040; }
.loot-pct {
  color: #666;
  font-variant-numeric: tabular-nums;
  text-align: right;
  border-bottom: 1px solid #0f346040;
  padding: 1px 0;
}
.loot-rows .loot-name:nth-last-child(2),
.loot-rows .loot-pct:last-child { border-bottom: none; }

.loot-name.loot-nothing { color: #444; font-style: italic; }
.loot-pct.loot-nothing { color: #444; }

.loot-name.loot-highlight { color: #e94560 !important; font-weight: bold; background: rgba(233, 69, 96, 0.12); }
.loot-pct.loot-highlight { color: #e94560; background: rgba(233, 69, 96, 0.12); }

/* ============================================================
   Item Tooltip (FFXI style)
   ============================================================ */
#item-tooltip {
  position: fixed;
  z-index: 10000;
  pointer-events: auto;
  display: none;
  background: #48473e;
  border: 1px solid #918e85;
  border-radius: 0;
  max-width: 320px;
  padding: 4px 6px;
  font-family: Tahoma, Geneva, Verdana, sans-serif;
  font-size: 11px;
  line-height: 1.4;
  color: #e8e8e0;
  box-shadow: 1px 1px 2px rgba(0, 0, 0, 0.5);
}
#item-tooltip .itt-name { margin-bottom: 0; }
#item-tooltip .itt-flags { margin-bottom: 0; }
#item-tooltip .itt-slot { margin-bottom: 0; }
#item-tooltip .itt-weapon { margin-bottom: 0; }
#item-tooltip .itt-stats { white-space: pre-line; margin-bottom: 0; }
#item-tooltip .itt-desc { margin-bottom: 0; }
#item-tooltip .itt-level { margin-top: 0; padding-top: 0; border-top: none; }
#item-tooltip .itt-vendor { color: #88cc88; font-size: 11px; margin-top: 3px; }

/* Tooltip price section */
#item-tooltip .itt-price { margin-top: 4px; padding-top: 3px; border-top: 1px solid #6b6b5e; }
#item-tooltip .fetch-price-btn {
  background: transparent;
  border: 1px solid #918e85;
  color: #f0c040;
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 2px;
  cursor: pointer;
}
#item-tooltip .fetch-price-btn:hover { background: rgba(240, 192, 64, 0.15); }
#item-tooltip .fetch-price-btn:disabled { opacity: 0.5; cursor: default; }
.ah-tt-avg { color: #f0c040; font-weight: bold; }
.ah-tt-stock { color: #888; margin-left: 4px; }
.ah-tt-none { color: #666; font-style: italic; }

/* Fetch Price button in loot */
.loot-pct .fetch-price-btn {
  background: transparent;
  border: 1px solid #f0c040;
  color: #f0c040;
  font-size: 9px;
  padding: 0 3px;
  border-radius: 2px;
  cursor: pointer;
  margin-left: 4px;
  vertical-align: middle;
}
.loot-pct .fetch-price-btn:hover { background: rgba(240, 192, 64, 0.15); }
.loot-pct .fetch-price-btn:disabled { opacity: 0.5; cursor: default; }

/* Inline AH price result */
.ah-inline-price { font-size: 10px; margin-left: 4px; }
.ah-inline-avg { color: #f0c040; font-weight: bold; }
.ah-inline-stock { color: #888; margin-left: 3px; }
.ah-inline-none { color: #666; font-style: italic; }
.ah-inline-stack { color: #aaa; }

/* Scrollbar */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: #1a1a2e; }
::-webkit-scrollbar-thumb { background: #0f3460; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #e94560; }

/* Wider displays — more columns */
@media (min-width: 1200px) {
  .bcnm-card.open .bcnm-body { columns: 3; }
}
@media (min-width: 1800px) {
  .bcnm-card.open .bcnm-body { columns: 4; }
}

/* Mobile */
@media (max-width: 768px) {
  #header-row1 { padding: 3px 6px 1px; gap: 4px; }
  #header-row2 { padding: 1px 6px 3px; gap: 4px; }
  #header h1 { font-size: 13px; }
  #results-wrap { padding: 4px 6px; }
  .bcnm-header { gap: 4px; padding: 4px 6px; }
  .bcnm-name { font-size: 12px; }
}

@media (max-width: 480px) {
  #header h1 { display: none; }
}
