@import url('https://fonts.googleapis.com/css2?family=Press+Start+2P&display=swap');
@import url('https://fonts.googleapis.com/css2?family=Share+Tech+Mono&display=swap');

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

body {
  background-color: #041E42;
  color: #FFFFFF;
  font-family: 'Share Tech Mono', monospace;
  font-size: 16px;
  line-height: 1.5;
  height: 100dvh;
  overflow: hidden;
}

#app {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  max-width: 820px;
  margin: 0 auto;
  padding: 0 20px;
}

/* -- Header -- */
header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 0;
  border-bottom: 1px solid rgba(140, 193, 255, 0.15);
  flex-shrink: 0;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.logo {
  font-family: 'Press Start 2P', cursive;
  font-size: 11px;
  background: linear-gradient(135deg, #8CC1FF, #5A9FE6);
  color: #041E42;
  width: 34px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  flex-shrink: 0;
}

.title {
  font-family: 'Press Start 2P', cursive;
  font-size: 15px;
  color: #FFFFFF;
  letter-spacing: 1px;
}

#header-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

#user-area {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
}

#user-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 1px solid rgba(140, 193, 255, 0.3);
}

#user-name {
  color: #8CC1FF;
}

#credits-badge {
  background: rgba(140, 193, 255, 0.15);
  border: 1px solid rgba(140, 193, 255, 0.25);
  color: #8CC1FF;
  padding: 4px 10px;
  border-radius: 12px;
  font-size: 12px;
  cursor: default;
}

#credits-badge.low {
  border-color: rgba(255, 170, 100, 0.4);
  color: #FFAA64;
  background: rgba(255, 170, 100, 0.1);
}

#credits-badge.empty {
  border-color: rgba(255, 100, 100, 0.4);
  color: #FF6464;
  background: rgba(255, 100, 100, 0.1);
}

#login-btn, #logout-btn {
  color: #8CC1FF;
  border: 1px solid rgba(140, 193, 255, 0.3);
  padding: 6px 14px;
  text-decoration: none;
  font-family: 'Share Tech Mono', monospace;
  font-size: 12px;
  border-radius: 6px;
  transition: all 0.2s;
}

#login-btn:hover, #logout-btn:hover {
  background-color: rgba(140, 193, 255, 0.15);
}

/* -- Chat -- */
#chat-container {
  flex: 1;
  overflow-y: auto;
  padding: 24px 0;
  scroll-behavior: smooth;
}

#messages {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* -- Messages -- */
.message {
  max-width: 82%;
  padding: 14px 18px;
  border-radius: 16px;
  word-wrap: break-word;
  white-space: pre-wrap;
  font-size: 14px;
  line-height: 1.7;
  animation: fadeIn 0.25s ease-out;
}

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

