// Estilos globais para o Material Dialog
:host ::ng-deep {
  .custom-modal-panel {
    background: transparent !important;
    box-shadow: none !important;
    border-radius: 0 !important;
    padding: 0 !important;
    max-width: none !important;
    max-height: none !important;
    overflow: visible !important;
  }

  .mat-mdc-dialog-container {
    background: transparent !important;
    box-shadow: none !important;
    border-radius: 0 !important;
    padding: 0 !important;
  }
}

// Reset e overlay
.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;
}

// Overlay tema escuro
:host-context(.dark-theme) .modal-overlay {
  background: rgba(0, 0, 0, 0.7);
}

.modal-container {
  background: white;
  border-radius: 16px;
  width: 500px;
  max-width: 90vw;
  max-height: 90vh;
  overflow: hidden;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.15);
  animation: modalShow 0.3s ease-out;
}

@keyframes modalShow {
  from {
    opacity: 0;
    transform: scale(0.95) translateY(-20px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

// Header
.modal-header {
  position: relative;
  padding: 2rem 2rem 1.5rem;
  text-align: center;
  background: white;

  .header-icon {
    margin-bottom: 1rem;
    
    .power-icon {
      width: 64px;
      height: 64px;
      background: linear-gradient(135deg, #9ca3af, #6b7280);
      border-radius: 50%;
      display: flex;
      align-items: center;
      justify-content: center;
      margin: 0 auto;
      
      i {
        color: white;
        font-size: 28px;
      }
    }
  }

  .modal-title {
    margin: 0 0 0.5rem;
    font-size: 1.5rem;
    font-weight: 600;
    color: #1f2937;
    line-height: 1.3;
  }

  .modal-subtitle {
    margin: 0;
    font-size: 0.875rem;
    color: #6b7280;
    line-height: 1.4;
  }

  .close-button {
    position: absolute;
    top: 1rem;
    right: 1rem;
    width: 40px;
    height: 40px;
    border: none;
    background: transparent;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    color: #9ca3af;

    &:hover {
      background: #f3f4f6;
      color: #6b7280;
    }

    i {
      font-size: 20px;
    }
  }
}

// Content
.modal-content {
  padding: 0 2rem 1.5rem;
}

.form-group {
  margin-bottom: 1.5rem;

  .field-label {
    display: block;
    margin-bottom: 0.5rem;
    font-size: 0.875rem;
    font-weight: 500;
    color: #374151;
  }

  .custom-input {
    position: relative;

    input {
      width: 100%;
      padding: 12px 16px;
      font-size: 14px;
      border: 1px solid #e5e7eb;
      border-radius: 8px;
      background: #f9fafb;
      color: #1f2937;
      transition: all 0.2s ease;
      box-sizing: border-box;

      &::placeholder {
        color: #9ca3af;
      }

      &:focus {
        outline: none;
        border-color: #FFC82E;
        box-shadow: 0 0 0 2px rgba(255, 200, 46, 0.1);
        background: #ffffff;
      }

      &:hover:not(:focus) {
        background: #f5f5f5;
        border-color: #d1d5db;
      }

      &.error {
        border-color: #ef4444;
        background: #fef2f2;
        
        &:focus {
          border-color: #ef4444;
          box-shadow: 0 0 0 2px rgba(239, 68, 68, 0.1);
          background: #ffffff;
        }
      }
    }
  }

  .error-message {
    margin-top: 0.5rem;
    font-size: 0.75rem;
    color: #ef4444;
    display: flex;
    align-items: center;
    gap: 0.25rem;

    &::before {
      content: '⚠';
      font-size: 0.875rem;
    }
  }
}

// Actions
.modal-actions {
  padding: 1.5rem 2rem 2rem;
  display: flex;
  gap: 1rem;
  justify-content: center;
  background: white;

  .btn-cancel,
  .btn-submit {
    padding: 10px 20px;
    border-radius: 8px;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    border: none;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    min-height: 40px;
  }

  .btn-cancel {
    background: transparent;
    color: #6b7280;
    border: 1px solid #d1d5db;

    &:hover {
      background: #f9fafb;
      color: #374151;
      border-color: #9ca3af;
    }
  }

  .btn-submit {
    background: #FFC82E;
    color: #000000;
    min-width: 120px;
    justify-content: center;

    &:hover:not(:disabled) {
      background: #FFD700;
      transform: translateY(-1px);
      box-shadow: 0 4px 12px rgba(255, 200, 46, 0.3);
    }

    &:disabled {
      background: #e5e7eb;
      color: #9ca3af;
      opacity: 0.6;
      cursor: not-allowed;
      transform: none;
      box-shadow: none;
    }

    i {
      font-size: 16px;

      &.loading {
        animation: spin 1s linear infinite;
      }
    }
  }
}

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

// Dark theme - seguindo padrão do projeto
:host-context(.dark-theme) {
  .modal-container {
    background: var(--surface);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.4);
  }

  .modal-header {
    background: var(--surface);

    .header-icon .power-icon {
      background: linear-gradient(135deg, #FFC82E, #FFD700);
    }

    .modal-title {
      color: var(--text-primary);
    }

    .modal-subtitle {
      color: var(--text-secondary);
    }

    .close-button {
      color: var(--text-secondary);

      &:hover {
        background: var(--hover-bg);
        color: var(--text-primary);
      }
    }
  }

  .modal-content {
    .form-group {
      .field-label {
        color: var(--text-primary);
      }

      .custom-input input {
        background: var(--hover-bg);
        color: var(--text-primary);
        border-color: var(--divider);

        &::placeholder {
          color: var(--text-secondary);
        }

        &:focus {
          border-color: #FFC82E;
          box-shadow: 0 0 0 2px rgba(255, 200, 46, 0.1);
          background: var(--surface);
        }

        &:hover:not(:focus) {
          background: rgba(255, 255, 255, 0.05);
          border-color: var(--text-secondary);
        }

        &.error {
          border-color: #f87171;
          background: rgba(248, 113, 113, 0.1);
          
          &:focus {
            border-color: #f87171;
            box-shadow: 0 0 0 2px rgba(248, 113, 113, 0.1);
            background: var(--surface);
          }
        }
      }

      .error-message {
        color: #f87171;
      }
    }
  }

  .modal-actions {
    background: var(--surface);

    .btn-cancel {
      background: transparent;
      color: var(--text-secondary);
      border-color: var(--divider);

      &:hover {
        background: var(--hover-bg);
        color: var(--text-primary);
        border-color: var(--text-secondary);
      }
    }

    .btn-submit {
      background: #FFC82E;
      color: #000000;

      &:hover:not(:disabled) {
        background: #FFD700;
        box-shadow: 0 4px 12px rgba(255, 200, 46, 0.4);
      }

      &:disabled {
        background: var(--divider);
        color: var(--text-secondary);
      }
    }
  }
}

// Mobile responsivo
@media (max-width: 768px) {
  .modal-container {
    width: 95vw;
    margin: 1rem;
  }

  .modal-header {
    padding: 1.5rem 1.5rem 1rem;

    .header-icon .power-icon {
      width: 56px;
      height: 56px;

      i {
        font-size: 24px;
      }
    }

    .modal-title {
      font-size: 1.25rem;
    }

    .close-button {
      top: 0.75rem;
      right: 0.75rem;
      width: 36px;
      height: 36px;

      i {
        font-size: 18px;
      }
    }
  }

  .modal-content {
    padding: 0 1.5rem 1rem;

    .form-group {
      margin-bottom: 1.25rem;

      .custom-input input {
        padding: 14px 16px;
        font-size: 16px; // Evita zoom no iOS
      }
    }
  }

  .modal-actions {
    padding: 1rem 1.5rem 1.5rem;
    flex-direction: column;

    .btn-cancel,
    .btn-submit {
      width: 100%;
      justify-content: center;
      padding: 12px 20px;
    }
  }
}

@media (max-width: 480px) {
  .modal-header {
    padding: 1rem;
  }

  .modal-content {
    padding: 0 1rem 1rem;
  }

  .modal-actions {
    padding: 1rem;
  }
}

// Animações suaves
.modal-header,
.modal-content,
.modal-actions {
  transition: all 0.3s ease;
}

// Estados de foco melhorados
.mat-mdc-form-field.mat-focused {
  .mat-mdc-form-field-outline {
    border-color: var(--idt-primary);
  }
}

// Estilo customizado para inputs
.mat-mdc-form-field {
  .mat-mdc-text-field-wrapper {
    border-radius: 8px;
  }

  .mat-mdc-form-field-outline {
    border-radius: 8px;
  }

  &.mat-form-field-invalid {
    .mat-mdc-form-field-outline {
      border-color: #f44336;
    }
  }
} 