/* Equipment Browser — 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;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* 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: calc(5px + env(safe-area-inset-top)) 10px;
}

#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; }

/* Slot tabs */
#slot-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 2px;
  padding: 4px 10px;
  background: #16213e;
  border-bottom: 1px solid #0f3460;
  flex-shrink: 0;
}

.slot-btn {
  padding: 3px 8px;
  font-size: 11px;
  background: #1a1a2e;
  color: #aaa;
  border: 1px solid #0f3460;
  border-radius: 3px;
  cursor: pointer;
}

.slot-btn:hover { color: #fff; border-color: #e94560; }
.slot-btn.active { background: #e94560; color: #fff; border-color: #e94560; }

/* Weapon sub-tabs */
#weapon-subtabs {
  display: flex;
  flex-wrap: wrap;
  gap: 2px;
  padding: 3px 10px;
  background: #1a1a2e;
  border-bottom: 1px solid #0f3460;
  flex-shrink: 0;
}

#weapon-subtabs.hidden { display: none; }

.subtab-btn {
  padding: 2px 6px;
  font-size: 10px;
  background: transparent;
  color: #888;
  border: 1px solid #0f3460;
  border-radius: 3px;
  cursor: pointer;
}

.subtab-btn:hover { color: #ccc; border-color: #e94560; }
.subtab-btn.active { color: #e94560; border-color: #e94560; font-weight: bold; }

/* Filters bar */
#filters {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 10px;
  background: #16213e;
  border-bottom: 1px solid #0f3460;
  flex-shrink: 0;
}

#job-filter-wrap { position: relative; }

#job-filter-btn {
  padding: 3px 8px;
  font-size: 12px;
  background: #1a1a2e;
  color: #e0e0e0;
  border: 1px solid #0f3460;
  border-radius: 3px;
  cursor: pointer;
  white-space: nowrap;
}

#job-filter-btn:hover { border-color: #e94560; }

#job-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  z-index: 100;
  background: #16213e;
  border: 1px solid #0f3460;
  border-radius: 4px;
  padding: 4px;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1px;
  min-width: 280px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
}

#job-dropdown.hidden { display: none; }

.job-option {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 3px 6px;
  font-size: 11px;
  color: #ccc;
  cursor: pointer;
  border-radius: 2px;
  white-space: nowrap;
}

.job-option:hover { background: #1a1a2e; }
.job-option.job-all { grid-column: 1 / -1; border-bottom: 1px solid #0f3460; padding-bottom: 4px; margin-bottom: 2px; }

.job-option input[type="checkbox"] {
  accent-color: #e94560;
  width: 13px;
  height: 13px;
}

/* Level filter */
#level-filter {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  color: #aaa;
}

#level-filter input[type="number"] {
  width: 40px;
  padding: 3px 4px;
  font-size: 12px;
  background: #1a1a2e;
  color: #e0e0e0;
  border: 1px solid #0f3460;
  border-radius: 3px;
  text-align: center;
  -moz-appearance: textfield;
}

#level-filter input::-webkit-inner-spin-button,
#level-filter input::-webkit-outer-spin-button {
  -webkit-appearance: none;
}

#level-filter input:focus { border-color: #e94560; outline: none; }

/* Stats filter */
#stats-search {
  width: 120px;
  padding: 3px 6px;
  font-size: 12px;
  background: #1a1a2e;
  color: #e0e0e0;
  border: 1px solid #0f3460;
  border-radius: 3px;
}
#stats-search:focus { border-color: #e94560; outline: none; }

/* Copy link button */
#copy-link {
  padding: 3px 8px;
  font-size: 11px;
  background: transparent;
  color: #888;
  border: 1px solid #0f3460;
  border-radius: 3px;
  cursor: pointer;
  margin-left: auto;
}

#copy-link:hover { color: #e94560; border-color: #e94560; }

#result-count {
  font-size: 11px;
  color: #888;
  white-space: nowrap;
}

/* Item detail panel */
#item-detail {
  background: #0c0c28;
  border-bottom: 1px solid #8b7d3c;
  padding: 12px 16px;
  flex-shrink: 0;
}

#item-detail.hidden { display: none; }

.detail-content { max-width: 600px; }

#detail-back {
  background: none;
  border: none;
  color: #e94560;
  font-size: 12px;
  cursor: pointer;
  margin-bottom: 8px;
  padding: 0;
}

#detail-back:hover { text-decoration: underline; }

