/* alchemy.css — Đan Đạo Các · Liễu Nhất Đan (Luyện Đan & Đột Phá Bình Cảnh) */

.al-modal {
  position: fixed;
  inset: 0;
  z-index: 10000;
  pointer-events: auto !important;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent !important;
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
  padding: 16px;
  animation: alFadeIn 0.25s ease-out;
}

.al-modal * {
  pointer-events: auto;
}

/* Scrollbars for recipe list and workspace */
.al-recipe-list,
.al-workspace {
  scrollbar-width: thin !important;
  scrollbar-color: rgba(16, 185, 129, 0.4) transparent !important;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y;
}

.al-recipe-list::-webkit-scrollbar,
.al-workspace::-webkit-scrollbar {
  display: block !important;
  width: 4px !important;
  height: 4px !important;
}

.al-recipe-list::-webkit-scrollbar-thumb,
.al-workspace::-webkit-scrollbar-thumb {
  background: rgba(16, 185, 129, 0.35) !important;
  border-radius: 4px !important;
}

.al-modal.hidden {
  display: none !important;
  pointer-events: none !important;
}

@keyframes alFadeIn {
  from { opacity: 0; transform: scale(0.98); }
  to { opacity: 1; transform: scale(1); }
}

.al-window {
  width: 100%;
  max-width: 960px;
  height: min(94%, 620px);
  max-height: 94%;
  min-height: 0;
  background: linear-gradient(175deg, #091c18 0%, #04100e 100%);
  border: 1px solid rgba(16, 185, 129, 0.35);
  border-radius: 16px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.9), 0 0 35px rgba(16, 185, 129, 0.15);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  color: #f1f5f9;
  font-family: 'Handjet', 'Be Vietnam Pro', monospace;
  box-sizing: border-box;
}

/* Header */
.al-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 22px;
  background: linear-gradient(90deg, rgba(16, 185, 129, 0.2), rgba(6, 78, 59, 0.6) 50%, rgba(16, 185, 129, 0.08));
  border-bottom: 1px solid rgba(16, 185, 129, 0.25);
  flex-shrink: 0;
}

.al-header-title {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.al-title-badge {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.15em;
  color: #34d399;
  text-transform: uppercase;
}

.al-title-text {
  font-size: 20px;
  font-weight: 800;
  color: #ffffff;
  text-shadow: 0 0 12px rgba(52, 211, 153, 0.5);
  letter-spacing: 0.05em;
}

/* Mode Switcher Tabs */
.al-mode-tabs {
  display: flex;
  background: rgba(0, 0, 0, 0.55);
  border: 1px solid rgba(16, 185, 129, 0.3);
  border-radius: 10px;
  padding: 3px;
  gap: 4px;
}
.al-mode-btn {
  background: transparent;
  border: none;
  color: #94a3b8;
  padding: 6px 14px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 800;
  cursor: pointer;
  transition: all 0.2s;
  font-family: inherit;
  display: flex;
  align-items: center;
  gap: 6px;
}
.al-mode-btn:hover {
  color: #e2e8f0;
}
.al-mode-btn.active {
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.85), rgba(5, 150, 105, 0.95));
  color: #ffffff;
  box-shadow: 0 2px 10px rgba(16, 185, 129, 0.4);
}

.al-header-stats {
  display: flex;
  align-items: center;
  gap: 16px;
}

.al-stat-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(0, 0, 0, 0.45);
  border: 1px solid rgba(255, 255, 255, 0.12);
  padding: 5px 12px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 700;
}

.al-stat-badge.stones {
  color: #facc15;
  border-color: rgba(250, 204, 21, 0.3);
}

.al-stat-badge img {
  width: 18px;
  height: 18px;
  object-fit: contain;
}

.al-close-btn {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: #94a3b8;
  font-size: 18px;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.al-close-btn:hover {
  background: rgba(239, 68, 68, 0.2);
  border-color: #ef4444;
  color: #ef4444;
}

/* Body Layout */
.al-body {
  display: grid;
  grid-template-columns: 320px 1fr;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

/* Left Sidebar: Recipe List */
.al-recipes-sidebar {
  background: rgba(0, 0, 0, 0.35);
  border-right: 1px solid rgba(16, 185, 129, 0.15);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.al-sidebar-head {
  padding: 10px 14px;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #34d399;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  background: rgba(16, 185, 129, 0.06);
}

.al-recipe-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.al-recipe-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.06);
  cursor: pointer;
  transition: all 0.18s;
  text-align: left;
}

.al-recipe-item:hover {
  background: rgba(16, 185, 129, 0.08);
  border-color: rgba(16, 185, 129, 0.3);
}

.al-recipe-item.selected {
  background: linear-gradient(90deg, rgba(16, 185, 129, 0.22), rgba(6, 78, 59, 0.3));
  border-color: #10b981;
  box-shadow: 0 0 14px rgba(16, 185, 129, 0.2);
}

.al-recipe-icon-box {
  width: 42px;
  height: 42px;
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.5);
  border: 1px solid rgba(255, 255, 255, 0.12);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  flex-shrink: 0;
}

