/*
 * The crafting station of the anvils (src/ui/modals/modal-crafting.js, TabTibia r131), laid out like the screenshot the
 * owner gave (gyazo 9f015666ab872e04c3e4f58c259c67a9) in the colours of the market window (market.css): the tabs and the
 * search on top, then Craftable Items, Ingredients and Result side by side, Close under them. Fixed to the page with the
 * z-index of every modal (modal.css .modal).
 */

#crafting-modal.crafting-window {
  position: fixed;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 830px;
  height: 500px;
  max-width: calc(100vw - 8px);
  max-height: calc(100vh - 8px);
  box-sizing: border-box;
  flex-direction: column;
  background-image: url("/png/bg3.png");
  border: 1px solid black;
  box-shadow: 0 0 12px 0 black;
  color: #d8d8d8;
  font-size: 11px;
  user-select: none;
}

#crafting-modal button {
  margin: 0;
  padding: 2px 8px;
  border-radius: 2px;
  font-size: 10px;
}

#crafting-modal input {
  box-sizing: border-box;
  height: 20px;
  padding: 1px 4px;
  color: white;
  background: #111317;
  border: 1px solid #3a3f47;
  font-family: Verdana, "Sans-Serif";
  font-size: 11px;
  font-weight: bold;
}

.crafting-titlebar {
  position: relative;
  height: 18px;
  line-height: 18px;
  flex: 0 0 auto;
  text-align: center;
  color: #b8b8b8;
  background-image: url("/png/bg4.png");
}

.crafting-titlebar .crafting-close-x {
  position: absolute;
  right: 2px;
  top: 1px;
  padding: 0 4px;
  line-height: 14px;
}

.crafting-content {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 6px;
}

.crafting-top {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 8px;
}

.crafting-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 2px;
}

#crafting-modal .crafting-tab {
  min-width: 80px;
  padding: 4px 12px;
  font-size: 11px;
  color: #c8c8c8;
  background: #101114;
  background-image: none;
  border: 1px solid #2c2f35;
  border-bottom: none;
  border-radius: 0;
}

#crafting-modal .crafting-tab:hover {
  color: white;
  border-color: #6c6c6c;
}

#crafting-modal .crafting-tab.selected {
  color: white;
  background: #222833;
}

#crafting-modal .crafting-search {
  width: 180px;
}

.crafting-columns {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  gap: 4px;
}

.crafting-panel {
  flex: 1 1 0;
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  border: 1px solid black;
  background: #1a1c20;
}

.crafting-panel-title {
  flex: 0 0 auto;
  text-align: center;
  padding: 3px 0;
  font-weight: bold;
  background: #101114;
  border-bottom: 1px solid #2c2f35;
}

.crafting-scroll {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding: 4px;
}

.crafting-item,
.crafting-ingredient {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 4px;
  padding: 3px 6px;
  min-height: 34px;
  background: #121317;
  border: 1px solid #2a2d33;
}

.crafting-item {
  cursor: pointer;
}

.crafting-item:hover {
  border-color: #6c6c6c;
}

.crafting-item.selected {
  border: 2px solid #e8e8e8;
  padding: 2px 5px;
}

.crafting-item canvas,
.crafting-ingredient canvas,
.crafting-result-head canvas {
  width: 32px;
  height: 32px;
  flex: 0 0 32px;
  image-rendering: pixelated;
}

.crafting-item-text {
  flex: 1 1 auto;
  min-width: 0;
}

.crafting-item-name,
.crafting-ingredient-name {
  font-weight: bold;
  color: #e6e6e6;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.crafting-ingredient-name {
  flex: 1 1 auto;
  min-width: 0;
}

.crafting-note {
  text-align: right;
  font-style: italic;
  font-size: 10px;
}

.crafting-ok {
  color: #3fd13f;
}

.crafting-missing {
  color: #e53b3b;
}

.crafting-soon {
  color: #8a8a8a;
}

.crafting-ingredient-count {
  flex: 0 0 auto;
  font-weight: bold;
}

.crafting-empty {
  padding: 8px 4px;
  text-align: center;
  color: #8a8a8a;
}

.crafting-result {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 6px;
}

.crafting-result-head {
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: 34px;
  font-weight: bold;
  color: #e6e6e6;
}

.crafting-description {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  color: #3fd13f;
  font-weight: bold;
}

.crafting-status-title {
  text-align: center;
  font-weight: bold;
  color: #b8b8b8;
}

.crafting-status {
  padding: 5px;
  text-align: center;
  font-style: italic;
  background: #08090b;
  border: 1px solid #2a2d33;
}

.crafting-amount {
  display: flex;
  justify-content: center;
  gap: 4px;
}

#crafting-modal .crafting-amount input {
  width: 46px;
  text-align: center;
}

#crafting-modal .crafting-craft {
  padding: 7px 0;
  font-size: 11px;
  font-weight: bold;
  color: #d8d8d8;
  background: #0c1a28;
  background-image: none;
  border: 1px solid #23364a;
}

#crafting-modal .crafting-craft:disabled {
  color: #6f6f6f;
  background: #101114;
  border-color: #2a2d33;
}