.detail-header { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; }
.detail-icon { width: 32px; height: 32px; image-rendering: pixelated; flex-shrink: 0; }
.detail-name { color: #fff; font-weight: bold; font-size: 16px; }
.detail-flags { margin-bottom: 4px; }
.detail-flags .flag-rare { color: #5fd35f; font-size: 12px; font-weight: bold; }
.detail-flags .flag-ex { color: #5fd3d3; font-size: 12px; font-weight: bold; margin-left: 6px; }
.detail-slot { color: #c0b070; margin-bottom: 4px; }
.detail-weapon { color: #e0d0a0; margin-bottom: 4px; }
.detail-stats { color: #d0d0d0; margin-bottom: 4px; line-height: 1.5; }
.detail-latents { color: #80c8a0; margin-bottom: 4px; line-height: 1.5; font-size: 12px; }
.detail-desc { color: #c8b8e8; margin-bottom: 4px; line-height: 1.5; font-style: italic; }
.detail-level { color: #a0a0a0; margin-top: 6px; padding-top: 6px; border-top: 1px solid #2a2a4a; font-size: 12px; }
.detail-wiki { margin-top: 8px; }
.detail-wiki a { color: #e94560; text-decoration: none; font-size: 12px; }
.detail-wiki a:hover { text-decoration: underline; }

/* Detail price */
.detail-price { margin-top: 8px; }
.detail-fetch-price {
  background: transparent;
  border: 1px solid #8b7d3c;
  color: #f0c040;
  font-size: 12px;
  padding: 3px 10px;
  border-radius: 3px;
  cursor: pointer;
}
.detail-fetch-price:hover { background: rgba(240, 192, 64, 0.15); }
.detail-fetch-price:disabled { opacity: 0.5; cursor: default; }
.ah-detail-result { margin-top: 4px; font-size: 12px; line-height: 1.6; }
.ah-detail-label { color: #888; }
.ah-detail-value { color: #f0c040; }
.ah-detail-none { color: #666; font-style: italic; font-size: 12px; }

/* Results table */
#results-wrap {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
}

#results-table {
  border-collapse: collapse;
  font-size: 12px;
  width: 100%;
  table-layout: fixed;
}

#results-table thead {
  position: sticky;
  top: 0;
  z-index: 10;
}

#results-table th {
  background: #16213e;
  border-bottom: 2px solid #0f3460;
  padding: 5px 8px;
  text-align: left;
  font-weight: bold;
  font-size: 11px;
  color: #aaa;
  white-space: nowrap;
}

th.sortable {
  cursor: pointer;
  user-select: none;
}

th.sortable:hover { color: #fff; }

th.sort-asc::after { content: ' \25B2'; font-size: 9px; }
th.sort-desc::after { content: ' \25BC'; font-size: 9px; }

#results-table td {
  padding: 4px 8px;
  border-bottom: 1px solid #0f3460;
  vertical-align: top;
}

#results-table tbody tr:hover { background: rgba(233, 69, 96, 0.08); }

.cell-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.col-name { width: 200px; }
.col-lv { width: 40px; }
.col-dps { width: 55px; }
.col-stats { }
.col-jobs { width: 140px; }

.item-icon {
  width: 24px;
  height: 24px;
  image-rendering: pixelated;
  vertical-align: middle;
  margin-right: 4px;
}

.item-name-link {
  color: #f0c040;
  cursor: pointer;
}

.item-name-link:hover { text-decoration: underline; }

.item-flags {
  margin-left: 6px;
  font-size: 10px;
}

.flag-rare { color: #5fd35f; font-weight: bold; }
.flag-ex { color: #5fd3d3; font-weight: bold; margin-left: 2px; }

.cell-lv { text-align: center; color: #aaa; white-space: nowrap; }
.col-dps { display: none; }
.show-dps .col-dps { display: table-cell; }
.cell-dps { text-align: right; color: #f5a623; white-space: nowrap; }
.cell-stats { color: #d0d0d0; font-size: 11px; }
.cell-jobs { color: #888; font-size: 11px; white-space: nowrap; }

#loading {
  text-align: center;
  color: #888;
  padding: 40px;
  font-size: 14px;
}

/* Item tooltip — FFXI in-game examine style */
#item-tooltip {
  position: fixed;
  z-index: 10000;
  pointer-events: none;
  display: none;
  background: #3a3a2e;
  border: 1px solid #7a7768;
  border-radius: 0;
  max-width: 280px;
  padding: 5px 7px;
  font-family: Tahoma, 'Segoe UI', Geneva, Verdana, sans-serif;
  font-size: 11px;
  line-height: 1.3;
  color: #e8e8e0;
  box-shadow: 1px 1px 2px rgba(0, 0, 0, 0.5);
  -webkit-font-smoothing: none;
  -moz-osx-font-smoothing: unset;
  text-rendering: optimizeSpeed;
  letter-spacing: 0.2px;
}

#item-tooltip .itt-name { color: #e8e8e0; font-weight: normal; font-size: 11px; margin-bottom: 1px; }
#item-tooltip .itt-flags { margin-bottom: 2px; }
#item-tooltip .itt-rare { color: #5fd35f; font-size: 11px; font-weight: bold; }
#item-tooltip .itt-ex { color: #5fd3d3; font-size: 11px; font-weight: bold; }
#item-tooltip .itt-slot { color: #e8e8e0; margin-bottom: 1px; }
#item-tooltip .itt-weapon { color: #e8e8e0; margin-bottom: 1px; }
#item-tooltip .itt-stats { color: #e8e8e0; white-space: pre-line; margin-bottom: 1px; }
#item-tooltip .itt-latents { color: #80c8a0; white-space: pre-line; margin-bottom: 1px; font-size: 11px; }
#item-tooltip .itt-desc { color: #e8e8e0; font-style: normal; margin-bottom: 1px; }
#item-tooltip .itt-level { color: #e8e8e0; margin-top: 1px; padding-top: 0; border-top: none; font-size: 11px; }
#item-tooltip .itt-vendor { color: #88cc88; font-size: 11px; margin-top: 2px; }

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

/* Mobile responsive */
@media (max-width: 768px) {
  #header-row1 { padding: calc(3px + env(safe-area-inset-top)) 6px; gap: 4px; }
  #header h1 { font-size: 13px; }
  #slot-tabs { padding: 3px 6px; }
  .slot-btn { padding: 2px 6px; font-size: 10px; }
  #filters { padding: 3px 6px; gap: 4px; }
  #job-dropdown { grid-template-columns: repeat(3, 1fr); min-width: 220px; }
  #results-wrap { overflow: auto; }
  #results-table { font-size: 11px; table-layout: auto; }
  #results-table th, #results-table td { padding: 3px 4px; }
  .col-name { width: auto; }
  .col-jobs { width: auto; }
  .cell-stats { white-space: nowrap; }
}

@media (max-width: 480px) {
  #header h1 { display: none; }
  #job-dropdown { grid-template-columns: repeat(2, 1fr); min-width: 180px; }
}
