@import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@300;400;600&display=swap');

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

body {
  background: #0a0a0f;
  color: #e0e0e0;
  font-family: 'Space Grotesk', sans-serif;
  height: 100vh;
  overflow: hidden;
}

#app {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0.5rem;
  height: 100vh;
  display: flex;
  flex-direction: column;
}

header {
  text-align: center;
  padding: 0.5rem 0;
  flex-shrink: 0;
}

header h1 {
  font-size: 2.5rem;
  font-weight: 600;
  background: linear-gradient(135deg, #8e44ad, #3498db, #2ecc71);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  letter-spacing: 2px;
}

.subtitle {
  color: #666;
  font-size: 0.9rem;
  margin-top: 0.3rem;
  letter-spacing: 4px;
  text-transform: lowercase;
}

.colony-container {
  display: flex;
  gap: 1rem;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

/* Creatures sidebar */
.creatures-panel {
  width: 240px;
  flex-shrink: 0;
  background: #111118;
  border-radius: 12px;
  padding: 1rem;
  overflow-y: auto;
  border: 1px solid #1a1a2e;
}

.creatures-panel h2 {
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 2px;
  color: #555;
  margin-bottom: 1rem;
}

.creature-card {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.6rem;
  border-radius: 8px;
  margin-bottom: 0.5rem;
  cursor: pointer;
  transition: background 0.3s, box-shadow 0.3s;
  border: 1px solid transparent;
}

.creature-card:hover {
  background: #1a1a2e;
}

.creature-card.active {
  border-color: var(--mood-color, #555);
  box-shadow: 0 0 12px var(--mood-color, transparent);
}

.creature-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--mood-color, #333);
  box-shadow: 0 0 8px var(--mood-color, transparent);
}

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

.creature-name {
  font-size: 0.9rem;
  font-weight: 600;
  color: #ddd;
}

.creature-mood {
  font-size: 0.75rem;
  color: var(--mood-color, #888);
  text-transform: capitalize;
}

/* Feed */
.feed-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: #111118;
  border-radius: 12px;
  border: 1px solid #1a1a2e;
  overflow: hidden;
}

.feed {
  flex: 1;
  overflow-y: auto;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
}

.feed::-webkit-scrollbar { width: 4px; }
.feed::-webkit-scrollbar-thumb { background: #333; border-radius: 2px; }

/* Messages */
.msg {
  display: flex;
  gap: 0.7rem;
  animation: fadeIn 0.4s ease;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

.msg-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
  border: 2px solid var(--mood-color, #333);
}

.msg-body {
  flex: 1;
  min-width: 0;
}

.msg-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.2rem;
}

.msg-name {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--mood-color, #aaa);
}

.msg-mood {
  font-size: 0.7rem;
}

.msg-time {
  font-size: 0.65rem;
  color: #444;
}

.msg-text {
  font-size: 0.9rem;
  line-height: 1.5;
  color: #ccc;
}

.msg-text em {
  color: #777;
  font-style: italic;
}

.msg-image {
  max-width: 300px;
  border-radius: 8px;
  margin-top: 0.5rem;
  border: 1px solid #222;
}

/* Visitor messages */
.msg.visitor {
  justify-content: flex-end;
}

.msg.visitor .msg-body {
  text-align: right;
  background: #1a1a3e;
  padding: 0.6rem 0.9rem;
  border-radius: 12px 12px 0 12px;
  max-width: 70%;
}

.msg.visitor .msg-name {
  color: #6c5ce7;
}

/* Chat input */
.chat-input {
  display: flex;
  gap: 0.5rem;
  padding: 0.8rem 1rem;
  border-top: 1px solid #1a1a2e;
  background: #0d0d15;
}

.chat-input input {
  flex: 1;
  background: #1a1a2e;
  border: 1px solid #2a2a3e;
  border-radius: 8px;
  padding: 0.6rem 1rem;
  color: #ddd;
  font-family: inherit;
  font-size: 16px;
  outline: none;
  transition: border-color 0.3s;
}

.chat-input input:focus {
  border-color: #6c5ce7;
}

.chat-input button {
  background: linear-gradient(135deg, #6c5ce7, #8e44ad);
  color: white;
  border: none;
  border-radius: 8px;
  padding: 0.6rem 1.2rem;
  font-family: inherit;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.3s;
}

.chat-input button:hover { opacity: 0.85; }
.chat-input button:disabled { opacity: 0.4; cursor: not-allowed; }

/* Loading */
.loading {
  text-align: center;
  padding: 2rem;
  color: #444;
}

.loading::after {
  content: '';
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 2px solid #333;
  border-top-color: #8e44ad;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin-left: 0.5rem;
  vertical-align: middle;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* Creature Detail Popup */
#creatureDetailOverlay {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.7);
  z-index: 100;
  align-items: center;
  justify-content: center;
}
#creatureDetailOverlay.active { display: flex; }

#creatureDetail {
  background: #12121e;
  border: 1px solid #2a2a3e;
  border-radius: 16px;
  padding: 1.5rem;
  max-width: 400px;
  width: 90%;
  max-height: 80vh;
  overflow-y: auto;
}

.detail-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.8rem;
  position: relative;
}

.detail-header h3 { font-size: 1rem; color: #fff; }
.detail-avatar { width: 36px; height: 36px; border-radius: 50%; }
.detail-mood { font-size: 0.8rem; margin-left: auto; }
.detail-close {
  position: absolute;
  top: -4px;
  right: -4px;
  background: none;
  border: none;
  color: #777;
  font-size: 1.2rem;
  cursor: pointer;
}
.detail-close:hover { color: #fff; }

.detail-section { margin-bottom: 0.8rem; }
.detail-label { font-size: 0.7rem; color: #8e44ad; text-transform: uppercase; letter-spacing: 1px; margin-bottom: 0.3rem; }
.detail-text { font-size: 0.85rem; color: #ccc; line-height: 1.4; }

.detail-memories {
  max-height: 150px;
  overflow-y: auto;
}

.memory-entry {
  font-size: 0.8rem;
  color: #999;
  padding: 0.3rem 0;
  border-bottom: 1px solid #1a1a2e;
}

/* Mobile */
@media (max-width: 768px) {
  .colony-container {
    flex-direction: column;
    height: auto;
  }

  header { padding: 0.8rem 0; }
  header h1 { font-size: 1.8rem; }

  .creatures-panel {
    width: 100%;
    max-height: 100px;
    padding: 0.5rem;
  }

  .creatures-panel h2 { display: none; }

  .creatures-panel #creaturesList {
    display: flex;
    gap: 0.5rem;
    overflow-x: auto;
  }

  .creature-card {
    flex-shrink: 0;
    margin-bottom: 0;
    padding: 0.4rem;
  }

  .feed-panel {
    flex: 1;
    min-height: 70vh;
    height: calc(100vh - 150px);
  }
}
