/* src/public/styles.css - Design GRETA 06 avec glassmorphisme */

/* Reset et base */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%);
  min-height: 100vh;
  color: var(--text-primary);
  overflow-x: hidden;
  position: relative;
}

/* Arrière-plan glassmorphisme */
.glass-background {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: 
    radial-gradient(circle at 20% 50%, rgba(255, 140, 56, 0.1) 0%, transparent 50%),
    radial-gradient(circle at 80% 20%, rgba(3, 169, 244, 0.1) 0%, transparent 50%),
    radial-gradient(circle at 40% 80%, rgba(76, 175, 80, 0.1) 0%, transparent 50%);
  z-index: -1;
}

.glass-background::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"><defs><pattern id="grain" width="100" height="100" patternUnits="userSpaceOnUse"><circle cx="50" cy="50" r="0.5" fill="rgba(255,255,255,0.02)"/></pattern></defs><rect width="100" height="100" fill="url(%23grain)"/></svg>');
  opacity: 0.3;
}

/* Container principal */
.container {
  max-width: 900px;
  margin: 0 auto;
  padding: 20px;
  position: relative;
  z-index: 1;
}

/* Header de l'application */
.app-header {
  text-align: center;
  margin-bottom: 40px;
}

.logo-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 15px;
}

.logo-icon {
  font-size: 3rem;
  filter: drop-shadow(0 4px 8px rgba(255, 140, 56, 0.3));
  animation: float 3s ease-in-out infinite;
}

@keyframes float {
  0%, 100% { transform: translateY(0px); }
  50% { transform: translateY(-10px); }
}

.app-header h1 {
  font-size: 2.5rem;
  font-weight: 700;
  color: var(--text-primary);
  margin: 0;
  text-shadow: 0 2px 20px rgba(255, 140, 56, 0.3);
  letter-spacing: -0.02em;
}

.subtitle {
  font-size: 1rem;
  color: var(--text-secondary);
  font-weight: 500;
  letter-spacing: 0.05em;
}

/* Cartes glassmorphisme */
.glass-card {
  background: var(--glass-bg);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border-radius: 20px;
  border: 1px solid var(--glass-border);
  box-shadow: var(--glass-shadow);
  padding: 30px;
  margin-bottom: 30px;
  position: relative;
  overflow: hidden;
}

.glass-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.4), transparent);
  opacity: 0.6;
}

/* Section scanner */
.scanner-section {
  text-align: center;
  animation: slideUp 0.8s ease-out;
}

.scanner-header {
  margin-bottom: 30px;
}

.scanner-header h2 {
  font-size: 1.8rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 10px;
  letter-spacing: -0.01em;
}

.scanner-header p {
  color: var(--text-secondary);
  font-size: 1rem;
}

/* Container vidéo */
.video-container {
  position: relative;
  max-width: 450px;
  margin: 0 auto 30px;
  border-radius: 15px;
  overflow: hidden;
  box-shadow: 
    0 10px 40px rgba(0, 0, 0, 0.3),
    0 0 0 1px var(--glass-border);
}

#scanner-container {
    position: relative;
    width: 100%;
    max-width: 600px;
    margin: 0 auto 1rem;
    border-radius: 12px;
    overflow: hidden;
    background-color: #000;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

#video {
    /* On masque la vidéo source (mais on la garde active pour le flux) */
    /* display: none peut bloquer le flux sur certains mobiles, donc on utilise l'opacité */
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    z-index: -1;
}

#canvas {
    /* C'est le canvas qui affiche l'image + le cadre */
    display: block;
    width: 100%;
    height: auto;
    border-radius: 12px;
}

/* Overlay de scan */
.scan-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  pointer-events: none;
  display: flex;
  align-items: center;
  justify-content: center;
}

.scan-frame {
  width: 200px;
  height: 200px;
  border: 2px solid var(--orange-primary);
  border-radius: 15px;
  position: relative;
  opacity: 0;
  transition: opacity 0.3s ease;
  animation: scanPulse 2s infinite;
}

