<script lang="ts">
  import type { ConsoleMessage } from '../../stores/console';
  import { onMount } from 'svelte';
  import gsap from 'gsap';
  
  export let message: ConsoleMessage;
  
  let messageElement: HTMLDivElement;
  
  onMount(() => {
    gsap.fromTo(messageElement, 
      { opacity: 0, y: -5 },
      { opacity: 1, y: 0, duration: 0.3, ease: "power2.out" }
    );
  });
</script>

<div 
  bind:this={messageElement}
  class="console-line console-{message.type}"
>
  <span class="console-type">{message.type}</span>
  <span class="console-msg">{message.message}</span>
</div>

<style>
  .console-line {
    margin-bottom: 6px;
    display: flex;
    gap: 10px;
    align-items: flex-start;
    padding: 4px 6px;
    border-radius: 4px;
    transition: background 0.2s;
  }

  .console-line:hover {
    background: rgba(139, 115, 85, 0.02);
  }

  .console-type {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 9px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    opacity: 0.5;
  }

  .console-type::before {
    content: '';
    width: 6px;
    height: 6px;
    border-radius: 50%;
    display: inline-block;
  }

  .console-log .console-type::before {
    background: rgba(251, 248, 244, 0.5);
  }

  .console-warn .console-type::before {
    background: #D4A574;
  }

  .console-error .console-type::before {
    background: #B85450;
  }

  .console-info .console-type::before {
    background: #7C9885;
  }

  .console-msg {
    flex: 1;
    word-break: break-word;
    white-space: pre-wrap;
    color: rgba(251, 248, 244, 0.8);
  }

  .console-log {
    color: rgba(251, 248, 244, 0.7);
  }

  .console-warn {
    background: rgba(212, 165, 116, 0.05);
  }

  .console-warn .console-msg {
    color: #D4A574;
  }

  .console-error {
    background: rgba(184, 84, 80, 0.05);
  }

  .console-error .console-msg {
    color: #B85450;
  }

  .console-info {
    background: rgba(124, 152, 133, 0.03);
  }

  .console-info .console-msg {
    color: #7C9885;
  }
</style>