.crafting-bottom {
  display: flex;
  justify-content: flex-end;
}

#crafting-modal .crafting-close {
  min-width: 70px;
  padding: 4px 12px;
}

/* A phone: the three panels one under the other, the window as tall as the screen allows */
@media (max-width: 720px) {
  #crafting-modal.crafting-window {
    height: calc(100vh - 8px);
  }
  .crafting-top {
    flex-direction: column;
    align-items: stretch;
  }
  #crafting-modal .crafting-search {
    width: 100%;
  }
  .crafting-columns {
    flex-direction: column;
    overflow-y: auto;
  }
  .crafting-panel {
    flex: 0 0 auto;
    min-height: 140px;
  }
  .crafting-scroll {
    max-height: 180px;
  }
}

/* r183b (user 2026-11-02: "otras ventanas del juego, como ... la de mejorar y Craft ... deberia hacerse con el estilo y que
   se vea bien en Movil que estas nuevas"): on a phone the station is the dark panel of the NPC windows (npc-dialog.css),
   over the HUD and inside the screen, with a 40 px title, a 34 px ✕, finger-sized tabs, rows and buttons, and 16 px fields
   (an iPhone zooms into a smaller one). Lying down the three panels stay side by side; upright they go one under the
   other: the list scrolls in its own box and the window is as tall as what it holds */
body.force-mobile #crafting-modal.crafting-window {
  z-index: 40000;
  width: min(830px, calc(100vw - 16px));
  height: calc(100dvh - 16px);
  max-width: none;
  max-height: calc(100dvh - 16px);
  background: rgba(38, 37, 35, 0.97);
  color: #ece6d6;
  border: 1px solid #0c0c0c;
  outline: 1px solid #4a4741;
  border-radius: 3px;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.7);
  font: 12px Verdana, Arial, sans-serif;
}
body.force-mobile .crafting-titlebar {
  height: 40px;
  line-height: 40px;
  background: linear-gradient(180deg, rgba(60, 58, 54, 0.9), rgba(40, 39, 36, 0.9));
  border-bottom: 1px solid #0c0c0c;
  font: bold 16px Verdana, Arial, sans-serif;
  color: #f4efe2;
}
body.force-mobile #crafting-modal .crafting-close-x {
  top: 3px;
  right: 4px;
  width: 34px;
  height: 34px;
  padding: 0;
  justify-content: center;
  align-items: center;
  font-size: 16px;
}
body.force-mobile #crafting-modal button {
  min-height: 34px;
  padding: 0 12px;
  font: bold 13px Verdana, Arial, sans-serif;
  color: #ece6d6;
  background: #1b1a18;
  border: 1px solid #0c0c0c;
  box-shadow: inset 0 0 0 1px #3d3a34;
  border-radius: 6px;
}
body.force-mobile #crafting-modal .crafting-tab.selected {
  color: #f1c75a;
  box-shadow: inset 0 0 0 1px #d9a72c;
}
body.force-mobile #crafting-modal input {
  height: 34px;
  font-size: 16px;
}
body.force-mobile #crafting-modal .crafting-amount input {
  width: 56px;
}
body.force-mobile #crafting-modal .crafting-craft {
  min-height: 40px;
  font-size: 15px;
}
body.force-mobile #crafting-modal .crafting-craft:not(:disabled) {
  color: #1d1606;
  background: #d9a72c;
  box-shadow: none;
}
body.force-mobile .crafting-panel-title {
  padding: 6px 0;
  font-size: 13px;
}
body.force-mobile .crafting-item {
  min-height: 44px;
}
body.force-mobile .crafting-bottom {
  display: none;
}
@media screen and (orientation: portrait) {
  body.force-mobile #crafting-modal.crafting-window {
    height: auto;
  }
  body.force-mobile .crafting-top {
    flex-direction: column;
    align-items: stretch;
    gap: 6px;
  }
  body.force-mobile .crafting-tabs {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 6px;
  }
  body.force-mobile #crafting-modal .crafting-tabs > * {
    min-width: 0;
    grid-column: span 2;
    margin: 0;
  }
  body.force-mobile .crafting-tabs > :nth-child(4),
  body.force-mobile .crafting-tabs > :nth-child(5) {
    grid-column: span 3;
  }
  body.force-mobile #crafting-modal .crafting-search {
    width: 100%;
  }
  body.force-mobile .crafting-columns {
    flex-direction: column;
    overflow-y: auto;
    min-height: 0;
  }
  body.force-mobile .crafting-panel {
    flex: 0 0 auto;
    min-height: 0;
  }
  body.force-mobile .crafting-items-panel .crafting-scroll {
    max-height: 30dvh;
  }
  body.force-mobile .crafting-ingredients-panel .crafting-scroll {
    max-height: 22dvh;
    min-height: 44px;
  }
}
body.force-mobile .crafting-titlebar {
  display: flex;
  align-items: center;
  justify-content: center;
}
body.force-mobile #crafting-modal input {
  font-family: Verdana, Arial, sans-serif;
}
