/* ==========================================================================
   toolbar.css — Bottom toolbar: category tabs + building item cards
   ========================================================================== */

/* ---------------------------------------------------------------------------
   Toolbar Container
   --------------------------------------------------------------------------- */
#toolbar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: var(--z-hud);

  display: flex;
  flex-direction: column;

  background: linear-gradient(0deg, rgba(10, 12, 18, 0.94), rgba(14, 16, 24, 0.88));
  backdrop-filter: blur(24px) saturate(1.3);
  -webkit-backdrop-filter: blur(24px) saturate(1.3);
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  box-shadow:
    0 -1px 0 rgba(255, 255, 255, 0.03) inset,
    0 -8px 32px rgba(0, 0, 0, 0.5);
}

/* ---------------------------------------------------------------------------
   Category Tabs (top row)
   --------------------------------------------------------------------------- */
.toolbar-tabs {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 8px 16px 4px;
  overflow-x: auto;
  scrollbar-width: none;
}

.toolbar-tabs::-webkit-scrollbar {
  display: none;
}

.toolbar-tab {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 16px;
  border-radius: var(--radius-pill);
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-secondary);
  font-family: var(--font-body);
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  cursor: pointer;
}

.toolbar-tab svg {
  width: 14px;
  height: 14px;
  vertical-align: -2px;
  white-space: nowrap;
  transition: all var(--transition-fast);
}

.toolbar-tab:hover {
  background: var(--surface-hover);
  color: var(--text-primary);
}

/* Active tab — mint glow */
.toolbar-tab.active {
  background: rgba(0, 212, 170, 0.14);
  border-color: rgba(0, 212, 170, 0.3);
  color: var(--color-primary);
  box-shadow: 0 0 16px rgba(0, 212, 170, 0.1);
}

/* Category-specific colors */
.toolbar-tab[data-category="production"].active {
  background: rgba(0, 212, 170, 0.14);
  border-color: rgba(0, 212, 170, 0.3);
  color: var(--color-primary);
  box-shadow: 0 0 16px rgba(0, 212, 170, 0.1);
}

.toolbar-tab[data-category="storage"].active {
  background: rgba(255, 140, 66, 0.14);
  border-color: rgba(255, 140, 66, 0.3);
  color: var(--color-secondary);
  box-shadow: 0 0 16px rgba(255, 140, 66, 0.1);
}

.toolbar-tab[data-category="logistics"].active {
  background: rgba(124, 106, 255, 0.14);
  border-color: rgba(124, 106, 255, 0.3);
  color: var(--color-accent);
  box-shadow: 0 0 16px rgba(124, 106, 255, 0.1);
}

.toolbar-tab[data-category="support"].active {
  background: rgba(52, 211, 153, 0.14);
  border-color: rgba(52, 211, 153, 0.3);
  color: var(--color-success);
  box-shadow: 0 0 16px rgba(52, 211, 153, 0.1);
}

.toolbar-tab[data-category="scenic"].active {
  background: rgba(255, 215, 0, 0.14);
  border-color: rgba(255, 215, 0, 0.3);
  color: var(--color-cash);
  box-shadow: 0 0 16px rgba(255, 215, 0, 0.1);
}

/* ---------------------------------------------------------------------------
   Item Cards — horizontal scrolling strip
   --------------------------------------------------------------------------- */
.toolbar-items {
  position: relative;
  display: flex;
  align-items: stretch;
  gap: 6px;
  flex: 1;
  padding: 4px 16px 10px;
  overflow-x: auto;
  overflow-y: hidden;
  scroll-behavior: smooth;
  scrollbar-width: none;
}

.toolbar-items::-webkit-scrollbar {
  display: none;
}

/* Individual item card */
.toolbar-card {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  width: 76px;
  padding: 8px 6px 6px;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.05);
  cursor: pointer;
  transition: all var(--transition-fast);
  position: relative;
}

.toolbar-card:hover {
  transform: translateY(-3px);
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.12);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3);
}

.toolbar-card:active {
  transform: translateY(-1px);
}

/* Active / selected card */
.toolbar-card.active {
  background: rgba(0, 212, 170, 0.12);
  border-color: rgba(0, 212, 170, 0.4);
  box-shadow:
    0 0 16px rgba(0, 212, 170, 0.15),
    0 0 1px rgba(0, 212, 170, 0.5) inset;
}

.toolbar-card.active .toolbar-card-name {
  color: var(--color-primary);
}

.toolbar-card.active .toolbar-card-icon {
  filter: drop-shadow(0 2px 8px currentColor) brightness(1.2);
}

/* Card icon */
.toolbar-card-icon {
  font-size: 26px;
  line-height: 1;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.3));
  display: flex;
  align-items: center;
  justify-content: center;
}

.toolbar-card-icon svg {
  width: 26px;
  height: 26px;
}

/* Category-tinted card icons */
.toolbar-items[data-category="production"] .toolbar-card-icon {
  color: #00d4aa;
  filter: drop-shadow(0 2px 6px rgba(0, 212, 170, 0.35));
}
.toolbar-items[data-category="storage"] .toolbar-card-icon {
  color: #ff8c42;
  filter: drop-shadow(0 2px 6px rgba(255, 140, 66, 0.35));
}
.toolbar-items[data-category="logistics"] .toolbar-card-icon {
  color: #7c6aff;
  filter: drop-shadow(0 2px 6px rgba(124, 106, 255, 0.35));
}
.toolbar-items[data-category="support"] .toolbar-card-icon {
  color: #34d399;
  filter: drop-shadow(0 2px 6px rgba(52, 211, 153, 0.35));
}
.toolbar-items[data-category="scenic"] .toolbar-card-icon {
  color: #ffd700;
  filter: drop-shadow(0 2px 6px rgba(255, 215, 0, 0.35));
}

