/* ============================================
   Recipes System UI Styles for OpenMUD
   Two-panel layout: recipe list | recipe details
   Uses theme variables from theme.css
   ============================================ */

/* Recipes window positioning and base styles */
#recipes-window {
  position: absolute;
  top: 100px;
  left: 250px;
  width: 800px;
  max-width: 90vw;
  max-height: 85vh;
  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 */
#recipes-window.window-dragging {
  transition: none !important;
  user-select: none;
}

/* Window header drag handle styling */
#recipes-window .window-header {
  cursor: move;
  user-select: none;
}

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

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

/* ============================================
   Two-Panel Layout
   ============================================ */

.recipes-layout {
  display: grid;
  grid-template-columns: 280px 1fr;
  height: 100%;
  overflow: hidden;
}

/* ============================================
   Left Panel - Recipe List
   ============================================ */

.recipes-list-panel {
  display: flex;
  flex-direction: column;
  background: var(--theme-bg-tertiary);
  border-right: 1px solid var(--theme-border-primary);
  overflow: hidden;
}

/* Header with filter and search */
.recipes-header {
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  border-bottom: 1px solid var(--theme-border-secondary);
}

#recipes-skill-filter {
  width: 100%;
  padding: 6px 8px;
  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;
  cursor: pointer;
}

#recipes-skill-filter:focus {
  outline: none;
  border-color: var(--theme-accent-green);
}

#recipes-search {
  width: 100%;
  padding: 6px 8px;
  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;
}

#recipes-search:focus {
  outline: none;
  border-color: var(--theme-accent-green);
}

#recipes-search::placeholder {
  color: var(--theme-text-muted);
}

/* ============================================
   Filter Buttons Row
   ============================================ */

.recipes-filter-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  padding: 0;
}

.recipes-filter-buttons .filter-btn {
  flex: 1;
  min-width: 60px;
  padding: 6px 8px;
  background: var(--theme-bg-primary);
  border: 1px solid var(--theme-border-secondary);
  border-radius: 3px;
  color: var(--theme-text-secondary);
  font-family: var(--theme-font-family);
  font-size: 11px;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}

.recipes-filter-buttons .filter-btn:hover {
  background: rgba(255, 255, 255, 0.05);
  border-color: var(--theme-border-primary);
  color: var(--theme-text-primary);
}

.recipes-filter-buttons .filter-btn.active {
  background: rgba(76, 175, 80, 0.15);
  border-color: var(--theme-accent-green);
  color: var(--theme-accent-green);
}

.recipes-filter-buttons .filter-count {
  display: inline-block;
  min-width: 16px;
  padding: 1px 4px;
  margin-left: 4px;
  background: rgba(0, 0, 0, 0.3);
  border-radius: 8px;
  font-size: 10px;
  text-align: center;
}

.recipes-filter-buttons .filter-btn.active .filter-count {
  background: rgba(76, 175, 80, 0.3);
}

/* Skill info display */
#recipes-skill-info {
  display: none;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  background: var(--theme-bg-primary);
  border-bottom: 1px solid var(--theme-border-secondary);
  font-size: 12px;
}

.skill-info-name {
  color: var(--theme-text-primary);
  font-weight: bold;
}

.skill-info-level {
  color: var(--theme-text-secondary);
}

/* Recipe List */
#recipes-list {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 8px;
}

#recipes-list::-webkit-scrollbar {
  width: 6px;
}

#recipes-list::-webkit-scrollbar-track {
  background: var(--theme-bg-primary);
}

#recipes-list::-webkit-scrollbar-thumb {
  background: var(--theme-border-primary);
  border-radius: 3px;
}

#recipes-list::-webkit-scrollbar-thumb:hover {
  background: var(--theme-border-highlight);
}

/* Recipe Item */
.recipe-item {
  background: var(--theme-bg-secondary);
  border: 1px solid var(--theme-border-secondary);
  border-radius: 3px;
  padding: 8px;
  margin-bottom: 6px;
  cursor: pointer;
  transition: all 0.2s;
}

.recipe-item:hover {
  background: #333333;
  border-color: var(--theme-border-primary);
}

.recipe-item.selected {
  border-color: var(--theme-accent-green);
  background: rgba(76, 175, 80, 0.1);
}

.recipe-item.cannot-craft {
  opacity: 0.6;
}

.recipe-item.has-materials .recipe-name {
  color: var(--theme-accent-green);
}

.recipe-item.missing-materials .recipe-name {
  color: var(--theme-text-primary);
}

.recipe-item-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 2px;
}

.recipe-name {
  font-size: 13px;
  font-weight: bold;
}

.recipe-difficulty {
  font-size: 11px;
  padding: 2px 6px;
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.1);
}

.recipe-difficulty.difficulty-trivial {
  color: #808080;
}

.recipe-difficulty.difficulty-easy {
  color: #4CAF50;
}

.recipe-difficulty.difficulty-moderate {
  color: #2196F3;
}

.recipe-difficulty.difficulty-challenging {
  color: #FF9800;
}

