<template>
  <div>
    <button @click="showModal = true" class="shortcuts-btn">
      <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
        <rect x="2" y="3" width="20" height="14" rx="2" ry="2"/>
        <line x1="8" y1="21" x2="16" y2="21"/>
        <line x1="12" y1="17" x2="12" y2="21"/>
      </svg>
      Shortcuts
    </button>

    <div v-if="showModal" class="modal-overlay" @click="showModal = false">
      <div class="modal-content" @click.stop>
        <div class="modal-header">
          <h2>Guide d'utilisation</h2>
          <button class="close-btn" @click="showModal = false">&times;</button>
        </div>
        <div class="shortcuts-content">
          <div class="shortcuts-section">
            <h3>Points de calibration</h3>
            <div class="shortcut-item">
              <span class="key">Clic gauche</span>
              <span class="description">Placer un point (sélectionner d'abord un point sur le terrain)</span>
            </div>
            <div class="shortcut-item">
              <span class="key">Glisser</span>
              <span class="description">Déplacer un point existant</span>
            </div>
          </div>

          <div class="shortcuts-section">
            <h3>Lignes de calibration</h3>
            <div class="shortcut-item">
              <span class="key">Clic gauche</span>
              <span class="description">Ajouter un point à la ligne (sélectionner d'abord une ligne sur le terrain)</span>
            </div>
            <div class="shortcut-item">
              <span class="key">Clic droit</span>
              <span class="description">Terminer la ligne (minimum 2 points)</span>
            </div>
            <div class="shortcut-item">
              <span class="key">Ctrl + Clic</span>
              <span class="description">Utiliser un point d'intersection existant</span>
            </div>
          </div>

          <div class="shortcuts-section">
            <h3>Navigation</h3>
            <div class="shortcut-item">
              <span class="key">Molette</span>
              <span class="description">Zoomer/Dézoomer (1x à 15x)</span>
            </div>
            <div class="shortcut-item">
              <span class="key">Clic molette + Glisser</span>
              <span class="description">Déplacer l'image</span>
            </div>
          </div>

          <div class="shortcuts-section">
            <h3>Édition</h3>
            <div class="shortcut-item">
              <span class="key">Delete / Backspace</span>
              <span class="description">Supprimer la ligne sélectionnée</span>
            </div>
            <div class="shortcut-item">
              <span class="key">Clear</span>
              <span class="description">Effacer toute la calibration</span>
            </div>
          </div>

          <div class="shortcuts-section">
            <h3>Workflow</h3>
            <div class="shortcut-item">
              <span class="step">1.</span>
              <span class="description">Sélectionner un élément sur le terrain de football (point ou ligne)</span>
            </div>
            <div class="shortcut-item">
              <span class="step">2.</span>
              <span class="description">Placer/Dessiner l'élément correspondant sur l'image</span>
            </div>
            <div class="shortcut-item">
              <span class="step">3.</span>
              <span class="description">Répéter pour tous les éléments nécessaires</span>
            </div>
            <div class="shortcut-item">
              <span class="step">4.</span>
              <span class="description">Cliquer sur "Traiter la calibration"</span>
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  name: 'KeyboardShortcuts',
  data() {
    return {
      showModal: false
    }
  }
}
</script>

<style scoped>
.shortcuts-btn {
  background: rgba(255, 255, 255, 0.1);
  color: #888;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 6px;
  padding: 8px 12px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: all 0.3s ease;
  font-size: 0.85rem;
  backdrop-filter: blur(10px);
}

.shortcuts-btn:hover {
  background: rgba(255, 255, 255, 0.15);
  color: var(--color-primary);
  border-color: var(--color-primary);
}

.shortcuts-btn svg {
  transition: all 0.3s ease;
}

.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.7);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 2000;
  backdrop-filter: blur(5px);
}

.modal-content {
  background-color: #1a1a1a;
  border: 1px solid #333;
  border-radius: 12px;
  width: 90%;
  max-width: 700px;
  max-height: 85vh;
  overflow-y: auto;
  color: white;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.5);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 24px;
  border-bottom: 1px solid #333;
  background: #2a2a2a;
  border-radius: 12px 12px 0 0;
}

.modal-header h2 {
  margin: 0;
  font-size: 1.5rem;
  color: var(--color-primary);
}

.close-btn {
  background: none;
  border: none;
  color: #888;
  font-size: 1.8rem;
  cursor: pointer;
  padding: 0 8px;
  transition: color 0.3s ease;
  line-height: 1;
}

.close-btn:hover {
  color: var(--color-primary);
}

.shortcuts-content {
  padding: 24px;
}

.shortcuts-section {
  margin-bottom: 32px;
}

.shortcuts-section:last-child {
  margin-bottom: 0;
}

.shortcuts-section h3 {
  color: var(--color-primary);
  margin-bottom: 16px;
  font-size: 1.1rem;
  font-weight: 600;
  border-bottom: 1px solid #333;
  padding-bottom: 8px;
}

.shortcut-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.shortcut-item:last-child {
  border-bottom: none;
}

.key {
  background-color: #333;
  color: var(--color-primary);
  padding: 6px 12px;
  border-radius: 6px;
  font-family: monospace;
  font-size: 0.85rem;
  font-weight: 600;
  min-width: 120px;
  text-align: center;
  border: 1px solid #444;
}

.step {
  background-color: var(--color-primary);
  color: var(--color-secondary);
  padding: 6px 12px;
  border-radius: 50%;
  font-family: monospace;
  font-size: 0.85rem;
  font-weight: 700;
  min-width: 30px;
  text-align: center;
  margin-right: 10px;
}

.description {
  color: #ccc;
  flex: 1;
  margin-left: 16px;
  line-height: 1.4;
}

/* Scrollbar styling */
.modal-content::-webkit-scrollbar {
  width: 8px;
}

.modal-content::-webkit-scrollbar-track {
  background: #2a2a2a;
}

.modal-content::-webkit-scrollbar-thumb {
  background: #555;
  border-radius: 4px;
}

.modal-content::-webkit-scrollbar-thumb:hover {
  background: #666;
}
</style> 