/* Card name */
.toolbar-card-name {
  font-family: var(--font-body);
  font-size: 10px;
  font-weight: 600;
  color: var(--text-primary);
  text-align: center;
  line-height: 1.2;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Card cost */
.toolbar-card-cost {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 600;
  color: var(--color-cash);
  font-variant-numeric: tabular-nums;
  opacity: 0.85;
}

.toolbar-card-cost.free {
  color: var(--color-success);
}

/* ---------------------------------------------------------------------------
   State: Unaffordable
   --------------------------------------------------------------------------- */
.toolbar-card.unaffordable {
  opacity: 0.35;
  cursor: not-allowed;
  filter: grayscale(0.3);
}

.toolbar-card.unaffordable:hover {
  transform: none;
  box-shadow: none;
  background: rgba(255, 255, 255, 0.03);
  border-color: rgba(255, 255, 255, 0.05);
}

.toolbar-card.unaffordable .toolbar-card-cost {
  color: var(--color-danger);
  opacity: 1;
}

/* ---------------------------------------------------------------------------
   State: Locked
   --------------------------------------------------------------------------- */
.toolbar-card.locked {
  opacity: 0.3;
  cursor: not-allowed;
  position: relative;
}

.toolbar-card.locked:hover {
  transform: none;
  box-shadow: none;
}

.toolbar-card.locked::after {
  content: '\1F512';
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  background: rgba(10, 12, 18, 0.6);
  border-radius: var(--radius-sm);
}

/* ---------------------------------------------------------------------------
   Tooltip
   --------------------------------------------------------------------------- */
.toolbar-tooltip {
  font-family: var(--font-body);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}

/* ---------------------------------------------------------------------------
   Scroll Arrows
   --------------------------------------------------------------------------- */
.toolbar-scroll-arrow {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: rgba(10, 12, 18, 0.9);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: var(--text-secondary);
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 2;
  transition: all var(--transition-fast);
}

.toolbar-scroll-arrow:hover {
  background: rgba(20, 22, 32, 0.95);
  color: var(--text-primary);
  border-color: rgba(255, 255, 255, 0.2);
}

.toolbar-scroll-arrow.left { left: 4px; }
.toolbar-scroll-arrow.right { right: 4px; }
.toolbar-scroll-arrow.hidden { display: none; }

/* ---------------------------------------------------------------------------
   Responsive
   --------------------------------------------------------------------------- */
@media (max-width: 768px) {
  .toolbar-tabs { padding: 6px 10px 2px; }
  .toolbar-items { padding: 2px 10px 8px; gap: 4px; }
  .toolbar-card { width: 64px; padding: 6px 4px 4px; }
  .toolbar-card-icon { font-size: 22px; }
  .toolbar-card-icon svg { width: 22px; height: 22px; }
  .toolbar-card-name { font-size: 9px; }
  .toolbar-tab { padding: 4px 10px; font-size: 10px; }
}

/* ---------------------------------------------------------------------------
   Phone breakpoint
   --------------------------------------------------------------------------- */
@media (max-width: 767px) {
    #toolbar {
        padding-bottom: var(--safe-bottom);
        padding-left: var(--safe-left);
        padding-right: var(--safe-right);
    }

    .toolbar-tabs {
        gap: 2px;
        padding: 6px 8px 2px;
    }

    .toolbar-tab {
        min-width: 44px;
        min-height: 40px;
        padding: 6px 8px;
        font-size: 0; /* hide text, show only icon */
        justify-content: center;
    }
    .toolbar-tab svg {
        width: 20px;
        height: 20px;
    }

    .toolbar-items {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        flex-wrap: nowrap;
        gap: 6px;
        padding: 4px 8px 8px;
        /* Scroll fade hints */
        mask-image: linear-gradient(to right, transparent 0px, black 8px, black calc(100% - 8px), transparent 100%);
        -webkit-mask-image: linear-gradient(to right, transparent 0px, black 8px, black calc(100% - 8px), transparent 100%);
    }
    .toolbar-items::-webkit-scrollbar { display: none; }

    .toolbar-card {
        min-width: 64px;
        width: 64px;
        flex-shrink: 0;
        padding: 6px 4px 4px;
    }
    .toolbar-card-icon { font-size: 22px; }
    .toolbar-card-icon svg { width: 22px; height: 22px; }
    .toolbar-card-name { font-size: 9px; }
    .toolbar-card-cost { font-size: 9px; }

    /* Hide scroll arrows on touch devices */
    .toolbar-scroll-arrow { display: none !important; }
}

/* ---------------------------------------------------------------------------
   Landscape phone — compact toolbar when viewport is short
   --------------------------------------------------------------------------- */
@media (max-height: 500px) and (max-width: 1024px) {
    #toolbar {
        padding-bottom: var(--safe-bottom);
        padding-left: var(--safe-left);
        padding-right: var(--safe-right);
    }

    .toolbar-tabs {
        gap: 2px;
        padding: 2px 8px 0;
    }

    .toolbar-tab {
        padding: 2px 6px;
        font-size: 9px;
        min-height: unset;
    }
    .toolbar-tab svg {
        width: 12px;
        height: 12px;
    }

    .toolbar-items {
        padding: 1px 8px 2px;
        gap: 3px;
    }

    .toolbar-card {
        width: 48px;
        min-width: 48px;
        padding: 2px 2px 1px;
        gap: 0;
    }
    .toolbar-card-icon { font-size: 16px; }
    .toolbar-card-icon svg { width: 16px; height: 16px; }
    .toolbar-card-name { font-size: 7px; }
    .toolbar-card-cost { font-size: 7px; }

    .toolbar-scroll-arrow { display: none !important; }
}
