/* ============================================================
   LOGROS — PANEL
   ============================================================ */
#achievements-section {
  background: var(--bg-panel);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
}

#achievements-section h2 {
  margin-bottom: 4px;
}

.achievements-summary {
  font-size: 11px;
  color: var(--text-muted);
  margin-bottom: 12px;
}

#achievements-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 8px;
}

/* ---- Card de logro ---- */
.ach-card {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  transition: border-color 0.2s;
}

/* Raridades — borde izquierdo de color */
.ach-card.bronze  { border-left: 3px solid #cd7f32; }
.ach-card.silver  { border-left: 3px solid #a8a9ad; }
.ach-card.gold    { border-left: 3px solid #fbbf24; }
.ach-card.diamond { border-left: 3px solid #38bdf8; }

.ach-card.locked {
  opacity: 0.4;
  filter: grayscale(1);
}

.ach-icon {
  font-size: 24px;
  flex-shrink: 0;
  line-height: 1;
}

.ach-info {
  min-width: 0;
}

.ach-name {
  font-weight: 700;
  font-size: 12px;
  line-height: 1.3;
}

.ach-desc {
  font-size: 10px;
  color: var(--text-muted);
  margin-top: 2px;
  line-height: 1.4;
}

.ach-rarity {
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-top: 4px;
}

.ach-card.bronze  .ach-rarity { color: #cd7f32; }
.ach-card.silver  .ach-rarity { color: #a8a9ad; }
.ach-card.gold    .ach-rarity { color: #d97706; }
.ach-card.diamond .ach-rarity { color: #0ea5e9; }

/* ============================================================
   TOAST DE LOGRO
   ============================================================ */
#achievement-toast-container {
  position: fixed;
  bottom: 72px;   /* encima del tab bar en móvil */
  right: 16px;
  z-index: 2000;
  display: flex;
  flex-direction: column-reverse;
  gap: 8px;
  pointer-events: none;
}

.achievement-toast {
  display: flex;
  align-items: center;
  gap: 10px;
  background: #1e293b;
  color: #fff;
  border-radius: 10px;
  padding: 10px 14px;
  box-shadow: 0 6px 20px rgba(0,0,0,0.28);
  min-width: 230px;
  max-width: 300px;
  border-left: 4px solid #fbbf24;
  animation: toastIn 0.4s cubic-bezier(.22,.68,0,1.2) forwards;
  pointer-events: auto;
}

.achievement-toast.bronze  { border-color: #cd7f32; }
.achievement-toast.silver  { border-color: #a8a9ad; }
.achievement-toast.gold    { border-color: #fbbf24; }
.achievement-toast.diamond { border-color: #38bdf8; }

.achievement-toast.hide {
  animation: toastOut 0.35s ease forwards;
}

@keyframes toastIn {
  from { transform: translateX(120%); opacity: 0; }
  to   { transform: translateX(0);    opacity: 1; }
}

@keyframes toastOut {
  from { transform: translateX(0);    opacity: 1; }
  to   { transform: translateX(120%); opacity: 0; }
}

.toast-icon {
  font-size: 26px;
  flex-shrink: 0;
  line-height: 1;
}

.toast-body {}

.toast-label {
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  opacity: 0.6;
  margin-bottom: 2px;
}

.toast-name {
  font-size: 13px;
  font-weight: 700;
  line-height: 1.2;
}

.toast-desc {
  font-size: 11px;
  opacity: 0.7;
  margin-top: 2px;
}

/* ============================================================
   EXPANSIÓN — dentro de la tarjeta de departamento
   ============================================================ */
.dept-cap-row {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 5px;
  padding-top: 6px;
  border-top: 1px dashed var(--border);
}

.dept-cap-track {
  flex: 1;
  height: 4px;
  background: #e2e8f0;
  border-radius: 2px;
  overflow: hidden;
}

.dept-cap-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 2px;
  transition: width 0.5s ease;
}

.dept-cap-fill.near-cap { background: var(--yellow); }
.dept-cap-fill.at-cap   { background: var(--red); }

.dept-cap-label {
  font-size: 10px;
  color: var(--text-muted);
  white-space: nowrap;
  flex-shrink: 0;
}

.btn-expand {
  background: #4b5563;
  color: #d1d5db;
  border: 1px solid #6b7280;
  padding: 4px 9px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 10px;
  font-weight: 700;
  white-space: nowrap;
  flex-shrink: 0;
  line-height: 1.3;
  text-align: center;
  transition: background 0.15s, transform 0.1s;
  min-height: 32px;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

/* Cuando está listo para comprar (at cap + afford) */
.btn-expand.ready {
  background: linear-gradient(135deg, #7c3aed, #6d28d9);
  border-color: transparent;
  color: #fff;
  animation: expand-pulse 2s ease-in-out infinite;
  will-change: transform;
}

@keyframes expand-pulse {
  0%, 100% { transform: scale(1);    filter: brightness(1); }
  50%       { transform: scale(1.05); filter: brightness(1.2); }
}

.btn-expand.ready:hover {
  background: linear-gradient(135deg, #6d28d9, #5b21b6);
  transform: translateY(-1px);
}

.btn-expand:disabled:not(.ready) {
  cursor: not-allowed;
}

/* Segunda línea del botón: costo + cap */
.btn-expand-detail {
  display: block;
  font-size: 9px;
  font-weight: 400;
  opacity: .75;
  margin-top: 1px;
}

/* Badge de multiplicador activo junto a la producción */
.dept-expand-badge {
  display: inline-block;
  background: rgba(124, 58, 237, .2);
  border: 1px solid #7c3aed;
  color: #a78bfa;
  font-size: 10px;
  font-weight: 700;
  border-radius: 4px;
  padding: 0 4px;
  margin-left: 4px;
  vertical-align: middle;
}

/* Hint cuando no está lleno pero puede expandirse */
.dept-expand-hint {
  font-size: 9px;
  color: var(--text-muted);
  flex-shrink: 0;
  opacity: .7;
}

/* Etiqueta nivel expansión */
.dept-expand-lv {
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #7c3aed;
  flex-shrink: 0;
}

/* ============================================================
   RESPONSIVE — MOBILE
   ============================================================ */
@media (max-width: 640px) {
  #achievements-grid {
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  }
  .ach-icon  { font-size: 20px; }
  .ach-name  { font-size: 11px; }
  .ach-desc  { font-size: 10px; }

  #achievement-toast-container {
    bottom: 80px;
    right: 8px;
    left: 8px;
  }
  .achievement-toast {
    min-width: unset;
    max-width: unset;
    width: 100%;
  }
}

@media (min-width: 641px) {
  #achievement-toast-container { bottom: 16px; }
}
