/**
 * 📄 FiscalDocumentModalComponent - Modal de Documentos Fiscais
 * 
 * Componente responsável pelo modal de criação/edição de documentos fiscais NFe/NFCe.
 */

import { Component, Output, EventEmitter } from '@angular/core';
import { CommonModule } from '@angular/common';
import { ReactiveFormsModule } from '@angular/forms';
import { FiscalDocument } from '../route-stops.interface';

@Component({
  selector: 'app-fiscal-document-modal',
  standalone: true,
  imports: [CommonModule, ReactiveFormsModule],
  template: `
    <div class="modal-overlay" *ngIf="isOpen">
      <div class="modal-content">
        <h3>Documento Fiscal</h3>
        <form>
          <div>
            <label>Tipo:</label>
            <select>
              <option value="NFe">NFe</option>
              <option value="NFCe">NFCe</option>
            </select>
          </div>
          
          <div>
            <label>Número do Documento:</label>
            <input type="text" placeholder="123456789">
          </div>
          
          <div>
            <label>Valor Total:</label>
            <input type="number" placeholder="0.00">
          </div>
          
          <div class="modal-actions">
            <button type="button" (click)="close()">Cancelar</button>
            <button type="submit">Salvar</button>
          </div>
        </form>
      </div>
    </div>
  `,
  styles: [`
    .modal-overlay {
      position: fixed;
      top: 0;
      left: 0;
      width: 100%;
      height: 100%;
      background: rgba(0,0,0,0.5);
      display: flex;
      align-items: center;
      justify-content: center;
      z-index: 1000;
    }
    .modal-content {
      background: white;
      padding: 2rem;
      border-radius: 8px;
      max-width: 500px;
      width: 90%;
    }
    .modal-actions {
      margin-top: 1rem;
      display: flex;
      gap: 0.5rem;
      justify-content: flex-end;
    }
  `]
})
export class FiscalDocumentModalComponent {
  isOpen = false;
  currentStopId = '';
  
  @Output() documentSaved = new EventEmitter<FiscalDocument>();
  @Output() modalClosed = new EventEmitter<void>();
  
  open(stopId: string): void {
    this.currentStopId = stopId;
    this.isOpen = true;
  }
  
  close(): void {
    this.isOpen = false;
    this.modalClosed.emit();
  }
} 