{% extends "base.html" %}

{% block title %}Trading Signal: {{ active_symbol }}{% endblock %}

{% block head %}
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;700&display=swap" rel="stylesheet">
<style>
  :root {
    --bg-color: #121212;
    --text-color: #e0e0e0;
    --card-bg-color: #1e1e1e;
    --card-border-color: #2c2c2c;
    --primary-color: #4A90E2; /* A modern blue */
    --buy-color: #4CAF50;
    --sell-color: #F44336;
    --wait-color: #FFC107;
    --font-family: 'Inter', sans-serif;
  }

  * {
    box-sizing: border-box;
  }

  body {
    margin: 0;
    font-family: var(--font-family);
    background-color: var(--bg-color);
    color: var(--text-color);
    display: flex;
    flex-direction: column;
    align-items: center;
    min-height: 100vh;
    padding: 2rem;
  }

  header {
    width: 100%;
    max-width: 600px;
    display: flex;
    justify-content: center;
    align-items: center;
    margin-bottom: 2rem;
  }

  .symbol-selector-form {
    display: flex;
    gap: 1rem;
    align-items: center;
  }

  .symbol-selector-form label {
    font-size: 1rem;
    font-weight: 700;
  }

  .symbol-selector {
    padding: 0.75rem 1rem;
    font-size: 1rem;
    background-color: var(--card-bg-color);
    color: var(--text-color);
    border: 1px solid var(--card-border-color);
    border-radius: 8px;
    cursor: pointer;
  }

  .submit-btn {
    padding: 0.75rem 1.5rem;
    font-size: 1rem;
    font-weight: 700;
    background-color: var(--primary-color);
    color: #ffffff;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: background-color 0.3s ease;
  }

  .submit-btn:hover {
    background-color: #357ABD;
  }

  main {
    width: 100%;
    max-width: 600px;
    display: flex;
    flex-direction: column;
    align-items: center;
  }

  .signal-card {
    width: 100%;
    background-color: var(--card-bg-color);
    border: 1px solid var(--card-border-color);
    border-radius: 12px;
    padding: 2.5rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
  }
  
  .signal-card h1 {
    margin: 0;
    font-size: 1.5rem;
    color: var(--primary-color);
    font-weight: 700;
    margin-bottom: 0.5rem;
  }

  .signal-card p {
    margin: 0;
    font-size: 4rem;
    font-weight: 700;
  }

  .signal-BUY {
    color: var(--buy-color);
  }

  .signal-SELL {
    color: var(--sell-color);
  }

  .signal-WAIT {
    color: var(--wait-color);
  }

</style>
{% endblock %}

{% block content %}
<header>
  <!-- 2.A. MANUAL SYMBOL SELECTOR -->
  <form action="{% url 'home' %}" method="get" class="symbol-selector-form">
    <label for="symbol-select">Active Symbol:</label>
    <select name="symbol" id="symbol-select" class="symbol-selector">
      {% for sym in available_symbols %}
        <option value="{{ sym }}" {% if sym == active_symbol %}selected{% endif %}>
          {{ sym }}
        </option>
      {% endfor %}
    </select>
    <button type="submit" class="submit-btn">Analyze</button>
  </form>
</header>

<main>
  <!-- 4. FRONTEND BEHAVIOR: Display data for the active symbol -->
  <div class="signal-card">
    <h1>{{ active_symbol }}</h1>
    <p class="signal-{{ signal }}">{{ signal }}</p>
  </div>
</main>
{% endblock %}
