/* AH — 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;
}

#ah-search {
  width: 100%;
  padding: 4px 8px;
  border: 1px solid #0f3460;
  border-radius: 4px;
  background: #1a1a2e;
  color: #e0e0e0;
  font-size: 16px;
  outline: none;
}
#ah-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-rare { color: #888; font-size: 10px; margin-left: 4px; }

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

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

/* Item Card */
.ah-card {
  background: #16213e;
  border: 1px solid #0f3460;
  border-radius: 4px;
  padding: 12px;
  max-width: 700px;
}

/* Item header */
.ah-item-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
  padding-bottom: 8px;
  border-bottom: 1px solid #0f346044;
}

.ah-item-name {
  font-size: 16px;
  font-weight: bold;
  color: #f0c040;
}

.ah-item-flags {
  font-size: 10px;
  color: #888;
}

.ah-item-desc {
  font-size: 12px;
  color: #aaa;
  margin-bottom: 4px;
}

.ah-item-armor {
  font-size: 11px;
  color: #888;
  margin-bottom: 8px;
}

.ah-vendor-price {
  font-size: 12px;
  color: #88cc88;
  margin-bottom: 8px;
}

/* Single/Stack side-by-side columns */
.ah-columns {
  display: flex;
  gap: 12px;
}

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

.ah-col-title {
  font-size: 11px;
  color: #e94560;
  font-weight: bold;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 6px;
  padding-bottom: 4px;
  border-bottom: 1px solid #0f346044;
}

/* Market summary */
.ah-market {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 10px;
  padding: 6px 10px;
  background: #13192e;
  border-radius: 4px;
}

.ah-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.ah-stat-value {
  font-size: 16px;
  font-weight: bold;
  color: #e94560;
  font-variant-numeric: tabular-nums;
}

.ah-stat-label {
  font-size: 10px;
  color: #666;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* Sale history */
.ah-history-title {
  font-size: 11px;
  color: #e94560;
  font-weight: bold;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 4px;
}

.ah-history {
  display: grid;
  grid-template-columns: auto 1fr 1fr auto;
  column-gap: 10px;
  row-gap: 1px;
  font-size: 12px;
  width: fit-content;
}

.ah-col-head {
  color: #667;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding-bottom: 2px;
}
.ah-date { color: #666; }
.ah-seller { color: #aaa; }
.ah-buyer { color: #aaa; }
.ah-price {
  color: #f0c040;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

/* Loading spinner */
.ah-loading {
  text-align: center;
  color: #888;
  padding: 20px;
  font-size: 13px;
}

/* Error */
.ah-error {
  color: #e94560;
  text-align: center;
  padding: 20px;
  font-size: 13px;
}

/* Dashboard */
#dashboard {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  max-width: 700px;
}

#dashboard:empty { display: none; }

.dash-range-bar {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 2px;
}

.dash-range-label {
  font-size: 12px;
  color: #e94560;
  font-weight: bold;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.dash-ranges {
  display: flex;
  gap: 3px;
}

.dash-card {
  background: #16213e;
  border: 1px solid #0f3460;
  border-radius: 4px;
  padding: 8px 10px;
  cursor: pointer;
  transition: border-color 0.15s;
}
.dash-card:hover { border-color: #e94560; }

.dash-card-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 4px;
}

.dash-item-name {
  font-size: 12px;
  font-weight: bold;
  color: #f0c040;
}

.dash-price {
  font-size: 13px;
  font-weight: bold;
  color: #e94560;
  font-variant-numeric: tabular-nums;
}

.dash-chart { width: 100%; height: 90px; }
.dash-chart svg { width: 100%; height: 100%; }

.dash-meta {
  display: flex;
  justify-content: space-between;
  font-size: 10px;
  color: #556;
  margin-top: 2px;
}

/* Price chart in item detail view */
.ah-chart-wrap {
  margin: 8px 0 12px;
  padding: 8px;
  background: #13192e;
  border-radius: 4px;
}

.ah-chart-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}

.ah-chart-title {
  font-size: 11px;
  color: #e94560;
  font-weight: bold;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.ah-chart-ranges {
  display: flex;
  gap: 3px;
}

.ah-range-btn {
  background: #1a1a2e;
  border: 1px solid #0f3460;
  color: #888;
  font-size: 10px;
  padding: 1px 7px;
  border-radius: 3px;
  cursor: pointer;
}
.ah-range-btn:hover { color: #ccc; }
.ah-range-btn.active { border-color: #e94560; color: #e94560; }

.ah-chart svg { width: 100%; }

/* Chart tooltip */
#chart-tip {
  display: none;
  position: fixed;
  background: #16213e;
  border: 1px solid #0f3460;
  color: #e0e0e0;
  font-size: 11px;
  padding: 3px 8px;
  border-radius: 3px;
  pointer-events: none;
  white-space: nowrap;
  z-index: 200;
}

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

/* 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; }
}

@media (max-width: 480px) {
  #header h1 { display: none; }
  .ah-columns { flex-direction: column; gap: 8px; }
  #dashboard { grid-template-columns: 1fr; }
}