.scan-frame::before,
.scan-frame::after {
  content: '';
  position: absolute;
  width: 30px;
  height: 30px;
  border: 3px solid var(--orange-primary);
  border-radius: 3px;
}

.scan-frame::before {
  top: -3px;
  left: -3px;
  border-right: none;
  border-bottom: none;
  box-shadow: 0 0 10px rgba(255, 140, 56, 0.5);
}

.scan-frame::after {
  bottom: -3px;
  right: -3px;
  border-left: none;
  border-top: none;
  box-shadow: 0 0 10px rgba(255, 140, 56, 0.5);
}

@keyframes scanPulse {
  0%, 100% { 
    transform: scale(1);
    box-shadow: 0 0 20px rgba(255, 140, 56, 0.3);
  }
  50% { 
    transform: scale(1.05);
    box-shadow: 0 0 30px rgba(255, 140, 56, 0.6);
  }
}

/* Boutons */
.controls {
  display: flex;
  justify-content: center;
  gap: 20px;
}

.btn-primary {
  background: linear-gradient(135deg, var(--orange-primary) 0%, rgba(255, 140, 56, 0.8) 100%);
  color: white;
  border: none;
  padding: 16px 32px;
  border-radius: 50px;
  font-size: 1.1rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 12px;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 
    0 8px 25px rgba(255, 140, 56, 0.3),
    0 0 0 1px rgba(255, 140, 56, 0.2);
  position: relative;
  overflow: hidden;
}

.btn-primary::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
  transition: left 0.5s;
}

.btn-primary:hover::before {
  left: 100%;
}

.btn-primary:hover {
  transform: translateY(-3px) scale(1.02);
  box-shadow: 
    0 12px 35px rgba(255, 140, 56, 0.4),
    0 0 0 1px rgba(255, 140, 56, 0.3);
}

.btn-primary:active {
  transform: translateY(-1px) scale(0.98);
}

.btn-primary.scanning {
  background: linear-gradient(135deg, var(--error) 0%, rgba(244, 67, 54, 0.8) 100%);
  animation: scanningPulse 1.5s infinite;
}

@keyframes scanningPulse {
  0%, 100% { box-shadow: 0 8px 25px rgba(244, 67, 54, 0.3); }
  50% { box-shadow: 0 8px 25px rgba(244, 67, 54, 0.6); }
}

.btn-icon {
  font-size: 1.2rem;
}

.btn-text {
  font-weight: 600;
}

/* Section résultats */
.result-section {
  animation: slideUp 0.5s ease-out;
}

/* Carte ordinateur */
.computer-card {
  background: var(--glass-bg);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border-radius: 20px;
  border: 1px solid var(--glass-border);
  box-shadow: var(--glass-shadow);
  padding: 30px;
  position: relative;
  animation: slideUp 0.8s ease-out;
}

.computer-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 30px;
  flex-wrap: wrap;
  gap: 15px;
}

.computer-header h2 {
  color: var(--text-primary);
  font-size: 1.6rem;
  font-weight: 600;
  margin: 0;
}

/* Badges de statut */
.status-badge {
  padding: 8px 16px;
  border-radius: 25px;
  font-size: 0.9rem;
  font-weight: 600;
  white-space: nowrap;
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.status-found {
  background: rgba(76, 175, 80, 0.2);
  color: rgba(76, 175, 80, 1);
  border-color: rgba(76, 175, 80, 0.3);
  box-shadow: 0 4px 15px rgba(76, 175, 80, 0.2);
}

.status-test {
  background: var(--orange-light);
  color: var(--orange-primary);
  border-color: rgba(255, 140, 56, 0.3);
  box-shadow: 0 4px 15px rgba(255, 140, 56, 0.2);
}

.status-error {
  background: rgba(244, 67, 54, 0.2);
  color: rgba(244, 67, 54, 1);
  border-color: rgba(244, 67, 54, 0.3);
  box-shadow: 0 4px 15px rgba(244, 67, 54, 0.2);
}

.status-unknown {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-secondary);
  border-color: rgba(255, 255, 255, 0.2);
}

