/* ============================================
   Shop System UI Styles for OpenMUD
   Merchant window with buy/sell tabs
   Uses theme variables from theme.css
   ============================================ */

/* Shop window positioning and base styles */
#shop-window {
  position: absolute;
  top: 100px;
  left: 250px;
  width: 500px;
  max-width: 90vw;
  max-height: 70vh;
  background: var(--theme-bg-secondary);
  border: 2px solid var(--theme-border-primary);
  border-radius: 4px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.8);
  z-index: 9999;
  display: none;
  flex-direction: column;
}

/* Dragging state */
#shop-window.window-dragging {
  transition: none !important;
  user-select: none;
}

/* Window header drag handle styling */
#shop-window .window-header {
  cursor: move;
  user-select: none;
  background: var(--theme-bg-tertiary);
  border-bottom: 1px solid var(--theme-border-secondary);
  padding: 8px 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

#shop-window .window-header:active {
  cursor: grabbing;
}

#shop-window .window-title {
  font-weight: bold;
  color: var(--theme-text-primary);
  font-size: 14px;
}

#shop-window .window-controls {
  display: flex;
  gap: 4px;
}

#shop-window .window-btn {
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  border-radius: 3px;
  font-size: 14px;
  color: var(--theme-text-muted);
  transition: all 0.2s;
}

#shop-window .window-btn:hover {
  background: var(--theme-bg-hover);
  color: var(--theme-text-primary);
}

#shop-window .window-close:hover {
  background: #c0392b;
  color: #fff;
}

/* Override window-content */
#shop-window .window-content {
  display: flex;
  flex-direction: column;
  padding: 0;
  gap: 0;
  overflow: hidden;
  flex: 1;
}

/* ============================================
   Shop Header - Merchant name and currency
   ============================================ */

.shop-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 12px;
  border-bottom: 1px solid var(--theme-border-secondary);
  background: var(--theme-bg-tertiary);
}

.shop-merchant-name {
  font-size: 16px;
  font-weight: bold;
  color: #ffd700;
}

.shop-player-currency {
  font-family: monospace;
  font-size: 14px;
  color: var(--theme-text-primary);
  background: rgba(0, 0, 0, 0.3);
  padding: 4px 10px;
  border-radius: 3px;
  border: 1px solid var(--theme-border-secondary);
}

/* ============================================
   Shop Tabs
   ============================================ */

.shop-tabs {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--theme-border-secondary);
}

.shop-tab {
  flex: 1;
  padding: 10px 16px;
  background: var(--theme-bg-tertiary);
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--theme-text-muted);
  cursor: pointer;
  font-family: var(--theme-font-family);
  font-size: 13px;
  font-weight: 500;
  transition: all 0.2s;
}

.shop-tab:hover {
  background: var(--theme-bg-hover);
  color: var(--theme-text-secondary);
}

.shop-tab.active {
  background: var(--theme-bg-secondary);
  color: var(--theme-text-primary);
  border-bottom-color: var(--theme-accent-green);
}

/* ============================================
   Shop Search
   ============================================ */

.shop-search-container {
  padding: 10px 12px;
  border-bottom: 1px solid var(--theme-border-secondary);
}

.shop-search-input {
  width: 100%;
  padding: 8px 10px;
  background: var(--theme-bg-input);
  border: 1px solid var(--theme-border-secondary);
  border-radius: 3px;
  color: var(--theme-text-primary);
  font-family: var(--theme-font-family);
  font-size: 12px;
}

.shop-search-input:focus {
  outline: none;
  border-color: var(--theme-accent-green);
}

.shop-search-input::placeholder {
  color: var(--theme-text-muted);
}

/* ============================================
   Shop Items List
   ============================================ */

.shop-items-container {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
}

.shop-items-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.shop-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  background: var(--theme-bg-tertiary);
  border: 1px solid var(--theme-border-secondary);
  border-radius: 3px;
  transition: all 0.15s;
}

.shop-item:hover {
  background: var(--theme-bg-hover);
  border-color: var(--theme-border-primary);
}

.shop-item.cannot-afford {
  opacity: 0.6;
}

.shop-item.cannot-afford .shop-item-price {
  color: #e74c3c;
}

.shop-item-index {
  width: 24px;
  text-align: right;
  color: var(--theme-text-muted);
  font-size: 11px;
  font-family: monospace;
}

.shop-item-info {
  flex: 1;
  min-width: 0;
}

.shop-item-name {
  color: var(--theme-text-primary);
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.shop-item-category {
  color: var(--theme-text-muted);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.shop-item-price {
  font-family: monospace;
  font-size: 12px;
  color: #ffd700;
  min-width: 70px;
  text-align: right;
}

.shop-item-price.sell-price {
  color: #4CAF50;
}

.shop-item-stock {
  width: 30px;
  text-align: center;
  font-size: 11px;
  color: var(--theme-text-muted);
}

.shop-action-btn {
  padding: 5px 12px;
  background: var(--theme-accent-green);
  border: none;
  border-radius: 3px;
  color: #fff;
  cursor: pointer;
  font-family: var(--theme-font-family);
  font-size: 11px;
  font-weight: 500;
  transition: all 0.15s;
}

.shop-action-btn:hover {
  background: #45a049;
  transform: scale(1.02);
}

.shop-action-btn:active,
.shop-action-btn.clicked {
  transform: scale(0.98);
}

/* Sell button variant */
.shop-item .shop-action-btn[data-action="sell"] {
  background: #2196F3;
}

.shop-item .shop-action-btn[data-action="sell"]:hover {
  background: #1976D2;
}

/* ============================================
   Empty State
   ============================================ */

.shop-empty {
  text-align: center;
  color: var(--theme-text-muted);
  padding: 40px 20px;
  font-style: italic;
  font-size: 13px;
}

/* ============================================
   Shop Footer
   ============================================ */

.shop-footer {
  padding: 8px 12px;
  border-top: 1px solid var(--theme-border-secondary);
  background: var(--theme-bg-tertiary);
  font-size: 11px;
  color: var(--theme-text-muted);
  display: flex;
  justify-content: space-between;
}

.shop-footer-hint {
  font-style: italic;
}

/* ============================================
   Scrollbar Styling
   ============================================ */

.shop-items-container::-webkit-scrollbar {
  width: 8px;
}

.shop-items-container::-webkit-scrollbar-track {
  background: var(--theme-bg-primary);
}

.shop-items-container::-webkit-scrollbar-thumb {
  background: #444;
  border-radius: 4px;
}

.shop-items-container::-webkit-scrollbar-thumb:hover {
  background: #555;
}

/* ============================================
   Responsive Adjustments
   ============================================ */

@media (max-width: 600px) {
  #shop-window {
    width: 95vw;
    left: 2.5vw;
    top: 50px;
  }

  .shop-item {
    flex-wrap: wrap;
  }

  .shop-item-info {
    flex-basis: calc(100% - 100px);
  }

  .shop-item-stock {
    display: none;
  }
}
