/* ============================================================================
   Tamagotchi as a Service — Stylesheet
   Premium dark theme with neon accents and glassmorphism
   ============================================================================ */

:root {
  --bg-primary: #0a0a1a;
  --bg-card: rgba(20, 20, 45, 0.7);
  --bg-card-hover: rgba(30, 30, 60, 0.85);
  --glass-border: rgba(255, 255, 255, 0.08);
  --text-primary: #e8e8f0;
  --text-secondary: #8888aa;
  --text-muted: #555577;
  --accent-cyan: #00e5ff;
  --accent-magenta: #ff00e5;
  --accent-purple: #a855f7;
  --accent-green: #00ff88;
  --accent-red: #ff4466;
  --accent-yellow: #ffbb00;
  --accent-orange: #ff8800;
  --gradient-primary: linear-gradient(135deg, #a855f7 0%, #00e5ff 100%);
  --gradient-danger: linear-gradient(135deg, #ff4466 0%, #ff8800 100%);
  --shadow-glow: 0 0 20px rgba(168, 85, 247, 0.3);
  --radius-sm: 8px;
  --radius-md: 16px;
  --radius-lg: 24px;
  --font: 'Space Grotesk', system-ui, sans-serif;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: var(--font);
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  overflow-x: hidden;
}

body::before {
  content: '';
  position: fixed;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: radial-gradient(ellipse at 20% 50%, rgba(168, 85, 247, 0.08) 0%, transparent 50%),
              radial-gradient(ellipse at 80% 20%, rgba(0, 229, 255, 0.06) 0%, transparent 50%),
              radial-gradient(ellipse at 50% 80%, rgba(255, 0, 229, 0.05) 0%, transparent 50%);
  z-index: -1;
  animation: bgShift 20s ease-in-out infinite alternate;
}

@keyframes bgShift {
  0% { transform: translate(0, 0) rotate(0deg); }
  100% { transform: translate(-5%, 3%) rotate(3deg); }
}

/* ---- Header ---- */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.2rem 2rem;
  backdrop-filter: blur(20px);
  background: rgba(10, 10, 26, 0.8);
  border-bottom: 1px solid var(--glass-border);
  position: sticky;
  top: 0;
  z-index: 100;
}

.header__logo {
  display: flex;
  align-items: center;
  gap: 0.7rem;
}

.header__emoji {
  font-size: 2rem;
  animation: bounce 2s ease-in-out infinite;
}

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

.header__logo h1 {
  font-size: 1.3rem;
  font-weight: 700;
  letter-spacing: -0.5px;
}

.header__accent {
  background: var(--gradient-primary);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.header__stats {
  display: flex;
  gap: 0.5rem;
}

.stat-chip {
  padding: 0.35rem 0.8rem;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 600;
  backdrop-filter: blur(10px);
  border: 1px solid var(--glass-border);
}
.stat-chip.alive { background: rgba(0, 255, 136, 0.1); color: var(--accent-green); border-color: rgba(0, 255, 136, 0.2); }
.stat-chip.dead { background: rgba(255, 68, 102, 0.1); color: var(--accent-red); border-color: rgba(255, 68, 102, 0.2); }
.stat-chip.starving { background: rgba(255, 187, 0, 0.1); color: var(--accent-yellow); border-color: rgba(255, 187, 0, 0.2); }

.header__lang { display: flex; gap: 0.3rem; }
.lang-btn {
  padding: 0.3rem 0.6rem;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--glass-border);
  cursor: pointer;
  font-family: var(--font);
  font-size: 0.75rem;
  font-weight: 600;
  transition: all 0.2s;
}
.lang-btn.active, .lang-btn:hover {
  background: var(--accent-purple);
  color: white;
  border-color: var(--accent-purple);
}

/* ---- Creatures Grid ---- */
.creatures-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 1.5rem;
  padding: 2rem;
  max-width: 1400px;
  margin: 0 auto;
}

/* ---- Creature Card ---- */
.creature-card {
  background: var(--bg-card);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  backdrop-filter: blur(20px);
  transition: all 0.3s ease;
  position: relative;
  overflow: hidden;
}

.creature-card:hover {
  background: var(--bg-card-hover);
  transform: translateY(-4px);
  box-shadow: var(--shadow-glow);
  border-color: rgba(168, 85, 247, 0.3);
}

.creature-card.dead {
  opacity: 0.5;
  filter: grayscale(0.6);
}

.creature-card__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
}

.creature-card__avatar {
  font-size: 3rem;
  width: 70px;
  height: 70px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: rgba(168, 85, 247, 0.1);
  border: 2px solid rgba(168, 85, 247, 0.2);
  animation: pulse 3s ease-in-out infinite;
}

.creature-card.dead .creature-card__avatar {
  animation: none;
  border-color: rgba(255, 68, 102, 0.3);
  background: rgba(255, 68, 102, 0.05);
}

@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(168, 85, 247, 0.2); }
  50% { box-shadow: 0 0 20px 5px rgba(168, 85, 247, 0.15); }
}

.creature-card__info h3 {
  font-size: 1.1rem;
  font-weight: 700;
  margin-bottom: 0.2rem;
}

.creature-card__type {
  font-size: 0.75rem;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 1px;
}

.creature-card__status {
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 600;
}
.creature-card__status.alive { background: rgba(0, 255, 136, 0.15); color: var(--accent-green); }
.creature-card__status.dead { background: rgba(255, 68, 102, 0.15); color: var(--accent-red); }

/* ---- Stats Bars ---- */
.creature-card__stats { margin: 1rem 0; }

.stat-bar {
  margin-bottom: 0.7rem;
}