/* Grille d'informations */
.info-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 20px;
  margin-bottom: 30px;
}

.info-section {
  background: rgba(255, 255, 255, 0.05);
  backdrop-filter: blur(5px);
  border-radius: 15px;
  padding: 20px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-left: 4px solid var(--orange-primary);
}

.info-section.full-width {
  grid-column: 1 / -1;
}

.info-section h3 {
  color: var(--text-primary);
  margin-bottom: 15px;
  font-size: 1.1rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
}

.info-item {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 12px;
  gap: 15px;
}

.info-item:last-child {
  margin-bottom: 0;
}

.label {
  font-weight: 600;
  color: var(--text-secondary);
  min-width: 130px;
  flex-shrink: 0;
}

.value {
  color: var(--text-primary);
  text-align: right;
  word-break: break-word;
  flex: 1;
  font-weight: 500;
}

/* Style spécifique pour les adresses IP */
.network-ips .value {
  font-family: 'JetBrains Mono', 'Fira Code', monospace;
  font-size: 0.9rem;
  line-height: 1.6;
}

.network-ips .value strong {
  color: var(--orange-primary);
  font-weight: 600;
}

.comments-box {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 10px;
  padding: 15px;
  min-height: 60px;
  color: var(--text-primary);
  line-height: 1.6;
  white-space: pre-wrap;
  font-family: inherit;
}

/* Actions */
.actions {
  display: flex;
  gap: 15px;
  justify-content: center;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(10px);
  color: var(--text-primary);
  border: 1px solid rgba(255, 255, 255, 0.2);
  padding: 12px 25px;
  border-radius: 25px;
  cursor: pointer;
  font-size: 1rem;
  font-weight: 500;
  font-family: inherit;
  transition: all 0.3s ease;
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.15);
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.2);
}

/* Footer */
.app-footer {
  text-align: center;
  margin-top: 40px;
  padding: 20px;
  color: var(--text-disabled);
  font-size: 0.9rem;
}