.recipe-difficulty.difficulty-too-hard {
  color: #f44336;
}

.recipe-item-skill {
  font-size: 10px;
  color: var(--theme-text-muted);
  text-transform: capitalize;
}

/* ============================================
   Right Panel - Recipe Details
   ============================================ */

.recipes-detail-panel {
  display: flex;
  flex-direction: column;
  background: var(--theme-bg-primary);
  padding: 16px;
  overflow-y: auto;
}

.recipes-detail-panel::-webkit-scrollbar {
  width: 8px;
}

.recipes-detail-panel::-webkit-scrollbar-track {
  background: var(--theme-bg-primary);
}

.recipes-detail-panel::-webkit-scrollbar-thumb {
  background: var(--theme-border-primary);
  border-radius: 4px;
}

/* Empty state */
#recipes-detail-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: var(--theme-text-muted);
  font-size: 14px;
  text-align: center;
}

/* Detail Content */
#recipes-detail-content {
  display: none;
}

.recipe-detail-name {
  color: var(--theme-room-name);
  font-size: 18px;
  margin: 0 0 8px 0;
}

.recipe-description {
  color: var(--theme-text-secondary);
  font-size: 12px;
  font-style: italic;
  margin: 0 0 16px 0;
  line-height: 1.5;
}

/* Requirements */
.recipe-requirements {
  background: var(--theme-bg-tertiary);
  border: 1px solid var(--theme-border-secondary);
  border-radius: 3px;
  padding: 10px;
  margin-bottom: 16px;
}

.requirement-item {
  font-size: 12px;
  color: var(--theme-text-secondary);
  margin-bottom: 4px;
}

.requirement-item:last-child {
  margin-bottom: 0;
}

.req-label {
  color: var(--theme-text-muted);
}

/* Materials Section */
.recipe-materials h4,
.recipe-output h4,
.recipe-quality h4 {
  color: var(--theme-text-primary);
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 1px solid var(--theme-border-secondary);
  padding-bottom: 6px;
  margin: 0 0 10px 0;
}

.materials-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 8px;
  margin-bottom: 16px;
}

.material-slot {
  background: var(--theme-bg-tertiary);
  border: 1px solid var(--theme-border-secondary);
  border-radius: 3px;
  padding: 8px;
  text-align: center;
}

.material-slot.have {
  border-color: var(--theme-accent-green);
  background: rgba(76, 175, 80, 0.1);
}

.material-slot.missing {
  border-color: #f44336;
  background: rgba(244, 67, 54, 0.1);
}

.material-name {
  font-size: 11px;
  color: var(--theme-text-primary);
  margin-bottom: 4px;
  word-wrap: break-word;
}

.material-count {
  font-size: 12px;
  font-weight: bold;
}

.material-slot.have .material-count {
  color: var(--theme-accent-green);
}

.material-slot.missing .material-count {
  color: #f44336;
}

/* Output Section */
.recipe-output {
  margin-bottom: 16px;
}

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

.output-name {
  color: var(--theme-room-name);
  font-size: 14px;
  font-weight: bold;
}

.output-qty {
  color: var(--theme-text-secondary);
  font-size: 12px;
}

/* Quality Section */
.recipe-quality {
  margin-bottom: 16px;
}

.quality-note {
  color: var(--theme-text-muted);
  font-size: 11px;
  font-style: italic;
  margin: 0;
}

/* Actions */
.recipe-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: auto;
  padding-top: 16px;
  border-top: 1px solid var(--theme-border-secondary);
}

.quantity-selector {
  display: flex;
  align-items: center;
  gap: 4px;
}

.qty-btn {
  width: 28px;
  height: 28px;
  background: var(--theme-bg-tertiary);
  border: 1px solid var(--theme-border-secondary);
  border-radius: 3px;
  color: var(--theme-text-primary);
  font-size: 16px;
  cursor: pointer;
  transition: all 0.2s;
}

.qty-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: var(--theme-border-primary);
}

.qty-value {
  width: 40px;
  text-align: center;
  font-size: 14px;
  color: var(--theme-text-primary);
}

.craft-btn {
  flex: 1;
  padding: 10px 16px;
  background: var(--theme-accent-green);
  border: none;
  border-radius: 4px;
  color: #fff;
  font-size: 14px;
  font-weight: bold;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.2s;
}

.craft-btn:hover:not(.disabled) {
  background: #66BB6A;
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(76, 175, 80, 0.4);
}

.craft-btn.disabled {
  background: #555;
  cursor: not-allowed;
  opacity: 0.6;
}

/* No Data Message */
.no-data {
  text-align: center;
  padding: 20px;
  color: var(--theme-text-muted);
  font-size: 13px;
}

/* ============================================
   Responsive Design
   ============================================ */

@media (max-width: 800px) {
  #recipes-window {
    width: 95%;
    left: 2.5%;
  }

  .recipes-layout {
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr;
  }

  .recipes-list-panel {
    max-height: 200px;
    border-right: none;
    border-bottom: 1px solid var(--theme-border-primary);
  }
}