.stat-bar__label {
  display: flex;
  justify-content: space-between;
  font-size: 0.75rem;
  color: var(--text-secondary);
  margin-bottom: 0.3rem;
}

.stat-bar__track {
  height: 8px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 999px;
  overflow: hidden;
}

.stat-bar__fill {
  height: 100%;
  border-radius: 999px;
  transition: width 0.8s ease, background 0.5s ease;
}

.stat-bar__fill.hunger { background: var(--gradient-danger); }
.stat-bar__fill.happiness { background: var(--gradient-primary); }
.stat-bar__fill.energy { background: linear-gradient(135deg, #00ff88 0%, #00e5ff 100%); }

/* ---- Action Buttons ---- */
.creature-card__actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 1rem;
}

.action-btn {
  flex: 1;
  padding: 0.6rem 0.5rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--glass-border);
  background: rgba(255, 255, 255, 0.03);
  color: var(--text-primary);
  cursor: pointer;
  font-family: var(--font);
  font-size: 0.8rem;
  font-weight: 600;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.3rem;
}

.action-btn:hover {
  background: rgba(168, 85, 247, 0.15);
  border-color: rgba(168, 85, 247, 0.3);
  transform: scale(1.03);
}

.action-btn:active {
  transform: scale(0.97);
}

.action-btn.revive {
  background: rgba(0, 255, 136, 0.1);
  border-color: rgba(0, 255, 136, 0.2);
  color: var(--accent-green);
}

/* ---- FAB ---- */
.fab {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: var(--gradient-primary);
  border: none;
  color: white;
  font-size: 2rem;
  cursor: pointer;
  box-shadow: 0 4px 20px rgba(168, 85, 247, 0.4);
  transition: all 0.3s;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
}

.fab:hover {
  transform: scale(1.1) rotate(90deg);
  box-shadow: 0 6px 30px rgba(168, 85, 247, 0.6);
}

/* ---- Modal ---- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(8px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 200;
}

.modal-overlay.active { display: flex; }

.modal {
  background: var(--bg-card);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  padding: 2rem;
  width: 90%;
  max-width: 480px;
  backdrop-filter: blur(30px);
  animation: modalIn 0.3s ease;
}

@keyframes modalIn {
  from { transform: scale(0.9); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

.modal__title {
  font-size: 1.3rem;
  margin-bottom: 1.5rem;
  text-align: center;
}

.form-group {
  margin-bottom: 1.2rem;
}

.form-group label {
  display: block;
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin-bottom: 0.5rem;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.form-group input {
  width: 100%;
  padding: 0.7rem 1rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--glass-border);
  background: rgba(255, 255, 255, 0.03);
  color: var(--text-primary);
  font-family: var(--font);
  font-size: 0.95rem;
  outline: none;
  transition: border-color 0.2s;
}

.form-group input:focus {
  border-color: var(--accent-purple);
  box-shadow: 0 0 0 3px rgba(168, 85, 247, 0.15);
}

.type-selector {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.type-btn {
  padding: 0.5rem 0.8rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--glass-border);
  background: rgba(255, 255, 255, 0.03);
  color: var(--text-primary);
  cursor: pointer;
  font-family: var(--font);
  font-size: 0.85rem;
  transition: all 0.2s;
}

.type-btn.selected, .type-btn:hover {
  background: rgba(168, 85, 247, 0.15);
  border-color: var(--accent-purple);
}

.modal__actions {
  display: flex;
  gap: 0.8rem;
  margin-top: 1.5rem;
}

.btn {
  flex: 1;
  padding: 0.7rem 1rem;
  border-radius: var(--radius-md);
  border: none;
  cursor: pointer;
  font-family: var(--font);
  font-size: 0.9rem;
  font-weight: 600;
  transition: all 0.2s;
}

.btn--primary {
  background: var(--gradient-primary);
  color: white;
}
.btn--primary:hover { transform: translateY(-2px); box-shadow: 0 4px 15px rgba(168, 85, 247, 0.4); }

.btn--ghost {
  background: transparent;
  border: 1px solid var(--glass-border);
  color: var(--text-secondary);
}
.btn--ghost:hover { background: rgba(255, 255, 255, 0.05); }

/* ---- Toasts ---- */
.toast-container {
  position: fixed;
  bottom: 2rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 300;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.toast {
  padding: 0.8rem 1.5rem;
  border-radius: var(--radius-md);
  background: var(--bg-card);
  border: 1px solid var(--glass-border);
  backdrop-filter: blur(20px);
  color: var(--text-primary);
  font-size: 0.9rem;
  animation: toastIn 0.4s ease, toastOut 0.4s ease 2.6s forwards;
  white-space: nowrap;
}

@keyframes toastIn { from { transform: translateY(20px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
@keyframes toastOut { from { opacity: 1; } to { opacity: 0; transform: translateY(-10px); } }

/* ---- Empty State ---- */
.empty-state {
  grid-column: 1 / -1;
  text-align: center;
  padding: 4rem 2rem;
  color: var(--text-muted);
}

.empty-state__emoji { font-size: 4rem; margin-bottom: 1rem; }
.empty-state__title { font-size: 1.3rem; color: var(--text-secondary); margin-bottom: 0.5rem; }

/* ---- Responsive ---- */
@media (max-width: 768px) {
  .header { flex-wrap: wrap; gap: 0.8rem; padding: 1rem; }
  .header__stats { order: 3; width: 100%; justify-content: center; }
  .creatures-grid { padding: 1rem; gap: 1rem; grid-template-columns: 1fr; }
  .creature-card__actions { flex-wrap: wrap; }
}