/* Animations */
@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(30px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* États de chargement */
.loading {
  text-align: center;
  padding: 50px;
  background: var(--glass-bg);
  backdrop-filter: var(--glass-blur);
  border-radius: 20px;
  border: 1px solid var(--glass-border);
  box-shadow: var(--glass-shadow);
}

.spinner {
  width: 60px;
  height: 60px;
  border: 4px solid rgba(255, 255, 255, 0.1);
  border-top: 4px solid var(--orange-primary);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin: 0 auto 20px;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

.loading p {
    color: #666;
    margin: 1rem 0;
}

/* Styles pour la modale N8N */
.n8n-modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 2000;
  backdrop-filter: blur(4px);
}

.n8n-modal {
  background: white;
  border-radius: 12px;
  width: 90%;
  max-width: 600px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 10px 25px rgba(0,0,0,0.2);
  animation: slideIn 0.3s ease-out;
}

.n8n-modal-header {
  padding: 15px 20px;
  border-bottom: 1px solid #eee;
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: #f8f9fa;
  border-radius: 12px 12px 0 0;
}

.n8n-modal-header h3 {
  margin: 0;
  color: #2c3e50;
  font-size: 1.2rem;
}

.n8n-modal-content {
  padding: 20px;
  overflow-y: auto;
}

.n8n-data-grid {
  display: grid;
  gap: 12px;
}

.n8n-data-item {
  display: flex;
  flex-direction: column;
  padding: 10px;
  background: #f8f9fa;
  border-radius: 8px;
  border-left: 3px solid #ddd;
}

.n8n-data-item.priority {
  background: #eef2ff;
  border-left-color: #4a90e2;
  order: -1; /* Force l'affichage en premier si flex/grid le supporte mal ailleurs */
}

.n8n-label {
  font-size: 0.85rem;
  color: #666;
  font-weight: 600;
  margin-bottom: 4px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.n8n-value {
  color: #2c3e50;
  font-family: 'Courier New', monospace; /* Pour un look plus technique */
  word-break: break-word;
  font-size: 0.95rem;
}

.n8n-modal-footer {
  padding: 15px 20px;
  border-top: 1px solid #eee;
  text-align: right;
  background: #fff;
  border-radius: 0 0 12px 12px;
}

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

@media (min-width: 768px) {
  .n8n-data-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .n8n-data-item.priority {
    grid-column: span 2;
  }
}
/* États d'erreur */
.error {
  text-align: center;
  padding: 40px;
  background: var(--glass-bg);
  backdrop-filter: var(--glass-blur);
  border-radius: 20px;
  border: 1px solid rgba(244, 67, 54, 0.3);
  border-left: 4px solid var(--error);
}

.error-icon {
  font-size: 3rem;
  margin-bottom: 15px;
  filter: drop-shadow(0 4px 8px rgba(244, 67, 54, 0.3));
}

.error h3 {
  color: var(--error);
  margin-bottom: 15px;
  font-weight: 600;
}

/* Modal données brutes */
.raw-data-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.8);
  backdrop-filter: blur(5px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
}

.raw-data-modal {
  background: var(--glass-bg);
  backdrop-filter: var(--glass-blur);
  border: 1px solid var(--glass-border);
  border-radius: 20px;
  max-width: 90vw;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 25px 60px rgba(0, 0, 0, 0.4);
}

.raw-data-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 25px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.raw-data-header h3 {
  margin: 0;
  color: var(--text-primary);
  font-weight: 600;
}

.close-btn {
  background: none;
  border: none;
  font-size: 2rem;
  cursor: pointer;
  color: var(--text-secondary);
  padding: 5px;
  border-radius: 10px;
  transition: all 0.3s ease;
}

.close-btn:hover {
  color: var(--error);
  background: rgba(244, 67, 54, 0.1);
}

.raw-data-content {
  padding: 25px;
  overflow: auto;
  flex: 1;
}

.raw-data-content pre {
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid rgba(255, 255, 255, 0.1);
  padding: 20px;
  border-radius: 15px;
  font-size: 0.9rem;
  line-height: 1.5;
  overflow-x: auto;
  color: var(--text-primary);
  font-family: 'JetBrains Mono', 'Fira Code', monospace;
}

.raw-data-actions {
  padding: 25px;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  display: flex;
  gap: 15px;
  justify-content: flex-end;
}

/* Responsive */
@media (max-width: 768px) {
  .container {
    padding: 15px;
  }

  .app-header h1 {
    font-size: 2rem;
  }

  .logo-icon {
    font-size: 2.5rem;
  }

  .glass-card {
    padding: 20px;
  }

  .computer-header {
    flex-direction: column;
    align-items: stretch;
    text-align: center;
    gap: 15px;
  }

  .info-grid {
    grid-template-columns: 1fr;
  }

  .info-item {
    flex-direction: column;
    align-items: stretch;
    gap: 5px;
  }

  .label {
    min-width: auto;
  }

  .value {
    text-align: left;
  }

  .actions {
    flex-direction: column;
    align-items: stretch;
  }

  .btn-primary {
    justify-content: center;
  }

  .raw-data-modal {
    max-width: 95vw;
    max-height: 95vh;
  }

  .raw-data-actions {
    flex-direction: column;
  }

  .scan-frame {
    width: 150px;
    height: 150px;
  }
}

@media (max-width: 480px) {
  .app-header h1 {
    font-size: 1.8rem;
  }

  .scanner-header h2 {
    font-size: 1.5rem;
  }

  .glass-card {
    padding: 15px;
  }

  .btn-primary {
    padding: 14px 28px;
    font-size: 1rem;
  }

  .video-container {
    max-width: 100%;
  }
}

/* Mode scanning actif */
body.scanning .scan-frame {
  opacity: 1;
}

/* Activation du scan overlay quand la vidéo est active */
#video.active + .scan-overlay .scan-frame {
  opacity: 1;
}