.message.user {
  align-self: flex-end;
  background: linear-gradient(135deg, #1F5AA6, #1A4E8F);
  color: #FFFFFF;
  border-bottom-right-radius: 4px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.message.assistant {
  align-self: flex-start;
  background-color: rgba(10, 46, 92, 0.6);
  color: #D8E8F8;
  border-bottom-left-radius: 4px;
  border: 1px solid rgba(140, 193, 255, 0.08);
}

.message.assistant strong {
  color: #FFFFFF;
}

.message.assistant a {
  color: #8CC1FF;
  text-decoration: none;
}

.message.assistant a:hover {
  text-decoration: underline;
}

/* -- Welcome -- */
.message.welcome {
  align-self: center;
  background-color: transparent;
  text-align: center;
  max-width: 480px;
  padding: 60px 20px 40px;
  border: none;
  animation: fadeIn 0.5s ease-out;
}

.welcome-logo {
  font-family: 'Press Start 2P', cursive;
  font-size: 14px;
  background: linear-gradient(135deg, #8CC1FF, #5A9FE6);
  color: #041E42;
  width: 56px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 16px;
  margin: 0 auto 24px;
}

.message.welcome h2 {
  font-family: 'Press Start 2P', cursive;
  font-size: 16px;
  margin-bottom: 16px;
  color: #FFFFFF;
  letter-spacing: 1px;
}

.message.welcome p {
  color: #7AADDC;
  font-size: 14px;
  line-height: 1.8;
  margin-bottom: 24px;
}

.welcome-hints {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 8px;
}

.welcome-hint {
  background: rgba(31, 90, 166, 0.25);
  border: 1px solid rgba(140, 193, 255, 0.1);
  border-radius: 10px;
  padding: 10px 16px;
  font-size: 13px;
  color: #8CC1FF;
  cursor: pointer;
  transition: all 0.2s;
  text-align: left;
}

.welcome-hint:hover {
  background: rgba(31, 90, 166, 0.45);
  border-color: rgba(140, 193, 255, 0.25);
}

/* -- No credits banner -- */
.no-credits-banner {
  align-self: center;
  text-align: center;
  background: rgba(255, 100, 100, 0.08);
  border: 1px solid rgba(255, 100, 100, 0.2);
  border-radius: 12px;
  padding: 20px 24px;
  max-width: 400px;
  animation: fadeIn 0.3s ease-out;
}

.no-credits-banner p {
  color: #D8E8F8;
  font-size: 14px;
  margin-bottom: 14px;
}

.buy-credits-btn {
  display: inline-block;
  background: linear-gradient(135deg, #8CC1FF, #5A9FE6);
  color: #041E42;
  padding: 10px 24px;
  border-radius: 8px;
  text-decoration: none;
  font-family: 'Share Tech Mono', monospace;
  font-size: 14px;
  font-weight: bold;
  cursor: pointer;
  border: none;
  transition: all 0.2s;
}

.buy-credits-btn:hover {
  transform: scale(1.03);
  box-shadow: 0 2px 12px rgba(140, 193, 255, 0.3);
}

/* -- Status chips -- */
.status-chip {
  align-self: flex-start;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  background: rgba(13, 53, 104, 0.6);
  color: #8CC1FF;
  border-radius: 20px;
  font-size: 12px;
  border: 1px solid rgba(140, 193, 255, 0.1);
  animation: fadeIn 0.2s ease-out;
}

.status-chip .dot {
  width: 6px;
  height: 6px;
  background-color: #8CC1FF;
  border-radius: 50%;
  animation: pulse 1.2s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.3; transform: scale(0.8); }
}

.status-chip.done {
  background: rgba(80, 200, 120, 0.1);
  border-color: rgba(80, 200, 120, 0.25);
  color: #50C878;
}

.status-chip.done::before {
  content: "\2713";
  margin-right: 4px;
  font-size: 11px;
}

/* -- Spotify embed -- */
.spotify-embed {
  margin-top: 16px;
  border-radius: 12px;
  overflow: hidden;
  animation: fadeIn 0.4s ease-out;
}

.spotify-embed iframe {
  border: none;
  width: 100%;
  height: 352px;
  border-radius: 12px;
}

/* -- Input form -- */
#chat-form {
  padding: 14px 0 18px;
  border-top: 1px solid rgba(140, 193, 255, 0.15);
  flex-shrink: 0;
}

.input-row {
  display: flex;
  gap: 8px;
  align-items: flex-end;
  background: rgba(10, 46, 92, 0.5);
  border: 1px solid rgba(140, 193, 255, 0.12);
  border-radius: 14px;
  padding: 6px 6px 6px 16px;
  transition: border-color 0.2s;
}

.input-row:focus-within {
  border-color: rgba(140, 193, 255, 0.35);
}

#message-input {
  flex: 1;
  background: transparent;
  color: #FFFFFF;
  border: none;
  padding: 10px 0;
  font-family: 'Share Tech Mono', monospace;
  font-size: 14px;
  resize: none;
  max-height: 120px;
  outline: none;
  line-height: 1.5;
}

#message-input::placeholder {
  color: #5A7FA8;
}

#message-input:disabled {
  opacity: 0.4;
}

#send-btn {
  background: linear-gradient(135deg, #8CC1FF, #5A9FE6);
  color: #041E42;
  border: none;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  border-radius: 10px;
  transition: all 0.2s;
  flex-shrink: 0;
}

#send-btn:hover:not(:disabled) {
  transform: scale(1.05);
  box-shadow: 0 2px 12px rgba(140, 193, 255, 0.3);
}

#send-btn:disabled {
  opacity: 0.3;
  cursor: not-allowed;
  transform: none;
}

/* -- Scrollbar -- */
#chat-container::-webkit-scrollbar {
  width: 4px;
}

#chat-container::-webkit-scrollbar-track {
  background: transparent;
}

#chat-container::-webkit-scrollbar-thumb {
  background-color: rgba(140, 193, 255, 0.2);
  border-radius: 2px;
}

/* -- Mobile -- */
@media (max-width: 600px) {
  #app { padding: 0 12px; }
  .title { font-size: 12px; }
  .message { max-width: 90%; font-size: 13px; padding: 12px 14px; }
  #message-input { font-size: 14px; }
  .welcome-hints { gap: 6px; }
  .message.welcome { padding: 40px 12px 24px; }
  .message.welcome h2 { font-size: 13px; }
  #user-name { display: none; }
  #user-area { gap: 6px; }
}