.al-recipe-icon-box img {
  width: 34px;
  height: 34px;
  object-fit: contain;
}

.al-recipe-meta {
  flex: 1;
  min-width: 0;
}

.al-recipe-name {
  font-size: 14px;
  font-weight: 700;
  color: #f8fafc;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.al-recipe-sub {
  font-size: 11px;
  color: #94a3b8;
  margin-top: 2px;
}

.al-recipe-badge {
  font-size: 10px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 4px;
  background: rgba(16, 185, 129, 0.15);
  color: #34d399;
  border: 1px solid rgba(16, 185, 129, 0.3);
}

/* Right Detail: Furnace Workspace */
.al-workspace {
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  min-height: 0;
  padding: 20px 24px;
  background: radial-gradient(circle at 50% 25%, rgba(16, 185, 129, 0.08) 0%, transparent 70%);
  gap: 18px;
}

/* Big Pill Showcase */
.al-showcase {
  display: flex;
  align-items: center;
  gap: 20px;
  background: rgba(0, 0, 0, 0.45);
  border: 1px solid rgba(16, 185, 129, 0.25);
  border-radius: 14px;
  padding: 16px 20px;
  box-shadow: inset 0 0 20px rgba(0, 0, 0, 0.6);
}

.al-furnace-glow-box {
  width: 80px;
  height: 80px;
  border-radius: 16px;
  background: radial-gradient(circle, rgba(16, 185, 129, 0.3) 0%, rgba(0, 0, 0, 0.6) 80%);
  border: 1px solid rgba(52, 211, 153, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 25px rgba(16, 185, 129, 0.35);
  position: relative;
  flex-shrink: 0;
}

.al-furnace-glow-box img {
  width: 64px;
  height: 64px;
  object-fit: contain;
  filter: drop-shadow(0 0 8px rgba(52, 211, 153, 0.6));
  animation: alFloat 3s ease-in-out infinite;
}

@keyframes alFloat {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-4px); }
}

.al-showcase-info {
  flex: 1;
}

.al-showcase-name {
  font-size: 20px;
  font-weight: 800;
  color: #34d399;
  letter-spacing: 0.04em;
  text-shadow: 0 0 10px rgba(52, 211, 153, 0.4);
}

.al-showcase-desc {
  font-size: 13px;
  color: #cbd5e1;
  margin-top: 4px;
  line-height: 1.4;
}

.al-showcase-target {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 8px;
  padding: 3px 10px;
  border-radius: 6px;
  background: rgba(250, 204, 21, 0.12);
  border: 1px solid rgba(250, 204, 21, 0.3);
  color: #facc15;
  font-size: 11px;
  font-weight: 700;
}

/* Materials Required Checklist */
.al-section-title {
  font-size: 13px;
  font-weight: 700;
  color: #94a3b8;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  display: flex;
  align-items: center;
  gap: 8px;
}

.al-materials-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 10px;
}

.al-mat-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 10px;
  transition: all 0.2s;
}

.al-mat-card.ready {
  border-color: rgba(16, 185, 129, 0.4);
  background: rgba(16, 185, 129, 0.05);
}

.al-mat-card.missing {
  border-color: rgba(239, 68, 68, 0.3);
  background: rgba(239, 68, 68, 0.05);
}

.al-mat-icon {
  width: 36px;
  height: 36px;
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.1);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.al-mat-icon img {
  width: 28px;
  height: 28px;
  object-fit: contain;
}

.al-mat-info {
  flex: 1;
  min-width: 0;
}

.al-mat-name {
  font-size: 13px;
  font-weight: 700;
  color: #f1f5f9;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.al-mat-count {
  font-size: 12px;
  margin-top: 2px;
  font-weight: 600;
}

.al-mat-count.ok {
  color: #34d399;
}

.al-mat-count.no {
  color: #f87171;
}

/* Action Footer */
.al-action-box {
  margin-top: auto;
  background: rgba(0, 0, 0, 0.5);
  border: 1px solid rgba(16, 185, 129, 0.2);
  border-radius: 12px;
  padding: 14px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.al-cost-info {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.al-cost-label {
  font-size: 11px;
  color: #94a3b8;
  text-transform: uppercase;
}

.al-cost-val {
  font-size: 16px;
  font-weight: 800;
  color: #facc15;
  display: flex;
  align-items: center;
  gap: 6px;
}

.al-cost-val img {
  width: 18px;
  height: 18px;
}

.al-craft-btn {
  padding: 12px 32px;
  border-radius: 10px;
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  border: 1px solid #34d399;
  color: #ffffff;
  font-size: 16px;
  font-weight: 800;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(16, 185, 129, 0.4);
  transition: all 0.2s;
  letter-spacing: 0.05em;
  display: flex;
  align-items: center;
  gap: 8px;
}

.al-craft-btn:hover:not(:disabled) {
  background: linear-gradient(135deg, #34d399 0%, #10b981 100%);
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(52, 211, 153, 0.5);
}

.al-craft-btn:disabled {
  background: #334155;
  border-color: #475569;
  color: #94a3b8;
  cursor: not-allowed;
  box-shadow: none;
  transform: none;
}

/* Category Filter Tabs in Sidebar */
.al-recipe-filter-tabs {
  display: flex;
  padding: 8px 10px;
  gap: 6px;
  background: rgba(0, 0, 0, 0.45);
  border-bottom: 1px solid rgba(16, 185, 129, 0.15);
}
.al-filter-btn {
  flex: 1;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.09);
  color: #94a3b8;
  font-size: 11.5px;
  font-weight: 700;
  padding: 6px 4px;
  border-radius: 7px;
  cursor: pointer;
  transition: all 0.15s;
  text-align: center;
  font-family: inherit;
}
.al-filter-btn:hover {
  color: #f1f5f9;
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(16, 185, 129, 0.3);
}
.al-filter-btn.active {
  background: rgba(16, 185, 129, 0.22);
  border-color: #10b981;
  color: #34d399;
  box-shadow: 0 0 10px rgba(16, 185, 129, 0.25);
}

/* Batch Count Selector in Workspace */
.al-batch-selector {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: 10px;
  width: fit-content;
  margin-top: 6px;
}
.al-batch-label {
  font-size: 12px;
  color: #94a3b8;
  font-weight: 700;
  letter-spacing: 0.03em;
}
.al-batch-btn {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: #cbd5e1;
  padding: 5px 12px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s;
  font-family: inherit;
}
.al-batch-btn:hover {
  background: rgba(16, 185, 129, 0.15);
  border-color: #10b981;
  color: #ffffff;
}
.al-batch-btn.active {
  background: #10b981;
  border-color: #34d399;
  color: #064e3b;
  font-weight: 800;
  box-shadow: 0 0 10px rgba(16, 185, 129, 0.4);
}

/* ==========================================================================
   Responsive for Mobile Landscape & Small Screen Viewports
   ========================================================================== */
@media (max-height: 620px), (max-width: 860px) {
  .al-modal {
    padding: 4px !important;
  }

  .al-window {
    width: 100% !important;
    max-width: 98% !important;
    height: 98% !important;
    max-height: 98% !important;
    min-height: 0 !important;
    border-radius: 12px !important;
  }

  /* Compact Header */
  .al-header {
    padding: 5px 12px !important;
    gap: 8px !important;
  }
  .al-header-title {
    gap: 0 !important;
    min-width: 0;
  }
  .al-title-badge {
    display: none !important;
  }
  .al-title-text {
    font-size: 13.5px !important;
    white-space: nowrap !important;
    letter-spacing: 0.02em !important;
  }
  .al-mode-tabs {
    padding: 2px !important;
    gap: 2px !important;
    border-radius: 8px !important;
  }
  .al-mode-btn {
    padding: 4px 8px !important;
    font-size: 11px !important;
    gap: 4px !important;
    border-radius: 6px !important;
    white-space: nowrap !important;
  }
  .al-header-stats {
    gap: 6px !important;
  }
  .al-stat-badge {
    padding: 3px 8px !important;
    font-size: 11px !important;
    gap: 4px !important;
    border-radius: 12px !important;
  }
  .al-stat-badge img {
    width: 13px !important;
    height: 13px !important;
  }
  .al-close-btn {
    width: 28px !important;
    height: 28px !important;
    font-size: 14px !important;
    border-radius: 6px !important;
    flex-shrink: 0;
  }

  /* Body Grid */
  .al-body {
    grid-template-columns: 220px 1fr !important;
    min-height: 0 !important;
  }

  /* Left Sidebar: Recipe List */
  .al-sidebar-head {
    padding: 4px 8px !important;
    font-size: 11px !important;
  }
  .al-recipe-filter-tabs {
    padding: 4px 6px !important;
    gap: 4px !important;
  }
  .al-filter-btn {
    padding: 3px 2px !important;
    font-size: 10px !important;
    white-space: nowrap !important;
    border-radius: 6px !important;
  }
  .al-recipe-list {
    padding: 5px !important;
    gap: 4px !important;
    min-height: 0 !important;
  }
  .al-recipe-item {
    padding: 5px 7px !important;
    gap: 6px !important;
    border-radius: 8px !important;
  }
  .al-recipe-icon-box {
    width: 32px !important;
    height: 32px !important;
    border-radius: 6px !important;
  }
  .al-recipe-icon-box img {
    width: 24px !important;
    height: 24px !important;
  }
  .al-recipe-name {
    font-size: 11.5px !important;
  }
  .al-recipe-sub {
    font-size: 9.5px !important;
    margin-top: 1px !important;
  }
  .al-recipe-badge {
    font-size: 9px !important;
    padding: 1px 4px !important;
  }

  /* Right Detail: Workspace */
  .al-workspace {
    padding: 6px 12px !important;
    gap: 6px !important;
    min-height: 0 !important;
  }
  .al-showcase {
    padding: 6px 10px !important;
    gap: 10px !important;
    border-radius: 8px !important;
  }
  .al-furnace-glow-box {
    width: 44px !important;
    height: 44px !important;
    border-radius: 10px !important;
  }
  .al-furnace-glow-box img {
    width: 34px !important;
    height: 34px !important;
  }
  .al-showcase-name {
    font-size: 13.5px !important;
  }
  .al-showcase-desc {
    font-size: 10.5px !important;
    margin-top: 2px !important;
    line-height: 1.3 !important;
  }
  .al-showcase-target {
    font-size: 9.5px !important;
    padding: 2px 6px !important;
    margin-top: 4px !important;
  }
  .al-section-title {
    font-size: 11px !important;
    gap: 4px !important;
    margin-top: 1px !important;
  }
  .al-batch-selector {
    padding: 4px 8px !important;
    gap: 4px !important;
    border-radius: 6px !important;
    margin-top: 2px !important;
  }
  .al-batch-label {
    font-size: 10.5px !important;
  }
  .al-batch-btn {
    padding: 3px 8px !important;
    font-size: 10.5px !important;
    border-radius: 4px !important;
  }
  .al-materials-grid {
    grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)) !important;
    gap: 5px !important;
  }
  .al-mat-card {
    padding: 4px 8px !important;
    gap: 6px !important;
    border-radius: 6px !important;
  }
  .al-mat-icon {
    width: 26px !important;
    height: 26px !important;
    border-radius: 5px !important;
  }
  .al-mat-icon img {
    width: 20px !important;
    height: 20px !important;
  }
  .al-mat-name {
    font-size: 11px !important;
  }
  .al-mat-count {
    font-size: 10px !important;
  }
  .al-action-box {
    padding: 6px 12px !important;
    gap: 10px !important;
    border-radius: 8px !important;
    margin-top: auto !important;
  }
  .al-cost-label {
    font-size: 9.5px !important;
  }
  .al-cost-val {
    font-size: 13px !important;
    gap: 4px !important;
  }
  .al-cost-val img {
    width: 14px !important;
    height: 14px !important;
  }
  .al-craft-btn {
    padding: 6px 16px !important;
    font-size: 12.5px !important;
    border-radius: 8px !important;
  }
}

/* Narrow portrait phone (height > width, width <= 600px) */
@media (max-width: 600px) and (orientation: portrait) {
  .al-body {
    grid-template-columns: 1fr !important;
  }
  .al-recipes-sidebar {
    max-height: 170px !important;
    border-right: none !important;
    border-bottom: 1px solid rgba(16, 185, 129, 0.2) !important;
  }
}

